@sentry/react-native 5.31.1 → 5.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/android/src/main/java/io/sentry/react/RNSentryOnDrawReporterManager.java +18 -1
- package/dist/js/client.d.ts.map +1 -1
- package/dist/js/client.js +2 -2
- package/dist/js/client.js.map +1 -1
- package/dist/js/index.d.ts +1 -1
- package/dist/js/index.d.ts.map +1 -1
- package/dist/js/index.js +1 -3
- package/dist/js/index.js.map +1 -1
- package/dist/js/integrations/default.d.ts.map +1 -1
- package/dist/js/integrations/default.js +2 -1
- package/dist/js/integrations/default.js.map +1 -1
- package/dist/js/options.d.ts +34 -2
- package/dist/js/options.d.ts.map +1 -1
- package/dist/js/options.js.map +1 -1
- package/dist/js/profiling/integration.d.ts.map +1 -1
- package/dist/js/profiling/integration.js +6 -3
- package/dist/js/profiling/integration.js.map +1 -1
- package/dist/js/tools/metroconfig.d.ts +10 -1
- package/dist/js/tools/metroconfig.d.ts.map +1 -1
- package/dist/js/tools/metroconfig.js +42 -2
- package/dist/js/tools/metroconfig.js.map +1 -1
- package/dist/js/tracing/index.d.ts +3 -3
- package/dist/js/tracing/index.d.ts.map +1 -1
- package/dist/js/tracing/index.js +3 -3
- package/dist/js/tracing/index.js.map +1 -1
- package/dist/js/tracing/reactnativenavigation.d.ts +6 -0
- package/dist/js/tracing/reactnativenavigation.d.ts.map +1 -1
- package/dist/js/tracing/reactnativenavigation.js +6 -0
- package/dist/js/tracing/reactnativenavigation.js.map +1 -1
- package/dist/js/tracing/reactnativetracing.d.ts +6 -8
- package/dist/js/tracing/reactnativetracing.d.ts.map +1 -1
- package/dist/js/tracing/reactnativetracing.js +23 -15
- package/dist/js/tracing/reactnativetracing.js.map +1 -1
- package/dist/js/tracing/reactnavigation.d.ts +4 -0
- package/dist/js/tracing/reactnavigation.d.ts.map +1 -1
- package/dist/js/tracing/reactnavigation.js +6 -0
- package/dist/js/tracing/reactnavigation.js.map +1 -1
- package/dist/js/tracing/reactnavigationv4.d.ts +2 -0
- package/dist/js/tracing/reactnavigationv4.d.ts.map +1 -1
- package/dist/js/tracing/reactnavigationv4.js +2 -0
- package/dist/js/tracing/reactnavigationv4.js.map +1 -1
- package/dist/js/tracing/routingInstrumentation.d.ts +8 -2
- package/dist/js/tracing/routingInstrumentation.d.ts.map +1 -1
- package/dist/js/tracing/routingInstrumentation.js +3 -2
- package/dist/js/tracing/routingInstrumentation.js.map +1 -1
- package/dist/js/version.d.ts +1 -1
- package/dist/js/version.js +1 -1
- package/dist/js/version.js.map +1 -1
- package/package.json +2 -2
- package/ts3.8/dist/js/index.d.ts +1 -1
- package/ts3.8/dist/js/options.d.ts +34 -2
- package/ts3.8/dist/js/tracing/index.d.ts +3 -3
- package/ts3.8/dist/js/tracing/reactnativenavigation.d.ts +6 -0
- package/ts3.8/dist/js/tracing/reactnativetracing.d.ts +6 -8
- package/ts3.8/dist/js/tracing/reactnavigation.d.ts +4 -0
- package/ts3.8/dist/js/tracing/reactnavigationv4.d.ts +2 -0
- package/ts3.8/dist/js/tracing/routingInstrumentation.d.ts +8 -2
- package/ts3.8/dist/js/version.d.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.withSentryFramesCollapsed = exports.withSentryBabelTransformer = exports.getSentryExpoConfig = exports.withSentryConfig = void 0;
|
|
2
|
+
exports.withSentryFramesCollapsed = exports.withSentryResolver = exports.withSentryBabelTransformer = exports.getSentryExpoConfig = exports.withSentryConfig = void 0;
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const utils_1 = require("@sentry/utils");
|
|
5
5
|
const process = require("process");
|
|
@@ -15,7 +15,7 @@ tslib_1.__exportStar(require("./sentryMetroSerializer"), exports);
|
|
|
15
15
|
* Adds Debug ID to the output bundle and source maps.
|
|
16
16
|
* Collapses Sentry frames from the stack trace view in LogBox.
|
|
17
17
|
*/
|
|
18
|
-
function withSentryConfig(config, { annotateReactComponents = false } = {}) {
|
|
18
|
+
function withSentryConfig(config, { annotateReactComponents = false, includeWebReplay = true } = {}) {
|
|
19
19
|
setSentryMetroDevServerEnvFlag();
|
|
20
20
|
let newConfig = config;
|
|
21
21
|
newConfig = withSentryDebugId(newConfig);
|
|
@@ -23,6 +23,9 @@ function withSentryConfig(config, { annotateReactComponents = false } = {}) {
|
|
|
23
23
|
if (annotateReactComponents) {
|
|
24
24
|
newConfig = withSentryBabelTransformer(newConfig);
|
|
25
25
|
}
|
|
26
|
+
if (includeWebReplay === false) {
|
|
27
|
+
newConfig = withSentryResolver(newConfig, includeWebReplay);
|
|
28
|
+
}
|
|
26
29
|
return newConfig;
|
|
27
30
|
}
|
|
28
31
|
exports.withSentryConfig = withSentryConfig;
|
|
@@ -40,6 +43,9 @@ function getSentryExpoConfig(projectRoot, options = {}) {
|
|
|
40
43
|
if (options.annotateReactComponents) {
|
|
41
44
|
newConfig = withSentryBabelTransformer(newConfig);
|
|
42
45
|
}
|
|
46
|
+
if (options.includeWebReplay === false) {
|
|
47
|
+
newConfig = withSentryResolver(newConfig, options.includeWebReplay);
|
|
48
|
+
}
|
|
43
49
|
return newConfig;
|
|
44
50
|
}
|
|
45
51
|
exports.getSentryExpoConfig = getSentryExpoConfig;
|
|
@@ -82,6 +88,40 @@ function withSentryDebugId(config) {
|
|
|
82
88
|
// The default serializer is sync
|
|
83
89
|
return Object.assign(Object.assign({}, config), { serializer: Object.assign(Object.assign({}, config.serializer), { customSerializer }) });
|
|
84
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Includes `@sentry/replay` packages based on the `includeWebReplay` flag and current bundle `platform`.
|
|
93
|
+
*/
|
|
94
|
+
function withSentryResolver(config, includeWebReplay) {
|
|
95
|
+
var _a;
|
|
96
|
+
const originalResolver = (_a = config.resolver) === null || _a === void 0 ? void 0 : _a.resolveRequest;
|
|
97
|
+
const sentryResolverRequest = (context, moduleName, platform, oldMetroModuleName) => {
|
|
98
|
+
if ((includeWebReplay === false ||
|
|
99
|
+
(includeWebReplay === undefined && (platform === 'android' || platform === 'ios'))) &&
|
|
100
|
+
(oldMetroModuleName !== null && oldMetroModuleName !== void 0 ? oldMetroModuleName : moduleName).includes('@sentry/replay')) {
|
|
101
|
+
return { type: 'empty' };
|
|
102
|
+
}
|
|
103
|
+
if (originalResolver) {
|
|
104
|
+
return oldMetroModuleName
|
|
105
|
+
? originalResolver(context, moduleName, platform, oldMetroModuleName)
|
|
106
|
+
: originalResolver(context, moduleName, platform);
|
|
107
|
+
}
|
|
108
|
+
// Prior 0.68, resolve context.resolveRequest is sentryResolver itself, where on later version it is the default resolver.
|
|
109
|
+
if (context.resolveRequest === sentryResolverRequest) {
|
|
110
|
+
// eslint-disable-next-line no-console
|
|
111
|
+
console.error(`Error: [@sentry/react-native/metro] Can not resolve the defaultResolver on Metro older than 0.68.
|
|
112
|
+
Please follow one of the following options:
|
|
113
|
+
- Include your resolverRequest on your metroconfig.
|
|
114
|
+
- Update your Metro version to 0.68 or higher.
|
|
115
|
+
- Set includeWebReplay as true on your metro config.
|
|
116
|
+
- If you are still facing issues, report the issue at http://www.github.com/getsentry/sentry-react-native/issues`);
|
|
117
|
+
// Return required for test.
|
|
118
|
+
return process.exit(-1);
|
|
119
|
+
}
|
|
120
|
+
return context.resolveRequest(context, moduleName, platform);
|
|
121
|
+
};
|
|
122
|
+
return Object.assign(Object.assign({}, config), { resolver: Object.assign(Object.assign({}, config.resolver), { resolveRequest: sentryResolverRequest }) });
|
|
123
|
+
}
|
|
124
|
+
exports.withSentryResolver = withSentryResolver;
|
|
85
125
|
/**
|
|
86
126
|
* Collapses Sentry internal frames from the stack trace view in LogBox.
|
|
87
127
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metroconfig.js","sourceRoot":"","sources":["../../../src/js/tools/metroconfig.ts"],"names":[],"mappings":";;;AAAA,yCAAuC;AAEvC,mCAAmC;AACnC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;QAC9B,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,8CAA8C,CAAC;YAClE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,0CAA0C,CAAC,CAAC,CAAC;IAErE,MAAM,cAAc,GAAG,CAAC,KAAiB,EAAkC,EAAE;QAC3E,MAAM,8BAA8B,GAAG,CACrC,qBAAsD,EACjC,EAAE,CAAC,iCACrB,qBAAqB,KACxB,QAAQ,EAAE,CAAC,qBAAqB,IAAI,qBAAqB,CAAC,QAAQ,CAAC,IAAI,4BAA4B,CAAC,KAAK,CAAC,IAC1G,CAAC;QAEH,MAAM,yBAAyB,GAAG,CAAC,sBAAsB,IAAI,sBAAsB,CAAC,KAAK,CAAC,CAAC,IAAI,SAAS,CAAC;QAEzG,IAAI,yBAAyB,KAAK,SAAS,IAAI,MAAM,IAAI,yBAAyB,EAAE;YAClF,OAAO,yBAAyB,CAAC,IAAI,CAAsB,qBAAqB,CAAC,EAAE,CACjF,8BAA8B,CAAC,qBAAqB,CAAC,CACtD,CAAC;SACH;QAED,OAAO,8BAA8B,CAAC,yBAAyB,CAAC,CAAC;IACnE,CAAC,CAAC;IAEF,uCACK,MAAM,KACT,YAAY,kCACP,MAAM,CAAC,YAAY,KACtB,cAAc,OAEhB;AACJ,CAAC;AAjCD,8DAiCC;AAED;;;;GAIG;AACH,SAAS,8BAA8B;IACrC,aAAG,CAAC,6BAA6B,GAAG,MAAM,CAAC;AAC7C,CAAC","sourcesContent":["import { logger } from '@sentry/utils';\nimport type { MetroConfig, MixedOutput, Module, ReadOnlyGraph } from 'metro';\nimport * as process from 'process';\nimport { env } from 'process';\n\nimport { enableLogger } from './enableLogger';\nimport { cleanDefaultBabelTransformerPath, saveDefaultBabelTransformerPath } from './sentryBabelTransformerUtils';\nimport { createSentryMetroSerializer, unstable_beforeAssetSerializationPlugin } from './sentryMetroSerializer';\nimport type { DefaultConfigOptions } from './vendor/expo/expoconfig';\n\nexport * from './sentryMetroSerializer';\n\nenableLogger();\n\nexport interface SentryMetroConfigOptions {\n /**\n * Annotates React components with Sentry data.\n * @default false\n */\n annotateReactComponents?: boolean;\n}\n\nexport interface SentryExpoConfigOptions {\n /**\n * Pass a custom `getDefaultConfig` function to override the default Expo configuration getter.\n */\n getDefaultConfig?: typeof getSentryExpoConfig;\n}\n\n/**\n * Adds Sentry to the Metro config.\n *\n * Adds Debug ID to the output bundle and source maps.\n * Collapses Sentry frames from the stack trace view in LogBox.\n */\nexport function withSentryConfig(\n config: MetroConfig,\n { annotateReactComponents = false }: SentryMetroConfigOptions = {},\n): MetroConfig {\n setSentryMetroDevServerEnvFlag();\n\n let newConfig = config;\n\n newConfig = withSentryDebugId(newConfig);\n newConfig = withSentryFramesCollapsed(newConfig);\n if (annotateReactComponents) {\n newConfig = withSentryBabelTransformer(newConfig);\n }\n\n return newConfig;\n}\n\n/**\n * This function returns Default Expo configuration with Sentry plugins.\n */\nexport function getSentryExpoConfig(\n projectRoot: string,\n options: DefaultConfigOptions & SentryExpoConfigOptions & SentryMetroConfigOptions = {},\n): MetroConfig {\n setSentryMetroDevServerEnvFlag();\n\n const getDefaultConfig = options.getDefaultConfig || loadExpoMetroConfigModule().getDefaultConfig;\n const config = getDefaultConfig(projectRoot, {\n ...options,\n unstable_beforeAssetSerializationPlugins: [\n ...(options.unstable_beforeAssetSerializationPlugins || []),\n unstable_beforeAssetSerializationPlugin,\n ],\n });\n\n let newConfig = withSentryFramesCollapsed(config);\n if (options.annotateReactComponents) {\n newConfig = withSentryBabelTransformer(newConfig);\n }\n\n return newConfig;\n}\n\nfunction loadExpoMetroConfigModule(): {\n getDefaultConfig: (\n projectRoot: string,\n options: {\n unstable_beforeAssetSerializationPlugins?: ((serializationInput: {\n graph: ReadOnlyGraph<MixedOutput>;\n premodules: Module[];\n debugId?: string;\n }) => Module[])[];\n },\n ) => MetroConfig;\n} {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n return require('expo/metro-config');\n } catch (e) {\n throw new Error('Unable to load `expo/metro-config`. Make sure you have Expo installed.');\n }\n}\n\n/**\n * Adds Sentry Babel transformer to the Metro config.\n */\nexport function withSentryBabelTransformer(config: MetroConfig): MetroConfig {\n const defaultBabelTransformerPath = config.transformer && config.transformer.babelTransformerPath;\n logger.debug('Default Babel transformer path from `config.transformer`:', defaultBabelTransformerPath);\n\n if (!defaultBabelTransformerPath) {\n // This has to be console.warn because the options is enabled but won't be used\n // eslint-disable-next-line no-console\n console.warn('`transformer.babelTransformerPath` is undefined.');\n // eslint-disable-next-line no-console\n console.warn('Sentry Babel transformer cannot be used. Not adding it...');\n return config;\n }\n\n if (defaultBabelTransformerPath) {\n saveDefaultBabelTransformerPath(defaultBabelTransformerPath);\n process.on('exit', () => {\n cleanDefaultBabelTransformerPath();\n });\n }\n\n return {\n ...config,\n transformer: {\n ...config.transformer,\n babelTransformerPath: require.resolve('./sentryBabelTransformer'),\n },\n };\n}\n\ntype MetroCustomSerializer = Required<Required<MetroConfig>['serializer']>['customSerializer'] | undefined;\n\nfunction withSentryDebugId(config: MetroConfig): MetroConfig {\n const customSerializer = createSentryMetroSerializer(\n config.serializer?.customSerializer || undefined,\n ) as MetroCustomSerializer;\n // MetroConfig types customSerializers as async only, but sync returns are also supported\n // The default serializer is sync\n\n return {\n ...config,\n serializer: {\n ...config.serializer,\n customSerializer,\n },\n };\n}\n\ntype MetroFrame = Parameters<Required<Required<MetroConfig>['symbolicator']>['customizeFrame']>[0];\ntype MetroCustomizeFrame = { readonly collapse?: boolean };\ntype MetroCustomizeFrameReturnValue =\n | ReturnType<Required<Required<MetroConfig>['symbolicator']>['customizeFrame']>\n | undefined;\n\n/**\n * Collapses Sentry internal frames from the stack trace view in LogBox.\n */\nexport function withSentryFramesCollapsed(config: MetroConfig): MetroConfig {\n const originalCustomizeFrame = config.symbolicator?.customizeFrame;\n const collapseSentryInternalFrames = (frame: MetroFrame): boolean =>\n typeof frame.file === 'string' &&\n (frame.file.includes('node_modules/@sentry/utils/cjs/instrument.js') ||\n frame.file.includes('node_modules/@sentry/utils/cjs/logger.js'));\n\n const customizeFrame = (frame: MetroFrame): MetroCustomizeFrameReturnValue => {\n const originalOrSentryCustomizeFrame = (\n originalCustomization: MetroCustomizeFrame | undefined,\n ): MetroCustomizeFrame => ({\n ...originalCustomization,\n collapse: (originalCustomization && originalCustomization.collapse) || collapseSentryInternalFrames(frame),\n });\n\n const maybePromiseCustomization = (originalCustomizeFrame && originalCustomizeFrame(frame)) || undefined;\n\n if (maybePromiseCustomization !== undefined && 'then' in maybePromiseCustomization) {\n return maybePromiseCustomization.then<MetroCustomizeFrame>(originalCustomization =>\n originalOrSentryCustomizeFrame(originalCustomization),\n );\n }\n\n return originalOrSentryCustomizeFrame(maybePromiseCustomization);\n };\n\n return {\n ...config,\n symbolicator: {\n ...config.symbolicator,\n customizeFrame,\n },\n };\n}\n\n/**\n * Sets the `___SENTRY_METRO_DEV_SERVER___` environment flag.\n * This is used to determine if the SDK is running in Node in Metro Dev Server.\n * For example during static routes generation in `expo-router`.\n */\nfunction setSentryMetroDevServerEnvFlag(): void {\n env.___SENTRY_METRO_DEV_SERVER___ = 'true';\n}\n"]}
|
|
1
|
+
{"version":3,"file":"metroconfig.js","sourceRoot":"","sources":["../../../src/js/tools/metroconfig.ts"],"names":[],"mappings":";;;AAAA,yCAAuC;AAGvC,mCAAmC;AACnC,qCAA8B;AAE9B,iDAA8C;AAC9C,+EAAkH;AAClH,mEAA+G;AAE/G,kEAAwC;AAExC,IAAA,2BAAY,GAAE,CAAC;AAsBf;;;;;GAKG;AACH,SAAgB,gBAAgB,CAC9B,MAAmB,EACnB,EAAE,uBAAuB,GAAG,KAAK,EAAE,gBAAgB,GAAG,IAAI,KAA+B,EAAE;IAE3F,8BAA8B,EAAE,CAAC;IAEjC,IAAI,SAAS,GAAG,MAAM,CAAC;IAEvB,SAAS,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC;IACzC,SAAS,GAAG,yBAAyB,CAAC,SAAS,CAAC,CAAC;IACjD,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,EAAkC,EAAE;QAC3E,MAAM,8BAA8B,GAAG,CACrC,qBAAsD,EACjC,EAAE,CAAC,iCACrB,qBAAqB,KACxB,QAAQ,EAAE,CAAC,qBAAqB,IAAI,qBAAqB,CAAC,QAAQ,CAAC,IAAI,4BAA4B,CAAC,KAAK,CAAC,IAC1G,CAAC;QAEH,MAAM,yBAAyB,GAAG,CAAC,sBAAsB,IAAI,sBAAsB,CAAC,KAAK,CAAC,CAAC,IAAI,SAAS,CAAC;QAEzG,IAAI,yBAAyB,KAAK,SAAS,IAAI,MAAM,IAAI,yBAAyB,EAAE;YAClF,OAAO,yBAAyB,CAAC,IAAI,CAAsB,qBAAqB,CAAC,EAAE,CACjF,8BAA8B,CAAC,qBAAqB,CAAC,CACtD,CAAC;SACH;QAED,OAAO,8BAA8B,CAAC,yBAAyB,CAAC,CAAC;IACnE,CAAC,CAAC;IAEF,uCACK,MAAM,KACT,YAAY,kCACP,MAAM,CAAC,YAAY,KACtB,cAAc,OAEhB;AACJ,CAAC;AAjCD,8DAiCC;AAED;;;;GAIG;AACH,SAAS,8BAA8B;IACrC,aAAG,CAAC,6BAA6B,GAAG,MAAM,CAAC;AAC7C,CAAC","sourcesContent":["import { logger } from '@sentry/utils';\nimport type { MetroConfig, MixedOutput, Module, ReadOnlyGraph } from 'metro';\nimport type { CustomResolutionContext, CustomResolver, Resolution } from 'metro-resolver';\nimport * as process from 'process';\nimport { env } from 'process';\n\nimport { enableLogger } from './enableLogger';\nimport { cleanDefaultBabelTransformerPath, saveDefaultBabelTransformerPath } from './sentryBabelTransformerUtils';\nimport { createSentryMetroSerializer, unstable_beforeAssetSerializationPlugin } from './sentryMetroSerializer';\nimport type { DefaultConfigOptions } from './vendor/expo/expoconfig';\nexport * from './sentryMetroSerializer';\n\nenableLogger();\n\nexport interface SentryMetroConfigOptions {\n /**\n * Annotates React components with Sentry data.\n * @default false\n */\n annotateReactComponents?: boolean;\n /**\n * Adds the Sentry replay package for web.\n * @default true\n */\n includeWebReplay?: boolean;\n}\n\nexport interface SentryExpoConfigOptions {\n /**\n * Pass a custom `getDefaultConfig` function to override the default Expo configuration getter.\n */\n getDefaultConfig?: typeof getSentryExpoConfig;\n}\n\n/**\n * Adds Sentry to the Metro config.\n *\n * Adds Debug ID to the output bundle and source maps.\n * Collapses Sentry frames from the stack trace view in LogBox.\n */\nexport function withSentryConfig(\n config: MetroConfig,\n { annotateReactComponents = false, includeWebReplay = true }: SentryMetroConfigOptions = {},\n): MetroConfig {\n setSentryMetroDevServerEnvFlag();\n\n let newConfig = config;\n\n newConfig = withSentryDebugId(newConfig);\n newConfig = withSentryFramesCollapsed(newConfig);\n if (annotateReactComponents) {\n newConfig = withSentryBabelTransformer(newConfig);\n }\n if (includeWebReplay === false) {\n newConfig = withSentryResolver(newConfig, includeWebReplay);\n }\n\n return newConfig;\n}\n\n/**\n * This function returns Default Expo configuration with Sentry plugins.\n */\nexport function getSentryExpoConfig(\n projectRoot: string,\n options: DefaultConfigOptions & SentryExpoConfigOptions & SentryMetroConfigOptions = {},\n): MetroConfig {\n setSentryMetroDevServerEnvFlag();\n\n const getDefaultConfig = options.getDefaultConfig || loadExpoMetroConfigModule().getDefaultConfig;\n const config = getDefaultConfig(projectRoot, {\n ...options,\n unstable_beforeAssetSerializationPlugins: [\n ...(options.unstable_beforeAssetSerializationPlugins || []),\n unstable_beforeAssetSerializationPlugin,\n ],\n });\n\n let newConfig = withSentryFramesCollapsed(config);\n if (options.annotateReactComponents) {\n newConfig = withSentryBabelTransformer(newConfig);\n }\n\n if (options.includeWebReplay === false) {\n newConfig = withSentryResolver(newConfig, options.includeWebReplay);\n }\n\n return newConfig;\n}\n\nfunction loadExpoMetroConfigModule(): {\n getDefaultConfig: (\n projectRoot: string,\n options: {\n unstable_beforeAssetSerializationPlugins?: ((serializationInput: {\n graph: ReadOnlyGraph<MixedOutput>;\n premodules: Module[];\n debugId?: string;\n }) => Module[])[];\n },\n ) => MetroConfig;\n} {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n return require('expo/metro-config');\n } catch (e) {\n throw new Error('Unable to load `expo/metro-config`. Make sure you have Expo installed.');\n }\n}\n\n/**\n * Adds Sentry Babel transformer to the Metro config.\n */\nexport function withSentryBabelTransformer(config: MetroConfig): MetroConfig {\n const defaultBabelTransformerPath = config.transformer && config.transformer.babelTransformerPath;\n logger.debug('Default Babel transformer path from `config.transformer`:', defaultBabelTransformerPath);\n\n if (!defaultBabelTransformerPath) {\n // This has to be console.warn because the options is enabled but won't be used\n // eslint-disable-next-line no-console\n console.warn('`transformer.babelTransformerPath` is undefined.');\n // eslint-disable-next-line no-console\n console.warn('Sentry Babel transformer cannot be used. Not adding it...');\n return config;\n }\n\n if (defaultBabelTransformerPath) {\n saveDefaultBabelTransformerPath(defaultBabelTransformerPath);\n process.on('exit', () => {\n cleanDefaultBabelTransformerPath();\n });\n }\n\n return {\n ...config,\n transformer: {\n ...config.transformer,\n babelTransformerPath: require.resolve('./sentryBabelTransformer'),\n },\n };\n}\n\ntype MetroCustomSerializer = Required<Required<MetroConfig>['serializer']>['customSerializer'] | undefined;\n\nfunction withSentryDebugId(config: MetroConfig): MetroConfig {\n const customSerializer = createSentryMetroSerializer(\n config.serializer?.customSerializer || undefined,\n ) as MetroCustomSerializer;\n // MetroConfig types customSerializers as async only, but sync returns are also supported\n // The default serializer is sync\n\n return {\n ...config,\n serializer: {\n ...config.serializer,\n customSerializer,\n },\n };\n}\n\n// Based on: https://github.com/facebook/metro/blob/c21daba415ea26511e157f794689caab9abe8236/packages/metro-resolver/src/resolve.js#L86-L91\ntype CustomResolverBeforeMetro068 = (\n context: CustomResolutionContext,\n realModuleName: string,\n platform: string | null,\n moduleName?: string,\n) => Resolution;\n\n/**\n * Includes `@sentry/replay` packages based on the `includeWebReplay` flag and current bundle `platform`.\n */\nexport function withSentryResolver(config: MetroConfig, includeWebReplay: boolean | undefined): MetroConfig {\n const originalResolver = config.resolver?.resolveRequest as CustomResolver | CustomResolverBeforeMetro068 | undefined;\n\n const sentryResolverRequest: CustomResolver = (\n context: CustomResolutionContext,\n moduleName: string,\n platform: string | null,\n oldMetroModuleName?: string,\n ) => {\n if (\n (includeWebReplay === false ||\n (includeWebReplay === undefined && (platform === 'android' || platform === 'ios'))) &&\n (oldMetroModuleName ?? moduleName).includes('@sentry/replay')\n ) {\n return { type: 'empty' } as Resolution;\n }\n if (originalResolver) {\n return oldMetroModuleName\n ? originalResolver(context, moduleName, platform, oldMetroModuleName)\n : originalResolver(context, moduleName, platform);\n }\n\n // Prior 0.68, resolve context.resolveRequest is sentryResolver itself, where on later version it is the default resolver.\n if (context.resolveRequest === sentryResolverRequest) {\n // eslint-disable-next-line no-console\n console.error(\n `Error: [@sentry/react-native/metro] Can not resolve the defaultResolver on Metro older than 0.68.\nPlease follow one of the following options:\n- Include your resolverRequest on your metroconfig.\n- Update your Metro version to 0.68 or higher.\n- Set includeWebReplay as true on your metro config.\n- If you are still facing issues, report the issue at http://www.github.com/getsentry/sentry-react-native/issues`,\n );\n // Return required for test.\n return process.exit(-1);\n }\n\n return context.resolveRequest(context, moduleName, platform);\n };\n\n return {\n ...config,\n resolver: {\n ...config.resolver,\n resolveRequest: sentryResolverRequest,\n },\n };\n}\n\ntype MetroFrame = Parameters<Required<Required<MetroConfig>['symbolicator']>['customizeFrame']>[0];\ntype MetroCustomizeFrame = { readonly collapse?: boolean };\ntype MetroCustomizeFrameReturnValue =\n | ReturnType<Required<Required<MetroConfig>['symbolicator']>['customizeFrame']>\n | undefined;\n\n/**\n * Collapses Sentry internal frames from the stack trace view in LogBox.\n */\nexport function withSentryFramesCollapsed(config: MetroConfig): MetroConfig {\n const originalCustomizeFrame = config.symbolicator?.customizeFrame;\n const collapseSentryInternalFrames = (frame: MetroFrame): boolean =>\n typeof frame.file === 'string' &&\n (frame.file.includes('node_modules/@sentry/utils/cjs/instrument.js') ||\n frame.file.includes('node_modules/@sentry/utils/cjs/logger.js'));\n\n const customizeFrame = (frame: MetroFrame): MetroCustomizeFrameReturnValue => {\n const originalOrSentryCustomizeFrame = (\n originalCustomization: MetroCustomizeFrame | undefined,\n ): MetroCustomizeFrame => ({\n ...originalCustomization,\n collapse: (originalCustomization && originalCustomization.collapse) || collapseSentryInternalFrames(frame),\n });\n\n const maybePromiseCustomization = (originalCustomizeFrame && originalCustomizeFrame(frame)) || undefined;\n\n if (maybePromiseCustomization !== undefined && 'then' in maybePromiseCustomization) {\n return maybePromiseCustomization.then<MetroCustomizeFrame>(originalCustomization =>\n originalOrSentryCustomizeFrame(originalCustomization),\n );\n }\n\n return originalOrSentryCustomizeFrame(maybePromiseCustomization);\n };\n\n return {\n ...config,\n symbolicator: {\n ...config.symbolicator,\n customizeFrame,\n },\n };\n}\n\n/**\n * Sets the `___SENTRY_METRO_DEV_SERVER___` environment flag.\n * This is used to determine if the SDK is running in Node in Metro Dev Server.\n * For example during static routes generation in `expo-router`.\n */\nfunction setSentryMetroDevServerEnvFlag(): void {\n env.___SENTRY_METRO_DEV_SERVER___ = 'true';\n}\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { ReactNativeTracing } from './reactnativetracing';
|
|
1
|
+
export { ReactNativeTracing, reactNativeTracingIntegration } from './reactnativetracing';
|
|
2
2
|
export type { RoutingInstrumentationInstance } from './routingInstrumentation';
|
|
3
3
|
export { RoutingInstrumentation } from './routingInstrumentation';
|
|
4
|
-
export { ReactNavigationInstrumentation, ReactNavigationV5Instrumentation, } from './reactnavigation';
|
|
4
|
+
export { ReactNavigationInstrumentation, reactNavigationIntegration, ReactNavigationV5Instrumentation, } from './reactnavigation';
|
|
5
5
|
export { ReactNavigationV4Instrumentation } from './reactnavigationv4';
|
|
6
|
-
export { ReactNativeNavigationInstrumentation } from './reactnativenavigation';
|
|
6
|
+
export { ReactNativeNavigationInstrumentation, reactNativeNavigationIntegration } from './reactnativenavigation';
|
|
7
7
|
export type { ReactNavigationCurrentRoute, ReactNavigationRoute, ReactNavigationTransactionContext } from './types';
|
|
8
8
|
export { ReactNativeProfiler } from './reactnativeprofiler';
|
|
9
9
|
export { sentryTraceGesture } from './gesturetracing';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AAEzF,YAAY,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EACL,8BAA8B,EAC9B,0BAA0B,EAE1B,gCAAgC,GACjC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,oCAAoC,EAAE,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AAEjH,YAAY,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,iCAAiC,EAAE,MAAM,SAAS,CAAC;AAEpH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,cAAc,OAAO,CAAC;AAEtB,cAAc,iBAAiB,CAAC"}
|
package/dist/js/tracing/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { ReactNativeTracing } from './reactnativetracing';
|
|
1
|
+
export { ReactNativeTracing, reactNativeTracingIntegration } from './reactnativetracing';
|
|
2
2
|
export { RoutingInstrumentation } from './routingInstrumentation';
|
|
3
|
-
export { ReactNavigationInstrumentation,
|
|
3
|
+
export { ReactNavigationInstrumentation, reactNavigationIntegration,
|
|
4
4
|
// eslint-disable-next-line deprecation/deprecation
|
|
5
5
|
ReactNavigationV5Instrumentation, } from './reactnavigation';
|
|
6
6
|
export { ReactNavigationV4Instrumentation } from './reactnavigationv4';
|
|
7
|
-
export { ReactNativeNavigationInstrumentation } from './reactnativenavigation';
|
|
7
|
+
export { ReactNativeNavigationInstrumentation, reactNativeNavigationIntegration } from './reactnativenavigation';
|
|
8
8
|
export { ReactNativeProfiler } from './reactnativeprofiler';
|
|
9
9
|
export { sentryTraceGesture } from './gesturetracing';
|
|
10
10
|
export * from './ops';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/js/tracing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/js/tracing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AAGzF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EACL,8BAA8B,EAC9B,0BAA0B;AAC1B,mDAAmD;AACnD,gCAAgC,GACjC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,oCAAoC,EAAE,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AAIjH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,cAAc,OAAO,CAAC;AAEtB,cAAc,iBAAiB,CAAC","sourcesContent":["export { ReactNativeTracing, reactNativeTracingIntegration } from './reactnativetracing';\n\nexport type { RoutingInstrumentationInstance } from './routingInstrumentation';\nexport { RoutingInstrumentation } from './routingInstrumentation';\n\nexport {\n ReactNavigationInstrumentation,\n reactNavigationIntegration,\n // eslint-disable-next-line deprecation/deprecation\n ReactNavigationV5Instrumentation,\n} from './reactnavigation';\nexport { ReactNavigationV4Instrumentation } from './reactnavigationv4';\nexport { ReactNativeNavigationInstrumentation, reactNativeNavigationIntegration } from './reactnativenavigation';\n\nexport type { ReactNavigationCurrentRoute, ReactNavigationRoute, ReactNavigationTransactionContext } from './types';\n\nexport { ReactNativeProfiler } from './reactnativeprofiler';\n\nexport { sentryTraceGesture } from './gesturetracing';\n\nexport * from './ops';\n\nexport * from './timetodisplay';\n"]}
|
|
@@ -50,6 +50,12 @@ export interface NavigationDelegate {
|
|
|
50
50
|
* - `_onComponentWillAppear` is then called AFTER the state change happens due to a dispatch and sets the route context onto the active transaction.
|
|
51
51
|
* - If `_onComponentWillAppear` isn't called within `options.routeChangeTimeoutMs` of the dispatch, then the transaction is not sampled and finished.
|
|
52
52
|
*/
|
|
53
|
+
export declare const reactNativeNavigationIntegration: (options: Partial<ReactNativeNavigationOptions> & {
|
|
54
|
+
navigation: NavigationDelegate;
|
|
55
|
+
}) => ReactNativeNavigationInstrumentation;
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated Use `Sentry.reactNativeNavigationIntegration({ navigation })` instead.
|
|
58
|
+
*/
|
|
53
59
|
export declare class ReactNativeNavigationInstrumentation extends InternalRoutingInstrumentation {
|
|
54
60
|
static instrumentationName: string;
|
|
55
61
|
readonly name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactnativenavigation.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/reactnativenavigation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,KAAK,EAAE,cAAc,EAA0B,MAAM,SAAS,CAAC;AAGtE,UAAU,4BAA4B;IACpC;;;;;;OAM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AC7B,IAAI;IAYP;;OAEG;IACH,OAAO,CAAC,aAAa;IAerB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAyD9B,4DAA4D;IAC5D,OAAO,CAAC,oBAAoB;IAwB5B,wEAAwE;IACxE,OAAO,CAAC,yBAAyB;IAUjC,wEAAwE;IACxE,OAAO,CAAC,wBAAwB;CAMjC"}
|
|
@@ -13,6 +13,12 @@ const defaultOptions = {
|
|
|
13
13
|
* - `_onComponentWillAppear` is then called AFTER the state change happens due to a dispatch and sets the route context onto the active transaction.
|
|
14
14
|
* - If `_onComponentWillAppear` isn't called within `options.routeChangeTimeoutMs` of the dispatch, then the transaction is not sampled and finished.
|
|
15
15
|
*/
|
|
16
|
+
export const reactNativeNavigationIntegration = (options) => {
|
|
17
|
+
return new ReactNativeNavigationInstrumentation(options.navigation, options);
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Use `Sentry.reactNativeNavigationIntegration({ navigation })` instead.
|
|
21
|
+
*/
|
|
16
22
|
export class ReactNativeNavigationInstrumentation extends InternalRoutingInstrumentation {
|
|
17
23
|
constructor(
|
|
18
24
|
/** The react native navigation `NavigationDelegate`. This is usually the import named `Navigation`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactnativenavigation.js","sourceRoot":"","sources":["../../../src/js/tracing/reactnativenavigation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAIvC,OAAO,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAC;AAE1E,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAoBxG,MAAM,cAAc,GAAiC;IACnD,oBAAoB,EAAE,IAAI;IAC1B,yBAAyB,EAAE,IAAI;CAChC,CAAC;AAgCF;;;;;;;GAOG;AACH,MAAM,OAAO,oCAAqC,SAAQ,8BAA8B;IActF;IACE,uGAAuG;IACvG,UAAmB,E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SACtC;IACH,CAAC;;AAvKa,wDAAmB,GAAW,yBAAyB,CAAC","sourcesContent":["import type { Transaction as TransactionType, TransactionContext } from '@sentry/types';\nimport { logger } from '@sentry/utils';\n\nimport type { EmitterSubscription } from '../utils/rnlibrariesinterface';\nimport type { OnConfirmRoute, TransactionCreator } from './routingInstrumentation';\nimport { InternalRoutingInstrumentation } from './routingInstrumentation';\nimport type { BeforeNavigate, RouteChangeContextData } from './types';\nimport { customTransactionSource, defaultTransactionSource, getBlankTransactionContext } from './utils';\n\ninterface ReactNativeNavigationOptions {\n /**\n * How long the instrumentation will wait for the route to mount after a change has been initiated,\n * before the transaction is discarded.\n * Time is in ms.\n *\n * Default: 1000\n */\n routeChangeTimeoutMs: number;\n /**\n * Instrumentation will create a transaction on tab change.\n * By default only navigation commands create transactions.\n *\n * Default: true\n */\n enableTabsInstrumentation: boolean;\n}\n\nconst defaultOptions: ReactNativeNavigationOptions = {\n routeChangeTimeoutMs: 1000,\n enableTabsInstrumentation: true,\n};\n\ninterface ComponentEvent {\n componentId: string;\n}\n\ntype ComponentType = 'Component' | 'TopBarTitle' | 'TopBarBackground' | 'TopBarButton';\n\nexport interface ComponentWillAppearEvent extends ComponentEvent {\n componentName: string;\n passProps?: Record<string | number | symbol, unknown>;\n componentType: ComponentType;\n}\n\nexport interface EventSubscription {\n remove(): void;\n}\n\nexport interface BottomTabPressedEvent {\n tabIndex: number;\n}\n\nexport interface EventsRegistry {\n registerComponentWillAppearListener(callback: (event: ComponentWillAppearEvent) => void): EmitterSubscription;\n registerCommandListener(callback: (name: string, params: unknown) => void): EventSubscription;\n registerBottomTabPressedListener(callback: (event: BottomTabPressedEvent) => void): EmitterSubscription;\n}\n\nexport interface NavigationDelegate {\n events: () => EventsRegistry;\n}\n\n/**\n * Instrumentation for React Native Navigation. See docs or sample app for usage.\n *\n * How this works:\n * - `_onCommand` is called every time a commands happens and sets an IdleTransaction on the scope without any route context.\n * - `_onComponentWillAppear` is then called AFTER the state change happens due to a dispatch and sets the route context onto the active transaction.\n * - If `_onComponentWillAppear` isn't called within `options.routeChangeTimeoutMs` of the dispatch, then the transaction is not sampled and finished.\n */\nexport class ReactNativeNavigationInstrumentation extends InternalRoutingInstrumentation {\n public static instrumentationName: string = 'react-native-navigation';\n\n public readonly name: string = ReactNativeNavigationInstrumentation.instrumentationName;\n\n private _navigation: NavigationDelegate;\n private _options: ReactNativeNavigationOptions;\n\n private _prevComponentEvent: ComponentWillAppearEvent | null = null;\n\n private _latestTransaction?: TransactionType;\n private _recentComponentIds: string[] = [];\n private _stateChangeTimeout?: number | undefined;\n\n public constructor(\n /** The react native navigation `NavigationDelegate`. This is usually the import named `Navigation`. */\n navigation: unknown,\n options: Partial<ReactNativeNavigationOptions> = {},\n ) {\n super();\n\n this._navigation = navigation as NavigationDelegate;\n\n this._options = {\n ...defaultOptions,\n ...options,\n };\n }\n\n /**\n * Registers the event listeners for React Native Navigation\n */\n public registerRoutingInstrumentation(\n listener: TransactionCreator,\n beforeNavigate: BeforeNavigate,\n onConfirmRoute: OnConfirmRoute,\n ): void {\n super.registerRoutingInstrumentation(listener, beforeNavigate, onConfirmRoute);\n\n this._navigation.events().registerCommandListener(this._onNavigation.bind(this));\n\n if (this._options.enableTabsInstrumentation) {\n this._navigation.events().registerBottomTabPressedListener(this._onNavigation.bind(this));\n }\n\n this._navigation.events().registerComponentWillAppearListener(this._onComponentWillAppear.bind(this));\n }\n\n /**\n * To be called when a navigation is initiated. (Command, BottomTabSelected, etc.)\n */\n private _onNavigation(): void {\n if (this._latestTransaction) {\n this._discardLatestTransaction();\n }\n\n this._latestTransaction = this.onRouteWillChange(\n getBlankTransactionContext(ReactNativeNavigationInstrumentation.name),\n );\n\n this._stateChangeTimeout = setTimeout(\n this._discardLatestTransaction.bind(this),\n this._options.routeChangeTimeoutMs,\n );\n }\n\n /**\n * To be called AFTER the state has been changed to populate the transaction with the current route.\n */\n private _onComponentWillAppear(event: ComponentWillAppearEvent): void {\n if (!this._latestTransaction) {\n return;\n }\n\n // We ignore actions that pertain to the same screen.\n const isSameComponent = this._prevComponentEvent && event.componentId === this._prevComponentEvent.componentId;\n if (isSameComponent) {\n this._discardLatestTransaction();\n return;\n }\n\n this._clearStateChangeTimeout();\n\n const originalContext = this._latestTransaction.toContext();\n const routeHasBeenSeen = this._recentComponentIds.includes(event.componentId);\n\n const data: RouteChangeContextData = {\n ...originalContext.data,\n route: {\n ...event,\n name: event.componentName,\n hasBeenSeen: routeHasBeenSeen,\n },\n previousRoute: this._prevComponentEvent\n ? {\n ...this._prevComponentEvent,\n name: this._prevComponentEvent?.componentName,\n }\n : null,\n };\n\n const updatedContext = {\n ...originalContext,\n name: event.componentName,\n tags: {\n ...originalContext.tags,\n 'routing.route.name': event.componentName,\n },\n data,\n };\n\n const finalContext = this._prepareFinalContext(updatedContext);\n this._latestTransaction.updateWithContext(finalContext);\n\n const isCustomName = updatedContext.name !== finalContext.name;\n this._latestTransaction.setName(\n finalContext.name,\n isCustomName ? customTransactionSource : defaultTransactionSource,\n );\n\n this._onConfirmRoute?.(finalContext);\n this._prevComponentEvent = event;\n\n this._latestTransaction = undefined;\n }\n\n /** Creates final transaction context before confirmation */\n private _prepareFinalContext(updatedContext: TransactionContext): TransactionContext {\n let finalContext = this._beforeNavigate?.({ ...updatedContext });\n\n // This block is to catch users not returning a transaction context\n if (!finalContext) {\n logger.error(\n `[${ReactNativeNavigationInstrumentation.name}] beforeNavigate returned ${finalContext}, return context.sampled = false to not send transaction.`,\n );\n\n finalContext = {\n ...updatedContext,\n sampled: false,\n };\n }\n\n if (finalContext.sampled === false) {\n logger.log(\n `[${ReactNativeNavigationInstrumentation.name}] Will not send transaction \"${finalContext.name}\" due to beforeNavigate.`,\n );\n }\n\n return finalContext;\n }\n\n /** Cancels the latest transaction so it does not get sent to Sentry. */\n private _discardLatestTransaction(): void {\n if (this._latestTransaction) {\n this._latestTransaction.sampled = false;\n this._latestTransaction.finish();\n this._latestTransaction = undefined;\n }\n\n this._clearStateChangeTimeout();\n }\n\n /** Cancels the latest transaction so it does not get sent to Sentry. */\n private _clearStateChangeTimeout(): void {\n if (typeof this._stateChangeTimeout !== 'undefined') {\n clearTimeout(this._stateChangeTimeout);\n this._stateChangeTimeout = undefined;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"reactnativenavigation.js","sourceRoot":"","sources":["../../../src/js/tracing/reactnativenavigation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAIvC,OAAO,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAC;AAE1E,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAoBxG,MAAM,cAAc,GAAiC;IACnD,oBAAoB,EAAE,IAAI;IAC1B,yBAAyB,EAAE,IAAI;CAChC,CAAC;AAgCF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAC9C,OAEC,EACqC,EAAE;IACxC,OAAO,IAAI,oCAAoC,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAC/E,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,OAAO,oCAAqC,SAAQ,8BAA8B;IActF;IACE,uGAAuG;IACvG,UAAmB,EACnB,UAAiD,EAAE;QAEnD,KAAK,EAAE,CAAC;QAhBM,SAAI,GAAW,oCAAoC,CAAC,mBAAmB,CAAC;QAKhF,wBAAmB,GAAoC,IAAI,CAAC;QAG5D,wBAAmB,GAAa,EAAE,CAAC;QAUzC,IAAI,CAAC,WAAW,GAAG,UAAgC,CAAC;QAEpD,IAAI,CAAC,QAAQ,mCACR,cAAc,GACd,OAAO,CACX,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,8BAA8B,CACnC,QAA4B,EAC5B,cAA8B,EAC9B,cAA8B;QAE9B,KAAK,CAAC,8BAA8B,CAAC,QAAQ,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC;QAE/E,IAAI,CA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,MAAM,CAAC,KAAK,CACV,IAAI,oCAAoC,CAAC,IAAI,6BAA6B,YAAY,2DAA2D,CAClJ,CAAC;YAEF,YAAY,mCACP,cAAc,KACjB,OAAO,EAAE,KAAK,GACf,CAAC;SACH;QAED,IAAI,YAAY,CAAC,OAAO,KAAK,KAAK,EAAE;YAClC,MAAM,CAAC,GAAG,CACR,IAAI,oCAAoC,CAAC,IAAI,gCAAgC,YAAY,CAAC,IAAI,0BAA0B,CACzH,CAAC;SACH;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,wEAAwE;IAChE,yBAAyB;QAC/B,IAAI,IAAI,CAAC,kBAAkB,EAAE;YAC3B,IAAI,CAAC,kBAAkB,CAAC,OAAO,GAAG,KAAK,CAAC;YACxC,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,CAAC;YACjC,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;SACrC;QAED,IAAI,CAAC,wBAAwB,EAAE,CAAC;IAClC,CAAC;IAED,wEAAwE;IAChE,wBAAwB;QAC9B,IAAI,OAAO,IAAI,CAAC,mBAAmB,KAAK,WAAW,EAAE;YACnD,YAAY,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;YACvC,IAAI,CAAC,mBAAmB,GAAG,SAAS,CAAC;SACtC;IACH,CAAC;;AAvKa,wDAAmB,GAAW,yBAAyB,CAAC","sourcesContent":["import type { Transaction as TransactionType, TransactionContext } from '@sentry/types';\nimport { logger } from '@sentry/utils';\n\nimport type { EmitterSubscription } from '../utils/rnlibrariesinterface';\nimport type { OnConfirmRoute, TransactionCreator } from './routingInstrumentation';\nimport { InternalRoutingInstrumentation } from './routingInstrumentation';\nimport type { BeforeNavigate, RouteChangeContextData } from './types';\nimport { customTransactionSource, defaultTransactionSource, getBlankTransactionContext } from './utils';\n\ninterface ReactNativeNavigationOptions {\n /**\n * How long the instrumentation will wait for the route to mount after a change has been initiated,\n * before the transaction is discarded.\n * Time is in ms.\n *\n * Default: 1000\n */\n routeChangeTimeoutMs: number;\n /**\n * Instrumentation will create a transaction on tab change.\n * By default only navigation commands create transactions.\n *\n * Default: true\n */\n enableTabsInstrumentation: boolean;\n}\n\nconst defaultOptions: ReactNativeNavigationOptions = {\n routeChangeTimeoutMs: 1000,\n enableTabsInstrumentation: true,\n};\n\ninterface ComponentEvent {\n componentId: string;\n}\n\ntype ComponentType = 'Component' | 'TopBarTitle' | 'TopBarBackground' | 'TopBarButton';\n\nexport interface ComponentWillAppearEvent extends ComponentEvent {\n componentName: string;\n passProps?: Record<string | number | symbol, unknown>;\n componentType: ComponentType;\n}\n\nexport interface EventSubscription {\n remove(): void;\n}\n\nexport interface BottomTabPressedEvent {\n tabIndex: number;\n}\n\nexport interface EventsRegistry {\n registerComponentWillAppearListener(callback: (event: ComponentWillAppearEvent) => void): EmitterSubscription;\n registerCommandListener(callback: (name: string, params: unknown) => void): EventSubscription;\n registerBottomTabPressedListener(callback: (event: BottomTabPressedEvent) => void): EmitterSubscription;\n}\n\nexport interface NavigationDelegate {\n events: () => EventsRegistry;\n}\n\n/**\n * Instrumentation for React Native Navigation. See docs or sample app for usage.\n *\n * How this works:\n * - `_onCommand` is called every time a commands happens and sets an IdleTransaction on the scope without any route context.\n * - `_onComponentWillAppear` is then called AFTER the state change happens due to a dispatch and sets the route context onto the active transaction.\n * - If `_onComponentWillAppear` isn't called within `options.routeChangeTimeoutMs` of the dispatch, then the transaction is not sampled and finished.\n */\nexport const reactNativeNavigationIntegration = (\n options: Partial<ReactNativeNavigationOptions> & {\n navigation: NavigationDelegate;\n },\n): ReactNativeNavigationInstrumentation => {\n return new ReactNativeNavigationInstrumentation(options.navigation, options);\n};\n\n/**\n * @deprecated Use `Sentry.reactNativeNavigationIntegration({ navigation })` instead.\n */\nexport class ReactNativeNavigationInstrumentation extends InternalRoutingInstrumentation {\n public static instrumentationName: string = 'react-native-navigation';\n\n public readonly name: string = ReactNativeNavigationInstrumentation.instrumentationName;\n\n private _navigation: NavigationDelegate;\n private _options: ReactNativeNavigationOptions;\n\n private _prevComponentEvent: ComponentWillAppearEvent | null = null;\n\n private _latestTransaction?: TransactionType;\n private _recentComponentIds: string[] = [];\n private _stateChangeTimeout?: number | undefined;\n\n public constructor(\n /** The react native navigation `NavigationDelegate`. This is usually the import named `Navigation`. */\n navigation: unknown,\n options: Partial<ReactNativeNavigationOptions> = {},\n ) {\n super();\n\n this._navigation = navigation as NavigationDelegate;\n\n this._options = {\n ...defaultOptions,\n ...options,\n };\n }\n\n /**\n * Registers the event listeners for React Native Navigation\n */\n public registerRoutingInstrumentation(\n listener: TransactionCreator,\n beforeNavigate: BeforeNavigate,\n onConfirmRoute: OnConfirmRoute,\n ): void {\n super.registerRoutingInstrumentation(listener, beforeNavigate, onConfirmRoute);\n\n this._navigation.events().registerCommandListener(this._onNavigation.bind(this));\n\n if (this._options.enableTabsInstrumentation) {\n this._navigation.events().registerBottomTabPressedListener(this._onNavigation.bind(this));\n }\n\n this._navigation.events().registerComponentWillAppearListener(this._onComponentWillAppear.bind(this));\n }\n\n /**\n * To be called when a navigation is initiated. (Command, BottomTabSelected, etc.)\n */\n private _onNavigation(): void {\n if (this._latestTransaction) {\n this._discardLatestTransaction();\n }\n\n this._latestTransaction = this.onRouteWillChange(\n getBlankTransactionContext(ReactNativeNavigationInstrumentation.name),\n );\n\n this._stateChangeTimeout = setTimeout(\n this._discardLatestTransaction.bind(this),\n this._options.routeChangeTimeoutMs,\n );\n }\n\n /**\n * To be called AFTER the state has been changed to populate the transaction with the current route.\n */\n private _onComponentWillAppear(event: ComponentWillAppearEvent): void {\n if (!this._latestTransaction) {\n return;\n }\n\n // We ignore actions that pertain to the same screen.\n const isSameComponent = this._prevComponentEvent && event.componentId === this._prevComponentEvent.componentId;\n if (isSameComponent) {\n this._discardLatestTransaction();\n return;\n }\n\n this._clearStateChangeTimeout();\n\n const originalContext = this._latestTransaction.toContext();\n const routeHasBeenSeen = this._recentComponentIds.includes(event.componentId);\n\n const data: RouteChangeContextData = {\n ...originalContext.data,\n route: {\n ...event,\n name: event.componentName,\n hasBeenSeen: routeHasBeenSeen,\n },\n previousRoute: this._prevComponentEvent\n ? {\n ...this._prevComponentEvent,\n name: this._prevComponentEvent?.componentName,\n }\n : null,\n };\n\n const updatedContext = {\n ...originalContext,\n name: event.componentName,\n tags: {\n ...originalContext.tags,\n 'routing.route.name': event.componentName,\n },\n data,\n };\n\n const finalContext = this._prepareFinalContext(updatedContext);\n this._latestTransaction.updateWithContext(finalContext);\n\n const isCustomName = updatedContext.name !== finalContext.name;\n this._latestTransaction.setName(\n finalContext.name,\n isCustomName ? customTransactionSource : defaultTransactionSource,\n );\n\n this._onConfirmRoute?.(finalContext);\n this._prevComponentEvent = event;\n\n this._latestTransaction = undefined;\n }\n\n /** Creates final transaction context before confirmation */\n private _prepareFinalContext(updatedContext: TransactionContext): TransactionContext {\n let finalContext = this._beforeNavigate?.({ ...updatedContext });\n\n // This block is to catch users not returning a transaction context\n if (!finalContext) {\n logger.error(\n `[${ReactNativeNavigationInstrumentation.name}] beforeNavigate returned ${finalContext}, return context.sampled = false to not send transaction.`,\n );\n\n finalContext = {\n ...updatedContext,\n sampled: false,\n };\n }\n\n if (finalContext.sampled === false) {\n logger.log(\n `[${ReactNativeNavigationInstrumentation.name}] Will not send transaction \"${finalContext.name}\" due to beforeNavigate.`,\n );\n }\n\n return finalContext;\n }\n\n /** Cancels the latest transaction so it does not get sent to Sentry. */\n private _discardLatestTransaction(): void {\n if (this._latestTransaction) {\n this._latestTransaction.sampled = false;\n this._latestTransaction.finish();\n this._latestTransaction = undefined;\n }\n\n this._clearStateChangeTimeout();\n }\n\n /** Cancels the latest transaction so it does not get sent to Sentry. */\n private _clearStateChangeTimeout(): void {\n if (typeof this._stateChangeTimeout !== 'undefined') {\n clearTimeout(this._stateChangeTimeout);\n this._stateChangeTimeout = undefined;\n }\n }\n}\n"]}
|
|
@@ -5,6 +5,7 @@ import type { RoutingInstrumentationInstance } from '../tracing/routingInstrumen
|
|
|
5
5
|
import { NativeFramesInstrumentation } from './nativeframes';
|
|
6
6
|
import { StallTrackingInstrumentation } from './stalltracking';
|
|
7
7
|
import type { BeforeNavigate } from './types';
|
|
8
|
+
export declare const reactNativeTracingIntegration: (options?: Partial<ReactNativeTracingOptions>) => ReactNativeTracing;
|
|
8
9
|
export interface ReactNativeTracingOptions extends RequestInstrumentationOptions {
|
|
9
10
|
/**
|
|
10
11
|
* @deprecated Replaced by idleTimeoutMs
|
|
@@ -53,27 +54,24 @@ export interface ReactNativeTracingOptions extends RequestInstrumentationOptions
|
|
|
53
54
|
*/
|
|
54
55
|
beforeNavigate: BeforeNavigate;
|
|
55
56
|
/**
|
|
56
|
-
*
|
|
57
|
-
* an app start transaction will be started.
|
|
58
|
-
*
|
|
59
|
-
* Default: true
|
|
57
|
+
* @deprecated Use `Sentry.init({ enableAppStartTracking })` instead.
|
|
60
58
|
*/
|
|
61
59
|
enableAppStartTracking: boolean;
|
|
62
60
|
/**
|
|
63
|
-
*
|
|
61
|
+
* @deprecated Use `Sentry.init({ enableNativeFramesTracking })` instead.
|
|
64
62
|
*/
|
|
65
63
|
enableNativeFramesTracking: boolean;
|
|
66
64
|
/**
|
|
67
|
-
*
|
|
65
|
+
* @deprecated Use `Sentry.init({ enableStallTracking })` instead.
|
|
68
66
|
*/
|
|
69
67
|
enableStallTracking: boolean;
|
|
70
68
|
/**
|
|
71
|
-
*
|
|
69
|
+
* @deprecated Use `Sentry.init({ enableUserInteractionTracing })` instead.
|
|
72
70
|
*/
|
|
73
71
|
enableUserInteractionTracing: boolean;
|
|
74
72
|
}
|
|
75
73
|
/**
|
|
76
|
-
*
|
|
74
|
+
* @deprecated Use `Sentry.reactNativeTracingIntegration()` instead.
|
|
77
75
|
*/
|
|
78
76
|
export declare class ReactNativeTracing implements Integration {
|
|
79
77
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactnativetracing.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/reactnativetracing.ts"],"names":[],"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,WAAW,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI;IAKjF;;OAEG;IACI,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;IAInD;;OAEG;IACI,+CAA+C,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAI/E;;;OAGG;IACI,+BAA+B,CAAC,iBAAiB,EAAE;QACxD,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;QAC9B,EAAE,EAAE,MAAM,CAAC;KACZ,GAAG,eAAe,GAAG,SAAS;IAyD/B;;OAEG;IACH,OAAO,CAAC,2BAA2B;IAoCnC;;;OAGG;IACH,OAAO,CAAC,6BAA6B;IAOrC;;;OAGG;IACH,OAAO,CAAC,gCAAgC;IAOxC;;;OAGG;YACW,mBAAmB;IAoCjC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IA2DxB;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAyBjC;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAezB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAuBxB,6FAA6F;IAC7F,OAAO,CAAC,kBAAkB;IAI1B;;OAEG;IACH,OAAO,CAAC,eAAe;IA4BvB,uCAAuC;IACvC,OAAO,CAAC,uBAAuB;IAqE/B;;OAEG;IACH,OAAO,CAAC,qBAAqB;CAO9B"}
|
|
@@ -9,10 +9,13 @@ import { APP_START_COLD as APP_START_COLD_OP, APP_START_WARM as APP_START_WARM_O
|
|
|
9
9
|
import { StallTrackingInstrumentation } from './stalltracking';
|
|
10
10
|
import { cancelInBackground, onlySampleIfChildSpans } from './transaction';
|
|
11
11
|
import { adjustTransactionDuration, getBundleStartTimestampMs, getTimeOriginMilliseconds, isNearToNow, setSpanDurationAsMeasurement, } from './utils';
|
|
12
|
+
export const reactNativeTracingIntegration = (options) => {
|
|
13
|
+
return new ReactNativeTracing(options);
|
|
14
|
+
};
|
|
12
15
|
const DEFAULT_TRACE_PROPAGATION_TARGETS = ['localhost', /^\/(?!\/)/];
|
|
13
16
|
const defaultReactNativeTracingOptions = Object.assign(Object.assign({}, defaultRequestInstrumentationOptions), { idleTimeout: 1000, maxTransactionDuration: 600, idleTimeoutMs: 1000, finalTimeoutMs: 600000, ignoreEmptyBackNavigationTransactions: true, beforeNavigate: context => context, enableAppStartTracking: true, enableNativeFramesTracking: true, enableStallTracking: true, enableUserInteractionTracing: false });
|
|
14
17
|
/**
|
|
15
|
-
*
|
|
18
|
+
* @deprecated Use `Sentry.reactNativeTracingIntegration()` instead.
|
|
16
19
|
*/
|
|
17
20
|
export class ReactNativeTracing {
|
|
18
21
|
constructor(options = {}) {
|
|
@@ -41,6 +44,7 @@ export class ReactNativeTracing {
|
|
|
41
44
|
* Registers routing and request instrumentation.
|
|
42
45
|
*/
|
|
43
46
|
setupOnce(addGlobalEventProcessor, getCurrentHub) {
|
|
47
|
+
var _a, _b;
|
|
44
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45
49
|
const hub = getCurrentHub();
|
|
46
50
|
const client = hub.getClient();
|
|
@@ -71,13 +75,13 @@ export class ReactNativeTracing {
|
|
|
71
75
|
clientOptionsTracePropagationTargets) {
|
|
72
76
|
logger.warn('[ReactNativeTracing] The `tracePropagationTargets` option was set in the ReactNativeTracing integration and top level `Sentry.init`. The top level `Sentry.init` value is being used.');
|
|
73
77
|
}
|
|
74
|
-
if (enableAppStartTracking) {
|
|
75
|
-
this._instrumentAppStart().then(undefined, (reason) => {
|
|
78
|
+
if ((_a = clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.enableAppStartTracking) !== null && _a !== void 0 ? _a : enableAppStartTracking) {
|
|
79
|
+
this._instrumentAppStart(clientOptions).then(undefined, (reason) => {
|
|
76
80
|
logger.error(`[ReactNativeTracing] Error while instrumenting app start:`, reason);
|
|
77
81
|
});
|
|
78
82
|
}
|
|
79
|
-
this._enableNativeFramesTracking(addGlobalEventProcessor);
|
|
80
|
-
if (enableStallTracking) {
|
|
83
|
+
this._enableNativeFramesTracking(addGlobalEventProcessor, clientOptions);
|
|
84
|
+
if ((_b = clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.enableStallTracking) !== null && _b !== void 0 ? _b : enableStallTracking) {
|
|
81
85
|
this.stallTrackingInstrumentation = new StallTrackingInstrumentation();
|
|
82
86
|
}
|
|
83
87
|
if (routingInstrumentation) {
|
|
@@ -134,9 +138,10 @@ export class ReactNativeTracing {
|
|
|
134
138
|
* @param userInteractionId Consists of `op` representation UI Event and `elementId` unique element identifier on current screen.
|
|
135
139
|
*/
|
|
136
140
|
startUserInteractionTransaction(userInteractionId) {
|
|
137
|
-
var _a, _b;
|
|
141
|
+
var _a, _b, _c, _d, _e, _f;
|
|
138
142
|
const { elementId, op } = userInteractionId;
|
|
139
|
-
|
|
143
|
+
const clientOptions = (_c = (_b = (_a = this._getCurrentHub) === null || _a === void 0 ? void 0 : _a.call(this)) === null || _b === void 0 ? void 0 : _b.getClient()) === null || _c === void 0 ? void 0 : _c.getOptions();
|
|
144
|
+
if (!((_d = clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.enableUserInteractionTracing) !== null && _d !== void 0 ? _d : this.options.enableUserInteractionTracing)) {
|
|
140
145
|
logger.log('[ReactNativeTracing] User Interaction Tracing is disabled.');
|
|
141
146
|
return;
|
|
142
147
|
}
|
|
@@ -152,9 +157,9 @@ export class ReactNativeTracing {
|
|
|
152
157
|
logger.log('[ReactNativeTracing] User Interaction Tracing can not create transaction without a current route.');
|
|
153
158
|
return;
|
|
154
159
|
}
|
|
155
|
-
const hub = ((
|
|
160
|
+
const hub = ((_e = this._getCurrentHub) === null || _e === void 0 ? void 0 : _e.call(this)) || getCurrentHub();
|
|
156
161
|
const activeTransaction = getActiveTransaction(hub);
|
|
157
|
-
const activeTransactionIsNotInteraction = (activeTransaction === null || activeTransaction === void 0 ? void 0 : activeTransaction.spanId) !== ((
|
|
162
|
+
const activeTransactionIsNotInteraction = (activeTransaction === null || activeTransaction === void 0 ? void 0 : activeTransaction.spanId) !== ((_f = this._inflightInteractionTransaction) === null || _f === void 0 ? void 0 : _f.spanId);
|
|
158
163
|
if (activeTransaction && activeTransactionIsNotInteraction) {
|
|
159
164
|
logger.warn(`[ReactNativeTracing] Did not create ${op} transaction because active transaction ${activeTransaction.name} exists on the scope.`);
|
|
160
165
|
return;
|
|
@@ -182,18 +187,20 @@ export class ReactNativeTracing {
|
|
|
182
187
|
/**
|
|
183
188
|
* Enables or disables native frames tracking based on the `enableNativeFramesTracking` option.
|
|
184
189
|
*/
|
|
185
|
-
_enableNativeFramesTracking(addGlobalEventProcessor) {
|
|
186
|
-
|
|
190
|
+
_enableNativeFramesTracking(addGlobalEventProcessor, clientOptions) {
|
|
191
|
+
var _a;
|
|
192
|
+
const enableNativeFramesTracking = (_a = clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.enableNativeFramesTracking) !== null && _a !== void 0 ? _a : this.options.enableNativeFramesTracking;
|
|
193
|
+
if (enableNativeFramesTracking && !NATIVE.enableNative) {
|
|
187
194
|
// Do not enable native frames tracking if native is not available.
|
|
188
195
|
logger.warn('[ReactNativeTracing] NativeFramesTracking is not available on the Web, Expo Go and other platforms without native modules.');
|
|
189
196
|
return;
|
|
190
197
|
}
|
|
191
|
-
if (!
|
|
198
|
+
if (!enableNativeFramesTracking && NATIVE.enableNative) {
|
|
192
199
|
// Disable native frames tracking when native available and option is false.
|
|
193
200
|
NATIVE.disableNativeFramesTracking();
|
|
194
201
|
return;
|
|
195
202
|
}
|
|
196
|
-
if (!
|
|
203
|
+
if (!enableNativeFramesTracking) {
|
|
197
204
|
return;
|
|
198
205
|
}
|
|
199
206
|
NATIVE.enableNativeFramesTracking();
|
|
@@ -229,9 +236,10 @@ export class ReactNativeTracing {
|
|
|
229
236
|
* Instruments the app start measurements on the first route transaction.
|
|
230
237
|
* Starts a route transaction if there isn't routing instrumentation.
|
|
231
238
|
*/
|
|
232
|
-
_instrumentAppStart() {
|
|
239
|
+
_instrumentAppStart(clientOptions) {
|
|
240
|
+
var _a;
|
|
233
241
|
return __awaiter(this, void 0, void 0, function* () {
|
|
234
|
-
if (!this.options.enableAppStartTracking || !NATIVE.enableNative) {
|
|
242
|
+
if (!((_a = clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.enableAppStartTracking) !== null && _a !== void 0 ? _a : this.options.enableAppStartTracking) || !NATIVE.enableNative) {
|
|
235
243
|
return;
|
|
236
244
|
}
|
|
237
245
|
const appStart = yield NATIVE.fetchNativeAppStart();
|