Pluggable integrations that enhance Sentry JavaScript SDKs with additional error tracking, monitoring, and debugging capabilities.
—
Transforms stack frame filenames using configurable rules. This integration is useful for normalizing file paths in different deployment environments, removing sensitive paths, or creating consistent frame references.
/**
* Rewrites event frame paths using configurable transformation rules
* @param options - Frame rewriting configuration
* @returns Integration instance that processes stack frames
*/
function rewriteFramesIntegration(options?: RewriteFramesOptions): Integration;
interface RewriteFramesOptions {
/** Root path to strip from filenames */
root?: string;
/** Prefix to add to rewritten filenames. Default: 'app:///' */
prefix?: string;
/** Custom frame processing function */
iteratee?: StackFrameIteratee;
}
type StackFrameIteratee = (frame: StackFrame) => StackFrame;/**
* Legacy class-based frame rewriting integration
* @deprecated Use rewriteFramesIntegration() instead
*/
class RewriteFrames implements Integration {
constructor(options?: {
root?: string;
prefix?: string;
iteratee?: StackFrameIteratee
});
name: string;
processEvent(event: Event): Event;
}Base path to strip from filenames before applying prefix:
/var/www/app → strips this from /var/www/app/src/utils.jsString to prepend to processed filenames:
'app:///'utils.js → app:///utils.jsCustom frame transformation function:
(frame: StackFrame) => StackFrameWithout custom iteratee, the integration applies these transformations:
Automatically detects Windows vs Unix paths:
C:\) or containing backslashes/)For Windows-style paths:
C:)For Unix-style paths:
import { rewriteFramesIntegration } from '@sentry/integrations';
import * as Sentry from '@sentry/browser';
// Basic prefix-only transformation
Sentry.init({
dsn: 'YOUR_DSN',
integrations: [
rewriteFramesIntegration({
prefix: 'myapp:///'
})
]
});
// Strip deployment path and add prefix
Sentry.init({
dsn: 'YOUR_DSN',
integrations: [
rewriteFramesIntegration({
root: '/var/www/myapp',
prefix: 'app:///'
})
]
});
// Custom transformation logic
Sentry.init({
dsn: 'YOUR_DSN',
integrations: [
rewriteFramesIntegration({
iteratee: (frame) => {
if (frame.filename) {
// Custom logic: mask user-specific paths
frame.filename = frame.filename.replace(
/\/Users\/[^\/]+/,
'/Users/***'
);
// Add custom prefix
frame.filename = `custom:///${frame.filename}`;
}
return frame;
}
})
]
});// Input frames:
'/var/www/app/src/utils.js' → 'app:///src/utils.js'
'C:\\app\\src\\utils.js' → 'app:///src/utils.js'
'/home/user/project/main.js' → 'app:///main.js'// Configuration: { root: '/var/www/app', prefix: 'myapp:///' }
'/var/www/app/src/utils.js' → 'myapp:///src/utils.js'
'/var/www/app/lib/helper.js' → 'myapp:///lib/helper.js'
'/different/path/file.js' → 'myapp:///file.js'// Both produce same result:
'C:\\Users\\dev\\project\\src\\main.js' → 'app:///src/main.js'
'/home/dev/project/src/main.js' → 'app:///src/main.js'The integration processes all stack frames in:
This integration is essential for production applications where stack frame paths need to be normalized or sanitized for security and consistency.
Install with Tessl CLI
npx tessl i tessl/npm-sentry--integrations