@sentry/react-native
Version:
Official Sentry SDK for react-native
114 lines • 4.77 kB
TypeScript
import type { MetroConfig } from 'metro';
import type { DefaultConfigOptions } from './vendor/expo/expoconfig';
export * from './sentryMetroSerializer';
export interface SentryMetroConfigOptions {
/**
* Annotates React components with Sentry data.
* @default false
*/
annotateReactComponents?: boolean | {
ignoredComponents?: string[];
/**
* Automatically inject `sentry-label` props from static text content.
* When enabled, the Babel plugin extracts text from children of touchable
* components and injects it as a `sentry-label` prop at build time.
*
* @default true when `annotateReactComponents` is enabled
*/
autoInjectSentryLabel?: boolean;
/**
* Component names whose children's text content should be used for
* `sentry-label` injection. Useful for apps with custom text wrapper
* components.
*
* @default ['Text']
*/
textComponentNames?: string[];
};
/**
* Adds the Sentry replay package for web.
* @default true
*/
includeWebReplay?: boolean;
/**
* Adds the Sentry user feedback widget package.
* @default true
*/
includeWebFeedback?: boolean;
/**
* Add Sentry Metro Server Middleware which
* enables the app to fetch stack frames source context.
* @default true
*/
enableSourceContextInDevelopment?: boolean;
/**
* Load Sentry Options from a file. If `true` it will use the default path.
* If `false` it will not load any options from a file. Only options provided in the code will be used.
* If `string` it will use the provided path.
*
* @default '{projectRoot}/sentry.options.json'
*/
optionsFile?: string | boolean;
/**
* Auto-wrap Expo Router's per-route `ErrorBoundary` re-exports with
* `Sentry.wrapExpoRouterErrorBoundary` at build time so render-phase errors
* that hit the fallback are captured without requiring the user to change
* their route files.
*
* Detects `export { ErrorBoundary } from 'expo-router'` (and aliased
* variants) in non-`node_modules` files and rewrites them to import the
* wrapped boundary instead. Files that already import
* `wrapExpoRouterErrorBoundary` are left untouched.
*
* @default false
*/
autoWrapExpoRouterErrorBoundary?: boolean;
}
export interface SentryExpoConfigOptions {
/**
* Pass a custom `getDefaultConfig` function to override the default Expo configuration getter.
*/
getDefaultConfig?: (projectRoot: string, options?: Record<string, unknown>) => Record<string, unknown>;
/**
* For Expo Web, inject `release` and `version` options from `app.json`, the Expo Application Config.
*
* @default true
*/
injectReleaseForWeb?: boolean;
}
/**
* Adds Sentry to the Metro config.
*
* Adds Debug ID to the output bundle and source maps.
* Collapses Sentry frames from the stack trace view in LogBox.
*/
export declare function withSentryConfig(config: MetroConfig, { annotateReactComponents, includeWebReplay, includeWebFeedback, enableSourceContextInDevelopment, optionsFile, autoWrapExpoRouterErrorBoundary, }?: SentryMetroConfigOptions): MetroConfig;
/**
* This function returns Default Expo configuration with Sentry plugins.
*/
export declare function getSentryExpoConfig(projectRoot: string, options?: DefaultConfigOptions & SentryExpoConfigOptions & SentryMetroConfigOptions): MetroConfig;
/**
* Adds Sentry Babel transformer to the Metro config.
*/
export declare function withSentryBabelTransformer(config: MetroConfig, annotateReactComponents: boolean | {
ignoredComponents?: string[];
autoInjectSentryLabel?: boolean;
textComponentNames?: string[];
}, autoWrapExpoRouterErrorBoundary?: boolean): MetroConfig;
/**
* Includes `@sentry/replay` packages based on the `includeWebReplay` flag and current bundle `platform`.
*/
export declare function withSentryResolver(config: MetroConfig, includeWebReplay: boolean | undefined): MetroConfig;
/**
* Includes `@sentry-internal/feedback` packages based on the `includeWebFeedback` flag and current bundle `platform`.
*/
export declare function withSentryFeedbackResolver(config: MetroConfig, includeWebFeedback: boolean | undefined): MetroConfig;
/**
* Excludes server-only AI/MCP modules from native (Android/iOS) bundles.
*/
export declare function withSentryExcludeServerOnlyResolver(config: MetroConfig): MetroConfig;
/**
* Collapses Sentry internal frames from the stack trace view in LogBox.
*/
export declare function withSentryFramesCollapsed(config: MetroConfig): MetroConfig;
//# sourceMappingURL=metroconfig.d.ts.map