Pluggable integrations that enhance Sentry JavaScript SDKs with additional error tracking, monitoring, and debugging capabilities.
—
Extracts additional custom properties from Error objects and attaches them as event context. This integration captures non-standard error properties, error causes, and custom data attached to Error instances.
/**
* Extracts additional data from original exceptions
* @param options - Configuration for error data extraction
* @returns Integration instance that enhances error events
*/
function extraErrorDataIntegration(options?: Partial<ExtraErrorDataOptions>): Integration;
interface ExtraErrorDataOptions {
/** The object depth up to which to capture data on error objects. Default: 3 */
depth: number;
/** Whether to capture error causes (Error.cause property). Default: false */
captureErrorCause: boolean;
}/**
* Legacy class-based extra error data integration
* @deprecated Use extraErrorDataIntegration() instead
*/
class ExtraErrorData implements Integration {
constructor(options?: Partial<{
depth: number;
captureErrorCause: boolean;
}>);
name: string;
processEvent(event: Event, hint: EventHint): Event;
}Controls how deeply nested objects on Error instances are serialized:
normalize() from @sentry/utils with specified depthControls whether to capture the standard Error.cause property:
error.causeThe integration extracts all enumerable properties from Error objects, excluding standard Error properties:
Excluded Properties (native Error properties):
name, message, stackline, column, fileNamelineNumber, columnNumbertoJSONAdditional Processing:
toJSON() method results are merged if presentError.cause captured separately when enabledExtracted data is attached to the event under contexts[ExceptionName]:
name property__sentry_skip_normalization__ to prevent double-processingimport { extraErrorDataIntegration } from '@sentry/integrations';
import * as Sentry from '@sentry/browser';
// Basic setup with defaults
Sentry.init({
dsn: 'YOUR_DSN',
integrations: [
extraErrorDataIntegration()
]
});
// Custom configuration
Sentry.init({
dsn: 'YOUR_DSN',
integrations: [
extraErrorDataIntegration({
depth: 5, // Deeper object traversal
captureErrorCause: true // Include error causes
})
]
});
// Usage with custom error properties
class CustomError extends Error {
constructor(message, { userId, requestId, metadata }) {
super(message);
this.userId = userId;
this.requestId = requestId;
this.metadata = metadata;
this.timestamp = Date.now();
}
}
// Error with cause chain
const rootCause = new Error('Database connection failed');
const apiError = new Error('API request failed', { cause: rootCause });
apiError.statusCode = 500;
apiError.endpoint = '/api/users';
throw apiError;
// Results in Sentry event with custom properties in contextsconst error = new Error('Custom error');
error.userId = '12345';
error.context = {
action: 'data-processing',
retryCount: 3
};
error.timestamp = Date.now();
throw error;
// Custom properties appear in Sentry contextsMany libraries attach additional data to errors:
// Axios errors
const axiosError = new Error('Request failed');
axiosError.config = { url: '/api', method: 'POST' };
axiosError.response = { status: 404, data: { error: 'Not found' } };
// This data is automatically captured
throw axiosError;const dbError = new Error('Connection timeout');
const serviceError = new Error('Service unavailable', { cause: dbError });
// Both error messages and cause chain captured when enabled
throw serviceError;The integration is particularly valuable for applications using custom Error classes or third-party libraries that attach metadata to Error objects.
Install with Tessl CLI
npx tessl i tessl/npm-sentry--integrations