Capture and track errors in your JavaScript application with Sentry
Error monitoring is the core functionality of Sentry. The SDK automatically captures unhandled errors and allows you to manually capture exceptions with rich context.
const eventId = Sentry.captureException(error);console.log(`Error tracked with ID: ${eventId}`);// Get the last event ID from the isolation scopeconst lastEventId = Sentry.lastEventId();
The lastEventId() function returns the last recorded error on the current isolation scope. If another error is captured in between, it will return that one instead.
// Check if SDK is initializedif (Sentry.isInitialized()) { console.log('Sentry is ready');}// Check if SDK is enabledif (Sentry.isEnabled()) { console.log('Sentry is enabled and has a transport');}