Skip to content

Commit a951c6c

Browse files
committed
remove performance module
1 parent f4102de commit a951c6c

2 files changed

Lines changed: 18 additions & 22 deletions

File tree

src/setup/telemetry/index.ts

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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';
3-
import {PerformanceObserver} from 'react-native-performance';
44
import {isDevelopment} from '@libs/Environment/Environment';
55
import {endSpan, startSpan} from '@libs/telemetry/activeSpans';
66
import {breadcrumbsIntegration, browserProfilingIntegration, consoleIntegration, navigationIntegration, tracingIntegration} from '@libs/telemetry/integrations';
@@ -10,6 +10,8 @@ import CONST from '@src/CONST';
1010
import pkg from '../../../package.json';
1111
import makeDebugTransport from './debugTransport';
1212

13+
const bundleEndMs = Date.now();
14+
1315
export default function (): void {
1416
// With Sentry enabled in dev mode, profiling on iOS and Android does not work
1517
// If you want to enable Sentry in dev, set ENABLE_SENTRY_ON_DEV=true in .env
@@ -41,25 +43,15 @@ export default function (): void {
4143
op: CONST.TELEMETRY.SPAN_APP_STARTUP,
4244
});
4345

44-
let jsParseStartMs: number | undefined;
45-
const observer = new PerformanceObserver((list) => {
46-
const entries = list.getEntries();
47-
for (const entry of entries) {
48-
if (entry.name === 'runJsBundleStart' && jsParseStartMs === undefined) {
49-
jsParseStartMs = entry.startTime;
50-
startSpan(CONST.TELEMETRY.SPAN_JS_PARSE_TIME, {
51-
name: CONST.TELEMETRY.SPAN_JS_PARSE_TIME,
52-
op: CONST.TELEMETRY.SPAN_JS_PARSE_TIME,
53-
startTime: jsParseStartMs / 1000,
54-
});
55-
}
56-
if (entry.name === 'runJsBundleEnd') {
57-
if (jsParseStartMs !== undefined) {
58-
endSpan(CONST.TELEMETRY.SPAN_JS_PARSE_TIME, entry.startTime / 1000);
59-
}
60-
observer.disconnect();
61-
}
62-
}
63-
});
64-
observer.observe({type: 'react-native-mark', buffered: true});
46+
const bundleStartMs = getBundleStartTimestampMs();
47+
if (bundleStartMs) {
48+
const durationMs = bundleEndMs - bundleStartMs;
49+
console.debug(`[Telemetry] JS parse time: ${durationMs}ms`);
50+
startSpan(CONST.TELEMETRY.SPAN_JS_PARSE_TIME, {
51+
name: CONST.TELEMETRY.SPAN_JS_PARSE_TIME,
52+
op: CONST.TELEMETRY.SPAN_JS_PARSE_TIME,
53+
startTime: bundleStartMs / 1000,
54+
});
55+
endSpan(CONST.TELEMETRY.SPAN_JS_PARSE_TIME, bundleEndMs / 1000);
56+
}
6557
}

src/types/global.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,7 @@ interface ArrayBuffer {
4545
// Might be defined in browsers, in RN hermes it's not implemented yet
4646
transfer?: (length: number) => ArrayBuffer;
4747
}
48+
49+
// Set by the React Native native layer (epoch ms) right before the JS bundle starts executing
50+
// eslint-disable-next-line no-var, no-underscore-dangle, @typescript-eslint/naming-convention
51+
declare var __BUNDLE_START_TIME__: number | undefined;

0 commit comments

Comments
 (0)