Skip to content

Commit 652b1df

Browse files
elirangoshenclaude
andcommitted
Track JS bundle parse time as a Sentry span in setupSentry
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 4db9bcb commit 652b1df

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/setup/telemetry/setupSentry.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import * as Sentry from '@sentry/react-native';
2+
import {getBundleStartTimestampMs} from '@sentry/react-native/dist/js/tracing/utils';
23
import {Platform} from 'react-native';
34
import {isDevelopment} from '@libs/Environment/Environment';
5+
import {endSpan, startSpan} from '@libs/telemetry/activeSpans';
46
import {breadcrumbsIntegration, browserProfilingIntegration, consoleIntegration, navigationIntegration, tracingIntegration} from '@libs/telemetry/integrations';
57
import {processBeforeSendLogs, processBeforeSendTransactions} from '@libs/telemetry/middlewares';
68
import CONFIG from '@src/CONFIG';
79
import CONST from '@src/CONST';
810
import pkg from '../../../package.json';
911
import makeDebugTransport from './debugTransport';
1012

13+
const bundleEndMs = Date.now();
14+
1115
function setupSentry(): void {
1216
// With Sentry enabled in dev mode, profiling on iOS and Android does not work
1317
// If you want to enable Sentry in dev, set ENABLE_SENTRY_ON_DEV=true in .env
@@ -35,6 +39,18 @@ function setupSentry(): void {
3539
});
3640

3741
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+
}
3854
}
3955

4056
export default setupSentry;

0 commit comments

Comments
 (0)