|
1 | 1 | import * as Sentry from '@sentry/react-native'; |
| 2 | +import {getBundleStartTimestampMs} from '@sentry/react-native/dist/js/tracing/utils'; |
2 | 3 | import {Platform} from 'react-native'; |
3 | 4 | import {isDevelopment} from '@libs/Environment/Environment'; |
| 5 | +import {endSpan, startSpan} from '@libs/telemetry/activeSpans'; |
4 | 6 | import {breadcrumbsIntegration, browserProfilingIntegration, consoleIntegration, navigationIntegration, tracingIntegration} from '@libs/telemetry/integrations'; |
5 | 7 | import {processBeforeSendLogs, processBeforeSendTransactions} from '@libs/telemetry/middlewares'; |
6 | 8 | import CONFIG from '@src/CONFIG'; |
7 | 9 | import CONST from '@src/CONST'; |
8 | 10 | import pkg from '../../../package.json'; |
9 | 11 | import makeDebugTransport from './debugTransport'; |
10 | 12 |
|
| 13 | +const bundleEndMs = Date.now(); |
| 14 | + |
11 | 15 | function setupSentry(): void { |
12 | 16 | // With Sentry enabled in dev mode, profiling on iOS and Android does not work |
13 | 17 | // If you want to enable Sentry in dev, set ENABLE_SENTRY_ON_DEV=true in .env |
@@ -35,6 +39,18 @@ function setupSentry(): void { |
35 | 39 | }); |
36 | 40 |
|
37 | 41 | Sentry.setTag(CONST.TELEMETRY.TAG_BUILD_TYPE, CONFIG.IS_HYBRID_APP ? CONST.TELEMETRY.BUILD_TYPE_HYBRID_APP : CONST.TELEMETRY.BUILD_TYPE_STANDALONE); |
| 42 | + |
| 43 | + const bundleStartMs = getBundleStartTimestampMs(); |
| 44 | + if (bundleStartMs) { |
| 45 | + const durationMs = bundleEndMs - bundleStartMs; |
| 46 | + console.debug(`[Telemetry] JS parse time: ${durationMs}ms`); |
| 47 | + startSpan(CONST.TELEMETRY.SPAN_JS_PARSE_TIME, { |
| 48 | + name: CONST.TELEMETRY.SPAN_JS_PARSE_TIME, |
| 49 | + op: CONST.TELEMETRY.SPAN_JS_PARSE_TIME, |
| 50 | + startTime: bundleStartMs / 1000, |
| 51 | + }); |
| 52 | + endSpan(CONST.TELEMETRY.SPAN_JS_PARSE_TIME, bundleEndMs / 1000); |
| 53 | + } |
38 | 54 | } |
39 | 55 |
|
40 | 56 | export default setupSentry; |
0 commit comments