@sentry/react-native 6.15.0 → 7.0.0-beta.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/android/build.gradle +1 -1
- package/android/src/main/java/io/sentry/react/RNSentryModuleImpl.java +11 -14
- package/android/src/main/java/io/sentry/react/RNSentryVersion.java +1 -1
- package/dist/js/NativeRNSentry.d.ts.map +1 -1
- package/dist/js/NativeRNSentry.js.map +1 -1
- package/dist/js/client.d.ts.map +1 -1
- package/dist/js/client.js +5 -1
- package/dist/js/client.js.map +1 -1
- package/dist/js/feedback/FeedbackButton.d.ts.map +1 -1
- package/dist/js/feedback/FeedbackButton.js +1 -1
- package/dist/js/feedback/FeedbackButton.js.map +1 -1
- package/dist/js/feedback/FeedbackWidget.d.ts +1 -1
- package/dist/js/feedback/FeedbackWidget.d.ts.map +1 -1
- package/dist/js/feedback/FeedbackWidget.js +60 -46
- package/dist/js/feedback/FeedbackWidget.js.map +1 -1
- package/dist/js/feedback/FeedbackWidget.styles.d.ts.map +1 -1
- package/dist/js/feedback/FeedbackWidget.styles.js.map +1 -1
- package/dist/js/feedback/FeedbackWidget.theme.d.ts.map +1 -1
- package/dist/js/feedback/FeedbackWidget.theme.js.map +1 -1
- package/dist/js/feedback/FeedbackWidget.types.d.ts +30 -30
- package/dist/js/feedback/FeedbackWidget.types.d.ts.map +1 -1
- package/dist/js/feedback/FeedbackWidget.types.js.map +1 -1
- package/dist/js/feedback/FeedbackWidgetManager.d.ts.map +1 -1
- package/dist/js/feedback/FeedbackWidgetManager.js +6 -3
- package/dist/js/feedback/FeedbackWidgetManager.js.map +1 -1
- package/dist/js/feedback/FeedbackWidgetProvider.d.ts.map +1 -1
- package/dist/js/feedback/FeedbackWidgetProvider.js +9 -10
- package/dist/js/feedback/FeedbackWidgetProvider.js.map +1 -1
- package/dist/js/feedback/ScreenshotButton.d.ts.map +1 -1
- package/dist/js/feedback/ScreenshotButton.js.map +1 -1
- package/dist/js/feedback/defaults.d.ts +1 -1
- package/dist/js/feedback/defaults.d.ts.map +1 -1
- package/dist/js/feedback/defaults.js.map +1 -1
- package/dist/js/feedback/integration.d.ts +1 -1
- package/dist/js/feedback/integration.d.ts.map +1 -1
- package/dist/js/feedback/integration.js +1 -1
- package/dist/js/feedback/integration.js.map +1 -1
- package/dist/js/feedback/lazy.d.ts.map +1 -1
- package/dist/js/feedback/lazy.js.map +1 -1
- package/dist/js/feedback/utils.d.ts.map +1 -1
- package/dist/js/feedback/utils.js +2 -2
- package/dist/js/feedback/utils.js.map +1 -1
- package/dist/js/index.d.ts +3 -3
- package/dist/js/index.d.ts.map +1 -1
- package/dist/js/index.js +2 -2
- package/dist/js/index.js.map +1 -1
- package/dist/js/integrations/appRegistry.d.ts.map +1 -1
- package/dist/js/integrations/appRegistry.js.map +1 -1
- package/dist/js/integrations/breadcrumbs.d.ts +47 -0
- package/dist/js/integrations/breadcrumbs.d.ts.map +1 -0
- package/dist/js/integrations/breadcrumbs.js +15 -0
- package/dist/js/integrations/breadcrumbs.js.map +1 -0
- package/dist/js/integrations/debugsymbolicator.d.ts.map +1 -1
- package/dist/js/integrations/debugsymbolicator.js +2 -1
- package/dist/js/integrations/debugsymbolicator.js.map +1 -1
- package/dist/js/integrations/debugsymbolicatorutils.d.ts.map +1 -1
- package/dist/js/integrations/debugsymbolicatorutils.js +12 -2
- package/dist/js/integrations/debugsymbolicatorutils.js.map +1 -1
- package/dist/js/integrations/default.d.ts.map +1 -1
- package/dist/js/integrations/default.js +9 -5
- package/dist/js/integrations/default.js.map +1 -1
- package/dist/js/integrations/devicecontext.d.ts.map +1 -1
- package/dist/js/integrations/devicecontext.js.map +1 -1
- package/dist/js/integrations/expocontext.d.ts.map +1 -1
- package/dist/js/integrations/expocontext.js.map +1 -1
- package/dist/js/integrations/exports.d.ts +2 -1
- package/dist/js/integrations/exports.d.ts.map +1 -1
- package/dist/js/integrations/exports.js +2 -1
- package/dist/js/integrations/exports.js.map +1 -1
- package/dist/js/integrations/modulesloader.d.ts.map +1 -1
- package/dist/js/integrations/modulesloader.js.map +1 -1
- package/dist/js/integrations/nativelinkederrors.d.ts.map +1 -1
- package/dist/js/integrations/nativelinkederrors.js +4 -3
- package/dist/js/integrations/nativelinkederrors.js.map +1 -1
- package/dist/js/integrations/reactnativeerrorhandlers.js +2 -1
- package/dist/js/integrations/reactnativeerrorhandlers.js.map +1 -1
- package/dist/js/integrations/reactnativeerrorhandlersutils.d.ts.map +1 -1
- package/dist/js/integrations/reactnativeerrorhandlersutils.js.map +1 -1
- package/dist/js/integrations/reactnativeinfo.d.ts.map +1 -1
- package/dist/js/integrations/reactnativeinfo.js.map +1 -1
- package/dist/js/integrations/release.d.ts.map +1 -1
- package/dist/js/integrations/release.js.map +1 -1
- package/dist/js/integrations/rewriteframes.d.ts.map +1 -1
- package/dist/js/integrations/rewriteframes.js.map +1 -1
- package/dist/js/integrations/screenshot.d.ts.map +1 -1
- package/dist/js/integrations/screenshot.js +3 -3
- package/dist/js/integrations/screenshot.js.map +1 -1
- package/dist/js/integrations/sdkinfo.d.ts.map +1 -1
- package/dist/js/integrations/sdkinfo.js.map +1 -1
- package/dist/js/integrations/spotlight.d.ts.map +1 -1
- package/dist/js/integrations/spotlight.js +8 -4
- package/dist/js/integrations/spotlight.js.map +1 -1
- package/dist/js/integrations/viewhierarchy.d.ts.map +1 -1
- package/dist/js/integrations/viewhierarchy.js +2 -1
- package/dist/js/integrations/viewhierarchy.js.map +1 -1
- package/dist/js/options.d.ts +8 -1
- package/dist/js/options.d.ts.map +1 -1
- package/dist/js/options.js.map +1 -1
- package/dist/js/profiling/cache.d.ts +1 -1
- package/dist/js/profiling/convertHermesProfile.d.ts.map +1 -1
- package/dist/js/profiling/convertHermesProfile.js +18 -5
- package/dist/js/profiling/convertHermesProfile.js.map +1 -1
- package/dist/js/profiling/debugid.d.ts.map +1 -1
- package/dist/js/profiling/debugid.js +9 -1
- package/dist/js/profiling/debugid.js.map +1 -1
- package/dist/js/profiling/hermes.d.ts +1 -1
- package/dist/js/profiling/hermes.d.ts.map +1 -1
- package/dist/js/profiling/hermes.js.map +1 -1
- package/dist/js/profiling/integration.d.ts.map +1 -1
- package/dist/js/profiling/integration.js +2 -1
- package/dist/js/profiling/integration.js.map +1 -1
- package/dist/js/profiling/types.d.ts.map +1 -1
- package/dist/js/profiling/types.js.map +1 -1
- package/dist/js/profiling/utils.d.ts.map +1 -1
- package/dist/js/profiling/utils.js +15 -17
- package/dist/js/profiling/utils.js.map +1 -1
- package/dist/js/replay/CustomMask.d.ts.map +1 -1
- package/dist/js/replay/CustomMask.js +1 -1
- package/dist/js/replay/CustomMask.js.map +1 -1
- package/dist/js/replay/browserReplay.d.ts +13 -1
- package/dist/js/replay/browserReplay.d.ts.map +1 -1
- package/dist/js/replay/browserReplay.js +26 -0
- package/dist/js/replay/browserReplay.js.map +1 -1
- package/dist/js/replay/mobilereplay.d.ts.map +1 -1
- package/dist/js/replay/mobilereplay.js +2 -7
- package/dist/js/replay/mobilereplay.js.map +1 -1
- package/dist/js/replay/networkUtils.d.ts.map +1 -1
- package/dist/js/replay/networkUtils.js +4 -11
- package/dist/js/replay/networkUtils.js.map +1 -1
- package/dist/js/replay/replayInterface.d.ts +52 -0
- package/dist/js/replay/replayInterface.d.ts.map +1 -0
- package/dist/js/replay/replayInterface.js +2 -0
- package/dist/js/replay/replayInterface.js.map +1 -0
- package/dist/js/replay/xhrUtils.d.ts.map +1 -1
- package/dist/js/replay/xhrUtils.js.map +1 -1
- package/dist/js/scopeSync.d.ts.map +1 -1
- package/dist/js/scopeSync.js +7 -1
- package/dist/js/scopeSync.js.map +1 -1
- package/dist/js/sdk.d.ts +1 -6
- package/dist/js/sdk.d.ts.map +1 -1
- package/dist/js/sdk.js +3 -16
- package/dist/js/sdk.js.map +1 -1
- package/dist/js/tools/ModulesCollector.js +1 -0
- package/dist/js/tools/ModulesCollector.js.map +1 -1
- package/dist/js/tools/collectModules.js +1 -0
- package/dist/js/tools/collectModules.js.map +1 -1
- package/dist/js/tools/enableLogger.js +1 -0
- package/dist/js/tools/enableLogger.js.map +1 -1
- package/dist/js/tools/metroMiddleware.js +2 -1
- package/dist/js/tools/metroMiddleware.js.map +1 -1
- package/dist/js/tools/metroconfig.d.ts.map +1 -1
- package/dist/js/tools/metroconfig.js +6 -4
- package/dist/js/tools/metroconfig.js.map +1 -1
- package/dist/js/tools/sentryBabelTransformer.js +1 -0
- package/dist/js/tools/sentryBabelTransformer.js.map +1 -1
- package/dist/js/tools/sentryBabelTransformerUtils.d.ts.map +1 -1
- package/dist/js/tools/sentryBabelTransformerUtils.js +2 -1
- package/dist/js/tools/sentryBabelTransformerUtils.js.map +1 -1
- package/dist/js/tools/sentryMetroSerializer.d.ts.map +1 -1
- package/dist/js/tools/sentryMetroSerializer.js +1 -0
- package/dist/js/tools/sentryMetroSerializer.js.map +1 -1
- package/dist/js/tools/utils.js +1 -0
- package/dist/js/tools/utils.js.map +1 -1
- package/dist/js/tools/vendor/expo/expoconfig.js +1 -0
- package/dist/js/tools/vendor/expo/expoconfig.js.map +1 -1
- package/dist/js/tools/vendor/metro/metroBabelTransformer.js +1 -0
- package/dist/js/tools/vendor/metro/metroBabelTransformer.js.map +1 -1
- package/dist/js/tools/vendor/metro/utils.d.ts.map +1 -1
- package/dist/js/tools/vendor/metro/utils.js +1 -0
- package/dist/js/tools/vendor/metro/utils.js.map +1 -1
- package/dist/js/touchevents.d.ts.map +1 -1
- package/dist/js/touchevents.js +4 -0
- package/dist/js/touchevents.js.map +1 -1
- package/dist/js/tracing/gesturetracing.d.ts.map +1 -1
- package/dist/js/tracing/gesturetracing.js.map +1 -1
- package/dist/js/tracing/integrations/appStart.d.ts +1 -1
- package/dist/js/tracing/integrations/appStart.d.ts.map +1 -1
- package/dist/js/tracing/integrations/appStart.js +10 -3
- package/dist/js/tracing/integrations/appStart.js.map +1 -1
- package/dist/js/tracing/integrations/nativeFrames.d.ts.map +1 -1
- package/dist/js/tracing/integrations/nativeFrames.js.map +1 -1
- package/dist/js/tracing/integrations/stalltracking.d.ts +1 -1
- package/dist/js/tracing/integrations/stalltracking.d.ts.map +1 -1
- package/dist/js/tracing/integrations/stalltracking.js.map +1 -1
- package/dist/js/tracing/integrations/timeToDisplayIntegration.d.ts.map +1 -1
- package/dist/js/tracing/integrations/timeToDisplayIntegration.js +14 -10
- package/dist/js/tracing/integrations/timeToDisplayIntegration.js.map +1 -1
- package/dist/js/tracing/integrations/userInteraction.d.ts.map +1 -1
- package/dist/js/tracing/integrations/userInteraction.js.map +1 -1
- package/dist/js/tracing/onSpanEndUtils.d.ts +1 -1
- package/dist/js/tracing/onSpanEndUtils.d.ts.map +1 -1
- package/dist/js/tracing/onSpanEndUtils.js +2 -1
- package/dist/js/tracing/onSpanEndUtils.js.map +1 -1
- package/dist/js/tracing/reactnativenavigation.d.ts.map +1 -1
- package/dist/js/tracing/reactnativenavigation.js +1 -1
- package/dist/js/tracing/reactnativenavigation.js.map +1 -1
- package/dist/js/tracing/reactnativeprofiler.d.ts +3 -1
- package/dist/js/tracing/reactnativeprofiler.d.ts.map +1 -1
- package/dist/js/tracing/reactnativeprofiler.js +2 -1
- package/dist/js/tracing/reactnativeprofiler.js.map +1 -1
- package/dist/js/tracing/reactnativetracing.d.ts.map +1 -1
- package/dist/js/tracing/reactnativetracing.js.map +1 -1
- package/dist/js/tracing/reactnavigation.d.ts.map +1 -1
- package/dist/js/tracing/reactnavigation.js +5 -4
- package/dist/js/tracing/reactnavigation.js.map +1 -1
- package/dist/js/tracing/span.d.ts.map +1 -1
- package/dist/js/tracing/span.js +5 -5
- package/dist/js/tracing/span.js.map +1 -1
- package/dist/js/tracing/timeToDisplayFallback.d.ts +1 -1
- package/dist/js/tracing/timeToDisplayFallback.d.ts.map +1 -1
- package/dist/js/tracing/timeToDisplayFallback.js.map +1 -1
- package/dist/js/tracing/timetodisplay.d.ts.map +1 -1
- package/dist/js/tracing/timetodisplay.js +13 -13
- package/dist/js/tracing/timetodisplay.js.map +1 -1
- package/dist/js/tracing/timetodisplaynative.d.ts.map +1 -1
- package/dist/js/tracing/timetodisplaynative.js.map +1 -1
- package/dist/js/tracing/utils.d.ts.map +1 -1
- package/dist/js/tracing/utils.js.map +1 -1
- package/dist/js/transports/encodePolyfill.d.ts +4 -0
- package/dist/js/transports/encodePolyfill.d.ts.map +1 -1
- package/dist/js/transports/encodePolyfill.js +17 -3
- package/dist/js/transports/encodePolyfill.js.map +1 -1
- package/dist/js/transports/native.d.ts.map +1 -1
- package/dist/js/transports/native.js.map +1 -1
- package/dist/js/utils/AsyncExpiringMap.d.ts.map +1 -1
- package/dist/js/utils/AsyncExpiringMap.js +8 -4
- package/dist/js/utils/AsyncExpiringMap.js.map +1 -1
- package/dist/js/utils/carrier.d.ts +5 -0
- package/dist/js/utils/carrier.d.ts.map +1 -0
- package/dist/js/utils/carrier.js +11 -0
- package/dist/js/utils/carrier.js.map +1 -0
- package/dist/js/utils/encode.d.ts +5 -0
- package/dist/js/utils/encode.d.ts.map +1 -0
- package/dist/js/utils/encode.js +13 -0
- package/dist/js/utils/encode.js.map +1 -0
- package/dist/js/utils/envelope.d.ts.map +1 -1
- package/dist/js/utils/envelope.js +1 -2
- package/dist/js/utils/envelope.js.map +1 -1
- package/dist/js/utils/environment.d.ts.map +1 -1
- package/dist/js/utils/environment.js +5 -6
- package/dist/js/utils/environment.js.map +1 -1
- package/dist/js/utils/rnlibraries.d.ts.map +1 -1
- package/dist/js/utils/rnlibraries.js.map +1 -1
- package/dist/js/utils/safe.d.ts.map +1 -1
- package/dist/js/utils/safe.js.map +1 -1
- package/dist/js/utils/worldwide.d.ts +3 -2
- package/dist/js/utils/worldwide.d.ts.map +1 -1
- package/dist/js/utils/worldwide.js.map +1 -1
- package/dist/js/vendor/base64-js/fromByteArray.d.ts.map +1 -1
- package/dist/js/vendor/base64-js/fromByteArray.js +6 -0
- package/dist/js/vendor/base64-js/fromByteArray.js.map +1 -1
- package/dist/js/version.d.ts +1 -1
- package/dist/js/version.d.ts.map +1 -1
- package/dist/js/version.js +1 -1
- package/dist/js/version.js.map +1 -1
- package/dist/js/wrapper.d.ts.map +1 -1
- package/dist/js/wrapper.js +10 -8
- package/dist/js/wrapper.js.map +1 -1
- package/ios/RNSentryVersion.m +1 -1
- package/package.json +9 -10
- package/plugin/build/withSentry.js +3 -3
- package/plugin/build/withSentryAndroidGradlePlugin.js +3 -3
- package/scripts/expo-upload-sourcemaps.js +2 -2
- package/src/js/NativeRNSentry.ts +0 -1
- package/ts3.8/dist/js/feedback/FeedbackWidget.d.ts +1 -1
- package/ts3.8/dist/js/feedback/FeedbackWidget.types.d.ts +30 -30
- package/ts3.8/dist/js/feedback/defaults.d.ts +1 -1
- package/ts3.8/dist/js/feedback/integration.d.ts +1 -1
- package/ts3.8/dist/js/index.d.ts +3 -3
- package/ts3.8/dist/js/integrations/breadcrumbs.d.ts +47 -0
- package/ts3.8/dist/js/integrations/exports.d.ts +2 -1
- package/ts3.8/dist/js/options.d.ts +8 -1
- package/ts3.8/dist/js/profiling/cache.d.ts +1 -1
- package/ts3.8/dist/js/profiling/hermes.d.ts +1 -1
- package/ts3.8/dist/js/replay/browserReplay.d.ts +13 -1
- package/ts3.8/dist/js/replay/replayInterface.d.ts +52 -0
- package/ts3.8/dist/js/sdk.d.ts +1 -6
- package/ts3.8/dist/js/tracing/integrations/appStart.d.ts +1 -1
- package/ts3.8/dist/js/tracing/integrations/stalltracking.d.ts +1 -1
- package/ts3.8/dist/js/tracing/onSpanEndUtils.d.ts +1 -1
- package/ts3.8/dist/js/tracing/reactnativeprofiler.d.ts +3 -1
- package/ts3.8/dist/js/tracing/timeToDisplayFallback.d.ts +1 -1
- package/ts3.8/dist/js/transports/encodePolyfill.d.ts +4 -0
- package/ts3.8/dist/js/utils/carrier.d.ts +5 -0
- package/ts3.8/dist/js/utils/encode.d.ts +5 -0
- package/ts3.8/dist/js/utils/worldwide.d.ts +3 -2
- package/ts3.8/dist/js/version.d.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|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C,CAAC;aACD,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE;YACvB,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;QAEL,UAAU,CAAC,GAAG,EAAE;YACd,MAAM,CAAC,wDAAwD,CAAC,CAAC;QACnE,CAAC,EAAE,uBAAuB,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,OAAO,CAAC,EAAU,EAAE,EAAU;IACrC,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,uBAAuB,CAAC;AACrD,CAAC","sourcesContent":["import type { Client, Event, Integration, Measurements, MeasurementUnit, Span } from '@sentry/core';\nimport { logger, timestampInSeconds } from '@sentry/core';\n\nimport type { NativeFramesResponse } from '../../NativeRNSentry';\nimport { AsyncExpiringMap } from '../../utils/AsyncExpiringMap';\nimport { isRootSpan } from '../../utils/span';\nimport { NATIVE } from '../../wrapper';\n\n/**\n * Timeout from the start of a span to fetching the associated native frames.\n */\nconst FETCH_FRAMES_TIMEOUT_MS = 2_000;\n\n/**\n * This is the time end frames data from the native layer will be\n * kept in memory and waiting for the event processing. This ensures that spans\n * which are never processed are not leaking memory.\n */\nconst END_FRAMES_TIMEOUT_MS = 2_000;\n\n/**\n * This is the time start frames data from the native layer will be\n * kept in memory and waiting for span end. This ensures that spans\n * which never end or are not processed are not leaking memory.\n */\nconst START_FRAMES_TIMEOUT_MS = 60_000;\n\n/**\n * A margin of error of 50ms is allowed for the async native bridge call.\n * Anything larger would reduce the accuracy of our frames measurements.\n */\nconst MARGIN_OF_ERROR_SECONDS = 0.05;\n\nconst INTEGRATION_NAME = 'NativeFrames';\n\nexport interface FramesMeasurements extends Measurements {\n frames_total: { value: number; unit: MeasurementUnit };\n frames_slow: { value: number; unit: MeasurementUnit };\n frames_frozen: { value: number; unit: MeasurementUnit };\n}\n\ninterface NativeFramesResponseWithTimestamp {\n timestamp: number;\n nativeFrames: NativeFramesResponse;\n}\n\nexport const createNativeFramesIntegrations = (enable: boolean | undefined): Integration | undefined => {\n if (!enable && NATIVE.enableNative) {\n // On Android this will free up resource when JS reloaded (native modules stay) and thus JS side of the SDK reinitialized.\n NATIVE.disableNativeFramesTracking();\n return undefined;\n }\n\n return nativeFramesIntegration();\n};\n\n/**\n * Instrumentation to add native slow/frozen frames measurements onto transactions.\n */\nexport const nativeFramesIntegration = (): Integration => {\n /** The native frames at the finish time of the most recent span. */\n let _lastChildSpanEndFrames: NativeFramesResponseWithTimestamp | null = null;\n const _spanToNativeFramesAtStartMap: AsyncExpiringMap<string, NativeFramesResponse> = new AsyncExpiringMap({\n ttl: START_FRAMES_TIMEOUT_MS,\n });\n const _spanToNativeFramesAtEndMap: AsyncExpiringMap<string, NativeFramesResponseWithTimestamp | null> =\n new AsyncExpiringMap({ ttl: END_FRAMES_TIMEOUT_MS });\n\n /**\n * Hooks into the client start and end span events.\n */\n const setup = (client: Client): void => {\n if (!NATIVE.enableNative) {\n logger.warn(\n `[${INTEGRATION_NAME}] This is not available on the Web, Expo Go and other platforms without native modules.`,\n );\n return undefined;\n }\n\n NATIVE.enableNativeFramesTracking();\n client.on('spanStart', fetchStartFramesForSpan);\n client.on('spanEnd', fetchEndFramesForSpan);\n };\n\n const fetchStartFramesForSpan = (rootSpan: Span): void => {\n if (!isRootSpan(rootSpan)) {\n return;\n }\n\n const spanId = rootSpan.spanContext().spanId;\n logger.debug(`[${INTEGRATION_NAME}] Fetching frames for root span start (${spanId}).`);\n _spanToNativeFramesAtStartMap.set(\n spanId,\n new Promise<NativeFramesResponse | null>(resolve => {\n fetchNativeFrames()\n .then(frames => resolve(frames))\n .then(undefined, error => {\n logger.debug(`[${INTEGRATION_NAME}] Error while fetching native frames.`, error);\n resolve(null);\n });\n }),\n );\n };\n\n const fetchEndFramesForSpan = (span: Span): void => {\n const timestamp = timestampInSeconds();\n const spanId = span.spanContext().spanId;\n\n if (isRootSpan(span)) {\n const hasStartFrames = _spanToNativeFramesAtStartMap.has(spanId);\n if (!hasStartFrames) {\n // We don't have start frames, won't be able to calculate the difference.\n return;\n }\n\n logger.debug(`[${INTEGRATION_NAME}] Fetch frames for root span end (${spanId}).`);\n _spanToNativeFramesAtEndMap.set(\n spanId,\n new Promise<NativeFramesResponseWithTimestamp | null>(resolve => {\n fetchNativeFrames()\n .then(frames => {\n resolve({\n timestamp,\n nativeFrames: frames,\n });\n })\n .then(undefined, error => {\n logger.debug(`[${INTEGRATION_NAME}] Error while fetching native frames.`, error);\n resolve(null);\n });\n }),\n );\n return undefined;\n } else {\n logger.debug(`[${INTEGRATION_NAME}] Fetch frames for child span end (${spanId}).`);\n fetchNativeFrames()\n .then(frames => {\n _lastChildSpanEndFrames = {\n timestamp,\n nativeFrames: frames,\n };\n })\n .catch(error => logger.debug(`[${INTEGRATION_NAME}] Error while fetching native frames.`, error));\n }\n };\n\n const processEvent = async (event: Event): Promise<Event> => {\n if (\n event.type !== 'transaction' ||\n !event.transaction ||\n !event.contexts ||\n !event.contexts.trace ||\n !event.timestamp ||\n !event.contexts.trace.span_id\n ) {\n return event;\n }\n\n const traceOp = event.contexts.trace.op;\n const spanId = event.contexts.trace.span_id;\n const startFrames = await _spanToNativeFramesAtStartMap.pop(spanId);\n if (!startFrames) {\n logger.warn(\n `[${INTEGRATION_NAME}] Start frames of transaction ${event.transaction} (eventId, ${event.event_id}) are missing, but the transaction already ended.`,\n );\n return event;\n }\n\n const endFrames = await _spanToNativeFramesAtEndMap.pop(spanId);\n let finalEndFrames: NativeFramesResponse | undefined;\n\n if (endFrames && isClose(endFrames.timestamp, event.timestamp)) {\n // Must be in the margin of error of the actual transaction finish time (finalEndTimestamp)\n logger.debug(`[${INTEGRATION_NAME}] Using frames from root span end (spanId, ${spanId}).`);\n finalEndFrames = endFrames.nativeFrames;\n } else if (_lastChildSpanEndFrames && isClose(_lastChildSpanEndFrames.timestamp, event.timestamp)) {\n // Fallback to the last span finish if it is within the margin of error of the actual finish timestamp.\n // This should be the case for trimEnd.\n logger.debug(`[${INTEGRATION_NAME}] Using native frames from last child span end (spanId, ${spanId}).`);\n finalEndFrames = _lastChildSpanEndFrames.nativeFrames;\n } else {\n logger.warn(\n `[${INTEGRATION_NAME}] Frames were collected within larger than margin of error delay for spanId (${spanId}). Dropping the inaccurate values.`,\n );\n return event;\n }\n\n const measurements = {\n frames_total: {\n value: finalEndFrames.totalFrames - startFrames.totalFrames,\n unit: 'none',\n },\n frames_frozen: {\n value: finalEndFrames.frozenFrames - startFrames.frozenFrames,\n unit: 'none',\n },\n frames_slow: {\n value: finalEndFrames.slowFrames - startFrames.slowFrames,\n unit: 'none',\n },\n };\n\n if (\n measurements.frames_frozen.value <= 0 &&\n measurements.frames_slow.value <= 0 &&\n measurements.frames_total.value <= 0\n ) {\n logger.warn(\n `[${INTEGRATION_NAME}] Detected zero slow or frozen frames. Not adding measurements to spanId (${spanId}).`,\n );\n return event;\n }\n\n logger.log(\n `[${INTEGRATION_NAME}] Adding measurements to ${traceOp} transaction ${event.transaction}: ${JSON.stringify(\n measurements,\n undefined,\n 2,\n )}`,\n );\n event.measurements = {\n ...(event.measurements ?? {}),\n ...measurements,\n };\n return event;\n };\n\n return {\n name: INTEGRATION_NAME,\n setup,\n processEvent,\n };\n};\n\nfunction fetchNativeFrames(): Promise<NativeFramesResponse> {\n return new Promise<NativeFramesResponse>((resolve, reject) => {\n NATIVE.fetchNativeFrames()\n .then(value => {\n if (!value) {\n reject('Native frames response is null.');\n return;\n }\n resolve(value);\n })\n .then(undefined, error => {\n reject(error);\n });\n\n setTimeout(() => {\n reject('Fetching native frames took too long. Dropping frames.');\n }, FETCH_FRAMES_TIMEOUT_MS);\n });\n}\n\nfunction isClose(t1: number, t2: number): boolean {\n return Math.abs(t1 - t2) < MARGIN_OF_ERROR_SECONDS;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"nativeFrames.js","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/nativeFrames.ts"],"names":[],"mappings":";;;;;;;;;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CAAC,CAAC,CAAC;QAEL,UAAU,CAAC,GAAG,EAAE;YACd,MAAM,CAAC,wDAAwD,CAAC,CAAC;QACnE,CAAC,EAAE,uBAAuB,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,OAAO,CAAC,EAAU,EAAE,EAAU;IACrC,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,uBAAuB,CAAC;AACrD,CAAC","sourcesContent":["import type { Client, Event, Integration, Measurements, MeasurementUnit, Span } from '@sentry/core';\nimport { logger, timestampInSeconds } from '@sentry/core';\nimport type { NativeFramesResponse } from '../../NativeRNSentry';\nimport { AsyncExpiringMap } from '../../utils/AsyncExpiringMap';\nimport { isRootSpan } from '../../utils/span';\nimport { NATIVE } from '../../wrapper';\n\n/**\n * Timeout from the start of a span to fetching the associated native frames.\n */\nconst FETCH_FRAMES_TIMEOUT_MS = 2_000;\n\n/**\n * This is the time end frames data from the native layer will be\n * kept in memory and waiting for the event processing. This ensures that spans\n * which are never processed are not leaking memory.\n */\nconst END_FRAMES_TIMEOUT_MS = 2_000;\n\n/**\n * This is the time start frames data from the native layer will be\n * kept in memory and waiting for span end. This ensures that spans\n * which never end or are not processed are not leaking memory.\n */\nconst START_FRAMES_TIMEOUT_MS = 60_000;\n\n/**\n * A margin of error of 50ms is allowed for the async native bridge call.\n * Anything larger would reduce the accuracy of our frames measurements.\n */\nconst MARGIN_OF_ERROR_SECONDS = 0.05;\n\nconst INTEGRATION_NAME = 'NativeFrames';\n\nexport interface FramesMeasurements extends Measurements {\n frames_total: { value: number; unit: MeasurementUnit };\n frames_slow: { value: number; unit: MeasurementUnit };\n frames_frozen: { value: number; unit: MeasurementUnit };\n}\n\ninterface NativeFramesResponseWithTimestamp {\n timestamp: number;\n nativeFrames: NativeFramesResponse;\n}\n\nexport const createNativeFramesIntegrations = (enable: boolean | undefined): Integration | undefined => {\n if (!enable && NATIVE.enableNative) {\n // On Android this will free up resource when JS reloaded (native modules stay) and thus JS side of the SDK reinitialized.\n NATIVE.disableNativeFramesTracking();\n return undefined;\n }\n\n return nativeFramesIntegration();\n};\n\n/**\n * Instrumentation to add native slow/frozen frames measurements onto transactions.\n */\nexport const nativeFramesIntegration = (): Integration => {\n /** The native frames at the finish time of the most recent span. */\n let _lastChildSpanEndFrames: NativeFramesResponseWithTimestamp | null = null;\n const _spanToNativeFramesAtStartMap: AsyncExpiringMap<string, NativeFramesResponse | null> = new AsyncExpiringMap({\n ttl: START_FRAMES_TIMEOUT_MS,\n });\n const _spanToNativeFramesAtEndMap: AsyncExpiringMap<string, NativeFramesResponseWithTimestamp | null> =\n new AsyncExpiringMap({ ttl: END_FRAMES_TIMEOUT_MS });\n\n /**\n * Hooks into the client start and end span events.\n */\n const setup = (client: Client): void => {\n if (!NATIVE.enableNative) {\n logger.warn(\n `[${INTEGRATION_NAME}] This is not available on the Web, Expo Go and other platforms without native modules.`,\n );\n return undefined;\n }\n\n NATIVE.enableNativeFramesTracking();\n client.on('spanStart', fetchStartFramesForSpan);\n client.on('spanEnd', fetchEndFramesForSpan);\n };\n\n const fetchStartFramesForSpan = (rootSpan: Span): void => {\n if (!isRootSpan(rootSpan)) {\n return;\n }\n\n const spanId = rootSpan.spanContext().spanId;\n logger.debug(`[${INTEGRATION_NAME}] Fetching frames for root span start (${spanId}).`);\n _spanToNativeFramesAtStartMap.set(\n spanId,\n new Promise<NativeFramesResponse | null>(resolve => {\n fetchNativeFrames()\n .then(frames => resolve(frames))\n .then(undefined, error => {\n logger.debug(`[${INTEGRATION_NAME}] Error while fetching native frames.`, error);\n resolve(null);\n });\n }),\n );\n };\n\n const fetchEndFramesForSpan = (span: Span): void => {\n const timestamp = timestampInSeconds();\n const spanId = span.spanContext().spanId;\n\n if (isRootSpan(span)) {\n const hasStartFrames = _spanToNativeFramesAtStartMap.has(spanId);\n if (!hasStartFrames) {\n // We don't have start frames, won't be able to calculate the difference.\n return;\n }\n\n logger.debug(`[${INTEGRATION_NAME}] Fetch frames for root span end (${spanId}).`);\n _spanToNativeFramesAtEndMap.set(\n spanId,\n new Promise<NativeFramesResponseWithTimestamp | null>(resolve => {\n fetchNativeFrames()\n .then(frames => {\n resolve({\n timestamp,\n nativeFrames: frames,\n });\n })\n .then(undefined, error => {\n logger.debug(`[${INTEGRATION_NAME}] Error while fetching native frames.`, error);\n resolve(null);\n });\n }),\n );\n return undefined;\n } else {\n logger.debug(`[${INTEGRATION_NAME}] Fetch frames for child span end (${spanId}).`);\n fetchNativeFrames()\n .then(frames => {\n _lastChildSpanEndFrames = {\n timestamp,\n nativeFrames: frames,\n };\n })\n .catch(error => logger.debug(`[${INTEGRATION_NAME}] Error while fetching native frames.`, error));\n }\n };\n\n const processEvent = async (event: Event): Promise<Event> => {\n if (\n event.type !== 'transaction' ||\n !event.transaction ||\n !event.contexts ||\n !event.contexts.trace ||\n !event.timestamp ||\n !event.contexts.trace.span_id\n ) {\n return event;\n }\n\n const traceOp = event.contexts.trace.op;\n const spanId = event.contexts.trace.span_id;\n const startFrames = await _spanToNativeFramesAtStartMap.pop(spanId);\n if (!startFrames) {\n logger.warn(\n `[${INTEGRATION_NAME}] Start frames of transaction ${event.transaction} (eventId, ${event.event_id}) are missing, but the transaction already ended.`,\n );\n return event;\n }\n\n const endFrames = await _spanToNativeFramesAtEndMap.pop(spanId);\n let finalEndFrames: NativeFramesResponse | undefined;\n\n if (endFrames && isClose(endFrames.timestamp, event.timestamp)) {\n // Must be in the margin of error of the actual transaction finish time (finalEndTimestamp)\n logger.debug(`[${INTEGRATION_NAME}] Using frames from root span end (spanId, ${spanId}).`);\n finalEndFrames = endFrames.nativeFrames;\n } else if (_lastChildSpanEndFrames && isClose(_lastChildSpanEndFrames.timestamp, event.timestamp)) {\n // Fallback to the last span finish if it is within the margin of error of the actual finish timestamp.\n // This should be the case for trimEnd.\n logger.debug(`[${INTEGRATION_NAME}] Using native frames from last child span end (spanId, ${spanId}).`);\n finalEndFrames = _lastChildSpanEndFrames.nativeFrames;\n } else {\n logger.warn(\n `[${INTEGRATION_NAME}] Frames were collected within larger than margin of error delay for spanId (${spanId}). Dropping the inaccurate values.`,\n );\n return event;\n }\n\n const measurements = {\n frames_total: {\n value: finalEndFrames.totalFrames - startFrames.totalFrames,\n unit: 'none',\n },\n frames_frozen: {\n value: finalEndFrames.frozenFrames - startFrames.frozenFrames,\n unit: 'none',\n },\n frames_slow: {\n value: finalEndFrames.slowFrames - startFrames.slowFrames,\n unit: 'none',\n },\n };\n\n if (\n measurements.frames_frozen.value <= 0 &&\n measurements.frames_slow.value <= 0 &&\n measurements.frames_total.value <= 0\n ) {\n logger.warn(\n `[${INTEGRATION_NAME}] Detected zero slow or frozen frames. Not adding measurements to spanId (${spanId}).`,\n );\n return event;\n }\n\n logger.log(\n `[${INTEGRATION_NAME}] Adding measurements to ${traceOp} transaction ${event.transaction}: ${JSON.stringify(\n measurements,\n undefined,\n 2,\n )}`,\n );\n event.measurements = {\n ...(event.measurements ?? {}),\n ...measurements,\n };\n return event;\n };\n\n return {\n name: INTEGRATION_NAME,\n setup,\n processEvent,\n };\n};\n\nfunction fetchNativeFrames(): Promise<NativeFramesResponse> {\n return new Promise<NativeFramesResponse>((resolve, reject) => {\n NATIVE.fetchNativeFrames()\n .then(value => {\n if (!value) {\n reject('Native frames response is null.');\n return;\n }\n resolve(value);\n })\n .then(undefined, error => {\n reject(error);\n });\n\n setTimeout(() => {\n reject('Fetching native frames took too long. Dropping frames.');\n }, FETCH_FRAMES_TIMEOUT_MS);\n });\n}\n\nfunction isClose(t1: number, t2: number): boolean {\n return Math.abs(t1 - t2) < MARGIN_OF_ERROR_SECONDS;\n}\n"]}
|
|
@@ -26,6 +26,6 @@ export declare const stallTrackingIntegration: ({ minimumStallThresholdMs, }?: {
|
|
|
26
26
|
* How long in milliseconds an event loop iteration can be delayed for before being considered a "stall."
|
|
27
27
|
* @default 50
|
|
28
28
|
*/
|
|
29
|
-
minimumStallThresholdMs?: number;
|
|
29
|
+
minimumStallThresholdMs?: number | undefined;
|
|
30
30
|
}) => Integration;
|
|
31
31
|
//# sourceMappingURL=stalltracking.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stalltracking.d.ts","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/stalltracking.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAU,WAAW,EAAE,YAAY,EAAE,eAAe,EAAQ,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"stalltracking.d.ts","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/stalltracking.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAU,WAAW,EAAE,YAAY,EAAE,eAAe,EAAQ,MAAM,cAAc,CAAC;AAI7F,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAMvF,MAAM,WAAW,iBAAkB,SAAQ,YAAY;IACrD,CAAC,WAAW,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC;IACxD,CAAC,gBAAgB,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC;IAC7D,CAAC,kBAAkB,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC;CAChE;AASD;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB;IAGnC;;;OAGG;;MAEI,WA0TR,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stalltracking.js","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/stalltracking.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEnF,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEx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AQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,WAAW,EAAE;QACzB,6DAA6D;QAC7D,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,KAAK,CAAC,uBAAuB,CAAC,CAAC;KACpE;IAED,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,KAAK;QAEL,gCAAgC;QAChC,cAAc,EAAE,KAAK;KACP,CAAC;AACnB,CAAC,CAAC","sourcesContent":["/* eslint-disable max-lines */\nimport type { Client, Integration, Measurements, MeasurementUnit, Span } from '@sentry/core';\nimport { getRootSpan, logger, spanToJSON, timestampInSeconds } from '@sentry/core';\nimport type { AppStateStatus } from 'react-native';\nimport { AppState } from 'react-native';\n\nimport { STALL_COUNT, STALL_LONGEST_TIME, STALL_TOTAL_TIME } from '../../measurements';\nimport { isRootSpan } from '../../utils/span';\nimport { getLatestChildSpanEndTimestamp, isNearToNow, setSpanMeasurement } from '../utils';\n\nconst INTEGRATION_NAME = 'StallTracking';\n\nexport interface StallMeasurements extends Measurements {\n [STALL_COUNT]: { value: number; unit: MeasurementUnit };\n [STALL_TOTAL_TIME]: { value: number; unit: MeasurementUnit };\n [STALL_LONGEST_TIME]: { value: number; unit: MeasurementUnit };\n}\n\n/** Margin of error of 20ms */\nconst MARGIN_OF_ERROR_SECONDS = 0.02;\n/** How long between each iteration in the event loop tracker timeout */\nconst LOOP_TIMEOUT_INTERVAL_MS = 50;\n/** Limit for how many transactions the stall tracker will track at a time to prevent leaks due to transactions not being finished */\nconst MAX_RUNNING_TRANSACTIONS = 10;\n\n/**\n * Stall measurement tracker inspired by the `JSEventLoopWatchdog` used internally in React Native:\n * https://github.com/facebook/react-native/blob/006f5afe120c290a37cf6ff896748fbc062bf7ed/Libraries/Interaction/JSEventLoopWatchdog.js\n *\n * However, we modified the interval implementation to instead have a fixed loop timeout interval of `LOOP_TIMEOUT_INTERVAL_MS`.\n * We then would consider that iteration a stall when the total time for that interval to run is greater than `LOOP_TIMEOUT_INTERVAL_MS + minimumStallThreshold`\n */\nexport const stallTrackingIntegration = ({\n minimumStallThresholdMs = 50,\n}: {\n /**\n * How long in milliseconds an event loop iteration can be delayed for before being considered a \"stall.\"\n * @default 50\n */\n minimumStallThresholdMs?: number;\n} = {}): Integration => {\n const statsByRootSpan: Map<\n Span,\n {\n longestStallTime: number;\n atStart: StallMeasurements;\n atTimestamp: {\n timestamp: number;\n stats: StallMeasurements;\n } | null;\n }\n > = new Map();\n\n const state: {\n isTracking: boolean;\n timeout: ReturnType<typeof setTimeout> | null;\n isBackground: boolean;\n /** Switch that enables the iteration once app moves from background to foreground. */\n backgroundEventListener: (appState: AppStateStatus) => void;\n /** The last timestamp the iteration ran in milliseconds */\n lastIntervalMs: number;\n /** Total amount of time of all stalls that occurred during the current tracking session */\n totalStallTime: number;\n /** Total number of stalls that occurred during the current tracking session */\n stallCount: number;\n /**\n * Iteration of the stall tracking interval. Measures how long the timer strayed from its expected time of running, and how\n * long the stall is for.\n */\n iteration: () => void;\n } = {\n isTracking: false,\n timeout: null,\n isBackground: false,\n lastIntervalMs: 0,\n totalStallTime: 0,\n stallCount: 0,\n backgroundEventListener: (appState: AppStateStatus): void => {\n if (appState === ('active' as AppStateStatus)) {\n state.isBackground = false;\n if (state.timeout != null) {\n state.lastIntervalMs = timestampInSeconds() * 1000;\n state.iteration();\n }\n } else {\n state.isBackground = true;\n state.timeout !== null && clearTimeout(state.timeout);\n }\n },\n iteration: (): void => {\n const now = timestampInSeconds() * 1000;\n const totalTimeTaken = now - state.lastIntervalMs;\n\n if (totalTimeTaken >= LOOP_TIMEOUT_INTERVAL_MS + minimumStallThresholdMs) {\n const stallTime = totalTimeTaken - LOOP_TIMEOUT_INTERVAL_MS;\n state.stallCount += 1;\n state.totalStallTime += stallTime;\n\n for (const [transaction, value] of statsByRootSpan.entries()) {\n const longestStallTime = Math.max(value.longestStallTime ?? 0, stallTime);\n\n statsByRootSpan.set(transaction, {\n ...value,\n longestStallTime,\n });\n }\n }\n\n state.lastIntervalMs = now;\n\n if (state.isTracking && !state.isBackground) {\n state.timeout = setTimeout(state.iteration, LOOP_TIMEOUT_INTERVAL_MS);\n }\n },\n };\n\n const setup = (client: Client): void => {\n client.on('spanStart', _onSpanStart);\n client.on('spanEnd', _onSpanEnd);\n };\n\n const _onSpanStart = (rootSpan: Span): void => {\n if (!isRootSpan(rootSpan)) {\n return;\n }\n\n if (statsByRootSpan.has(rootSpan)) {\n logger.error(\n '[StallTracking] Tried to start stall tracking on a transaction already being tracked. Measurements might be lost.',\n );\n return;\n }\n\n _startTracking();\n statsByRootSpan.set(rootSpan, {\n longestStallTime: 0,\n atTimestamp: null,\n atStart: _getCurrentStats(rootSpan),\n });\n _flushLeakedTransactions();\n };\n\n const _onSpanEnd = (rootSpan: Span): void => {\n if (!isRootSpan(rootSpan)) {\n return _onChildSpanEnd(rootSpan);\n }\n\n const transactionStats = statsByRootSpan.get(rootSpan);\n\n if (!transactionStats) {\n // Transaction has been flushed out somehow, we return null.\n logger.log('[StallTracking] Stall measurements were not added to transaction due to exceeding the max count.');\n\n statsByRootSpan.delete(rootSpan);\n _shouldStopTracking();\n\n return;\n }\n\n // The endTimestamp is always set, but type-wise it's optional\n // https://github.com/getsentry/sentry-javascript/blob/38bd57b0785c97c413f36f89ff931d927e469078/packages/core/src/tracing/sentrySpan.ts#L170\n const endTimestamp = spanToJSON(rootSpan).timestamp;\n\n let statsOnFinish: StallMeasurements | undefined;\n if (isNearToNow(endTimestamp)) {\n statsOnFinish = _getCurrentStats(rootSpan);\n } else {\n // The idleSpan in JS V8 is always trimmed to the last span's endTimestamp (timestamp).\n // The unfinished child spans are removed from the root span after the `spanEnd` event.\n\n const latestChildSpanEnd = getLatestChildSpanEndTimestamp(rootSpan);\n if (latestChildSpanEnd !== endTimestamp) {\n logger.log(\n '[StallTracking] Stall measurements not added due to a custom `endTimestamp` (root end is not equal to the latest child span end).',\n );\n }\n\n if (!transactionStats.atTimestamp) {\n logger.log(\n '[StallTracking] Stall measurements not added due to `endTimestamp` not being close to now. And no previous stats from child end were found.',\n );\n }\n\n if (latestChildSpanEnd === endTimestamp && transactionStats.atTimestamp) {\n statsOnFinish = transactionStats.atTimestamp.stats;\n }\n }\n\n statsByRootSpan.delete(rootSpan);\n _shouldStopTracking();\n\n if (!statsOnFinish) {\n if (typeof endTimestamp !== 'undefined') {\n logger.log(\n '[StallTracking] Stall measurements not added due to `endTimestamp` not being close to now.',\n 'endTimestamp',\n endTimestamp,\n 'now',\n timestampInSeconds(),\n );\n }\n\n return;\n }\n\n setSpanMeasurement(\n rootSpan,\n STALL_COUNT,\n statsOnFinish.stall_count.value - transactionStats.atStart.stall_count.value,\n transactionStats.atStart.stall_count.unit,\n );\n\n setSpanMeasurement(\n rootSpan,\n STALL_TOTAL_TIME,\n statsOnFinish.stall_total_time.value - transactionStats.atStart.stall_total_time.value,\n transactionStats.atStart.stall_total_time.unit,\n );\n\n setSpanMeasurement(\n rootSpan,\n STALL_LONGEST_TIME,\n statsOnFinish.stall_longest_time.value,\n statsOnFinish.stall_longest_time.unit,\n );\n };\n\n const _onChildSpanEnd = (childSpan: Span): void => {\n const rootSpan = getRootSpan(childSpan);\n\n const finalEndTimestamp = spanToJSON(childSpan).timestamp;\n if (finalEndTimestamp) {\n _markSpanFinish(rootSpan, finalEndTimestamp);\n }\n };\n\n /**\n * Logs the finish time of the span for use in `trimEnd: true` transactions.\n */\n const _markSpanFinish = (rootSpan: Span, childSpanEndTime: number): void => {\n const previousStats = statsByRootSpan.get(rootSpan);\n if (previousStats) {\n if (Math.abs(timestampInSeconds() - childSpanEndTime) > MARGIN_OF_ERROR_SECONDS) {\n logger.log(\n '[StallTracking] Span end not logged due to end timestamp being outside the margin of error from now.',\n );\n\n if (previousStats.atTimestamp && previousStats.atTimestamp.timestamp < childSpanEndTime) {\n // We also need to delete the stat for the last span, as the transaction would be trimmed to this span not the last one.\n statsByRootSpan.set(rootSpan, {\n ...previousStats,\n atTimestamp: null,\n });\n }\n } else {\n statsByRootSpan.set(rootSpan, {\n ...previousStats,\n atTimestamp: {\n timestamp: childSpanEndTime,\n stats: _getCurrentStats(rootSpan),\n },\n });\n }\n }\n };\n\n /**\n * Get the current stats for a transaction at a given time.\n */\n const _getCurrentStats = (span: Span): StallMeasurements => {\n return {\n stall_count: { value: state.stallCount, unit: 'none' },\n stall_total_time: { value: state.totalStallTime, unit: 'millisecond' },\n stall_longest_time: {\n value: statsByRootSpan.get(span)?.longestStallTime ?? 0,\n unit: 'millisecond',\n },\n };\n };\n\n /**\n * Start tracking stalls\n */\n const _startTracking = (): void => {\n if (!state.isTracking) {\n state.isTracking = true;\n state.lastIntervalMs = Math.floor(timestampInSeconds() * 1000);\n\n state.iteration();\n }\n };\n\n /**\n * Stops the stall tracking interval and calls reset().\n */\n const _stopTracking = (): void => {\n state.isTracking = false;\n\n if (state.timeout !== null) {\n clearTimeout(state.timeout);\n state.timeout = null;\n }\n\n _reset();\n };\n\n /**\n * Will stop tracking if there are no more transactions.\n */\n const _shouldStopTracking = (): void => {\n if (statsByRootSpan.size === 0) {\n _stopTracking();\n }\n };\n\n /**\n * Clears all the collected stats\n */\n const _reset = (): void => {\n state.stallCount = 0;\n state.totalStallTime = 0;\n state.lastIntervalMs = 0;\n statsByRootSpan.clear();\n };\n\n /**\n * Deletes leaked transactions (Earliest transactions when we have more than MAX_RUNNING_TRANSACTIONS transactions.)\n */\n const _flushLeakedTransactions = (): void => {\n if (statsByRootSpan.size > MAX_RUNNING_TRANSACTIONS) {\n let counter = 0;\n const len = statsByRootSpan.size - MAX_RUNNING_TRANSACTIONS;\n const transactions = statsByRootSpan.keys();\n for (const t of transactions) {\n if (counter >= len) break;\n counter += 1;\n statsByRootSpan.delete(t);\n }\n }\n };\n\n // Avoids throwing any error if using React Native on a environment that doesn't implement AppState.\n if (AppState?.isAvailable) {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n AppState.addEventListener('change', state.backgroundEventListener);\n }\n\n return {\n name: INTEGRATION_NAME,\n setup,\n\n /** For testing only @private */\n _internalState: state,\n } as Integration;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"stalltracking.js","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/stalltracking.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEnF,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,8BAA8B,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE3F,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAQzC,8BAA8B;AAC9B,MAAM,uBAAuB,GAAG,IAAI,CAAC;AACrC,wEAAwE;AACxE,MAAM,wBAAwB,GAAG,EAAE,CAAC;AACpC,qIAAqI;AACrI,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,EACvC,uBAAuB,GAAG,EAAE,MAO1B,EAAE,EAAe,EAAE;IACrB,MAAM,eAAe,GAUjB,IAAI,GAAG,EAAE,CAAC;IAEd,MAAM,KAAK,GAiBP;QACF,UAAU,EAAE,KAAK;QACjB,OAAO,EAAE,IAAI;QACb,YAAY,EAAE,KAAK;QACnB,cAAc,EAAE,CAAC;QACjB,cAAc,EAAE,CAAC;QACjB,UAAU,EAAE,CAAC;QACb,uBAAuB,EAAE,CAAC,QAAwB,EAAQ,EAAE;YAC1D,IAAI,QAAQ,KAAM,QAA2B,EAAE;gBAC7C,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC;gBAC3B,IAAI,KAAK,CAAC,OAAO,IAAI,IAAI,EAAE;oBACzB,KAAK,CAAC,cAAc,GAAG,kBAAkB,EAAE,GAAG,I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AAG,eAAe,CAAC,IAAI,EAAE,CAAC;YAC5C,KAAK,MAAM,CAAC,IAAI,YAAY,EAAE;gBAC5B,IAAI,OAAO,IAAI,GAAG;oBAAE,MAAM;gBAC1B,OAAO,IAAI,CAAC,CAAC;gBACb,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;aAC3B;SACF;IACH,CAAC,CAAC;IAEF,oGAAoG;IACpG,IAAI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,WAAW,EAAE;QACzB,6DAA6D;QAC7D,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,KAAK,CAAC,uBAAuB,CAAC,CAAC;KACpE;IAED,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,KAAK;QAEL,gCAAgC;QAChC,cAAc,EAAE,KAAK;KACP,CAAC;AACnB,CAAC,CAAC","sourcesContent":["/* eslint-disable max-lines */\nimport type { Client, Integration, Measurements, MeasurementUnit, Span } from '@sentry/core';\nimport { getRootSpan, logger, spanToJSON, timestampInSeconds } from '@sentry/core';\nimport type { AppStateStatus } from 'react-native';\nimport { AppState } from 'react-native';\nimport { STALL_COUNT, STALL_LONGEST_TIME, STALL_TOTAL_TIME } from '../../measurements';\nimport { isRootSpan } from '../../utils/span';\nimport { getLatestChildSpanEndTimestamp, isNearToNow, setSpanMeasurement } from '../utils';\n\nconst INTEGRATION_NAME = 'StallTracking';\n\nexport interface StallMeasurements extends Measurements {\n [STALL_COUNT]: { value: number; unit: MeasurementUnit };\n [STALL_TOTAL_TIME]: { value: number; unit: MeasurementUnit };\n [STALL_LONGEST_TIME]: { value: number; unit: MeasurementUnit };\n}\n\n/** Margin of error of 20ms */\nconst MARGIN_OF_ERROR_SECONDS = 0.02;\n/** How long between each iteration in the event loop tracker timeout */\nconst LOOP_TIMEOUT_INTERVAL_MS = 50;\n/** Limit for how many transactions the stall tracker will track at a time to prevent leaks due to transactions not being finished */\nconst MAX_RUNNING_TRANSACTIONS = 10;\n\n/**\n * Stall measurement tracker inspired by the `JSEventLoopWatchdog` used internally in React Native:\n * https://github.com/facebook/react-native/blob/006f5afe120c290a37cf6ff896748fbc062bf7ed/Libraries/Interaction/JSEventLoopWatchdog.js\n *\n * However, we modified the interval implementation to instead have a fixed loop timeout interval of `LOOP_TIMEOUT_INTERVAL_MS`.\n * We then would consider that iteration a stall when the total time for that interval to run is greater than `LOOP_TIMEOUT_INTERVAL_MS + minimumStallThreshold`\n */\nexport const stallTrackingIntegration = ({\n minimumStallThresholdMs = 50,\n}: {\n /**\n * How long in milliseconds an event loop iteration can be delayed for before being considered a \"stall.\"\n * @default 50\n */\n minimumStallThresholdMs?: number;\n} = {}): Integration => {\n const statsByRootSpan: Map<\n Span,\n {\n longestStallTime: number;\n atStart: StallMeasurements;\n atTimestamp: {\n timestamp: number;\n stats: StallMeasurements;\n } | null;\n }\n > = new Map();\n\n const state: {\n isTracking: boolean;\n timeout: ReturnType<typeof setTimeout> | null;\n isBackground: boolean;\n /** Switch that enables the iteration once app moves from background to foreground. */\n backgroundEventListener: (appState: AppStateStatus) => void;\n /** The last timestamp the iteration ran in milliseconds */\n lastIntervalMs: number;\n /** Total amount of time of all stalls that occurred during the current tracking session */\n totalStallTime: number;\n /** Total number of stalls that occurred during the current tracking session */\n stallCount: number;\n /**\n * Iteration of the stall tracking interval. Measures how long the timer strayed from its expected time of running, and how\n * long the stall is for.\n */\n iteration: () => void;\n } = {\n isTracking: false,\n timeout: null,\n isBackground: false,\n lastIntervalMs: 0,\n totalStallTime: 0,\n stallCount: 0,\n backgroundEventListener: (appState: AppStateStatus): void => {\n if (appState === ('active' as AppStateStatus)) {\n state.isBackground = false;\n if (state.timeout != null) {\n state.lastIntervalMs = timestampInSeconds() * 1000;\n state.iteration();\n }\n } else {\n state.isBackground = true;\n state.timeout !== null && clearTimeout(state.timeout);\n }\n },\n iteration: (): void => {\n const now = timestampInSeconds() * 1000;\n const totalTimeTaken = now - state.lastIntervalMs;\n\n if (totalTimeTaken >= LOOP_TIMEOUT_INTERVAL_MS + minimumStallThresholdMs) {\n const stallTime = totalTimeTaken - LOOP_TIMEOUT_INTERVAL_MS;\n state.stallCount += 1;\n state.totalStallTime += stallTime;\n\n for (const [transaction, value] of statsByRootSpan.entries()) {\n const longestStallTime = Math.max(value.longestStallTime ?? 0, stallTime);\n\n statsByRootSpan.set(transaction, {\n ...value,\n longestStallTime,\n });\n }\n }\n\n state.lastIntervalMs = now;\n\n if (state.isTracking && !state.isBackground) {\n state.timeout = setTimeout(state.iteration, LOOP_TIMEOUT_INTERVAL_MS);\n }\n },\n };\n\n const setup = (client: Client): void => {\n client.on('spanStart', _onSpanStart);\n client.on('spanEnd', _onSpanEnd);\n };\n\n const _onSpanStart = (rootSpan: Span): void => {\n if (!isRootSpan(rootSpan)) {\n return;\n }\n\n if (statsByRootSpan.has(rootSpan)) {\n logger.error(\n '[StallTracking] Tried to start stall tracking on a transaction already being tracked. Measurements might be lost.',\n );\n return;\n }\n\n _startTracking();\n statsByRootSpan.set(rootSpan, {\n longestStallTime: 0,\n atTimestamp: null,\n atStart: _getCurrentStats(rootSpan),\n });\n _flushLeakedTransactions();\n };\n\n const _onSpanEnd = (rootSpan: Span): void => {\n if (!isRootSpan(rootSpan)) {\n return _onChildSpanEnd(rootSpan);\n }\n\n const transactionStats = statsByRootSpan.get(rootSpan);\n\n if (!transactionStats) {\n // Transaction has been flushed out somehow, we return null.\n logger.log('[StallTracking] Stall measurements were not added to transaction due to exceeding the max count.');\n\n statsByRootSpan.delete(rootSpan);\n _shouldStopTracking();\n\n return;\n }\n\n // The endTimestamp is always set, but type-wise it's optional\n // https://github.com/getsentry/sentry-javascript/blob/38bd57b0785c97c413f36f89ff931d927e469078/packages/core/src/tracing/sentrySpan.ts#L170\n const endTimestamp = spanToJSON(rootSpan).timestamp;\n\n let statsOnFinish: StallMeasurements | undefined;\n if (isNearToNow(endTimestamp)) {\n statsOnFinish = _getCurrentStats(rootSpan);\n } else {\n // The idleSpan in JS V8 is always trimmed to the last span's endTimestamp (timestamp).\n // The unfinished child spans are removed from the root span after the `spanEnd` event.\n\n const latestChildSpanEnd = getLatestChildSpanEndTimestamp(rootSpan);\n if (latestChildSpanEnd !== endTimestamp) {\n logger.log(\n '[StallTracking] Stall measurements not added due to a custom `endTimestamp` (root end is not equal to the latest child span end).',\n );\n }\n\n if (!transactionStats.atTimestamp) {\n logger.log(\n '[StallTracking] Stall measurements not added due to `endTimestamp` not being close to now. And no previous stats from child end were found.',\n );\n }\n\n if (latestChildSpanEnd === endTimestamp && transactionStats.atTimestamp) {\n statsOnFinish = transactionStats.atTimestamp.stats;\n }\n }\n\n statsByRootSpan.delete(rootSpan);\n _shouldStopTracking();\n\n if (!statsOnFinish) {\n if (typeof endTimestamp !== 'undefined') {\n logger.log(\n '[StallTracking] Stall measurements not added due to `endTimestamp` not being close to now.',\n 'endTimestamp',\n endTimestamp,\n 'now',\n timestampInSeconds(),\n );\n }\n\n return;\n }\n\n setSpanMeasurement(\n rootSpan,\n STALL_COUNT,\n statsOnFinish.stall_count.value - transactionStats.atStart.stall_count.value,\n transactionStats.atStart.stall_count.unit,\n );\n\n setSpanMeasurement(\n rootSpan,\n STALL_TOTAL_TIME,\n statsOnFinish.stall_total_time.value - transactionStats.atStart.stall_total_time.value,\n transactionStats.atStart.stall_total_time.unit,\n );\n\n setSpanMeasurement(\n rootSpan,\n STALL_LONGEST_TIME,\n statsOnFinish.stall_longest_time.value,\n statsOnFinish.stall_longest_time.unit,\n );\n };\n\n const _onChildSpanEnd = (childSpan: Span): void => {\n const rootSpan = getRootSpan(childSpan);\n\n const finalEndTimestamp = spanToJSON(childSpan).timestamp;\n if (finalEndTimestamp) {\n _markSpanFinish(rootSpan, finalEndTimestamp);\n }\n };\n\n /**\n * Logs the finish time of the span for use in `trimEnd: true` transactions.\n */\n const _markSpanFinish = (rootSpan: Span, childSpanEndTime: number): void => {\n const previousStats = statsByRootSpan.get(rootSpan);\n if (previousStats) {\n if (Math.abs(timestampInSeconds() - childSpanEndTime) > MARGIN_OF_ERROR_SECONDS) {\n logger.log(\n '[StallTracking] Span end not logged due to end timestamp being outside the margin of error from now.',\n );\n\n if (previousStats.atTimestamp && previousStats.atTimestamp.timestamp < childSpanEndTime) {\n // We also need to delete the stat for the last span, as the transaction would be trimmed to this span not the last one.\n statsByRootSpan.set(rootSpan, {\n ...previousStats,\n atTimestamp: null,\n });\n }\n } else {\n statsByRootSpan.set(rootSpan, {\n ...previousStats,\n atTimestamp: {\n timestamp: childSpanEndTime,\n stats: _getCurrentStats(rootSpan),\n },\n });\n }\n }\n };\n\n /**\n * Get the current stats for a transaction at a given time.\n */\n const _getCurrentStats = (span: Span): StallMeasurements => {\n return {\n stall_count: { value: state.stallCount, unit: 'none' },\n stall_total_time: { value: state.totalStallTime, unit: 'millisecond' },\n stall_longest_time: {\n value: statsByRootSpan.get(span)?.longestStallTime ?? 0,\n unit: 'millisecond',\n },\n };\n };\n\n /**\n * Start tracking stalls\n */\n const _startTracking = (): void => {\n if (!state.isTracking) {\n state.isTracking = true;\n state.lastIntervalMs = Math.floor(timestampInSeconds() * 1000);\n\n state.iteration();\n }\n };\n\n /**\n * Stops the stall tracking interval and calls reset().\n */\n const _stopTracking = (): void => {\n state.isTracking = false;\n\n if (state.timeout !== null) {\n clearTimeout(state.timeout);\n state.timeout = null;\n }\n\n _reset();\n };\n\n /**\n * Will stop tracking if there are no more transactions.\n */\n const _shouldStopTracking = (): void => {\n if (statsByRootSpan.size === 0) {\n _stopTracking();\n }\n };\n\n /**\n * Clears all the collected stats\n */\n const _reset = (): void => {\n state.stallCount = 0;\n state.totalStallTime = 0;\n state.lastIntervalMs = 0;\n statsByRootSpan.clear();\n };\n\n /**\n * Deletes leaked transactions (Earliest transactions when we have more than MAX_RUNNING_TRANSACTIONS transactions.)\n */\n const _flushLeakedTransactions = (): void => {\n if (statsByRootSpan.size > MAX_RUNNING_TRANSACTIONS) {\n let counter = 0;\n const len = statsByRootSpan.size - MAX_RUNNING_TRANSACTIONS;\n const transactions = statsByRootSpan.keys();\n for (const t of transactions) {\n if (counter >= len) break;\n counter += 1;\n statsByRootSpan.delete(t);\n }\n }\n };\n\n // Avoids throwing any error if using React Native on a environment that doesn't implement AppState.\n if (AppState?.isAvailable) {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n AppState.addEventListener('change', state.backgroundEventListener);\n }\n\n return {\n name: INTEGRATION_NAME,\n setup,\n\n /** For testing only @private */\n _internalState: state,\n } as Integration;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeToDisplayIntegration.d.ts","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/timeToDisplayIntegration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,WAAW,EAAY,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"timeToDisplayIntegration.d.ts","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/timeToDisplayIntegration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,WAAW,EAAY,MAAM,cAAc,CAAC;AAWjE,eAAO,MAAM,gBAAgB,kBAAkB,CAAC;AAKhD,eAAO,MAAM,wBAAwB,QAAO,WAwE3C,CAAC"}
|
|
@@ -29,12 +29,12 @@ export const timeToDisplayIntegration = () => {
|
|
|
29
29
|
(_b = (_a = getReactNavigationIntegration(client)) === null || _a === void 0 ? void 0 : _a.options.enableTimeToInitialDisplayForPreloadedRoutes) !== null && _b !== void 0 ? _b : false;
|
|
30
30
|
},
|
|
31
31
|
processEvent: (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
-
var _a, _b, _c;
|
|
32
|
+
var _a, _b, _c, _d, _e;
|
|
33
33
|
if (event.type !== 'transaction') {
|
|
34
34
|
// TimeToDisplay data is only relevant for transactions
|
|
35
35
|
return event;
|
|
36
36
|
}
|
|
37
|
-
const rootSpanId = event.contexts.trace.span_id;
|
|
37
|
+
const rootSpanId = (_b = (_a = event.contexts) === null || _a === void 0 ? void 0 : _a.trace) === null || _b === void 0 ? void 0 : _b.span_id;
|
|
38
38
|
if (!rootSpanId) {
|
|
39
39
|
logger.warn(`[${INTEGRATION_NAME}] No root span id found in transaction.`);
|
|
40
40
|
return event;
|
|
@@ -54,16 +54,18 @@ export const timeToDisplayIntegration = () => {
|
|
|
54
54
|
enableTimeToInitialDisplayForPreloadedRoutes,
|
|
55
55
|
});
|
|
56
56
|
const ttfdSpan = yield addTimeToFullDisplay({ event, rootSpanId, transactionStartTimestampSeconds, ttidSpan });
|
|
57
|
-
if (ttidSpan
|
|
57
|
+
if ((ttidSpan === null || ttidSpan === void 0 ? void 0 : ttidSpan.start_timestamp) && (ttidSpan === null || ttidSpan === void 0 ? void 0 : ttidSpan.timestamp)) {
|
|
58
58
|
event.measurements['time_to_initial_display'] = {
|
|
59
59
|
value: (ttidSpan.timestamp - ttidSpan.start_timestamp) * 1000,
|
|
60
60
|
unit: 'millisecond',
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
-
if (ttfdSpan
|
|
63
|
+
if ((ttfdSpan === null || ttfdSpan === void 0 ? void 0 : ttfdSpan.start_timestamp) && (ttfdSpan === null || ttfdSpan === void 0 ? void 0 : ttfdSpan.timestamp)) {
|
|
64
64
|
const durationMs = (ttfdSpan.timestamp - ttfdSpan.start_timestamp) * 1000;
|
|
65
65
|
if (isDeadlineExceeded(durationMs)) {
|
|
66
|
-
|
|
66
|
+
if (event.measurements['time_to_initial_display']) {
|
|
67
|
+
event.measurements['time_to_full_display'] = event.measurements['time_to_initial_display'];
|
|
68
|
+
}
|
|
67
69
|
}
|
|
68
70
|
else {
|
|
69
71
|
event.measurements['time_to_full_display'] = {
|
|
@@ -72,7 +74,7 @@ export const timeToDisplayIntegration = () => {
|
|
|
72
74
|
};
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
|
-
const newTransactionEndTimestampSeconds = Math.max((
|
|
77
|
+
const newTransactionEndTimestampSeconds = Math.max((_c = ttidSpan === null || ttidSpan === void 0 ? void 0 : ttidSpan.timestamp) !== null && _c !== void 0 ? _c : -1, (_d = ttfdSpan === null || ttfdSpan === void 0 ? void 0 : ttfdSpan.timestamp) !== null && _d !== void 0 ? _d : -1, (_e = event.timestamp) !== null && _e !== void 0 ? _e : -1);
|
|
76
78
|
if (newTransactionEndTimestampSeconds !== -1) {
|
|
77
79
|
event.timestamp = newTransactionEndTimestampSeconds;
|
|
78
80
|
}
|
|
@@ -84,6 +86,7 @@ function addTimeToInitialDisplay({ event, rootSpanId, transactionStartTimestampS
|
|
|
84
86
|
var _a;
|
|
85
87
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
88
|
const ttidEndTimestampSeconds = yield NATIVE.popTimeToDisplayFor(`ttid-${rootSpanId}`);
|
|
89
|
+
event.spans = event.spans || [];
|
|
87
90
|
let ttidSpan = (_a = event.spans) === null || _a === void 0 ? void 0 : _a.find(span => span.op === UI_LOAD_INITIAL_DISPLAY);
|
|
88
91
|
if (ttidSpan && (ttidSpan.status === undefined || ttidSpan.status === 'ok') && !ttidEndTimestampSeconds) {
|
|
89
92
|
logger.debug(`[${INTEGRATION_NAME}] Ttid span already exists and is ok.`, ttidSpan);
|
|
@@ -98,7 +101,7 @@ function addTimeToInitialDisplay({ event, rootSpanId, transactionStartTimestampS
|
|
|
98
101
|
enableTimeToInitialDisplayForPreloadedRoutes,
|
|
99
102
|
});
|
|
100
103
|
}
|
|
101
|
-
if (ttidSpan
|
|
104
|
+
if ((ttidSpan === null || ttidSpan === void 0 ? void 0 : ttidSpan.status) && ttidSpan.status !== 'ok') {
|
|
102
105
|
ttidSpan.status = 'ok';
|
|
103
106
|
ttidSpan.timestamp = ttidEndTimestampSeconds;
|
|
104
107
|
logger.debug(`[${INTEGRATION_NAME}] Updated existing ttid span.`, ttidSpan);
|
|
@@ -160,14 +163,15 @@ function addTimeToFullDisplay({ event, rootSpanId, transactionStartTimestampSeco
|
|
|
160
163
|
if (!ttidSpan || !ttfdEndTimestampSeconds) {
|
|
161
164
|
return undefined;
|
|
162
165
|
}
|
|
166
|
+
event.spans = event.spans || [];
|
|
163
167
|
let ttfdSpan = (_a = event.spans) === null || _a === void 0 ? void 0 : _a.find(span => span.op === UI_LOAD_FULL_DISPLAY);
|
|
164
168
|
let ttfdAdjustedEndTimestampSeconds = ttfdEndTimestampSeconds;
|
|
165
|
-
const ttfdIsBeforeTtid =
|
|
166
|
-
if (ttfdIsBeforeTtid) {
|
|
169
|
+
const ttfdIsBeforeTtid = ttidSpan.timestamp && ttfdEndTimestampSeconds < ttidSpan.timestamp;
|
|
170
|
+
if (ttfdIsBeforeTtid && ttidSpan.timestamp) {
|
|
167
171
|
ttfdAdjustedEndTimestampSeconds = ttidSpan.timestamp;
|
|
168
172
|
}
|
|
169
173
|
const durationMs = (ttfdAdjustedEndTimestampSeconds - transactionStartTimestampSeconds) * 1000;
|
|
170
|
-
if (ttfdSpan
|
|
174
|
+
if ((ttfdSpan === null || ttfdSpan === void 0 ? void 0 : ttfdSpan.status) && ttfdSpan.status !== 'ok') {
|
|
171
175
|
ttfdSpan.status = 'ok';
|
|
172
176
|
ttfdSpan.timestamp = ttfdAdjustedEndTimestampSeconds;
|
|
173
177
|
logger.debug(`[${INTEGRATION_NAME}] Updated existing ttfd span.`, ttfdSpan);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeToDisplayIntegration.js","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/timeToDisplayIntegration.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,QAAQ,CAAC;AACvE,OAAO,EAAE,mCAAmC,EAAE,qCAAqC,EAAE,MAAM,WAAW,CAAC;AACvG,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,sCAAsC,EAAE,MAAM,uBAAuB,CA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uBAAuB,GAAG,QAAQ,CAAC,SAAS,CAAC;QAC7F,IAAI,gBAAgB,EAAE;YACpB,+BAA+B,GAAG,QAAQ,CAAC,SAAS,CAAC;SACtD;QAED,MAAM,UAAU,GAAG,CAAC,+BAA+B,GAAG,gCAAgC,CAAC,GAAG,IAAI,CAAC;QAE/F,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,MAAM,KAAK,IAAI,EAAE;YAC3D,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC;YACvB,QAAQ,CAAC,SAAS,GAAG,+BAA+B,CAAC;YACrD,MAAM,CAAC,KAAK,CAAC,IAAI,gBAAgB,+BAA+B,EAAE,QAAQ,CAAC,CAAC;YAC5E,OAAO,QAAQ,CAAC;SACjB;QAED,QAAQ,GAAG,cAAc,CAAC;YACxB,MAAM,EAAE,kBAAkB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAI;YACnE,EAAE,EAAE,oBAAoB;YACxB,WAAW,EAAE,sBAAsB;YACnC,eAAe,EAAE,gCAAgC;YACjD,SAAS,EAAE,+BAA+B;YAC1C,MAAM,EAAE,qCAAqC;YAC7C,cAAc,EAAE,UAAU;YAC1B,IAAI,EAAE;gBACJ,CAAC,gBAAgB,CAAC,EAAE,2BAA2B;aAChD;SACF,CAAC,CAAC;QACH,MAAM,CAAC,KAAK,CAAC,IAAI,gBAAgB,mCAAmC,EAAE,QAAQ,CAAC,CAAC;QAChF,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC3B,OAAO,QAAQ,CAAC;;CACjB","sourcesContent":["import type { Event, Integration, SpanJSON } from '@sentry/core';\nimport { logger } from '@sentry/core';\n\nimport { NATIVE } from '../../wrapper';\nimport { UI_LOAD_FULL_DISPLAY, UI_LOAD_INITIAL_DISPLAY } from '../ops';\nimport { SPAN_ORIGIN_AUTO_UI_TIME_TO_DISPLAY, SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY } from '../origin';\nimport { getReactNavigationIntegration } from '../reactnavigation';\nimport { SEMANTIC_ATTRIBUTE_ROUTE_HAS_BEEN_SEEN } from '../semanticAttributes';\nimport { SPAN_THREAD_NAME, SPAN_THREAD_NAME_JAVASCRIPT } from '../span';\nimport { getTimeToInitialDisplayFallback } from '../timeToDisplayFallback';\nimport { createSpanJSON } from '../utils';\n\nexport const INTEGRATION_NAME = 'TimeToDisplay';\n\nconst TIME_TO_DISPLAY_TIMEOUT_MS = 30_000;\nconst isDeadlineExceeded = (durationMs: number): boolean => durationMs > TIME_TO_DISPLAY_TIMEOUT_MS;\n\nexport const timeToDisplayIntegration = (): Integration => {\n let enableTimeToInitialDisplayForPreloadedRoutes = false;\n\n return {\n name: INTEGRATION_NAME,\n afterAllSetup(client) {\n enableTimeToInitialDisplayForPreloadedRoutes =\n getReactNavigationIntegration(client)?.options.enableTimeToInitialDisplayForPreloadedRoutes ?? false;\n },\n processEvent: async event => {\n if (event.type !== 'transaction') {\n // TimeToDisplay data is only relevant for transactions\n return event;\n }\n\n const rootSpanId = event.contexts.trace.span_id;\n if (!rootSpanId) {\n logger.warn(`[${INTEGRATION_NAME}] No root span id found in transaction.`);\n return event;\n }\n\n const transactionStartTimestampSeconds = event.start_timestamp;\n if (!transactionStartTimestampSeconds) {\n // This should never happen\n logger.warn(`[${INTEGRATION_NAME}] No transaction start timestamp found in transaction.`);\n return event;\n }\n\n event.spans = event.spans || [];\n event.measurements = event.measurements || {};\n\n const ttidSpan = await addTimeToInitialDisplay({\n event,\n rootSpanId,\n transactionStartTimestampSeconds,\n enableTimeToInitialDisplayForPreloadedRoutes,\n });\n const ttfdSpan = await addTimeToFullDisplay({ event, rootSpanId, transactionStartTimestampSeconds, ttidSpan });\n\n if (ttidSpan && ttidSpan.start_timestamp && ttidSpan.timestamp) {\n event.measurements['time_to_initial_display'] = {\n value: (ttidSpan.timestamp - ttidSpan.start_timestamp) * 1000,\n unit: 'millisecond',\n };\n }\n\n if (ttfdSpan && ttfdSpan.start_timestamp && ttfdSpan.timestamp) {\n const durationMs = (ttfdSpan.timestamp - ttfdSpan.start_timestamp) * 1000;\n if (isDeadlineExceeded(durationMs)) {\n event.measurements['time_to_full_display'] = event.measurements['time_to_initial_display'];\n } else {\n event.measurements['time_to_full_display'] = {\n value: durationMs,\n unit: 'millisecond',\n };\n }\n }\n\n const newTransactionEndTimestampSeconds = Math.max(\n ttidSpan?.timestamp ?? -1,\n ttfdSpan?.timestamp ?? -1,\n event.timestamp ?? -1,\n );\n if (newTransactionEndTimestampSeconds !== -1) {\n event.timestamp = newTransactionEndTimestampSeconds;\n }\n\n return event;\n },\n };\n};\n\nasync function addTimeToInitialDisplay({\n event,\n rootSpanId,\n transactionStartTimestampSeconds,\n enableTimeToInitialDisplayForPreloadedRoutes,\n}: {\n event: Event;\n rootSpanId: string;\n transactionStartTimestampSeconds: number;\n enableTimeToInitialDisplayForPreloadedRoutes: boolean;\n}): Promise<SpanJSON | undefined> {\n const ttidEndTimestampSeconds = await NATIVE.popTimeToDisplayFor(`ttid-${rootSpanId}`);\n\n let ttidSpan: SpanJSON | undefined = event.spans?.find(span => span.op === UI_LOAD_INITIAL_DISPLAY);\n\n if (ttidSpan && (ttidSpan.status === undefined || ttidSpan.status === 'ok') && !ttidEndTimestampSeconds) {\n logger.debug(`[${INTEGRATION_NAME}] Ttid span already exists and is ok.`, ttidSpan);\n return ttidSpan;\n }\n\n if (!ttidEndTimestampSeconds) {\n logger.debug(`[${INTEGRATION_NAME}] No manual ttid end timestamp found for span ${rootSpanId}.`);\n return addAutomaticTimeToInitialDisplay({\n event,\n rootSpanId,\n transactionStartTimestampSeconds,\n enableTimeToInitialDisplayForPreloadedRoutes,\n });\n }\n\n if (ttidSpan && ttidSpan.status && ttidSpan.status !== 'ok') {\n ttidSpan.status = 'ok';\n ttidSpan.timestamp = ttidEndTimestampSeconds;\n logger.debug(`[${INTEGRATION_NAME}] Updated existing ttid span.`, ttidSpan);\n return ttidSpan;\n }\n\n ttidSpan = createSpanJSON({\n op: UI_LOAD_INITIAL_DISPLAY,\n description: 'Time To Initial Display',\n start_timestamp: transactionStartTimestampSeconds,\n timestamp: ttidEndTimestampSeconds,\n origin: SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY,\n parent_span_id: rootSpanId,\n data: {\n [SPAN_THREAD_NAME]: SPAN_THREAD_NAME_JAVASCRIPT,\n },\n });\n logger.debug(`[${INTEGRATION_NAME}] Added ttid span to transaction.`, ttidSpan);\n event.spans.push(ttidSpan);\n return ttidSpan;\n}\n\nasync function addAutomaticTimeToInitialDisplay({\n event,\n rootSpanId,\n transactionStartTimestampSeconds,\n enableTimeToInitialDisplayForPreloadedRoutes,\n}: {\n event: Event;\n rootSpanId: string;\n transactionStartTimestampSeconds: number;\n enableTimeToInitialDisplayForPreloadedRoutes: boolean;\n}): Promise<SpanJSON | undefined> {\n const ttidNativeTimestampSeconds = await NATIVE.popTimeToDisplayFor(`ttid-navigation-${rootSpanId}`);\n const ttidFallbackTimestampSeconds = await getTimeToInitialDisplayFallback(rootSpanId);\n\n const hasBeenSeen = event.contexts?.trace?.data?.[SEMANTIC_ATTRIBUTE_ROUTE_HAS_BEEN_SEEN];\n if (hasBeenSeen && !enableTimeToInitialDisplayForPreloadedRoutes) {\n logger.debug(\n `[${INTEGRATION_NAME}] Route has been seen and time to initial display is disabled for preloaded routes.`,\n );\n return undefined;\n }\n\n const ttidTimestampSeconds = ttidNativeTimestampSeconds ?? ttidFallbackTimestampSeconds;\n if (!ttidTimestampSeconds) {\n logger.debug(`[${INTEGRATION_NAME}] No automatic ttid end timestamp found for span ${rootSpanId}.`);\n return undefined;\n }\n\n const viewNames = event.contexts?.app?.view_names;\n const screenName = Array.isArray(viewNames) ? viewNames[0] : viewNames;\n\n const ttidSpan = createSpanJSON({\n op: UI_LOAD_INITIAL_DISPLAY,\n description: screenName ? `${screenName} initial display` : 'Time To Initial Display',\n start_timestamp: transactionStartTimestampSeconds,\n timestamp: ttidTimestampSeconds,\n origin: SPAN_ORIGIN_AUTO_UI_TIME_TO_DISPLAY,\n parent_span_id: rootSpanId,\n data: {\n [SPAN_THREAD_NAME]: SPAN_THREAD_NAME_JAVASCRIPT,\n },\n });\n event.spans = event.spans ?? [];\n event.spans.push(ttidSpan);\n return ttidSpan;\n}\n\nasync function addTimeToFullDisplay({\n event,\n rootSpanId,\n transactionStartTimestampSeconds,\n ttidSpan,\n}: {\n event: Event;\n rootSpanId: string;\n transactionStartTimestampSeconds: number;\n ttidSpan: SpanJSON | undefined;\n}): Promise<SpanJSON | undefined> {\n const ttfdEndTimestampSeconds = await NATIVE.popTimeToDisplayFor(`ttfd-${rootSpanId}`);\n\n if (!ttidSpan || !ttfdEndTimestampSeconds) {\n return undefined;\n }\n\n let ttfdSpan = event.spans?.find(span => span.op === UI_LOAD_FULL_DISPLAY);\n\n let ttfdAdjustedEndTimestampSeconds = ttfdEndTimestampSeconds;\n const ttfdIsBeforeTtid = ttidSpan?.timestamp && ttfdEndTimestampSeconds < ttidSpan.timestamp;\n if (ttfdIsBeforeTtid) {\n ttfdAdjustedEndTimestampSeconds = ttidSpan.timestamp;\n }\n\n const durationMs = (ttfdAdjustedEndTimestampSeconds - transactionStartTimestampSeconds) * 1000;\n\n if (ttfdSpan && ttfdSpan.status && ttfdSpan.status !== 'ok') {\n ttfdSpan.status = 'ok';\n ttfdSpan.timestamp = ttfdAdjustedEndTimestampSeconds;\n logger.debug(`[${INTEGRATION_NAME}] Updated existing ttfd span.`, ttfdSpan);\n return ttfdSpan;\n }\n\n ttfdSpan = createSpanJSON({\n status: isDeadlineExceeded(durationMs) ? 'deadline_exceeded' : 'ok',\n op: UI_LOAD_FULL_DISPLAY,\n description: 'Time To Full Display',\n start_timestamp: transactionStartTimestampSeconds,\n timestamp: ttfdAdjustedEndTimestampSeconds,\n origin: SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY,\n parent_span_id: rootSpanId,\n data: {\n [SPAN_THREAD_NAME]: SPAN_THREAD_NAME_JAVASCRIPT,\n },\n });\n logger.debug(`[${INTEGRATION_NAME}] Added ttfd span to transaction.`, ttfdSpan);\n event.spans.push(ttfdSpan);\n return ttfdSpan;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"timeToDisplayIntegration.js","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/timeToDisplayIntegration.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,QAAQ,CAAC;AACvE,OAAO,EAAE,mCAAmC,EAAE,qCAAqC,EAAE,MAAM,WAAW,CAAC;AACvG,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,sCAAsC,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,EAAE,+BAA+B,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,CAAC,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAEhD,MAAM,0BAA0B,GAAG,KAAM,CAAC;AAC1C,MAAM,kBAAkB,GAAG,CAAC,UAAkB,EAAW,EAAE,CAAC,UAAU,GAAG,0BAA0B,CAAC;AAEpG,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAgB,EAAE;IACxD,IAAI,4CAA4C,GAAG,KAAK,CAAC;IAEzD,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,aAAa,CAAC,MAAM;;YAClB,4CAA4C;gBAC1C,MAAA,MAAA,6BAA6B,CAAC,MAAM,CAAC,0CAAE,OAAO,CAAC,4CAA4C,mCAAI,KAAK,CAAC;QACzG,CAAC;QACD,YAAY,E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AChD,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC;YACvB,QAAQ,CAAC,SAAS,GAAG,+BAA+B,CAAC;YACrD,MAAM,CAAC,KAAK,CAAC,IAAI,gBAAgB,+BAA+B,EAAE,QAAQ,CAAC,CAAC;YAC5E,OAAO,QAAQ,CAAC;SACjB;QAED,QAAQ,GAAG,cAAc,CAAC;YACxB,MAAM,EAAE,kBAAkB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAI;YACnE,EAAE,EAAE,oBAAoB;YACxB,WAAW,EAAE,sBAAsB;YACnC,eAAe,EAAE,gCAAgC;YACjD,SAAS,EAAE,+BAA+B;YAC1C,MAAM,EAAE,qCAAqC;YAC7C,cAAc,EAAE,UAAU;YAC1B,IAAI,EAAE;gBACJ,CAAC,gBAAgB,CAAC,EAAE,2BAA2B;aAChD;SACF,CAAC,CAAC;QACH,MAAM,CAAC,KAAK,CAAC,IAAI,gBAAgB,mCAAmC,EAAE,QAAQ,CAAC,CAAC;QAChF,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC3B,OAAO,QAAQ,CAAC;;CACjB","sourcesContent":["import type { Event, Integration, SpanJSON } from '@sentry/core';\nimport { logger } from '@sentry/core';\nimport { NATIVE } from '../../wrapper';\nimport { UI_LOAD_FULL_DISPLAY, UI_LOAD_INITIAL_DISPLAY } from '../ops';\nimport { SPAN_ORIGIN_AUTO_UI_TIME_TO_DISPLAY, SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY } from '../origin';\nimport { getReactNavigationIntegration } from '../reactnavigation';\nimport { SEMANTIC_ATTRIBUTE_ROUTE_HAS_BEEN_SEEN } from '../semanticAttributes';\nimport { SPAN_THREAD_NAME, SPAN_THREAD_NAME_JAVASCRIPT } from '../span';\nimport { getTimeToInitialDisplayFallback } from '../timeToDisplayFallback';\nimport { createSpanJSON } from '../utils';\n\nexport const INTEGRATION_NAME = 'TimeToDisplay';\n\nconst TIME_TO_DISPLAY_TIMEOUT_MS = 30_000;\nconst isDeadlineExceeded = (durationMs: number): boolean => durationMs > TIME_TO_DISPLAY_TIMEOUT_MS;\n\nexport const timeToDisplayIntegration = (): Integration => {\n let enableTimeToInitialDisplayForPreloadedRoutes = false;\n\n return {\n name: INTEGRATION_NAME,\n afterAllSetup(client) {\n enableTimeToInitialDisplayForPreloadedRoutes =\n getReactNavigationIntegration(client)?.options.enableTimeToInitialDisplayForPreloadedRoutes ?? false;\n },\n processEvent: async event => {\n if (event.type !== 'transaction') {\n // TimeToDisplay data is only relevant for transactions\n return event;\n }\n\n const rootSpanId = event.contexts?.trace?.span_id;\n if (!rootSpanId) {\n logger.warn(`[${INTEGRATION_NAME}] No root span id found in transaction.`);\n return event;\n }\n\n const transactionStartTimestampSeconds = event.start_timestamp;\n if (!transactionStartTimestampSeconds) {\n // This should never happen\n logger.warn(`[${INTEGRATION_NAME}] No transaction start timestamp found in transaction.`);\n return event;\n }\n\n event.spans = event.spans || [];\n event.measurements = event.measurements || {};\n\n const ttidSpan = await addTimeToInitialDisplay({\n event,\n rootSpanId,\n transactionStartTimestampSeconds,\n enableTimeToInitialDisplayForPreloadedRoutes,\n });\n const ttfdSpan = await addTimeToFullDisplay({ event, rootSpanId, transactionStartTimestampSeconds, ttidSpan });\n\n if (ttidSpan?.start_timestamp && ttidSpan?.timestamp) {\n event.measurements['time_to_initial_display'] = {\n value: (ttidSpan.timestamp - ttidSpan.start_timestamp) * 1000,\n unit: 'millisecond',\n };\n }\n\n if (ttfdSpan?.start_timestamp && ttfdSpan?.timestamp) {\n const durationMs = (ttfdSpan.timestamp - ttfdSpan.start_timestamp) * 1000;\n if (isDeadlineExceeded(durationMs)) {\n if (event.measurements['time_to_initial_display']) {\n event.measurements['time_to_full_display'] = event.measurements['time_to_initial_display'];\n }\n } else {\n event.measurements['time_to_full_display'] = {\n value: durationMs,\n unit: 'millisecond',\n };\n }\n }\n\n const newTransactionEndTimestampSeconds = Math.max(\n ttidSpan?.timestamp ?? -1,\n ttfdSpan?.timestamp ?? -1,\n event.timestamp ?? -1,\n );\n if (newTransactionEndTimestampSeconds !== -1) {\n event.timestamp = newTransactionEndTimestampSeconds;\n }\n\n return event;\n },\n };\n};\n\nasync function addTimeToInitialDisplay({\n event,\n rootSpanId,\n transactionStartTimestampSeconds,\n enableTimeToInitialDisplayForPreloadedRoutes,\n}: {\n event: Event;\n rootSpanId: string;\n transactionStartTimestampSeconds: number;\n enableTimeToInitialDisplayForPreloadedRoutes: boolean;\n}): Promise<SpanJSON | undefined> {\n const ttidEndTimestampSeconds = await NATIVE.popTimeToDisplayFor(`ttid-${rootSpanId}`);\n\n event.spans = event.spans || [];\n\n let ttidSpan: SpanJSON | undefined = event.spans?.find(span => span.op === UI_LOAD_INITIAL_DISPLAY);\n\n if (ttidSpan && (ttidSpan.status === undefined || ttidSpan.status === 'ok') && !ttidEndTimestampSeconds) {\n logger.debug(`[${INTEGRATION_NAME}] Ttid span already exists and is ok.`, ttidSpan);\n return ttidSpan;\n }\n\n if (!ttidEndTimestampSeconds) {\n logger.debug(`[${INTEGRATION_NAME}] No manual ttid end timestamp found for span ${rootSpanId}.`);\n return addAutomaticTimeToInitialDisplay({\n event,\n rootSpanId,\n transactionStartTimestampSeconds,\n enableTimeToInitialDisplayForPreloadedRoutes,\n });\n }\n\n if (ttidSpan?.status && ttidSpan.status !== 'ok') {\n ttidSpan.status = 'ok';\n ttidSpan.timestamp = ttidEndTimestampSeconds;\n logger.debug(`[${INTEGRATION_NAME}] Updated existing ttid span.`, ttidSpan);\n return ttidSpan;\n }\n\n ttidSpan = createSpanJSON({\n op: UI_LOAD_INITIAL_DISPLAY,\n description: 'Time To Initial Display',\n start_timestamp: transactionStartTimestampSeconds,\n timestamp: ttidEndTimestampSeconds,\n origin: SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY,\n parent_span_id: rootSpanId,\n data: {\n [SPAN_THREAD_NAME]: SPAN_THREAD_NAME_JAVASCRIPT,\n },\n });\n logger.debug(`[${INTEGRATION_NAME}] Added ttid span to transaction.`, ttidSpan);\n event.spans.push(ttidSpan);\n return ttidSpan;\n}\n\nasync function addAutomaticTimeToInitialDisplay({\n event,\n rootSpanId,\n transactionStartTimestampSeconds,\n enableTimeToInitialDisplayForPreloadedRoutes,\n}: {\n event: Event;\n rootSpanId: string;\n transactionStartTimestampSeconds: number;\n enableTimeToInitialDisplayForPreloadedRoutes: boolean;\n}): Promise<SpanJSON | undefined> {\n const ttidNativeTimestampSeconds = await NATIVE.popTimeToDisplayFor(`ttid-navigation-${rootSpanId}`);\n const ttidFallbackTimestampSeconds = await getTimeToInitialDisplayFallback(rootSpanId);\n\n const hasBeenSeen = event.contexts?.trace?.data?.[SEMANTIC_ATTRIBUTE_ROUTE_HAS_BEEN_SEEN];\n if (hasBeenSeen && !enableTimeToInitialDisplayForPreloadedRoutes) {\n logger.debug(\n `[${INTEGRATION_NAME}] Route has been seen and time to initial display is disabled for preloaded routes.`,\n );\n return undefined;\n }\n\n const ttidTimestampSeconds = ttidNativeTimestampSeconds ?? ttidFallbackTimestampSeconds;\n if (!ttidTimestampSeconds) {\n logger.debug(`[${INTEGRATION_NAME}] No automatic ttid end timestamp found for span ${rootSpanId}.`);\n return undefined;\n }\n\n const viewNames = event.contexts?.app?.view_names;\n const screenName = Array.isArray(viewNames) ? viewNames[0] : viewNames;\n\n const ttidSpan = createSpanJSON({\n op: UI_LOAD_INITIAL_DISPLAY,\n description: screenName ? `${screenName} initial display` : 'Time To Initial Display',\n start_timestamp: transactionStartTimestampSeconds,\n timestamp: ttidTimestampSeconds,\n origin: SPAN_ORIGIN_AUTO_UI_TIME_TO_DISPLAY,\n parent_span_id: rootSpanId,\n data: {\n [SPAN_THREAD_NAME]: SPAN_THREAD_NAME_JAVASCRIPT,\n },\n });\n event.spans = event.spans ?? [];\n event.spans.push(ttidSpan);\n return ttidSpan;\n}\n\nasync function addTimeToFullDisplay({\n event,\n rootSpanId,\n transactionStartTimestampSeconds,\n ttidSpan,\n}: {\n event: Event;\n rootSpanId: string;\n transactionStartTimestampSeconds: number;\n ttidSpan: SpanJSON | undefined;\n}): Promise<SpanJSON | undefined> {\n const ttfdEndTimestampSeconds = await NATIVE.popTimeToDisplayFor(`ttfd-${rootSpanId}`);\n\n if (!ttidSpan || !ttfdEndTimestampSeconds) {\n return undefined;\n }\n\n event.spans = event.spans || [];\n\n let ttfdSpan = event.spans?.find(span => span.op === UI_LOAD_FULL_DISPLAY);\n\n let ttfdAdjustedEndTimestampSeconds = ttfdEndTimestampSeconds;\n const ttfdIsBeforeTtid = ttidSpan.timestamp && ttfdEndTimestampSeconds < ttidSpan.timestamp;\n if (ttfdIsBeforeTtid && ttidSpan.timestamp) {\n ttfdAdjustedEndTimestampSeconds = ttidSpan.timestamp;\n }\n\n const durationMs = (ttfdAdjustedEndTimestampSeconds - transactionStartTimestampSeconds) * 1000;\n\n if (ttfdSpan?.status && ttfdSpan.status !== 'ok') {\n ttfdSpan.status = 'ok';\n ttfdSpan.timestamp = ttfdAdjustedEndTimestampSeconds;\n logger.debug(`[${INTEGRATION_NAME}] Updated existing ttfd span.`, ttfdSpan);\n return ttfdSpan;\n }\n\n ttfdSpan = createSpanJSON({\n status: isDeadlineExceeded(durationMs) ? 'deadline_exceeded' : 'ok',\n op: UI_LOAD_FULL_DISPLAY,\n description: 'Time To Full Display',\n start_timestamp: transactionStartTimestampSeconds,\n timestamp: ttfdAdjustedEndTimestampSeconds,\n origin: SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY,\n parent_span_id: rootSpanId,\n data: {\n [SPAN_THREAD_NAME]: SPAN_THREAD_NAME_JAVASCRIPT,\n },\n });\n logger.debug(`[${INTEGRATION_NAME}] Added ttfd span to transaction.`, ttfdSpan);\n event.spans.push(ttfdSpan);\n return ttfdSpan;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userInteraction.d.ts","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/userInteraction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAoB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"userInteraction.d.ts","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/userInteraction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAoB,MAAM,cAAc,CAAC;AAiBxE,eAAO,MAAM,0BAA0B,QAAO,WAI7C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,sBAAuB;IAC1D,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,EAAE,EAAE,MAAM,CAAC;CACZ,KAAG,IAAI,GAAG,SAmEV,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userInteraction.js","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/userInteraction.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,SAAS,EACT,eAAe,EACf,MAAM,EACN,gCAAgC,EAChC,UAAU,GACX,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"userInteraction.js","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/userInteraction.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,SAAS,EACT,eAAe,EACf,MAAM,EACN,gCAAgC,EAChC,UAAU,GACX,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,8BAA8B,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,uCAAuC,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE3F,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAE3C,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAgB,EAAE;IAC1D,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CAAC;QACF,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,IAAI,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,YAAY,IAAI,SAAS,EAAE,CAAC;IAC1D,IACE,iBAAiB;QACjB,UAAU,CAAC,iBAAiB,CAAC,CAAC,WAAW,KAAK,IAAI;QAClD,UAAU,CAAC,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,EACvC;QACA,MAAM,CAAC,IAAI,CACT,IAAI,gBAAgB,oBAAoB,EAAE,gDACxC,UAAU,CAAC,iBAAiB,CAAC,CAAC,WAChC,+BAA+B,CAChC,CAAC;QACF,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,MAAM,OAAO,GAAqB;QAChC,IAAI;QACJ,EAAE;QACF,KAAK;KACN,CAAC;IACF,wBAAwB,CAAC,KAAK,CAAC,CAAC;IAChC,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,EAAE;QACrC,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,aAAa;QAC1C,YAAY,EAAE,OAAO,CAAC,OAAO,CAAC,cAAc;KAC7C,CAAC,CAAC;IACH,OAAO,CAAC,YAAY,CAAC,gCAAgC,EAAE,8BAA8B,CAAC,CAAC;IACvF,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,MAAM,CAAC,GAAG,CAAC,IAAI,gBAAgB,sCAAsC,EAAE,gBAAgB,IAAI,GAAG,CAAC,CAAC;IAChG,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["import type { Integration, Span, StartSpanOptions } from '@sentry/core';\nimport {\n getActiveSpan,\n getClient,\n getCurrentScope,\n logger,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n spanToJSON,\n} from '@sentry/core';\nimport type { ReactNativeClientOptions } from '../../options';\nimport { onlySampleIfChildSpans } from '../onSpanEndUtils';\nimport { SPAN_ORIGIN_MANUAL_INTERACTION } from '../origin';\nimport { getCurrentReactNativeTracingIntegration } from '../reactnativetracing';\nimport { clearActiveSpanFromScope, isSentryInteractionSpan, startIdleSpan } from '../span';\n\nconst INTEGRATION_NAME = 'UserInteraction';\n\nexport const userInteractionIntegration = (): Integration => {\n return {\n name: INTEGRATION_NAME,\n };\n};\n\n/**\n * Starts a new transaction for a user interaction.\n * @param userInteractionId Consists of `op` representation UI Event and `elementId` unique element identifier on current screen.\n */\nexport const startUserInteractionSpan = (userInteractionId: {\n elementId: string | undefined;\n op: string;\n}): Span | undefined => {\n const client = getClient();\n if (!client) {\n return undefined;\n }\n\n const tracing = getCurrentReactNativeTracingIntegration();\n if (!tracing) {\n logger.log(`[${INTEGRATION_NAME}] Tracing integration is not available. Can not start user interaction span.`);\n return undefined;\n }\n\n const options = client.getOptions() as ReactNativeClientOptions;\n const { elementId, op } = userInteractionId;\n if (!options.enableUserInteractionTracing) {\n logger.log(`[${INTEGRATION_NAME}] User Interaction Tracing is disabled.`);\n return undefined;\n }\n if (!elementId) {\n logger.log(`[${INTEGRATION_NAME}] User Interaction Tracing can not create transaction with undefined elementId.`);\n return undefined;\n }\n if (!tracing.state.currentRoute) {\n logger.log(`[${INTEGRATION_NAME}] User Interaction Tracing can not create transaction without a current route.`);\n return undefined;\n }\n\n const activeTransaction = getActiveSpan();\n const activeTransactionIsNotInteraction = activeTransaction && !isSentryInteractionSpan(activeTransaction);\n if (activeTransaction && activeTransactionIsNotInteraction) {\n logger.warn(\n `[${INTEGRATION_NAME}] Did not create ${op} transaction because active transaction ${\n spanToJSON(activeTransaction).description\n } exists on the scope.`,\n );\n return undefined;\n }\n\n const name = `${tracing.state.currentRoute}.${elementId}`;\n if (\n activeTransaction &&\n spanToJSON(activeTransaction).description === name &&\n spanToJSON(activeTransaction).op === op\n ) {\n logger.warn(\n `[${INTEGRATION_NAME}] Did not create ${op} transaction because it the same transaction ${\n spanToJSON(activeTransaction).description\n } already exists on the scope.`,\n );\n return undefined;\n }\n\n const scope = getCurrentScope();\n const context: StartSpanOptions = {\n name,\n op,\n scope,\n };\n clearActiveSpanFromScope(scope);\n const newSpan = startIdleSpan(context, {\n idleTimeout: tracing.options.idleTimeoutMs,\n finalTimeout: tracing.options.finalTimeoutMs,\n });\n newSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_ORIGIN_MANUAL_INTERACTION);\n onlySampleIfChildSpans(client, newSpan);\n logger.log(`[${INTEGRATION_NAME}] User Interaction Tracing Created ${op} transaction ${name}.`);\n return newSpan;\n};\n"]}
|
|
@@ -4,7 +4,7 @@ import type { Client, Span } from '@sentry/core';
|
|
|
4
4
|
*/
|
|
5
5
|
export declare function onThisSpanEnd(client: Client, span: Span, callback: (span: Span) => void): void;
|
|
6
6
|
export declare const adjustTransactionDuration: (client: Client, span: Span, maxDurationMs: number) => void;
|
|
7
|
-
export declare const ignoreEmptyBackNavigation: (client: Client | undefined, span: Span) => void;
|
|
7
|
+
export declare const ignoreEmptyBackNavigation: (client: Client | undefined, span: Span | undefined) => void;
|
|
8
8
|
/**
|
|
9
9
|
* Idle Transaction callback to only sample transactions with child spans.
|
|
10
10
|
* To avoid side effects of other callbacks this should be hooked as the last callback.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onSpanEndUtils.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/onSpanEndUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"onSpanEndUtils.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/onSpanEndUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAMjD;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,GAAG,IAAI,CAO9F;AAED,eAAO,MAAM,yBAAyB,WAAY,MAAM,QAAQ,IAAI,iBAAiB,MAAM,KAAG,IAyB7F,CAAC;AAEF,eAAO,MAAM,yBAAyB,WAAY,MAAM,GAAG,SAAS,QAAQ,IAAI,GAAG,SAAS,KAAG,IA0C9F,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,WAAY,MAAM,QAAQ,IAAI,KAAG,IAmBnE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,WAAY,MAAM,QAAQ,IAAI,KAAG,IAgB/D,CAAC"}
|
|
@@ -102,9 +102,10 @@ export const cancelInBackground = (client, span) => {
|
|
|
102
102
|
});
|
|
103
103
|
subscription &&
|
|
104
104
|
client.on('spanEnd', (endedSpan) => {
|
|
105
|
+
var _a;
|
|
105
106
|
if (endedSpan === span) {
|
|
106
107
|
logger.debug(`Removing AppState listener for ${spanToJSON(span).op} transaction.`);
|
|
107
|
-
subscription
|
|
108
|
+
(_a = subscription === null || subscription === void 0 ? void 0 : subscription.remove) === null || _a === void 0 ? void 0 : _a.call(subscription);
|
|
108
109
|
}
|
|
109
110
|
});
|
|
110
111
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onSpanEndUtils.js","sourceRoot":"","sources":["../../../src/js/tracing/onSpanEndUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAEzF,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"onSpanEndUtils.js","sourceRoot":"","sources":["../../../src/js/tracing/onSpanEndUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAEzF,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,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S,KAAK,IAAI,EAAE;gBACtB,MAAM,CAAC,KAAK,CAAC,kCAAkC,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC;gBACnF,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,MAAM,4DAAI,CAAC;aAC1B;QACH,CAAC,CAAC,CAAC;AACP,CAAC,CAAC","sourcesContent":["import type { Client, Span } from '@sentry/core';\nimport { getSpanDescendants, logger, SPAN_STATUS_ERROR, spanToJSON } from '@sentry/core';\nimport type { AppStateStatus } from 'react-native';\nimport { AppState } from 'react-native';\nimport { isRootSpan, isSentrySpan } from '../utils/span';\n\n/**\n * Hooks on span end event to execute a callback when the span ends.\n */\nexport function onThisSpanEnd(client: Client, span: Span, callback: (span: Span) => void): void {\n client.on('spanEnd', (endedSpan: Span) => {\n if (span !== endedSpan) {\n return;\n }\n callback(endedSpan);\n });\n}\n\nexport const adjustTransactionDuration = (client: Client, span: Span, maxDurationMs: number): void => {\n if (!isRootSpan(span)) {\n logger.warn('Not sampling empty back spans only works for Sentry Transactions (Root Spans).');\n return;\n }\n\n client.on('spanEnd', (endedSpan: Span) => {\n if (endedSpan !== span) {\n return;\n }\n\n const endTimestamp = spanToJSON(span).timestamp;\n const startTimestamp = spanToJSON(span).start_timestamp;\n if (!endTimestamp || !startTimestamp) {\n return;\n }\n\n const diff = endTimestamp - startTimestamp;\n const isOutdatedTransaction = endTimestamp && (diff > maxDurationMs || diff < 0);\n if (isOutdatedTransaction) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'deadline_exceeded' });\n // TODO: check where was used, might be possible to delete\n span.setAttribute('maxTransactionDurationExceeded', 'true');\n }\n });\n};\n\nexport const ignoreEmptyBackNavigation = (client: Client | undefined, span: Span | undefined): void => {\n if (!client) {\n logger.warn('Could not hook on spanEnd event because client is not defined.');\n return;\n }\n\n if (!span) {\n logger.warn('Could not hook on spanEnd event because span is not defined.');\n return;\n }\n\n if (!isRootSpan(span) || !isSentrySpan(span)) {\n logger.warn('Not sampling empty back spans only works for Sentry Transactions (Root Spans).');\n return;\n }\n\n client.on('spanEnd', (endedSpan: Span) => {\n if (endedSpan !== span) {\n return;\n }\n\n if (!spanToJSON(span).data?.['route.has_been_seen']) {\n return;\n }\n\n const children = getSpanDescendants(span);\n const filtered = children.filter(\n child =>\n child.spanContext().spanId !== span.spanContext().spanId &&\n spanToJSON(child).op !== 'ui.load.initial_display' &&\n spanToJSON(child).op !== 'navigation.processing',\n );\n\n if (filtered.length <= 0) {\n // filter children must include at least one span not created by the navigation automatic instrumentation\n logger.log(\n 'Not sampling transaction as route has been seen before. Pass ignoreEmptyBackNavigationTransactions = false to disable this feature.',\n );\n // Route has been seen before and has no child spans.\n span['_sampled'] = false;\n }\n });\n};\n\n/**\n * Idle Transaction callback to only sample transactions with child spans.\n * To avoid side effects of other callbacks this should be hooked as the last callback.\n */\nexport const onlySampleIfChildSpans = (client: Client, span: Span): void => {\n if (!isRootSpan(span) || !isSentrySpan(span)) {\n logger.warn('Not sampling childless spans only works for Sentry Transactions (Root Spans).');\n return;\n }\n\n client.on('spanEnd', (endedSpan: Span) => {\n if (endedSpan !== span) {\n return;\n }\n\n const children = getSpanDescendants(span);\n\n if (children.length <= 1) {\n // Span always has at lest one child, itself\n logger.log(`Not sampling as ${spanToJSON(span).op} transaction has no child spans.`);\n span['_sampled'] = false;\n }\n });\n};\n\n/**\n * Hooks on AppState change to cancel the span if the app goes background.\n */\nexport const cancelInBackground = (client: Client, span: Span): void => {\n const subscription = AppState.addEventListener('change', (newState: AppStateStatus) => {\n if (newState === 'background') {\n logger.debug(`Setting ${spanToJSON(span).op} transaction to cancelled because the app is in the background.`);\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'cancelled' });\n span.end();\n }\n });\n\n subscription &&\n client.on('spanEnd', (endedSpan: Span) => {\n if (endedSpan === span) {\n logger.debug(`Removing AppState listener for ${spanToJSON(span).op} transaction.`);\n subscription?.remove?.();\n }\n });\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactnativenavigation.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/reactnativenavigation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,WAAW,EAAQ,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"reactnativenavigation.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/reactnativenavigation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,WAAW,EAAQ,MAAM,cAAc,CAAC;AAS9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAazE,eAAO,MAAM,gBAAgB,0BAA0B,CAAC;AAIxD,UAAU,4BAA4B;IACpC;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B;;;;;OAKG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;IAEpC;;;;;OAKG;IACH,qCAAqC,CAAC,EAAE,OAAO,CAAC;IAEhD;;;;;OAKG;IACH,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,UAAU,cAAc;IACtB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,KAAK,aAAa,GAAG,WAAW,GAAG,aAAa,GAAG,kBAAkB,GAAG,cAAc,CAAC;AAEvF,MAAM,WAAW,wBAAyB,SAAQ,cAAc;IAC9D,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,CAAC;IACtD,aAAa,EAAE,aAAa,CAAC;CAC9B;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,IAAI,IAAI,CAAC;CAChB;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,mCAAmC,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,wBAAwB,KAAK,IAAI,GAAG,mBAAmB,CAAC;IAC9G,uBAAuB,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,GAAG,iBAAiB,CAAC;IAC9F,gCAAgC,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,GAAG,mBAAmB,CAAC;CACzG;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,cAAc,CAAC;CAC9B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,gCAAgC,+HAK1C,4BAA4B,KAAG,WAkIjC,CAAC"}
|
|
@@ -35,7 +35,7 @@ export const reactNativeNavigationIntegration = ({ navigation: optionsNavigation
|
|
|
35
35
|
if (latestNavigationSpan) {
|
|
36
36
|
discardLatestNavigationSpan();
|
|
37
37
|
}
|
|
38
|
-
latestNavigationSpan = startGenericIdleNavigationSpan(tracing
|
|
38
|
+
latestNavigationSpan = startGenericIdleNavigationSpan((tracing === null || tracing === void 0 ? void 0 : tracing.options.beforeStartSpan)
|
|
39
39
|
? tracing.options.beforeStartSpan(getDefaultIdleNavigationSpanOptions())
|
|
40
40
|
: getDefaultIdleNavigationSpanOptions(), idleSpanOptions);
|
|
41
41
|
latestNavigationSpan === null || latestNavigationSpan === void 0 ? void 0 : latestNavigationSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_ORIGIN_AUTO_NAVIGATION_REACT_NATIVE_NAVIGATION);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactnativenavigation.js","sourceRoot":"","sources":["../../../src/js/tracing/reactnativenavigation.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,SAAS,EACT,4BAA4B,EAC5B,gCAAgC,EAChC,gCAAgC,EAChC,UAAU,GACX,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,C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AAG,GAAS,EAAE;QAC7C,IAAI,oBAAoB,EAAE;YACxB,IAAI,YAAY,CAAC,oBAAoB,CAAC,EAAE;gBACtC,oBAAoB,CAAC,UAAU,CAAC,GAAG,KAAK,CAAC;aAC1C;YACD,qCAAqC;YACrC,oBAAoB,CAAC,GAAG,EAAE,CAAC;YAC3B,oBAAoB,GAAG,SAAS,CAAC;SAClC;QAED,uBAAuB,EAAE,CAAC;IAC5B,CAAC,CAAC;IAEF,MAAM,uBAAuB,GAAG,GAAS,EAAE;QACzC,IAAI,OAAO,kBAAkB,KAAK,WAAW,EAAE;YAC7C,YAAY,CAAC,kBAAkB,CAAC,CAAC;YACjC,kBAAkB,GAAG,SAAS,CAAC;SAChC;IACH,CAAC,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,aAAa;KACd,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { Client, Integration, Span } from '@sentry/core';\nimport {\n addBreadcrumb,\n getClient,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n spanToJSON,\n} from '@sentry/core';\n\nimport type { EmitterSubscription } from '../utils/rnlibrariesinterface';\nimport { isSentrySpan } from '../utils/span';\nimport { ignoreEmptyBackNavigation } from './onSpanEndUtils';\nimport { SPAN_ORIGIN_AUTO_NAVIGATION_REACT_NATIVE_NAVIGATION } from './origin';\nimport type { ReactNativeTracingIntegration } from './reactnativetracing';\nimport { getReactNativeTracingIntegration } from './reactnativetracing';\nimport {\n DEFAULT_NAVIGATION_SPAN_NAME,\n defaultIdleOptions,\n getDefaultIdleNavigationSpanOptions,\n startIdleNavigationSpan as startGenericIdleNavigationSpan,\n} from './span';\n\nexport const INTEGRATION_NAME = 'ReactNativeNavigation';\n\nconst NAVIGATION_HISTORY_MAX_SIZE = 200;\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 *\n * @default 1_000 (ms)\n */\n routeChangeTimeoutMs?: number;\n\n /**\n * Instrumentation will create a transaction on tab change.\n * By default only navigation commands create transactions.\n *\n * @default false\n */\n enableTabsInstrumentation?: boolean;\n\n /**\n * Does not sample transactions that are from routes that have been seen any more and don't have any spans.\n * This removes a lot of the clutter as most back navigation transactions are now ignored.\n *\n * @default true\n */\n ignoreEmptyBackNavigationTransactions?: boolean;\n\n /** The React Native Navigation `NavigationDelegate`.\n *\n * ```js\n * import { Navigation } from 'react-native-navigation';\n * ```\n */\n navigation: unknown;\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 navigation: optionsNavigation,\n routeChangeTimeoutMs = 1_000,\n enableTabsInstrumentation = false,\n ignoreEmptyBackNavigationTransactions = true,\n}: ReactNativeNavigationOptions): Integration => {\n const navigation = optionsNavigation as NavigationDelegate;\n let recentComponentIds: string[] = [];\n\n let tracing: ReactNativeTracingIntegration | undefined;\n let idleSpanOptions: Parameters<typeof startGenericIdleNavigationSpan>[1] = defaultIdleOptions;\n\n let stateChangeTimeout: ReturnType<typeof setTimeout> | undefined;\n let prevComponentEvent: ComponentWillAppearEvent | null = null;\n let latestNavigationSpan: Span | undefined;\n\n const afterAllSetup = (client: Client): void => {\n tracing = getReactNativeTracingIntegration(client);\n if (tracing) {\n idleSpanOptions = {\n finalTimeout: tracing.options.finalTimeoutMs,\n idleTimeout: tracing.options.idleTimeoutMs,\n };\n }\n };\n\n const startIdleNavigationSpan = (): void => {\n if (latestNavigationSpan) {\n discardLatestNavigationSpan();\n }\n\n latestNavigationSpan = startGenericIdleNavigationSpan(\n tracing && tracing.options.beforeStartSpan\n ? tracing.options.beforeStartSpan(getDefaultIdleNavigationSpanOptions())\n : getDefaultIdleNavigationSpanOptions(),\n idleSpanOptions,\n );\n latestNavigationSpan?.setAttribute(\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_ORIGIN_AUTO_NAVIGATION_REACT_NATIVE_NAVIGATION,\n );\n if (ignoreEmptyBackNavigationTransactions) {\n ignoreEmptyBackNavigation(getClient(), latestNavigationSpan);\n }\n\n stateChangeTimeout = setTimeout(discardLatestNavigationSpan.bind(this), routeChangeTimeoutMs);\n };\n\n const updateLatestNavigationSpanWithCurrentComponent = (event: ComponentWillAppearEvent): void => {\n if (!latestNavigationSpan) {\n return;\n }\n\n // We ignore actions that pertain to the same screen.\n const isSameComponent = prevComponentEvent && event.componentId === prevComponentEvent.componentId;\n if (isSameComponent) {\n discardLatestNavigationSpan();\n return;\n }\n\n clearStateChangeTimeout();\n\n const routeHasBeenSeen = recentComponentIds.includes(event.componentId);\n\n if (spanToJSON(latestNavigationSpan).description === DEFAULT_NAVIGATION_SPAN_NAME) {\n latestNavigationSpan.updateName(event.componentName);\n }\n latestNavigationSpan.setAttributes({\n // TODO: Should we include pass props? I don't know exactly what it contains, cant find it in the RNavigation docs\n 'route.name': event.componentName,\n 'route.component_id': event.componentId,\n 'route.component_type': event.componentType,\n 'route.has_been_seen': routeHasBeenSeen,\n 'previous_route.name': prevComponentEvent?.componentName,\n 'previous_route.component_id': prevComponentEvent?.componentId,\n 'previous_route.component_type': prevComponentEvent?.componentType,\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'component',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',\n });\n\n tracing?.setCurrentRoute(event.componentName);\n\n addBreadcrumb({\n category: 'navigation',\n type: 'navigation',\n message: `Navigation to ${event.componentName}`,\n data: {\n from: prevComponentEvent?.componentName,\n to: event.componentName,\n },\n });\n\n pushRecentComponentId(event.componentId);\n prevComponentEvent = event;\n latestNavigationSpan = undefined;\n };\n\n navigation.events().registerCommandListener(startIdleNavigationSpan);\n if (enableTabsInstrumentation) {\n navigation.events().registerBottomTabPressedListener(startIdleNavigationSpan);\n }\n navigation.events().registerComponentWillAppearListener(updateLatestNavigationSpanWithCurrentComponent);\n\n const pushRecentComponentId = (id: string): void => {\n recentComponentIds.push(id);\n\n if (recentComponentIds.length > NAVIGATION_HISTORY_MAX_SIZE) {\n recentComponentIds = recentComponentIds.slice(recentComponentIds.length - NAVIGATION_HISTORY_MAX_SIZE);\n }\n };\n\n const discardLatestNavigationSpan = (): void => {\n if (latestNavigationSpan) {\n if (isSentrySpan(latestNavigationSpan)) {\n latestNavigationSpan['_sampled'] = false;\n }\n // TODO: What if it's not SentrySpan?\n latestNavigationSpan.end();\n latestNavigationSpan = undefined;\n }\n\n clearStateChangeTimeout();\n };\n\n const clearStateChangeTimeout = (): void => {\n if (typeof stateChangeTimeout !== 'undefined') {\n clearTimeout(stateChangeTimeout);\n stateChangeTimeout = undefined;\n }\n };\n\n return {\n name: INTEGRATION_NAME,\n afterAllSetup,\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"reactnativenavigation.js","sourceRoot":"","sources":["../../../src/js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,EAAU,EAAQ,EAAE;QACjD,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAE5B,IAAI,kBAAkB,CAAC,MAAM,GAAG,2BAA2B,EAAE;YAC3D,kBAAkB,GAAG,kBAAkB,CAAC,KAAK,CAAC,kBAAkB,CAAC,MAAM,GAAG,2BAA2B,CAAC,CAAC;SACxG;IACH,CAAC,CAAC;IAEF,MAAM,2BAA2B,GAAG,GAAS,EAAE;QAC7C,IAAI,oBAAoB,EAAE;YACxB,IAAI,YAAY,CAAC,oBAAoB,CAAC,EAAE;gBACtC,oBAAoB,CAAC,UAAU,CAAC,GAAG,KAAK,CAAC;aAC1C;YACD,qCAAqC;YACrC,oBAAoB,CAAC,GAAG,EAAE,CAAC;YAC3B,oBAAoB,GAAG,SAAS,CAAC;SAClC;QAED,uBAAuB,EAAE,CAAC;IAC5B,CAAC,CAAC;IAEF,MAAM,uBAAuB,GAAG,GAAS,EAAE;QACzC,IAAI,OAAO,kBAAkB,KAAK,WAAW,EAAE;YAC7C,YAAY,CAAC,kBAAkB,CAAC,CAAC;YACjC,kBAAkB,GAAG,SAAS,CAAC;SAChC;IACH,CAAC,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,aAAa;KACd,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { Client, Integration, Span } from '@sentry/core';\nimport {\n addBreadcrumb,\n getClient,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n spanToJSON,\n} from '@sentry/core';\nimport type { EmitterSubscription } from '../utils/rnlibrariesinterface';\nimport { isSentrySpan } from '../utils/span';\nimport { ignoreEmptyBackNavigation } from './onSpanEndUtils';\nimport { SPAN_ORIGIN_AUTO_NAVIGATION_REACT_NATIVE_NAVIGATION } from './origin';\nimport type { ReactNativeTracingIntegration } from './reactnativetracing';\nimport { getReactNativeTracingIntegration } from './reactnativetracing';\nimport {\n DEFAULT_NAVIGATION_SPAN_NAME,\n defaultIdleOptions,\n getDefaultIdleNavigationSpanOptions,\n startIdleNavigationSpan as startGenericIdleNavigationSpan,\n} from './span';\n\nexport const INTEGRATION_NAME = 'ReactNativeNavigation';\n\nconst NAVIGATION_HISTORY_MAX_SIZE = 200;\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 *\n * @default 1_000 (ms)\n */\n routeChangeTimeoutMs?: number;\n\n /**\n * Instrumentation will create a transaction on tab change.\n * By default only navigation commands create transactions.\n *\n * @default false\n */\n enableTabsInstrumentation?: boolean;\n\n /**\n * Does not sample transactions that are from routes that have been seen any more and don't have any spans.\n * This removes a lot of the clutter as most back navigation transactions are now ignored.\n *\n * @default true\n */\n ignoreEmptyBackNavigationTransactions?: boolean;\n\n /** The React Native Navigation `NavigationDelegate`.\n *\n * ```js\n * import { Navigation } from 'react-native-navigation';\n * ```\n */\n navigation: unknown;\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 navigation: optionsNavigation,\n routeChangeTimeoutMs = 1_000,\n enableTabsInstrumentation = false,\n ignoreEmptyBackNavigationTransactions = true,\n}: ReactNativeNavigationOptions): Integration => {\n const navigation = optionsNavigation as NavigationDelegate;\n let recentComponentIds: string[] = [];\n\n let tracing: ReactNativeTracingIntegration | undefined;\n let idleSpanOptions: Parameters<typeof startGenericIdleNavigationSpan>[1] = defaultIdleOptions;\n\n let stateChangeTimeout: ReturnType<typeof setTimeout> | undefined;\n let prevComponentEvent: ComponentWillAppearEvent | null = null;\n let latestNavigationSpan: Span | undefined;\n\n const afterAllSetup = (client: Client): void => {\n tracing = getReactNativeTracingIntegration(client);\n if (tracing) {\n idleSpanOptions = {\n finalTimeout: tracing.options.finalTimeoutMs,\n idleTimeout: tracing.options.idleTimeoutMs,\n };\n }\n };\n\n const startIdleNavigationSpan = (): void => {\n if (latestNavigationSpan) {\n discardLatestNavigationSpan();\n }\n\n latestNavigationSpan = startGenericIdleNavigationSpan(\n tracing?.options.beforeStartSpan\n ? tracing.options.beforeStartSpan(getDefaultIdleNavigationSpanOptions())\n : getDefaultIdleNavigationSpanOptions(),\n idleSpanOptions,\n );\n latestNavigationSpan?.setAttribute(\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_ORIGIN_AUTO_NAVIGATION_REACT_NATIVE_NAVIGATION,\n );\n if (ignoreEmptyBackNavigationTransactions) {\n ignoreEmptyBackNavigation(getClient(), latestNavigationSpan);\n }\n\n stateChangeTimeout = setTimeout(discardLatestNavigationSpan.bind(this), routeChangeTimeoutMs);\n };\n\n const updateLatestNavigationSpanWithCurrentComponent = (event: ComponentWillAppearEvent): void => {\n if (!latestNavigationSpan) {\n return;\n }\n\n // We ignore actions that pertain to the same screen.\n const isSameComponent = prevComponentEvent && event.componentId === prevComponentEvent.componentId;\n if (isSameComponent) {\n discardLatestNavigationSpan();\n return;\n }\n\n clearStateChangeTimeout();\n\n const routeHasBeenSeen = recentComponentIds.includes(event.componentId);\n\n if (spanToJSON(latestNavigationSpan).description === DEFAULT_NAVIGATION_SPAN_NAME) {\n latestNavigationSpan.updateName(event.componentName);\n }\n latestNavigationSpan.setAttributes({\n // TODO: Should we include pass props? I don't know exactly what it contains, cant find it in the RNavigation docs\n 'route.name': event.componentName,\n 'route.component_id': event.componentId,\n 'route.component_type': event.componentType,\n 'route.has_been_seen': routeHasBeenSeen,\n 'previous_route.name': prevComponentEvent?.componentName,\n 'previous_route.component_id': prevComponentEvent?.componentId,\n 'previous_route.component_type': prevComponentEvent?.componentType,\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'component',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',\n });\n\n tracing?.setCurrentRoute(event.componentName);\n\n addBreadcrumb({\n category: 'navigation',\n type: 'navigation',\n message: `Navigation to ${event.componentName}`,\n data: {\n from: prevComponentEvent?.componentName,\n to: event.componentName,\n },\n });\n\n pushRecentComponentId(event.componentId);\n prevComponentEvent = event;\n latestNavigationSpan = undefined;\n };\n\n navigation.events().registerCommandListener(startIdleNavigationSpan);\n if (enableTabsInstrumentation) {\n navigation.events().registerBottomTabPressedListener(startIdleNavigationSpan);\n }\n navigation.events().registerComponentWillAppearListener(updateLatestNavigationSpanWithCurrentComponent);\n\n const pushRecentComponentId = (id: string): void => {\n recentComponentIds.push(id);\n\n if (recentComponentIds.length > NAVIGATION_HISTORY_MAX_SIZE) {\n recentComponentIds = recentComponentIds.slice(recentComponentIds.length - NAVIGATION_HISTORY_MAX_SIZE);\n }\n };\n\n const discardLatestNavigationSpan = (): void => {\n if (latestNavigationSpan) {\n if (isSentrySpan(latestNavigationSpan)) {\n latestNavigationSpan['_sampled'] = false;\n }\n // TODO: What if it's not SentrySpan?\n latestNavigationSpan.end();\n latestNavigationSpan = undefined;\n }\n\n clearStateChangeTimeout();\n };\n\n const clearStateChangeTimeout = (): void => {\n if (typeof stateChangeTimeout !== 'undefined') {\n clearTimeout(stateChangeTimeout);\n stateChangeTimeout = undefined;\n }\n };\n\n return {\n name: INTEGRATION_NAME,\n afterAllSetup,\n };\n};\n"]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Profiler } from '@sentry/react';
|
|
2
|
+
type ProfilerConstructorProps = ConstructorParameters<typeof Profiler>[0];
|
|
2
3
|
/**
|
|
3
4
|
* Custom profiler for the React Native app root.
|
|
4
5
|
*/
|
|
5
6
|
export declare class ReactNativeProfiler extends Profiler {
|
|
6
7
|
readonly name: string;
|
|
7
|
-
constructor(props:
|
|
8
|
+
constructor(props: ProfilerConstructorProps);
|
|
8
9
|
/**
|
|
9
10
|
* Get the app root mount time.
|
|
10
11
|
*/
|
|
@@ -14,4 +15,5 @@ export declare class ReactNativeProfiler extends Profiler {
|
|
|
14
15
|
*/
|
|
15
16
|
private _reportAppStart;
|
|
16
17
|
}
|
|
18
|
+
export {};
|
|
17
19
|
//# sourceMappingURL=reactnativeprofiler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactnativeprofiler.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/reactnativeprofiler.tsx"],"names":[],"mappings":"AACA,OAAO,EAAa,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"reactnativeprofiler.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/reactnativeprofiler.tsx"],"names":[],"mappings":"AACA,OAAO,EAAa,QAAQ,EAAE,MAAM,eAAe,CAAC;AAYpD,KAAK,wBAAwB,GAAG,qBAAqB,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AAE1E;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,QAAQ;IAC/C,SAAgB,IAAI,EAAE,MAAM,CAAyB;gBAElC,KAAK,EAAE,wBAAwB;IAKlD;;OAEG;IACI,iBAAiB,IAAI,IAAI;IAQhC;;OAEG;IACH,OAAO,CAAC,eAAe;CAsBxB"}
|
|
@@ -32,6 +32,7 @@ export class ReactNativeProfiler extends Profiler {
|
|
|
32
32
|
* Notifies the Tracing integration that the app start has finished.
|
|
33
33
|
*/
|
|
34
34
|
_reportAppStart() {
|
|
35
|
+
var _a;
|
|
35
36
|
const client = getClient();
|
|
36
37
|
if (!client) {
|
|
37
38
|
// We can't use logger here because this will be logged before the `Sentry.init`.
|
|
@@ -39,7 +40,7 @@ export class ReactNativeProfiler extends Profiler {
|
|
|
39
40
|
__DEV__ && console.warn('App Start Span could not be finished. `Sentry.wrap` was called before `Sentry.init`.');
|
|
40
41
|
return;
|
|
41
42
|
}
|
|
42
|
-
client.addIntegration
|
|
43
|
+
(_a = client.addIntegration) === null || _a === void 0 ? void 0 : _a.call(client, createIntegration(this.name));
|
|
43
44
|
const appRegistryIntegration = getAppRegistryIntegration(client);
|
|
44
45
|
if (appRegistryIntegration && typeof appRegistryIntegration.onRunApplication === 'function') {
|
|
45
46
|
appRegistryIntegration.onRunApplication(ReactNativeProfilerGlobalState.onRunApplicationHook);
|