@sentry/react-native 5.23.0 → 5.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -0
- package/RNSentry.podspec +1 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/io/sentry/react/RNSentryModuleImpl.java +7 -18
- package/dist/js/NativeRNSentry.d.ts +8 -3
- package/dist/js/NativeRNSentry.d.ts.map +1 -1
- package/dist/js/NativeRNSentry.js.map +1 -1
- package/dist/js/client.d.ts +1 -1
- package/dist/js/client.d.ts.map +1 -1
- package/dist/js/client.js +2 -2
- package/dist/js/client.js.map +1 -1
- package/dist/js/tracing/nativeframes.d.ts +2 -2
- package/dist/js/tracing/nativeframes.d.ts.map +1 -1
- package/dist/js/tracing/nativeframes.js +30 -14
- package/dist/js/tracing/nativeframes.js.map +1 -1
- package/dist/js/tracing/reactnativeprofiler.d.ts +1 -0
- package/dist/js/tracing/reactnativeprofiler.d.ts.map +1 -1
- package/dist/js/tracing/reactnativeprofiler.js +7 -3
- package/dist/js/tracing/reactnativeprofiler.js.map +1 -1
- package/dist/js/tracing/reactnativetracing.d.ts +18 -0
- package/dist/js/tracing/reactnativetracing.d.ts.map +1 -1
- package/dist/js/tracing/reactnativetracing.js +101 -11
- package/dist/js/tracing/reactnativetracing.js.map +1 -1
- package/dist/js/tracing/timetodisplay.d.ts +1 -1
- package/dist/js/tracing/timetodisplay.d.ts.map +1 -1
- package/dist/js/tracing/timetodisplay.js +15 -7
- package/dist/js/tracing/timetodisplay.js.map +1 -1
- package/dist/js/tracing/utils.d.ts +6 -0
- package/dist/js/tracing/utils.d.ts.map +1 -1
- package/dist/js/tracing/utils.js +21 -1
- package/dist/js/tracing/utils.js.map +1 -1
- package/dist/js/utils/worldwide.d.ts +2 -0
- package/dist/js/utils/worldwide.d.ts.map +1 -1
- package/dist/js/utils/worldwide.js.map +1 -1
- package/dist/js/version.d.ts +1 -1
- package/dist/js/version.js +1 -1
- package/dist/js/version.js.map +1 -1
- package/ios/RNSentry.mm +12 -40
- package/ios/RNSentryBreadcrumb.h +9 -0
- package/ios/RNSentryBreadcrumb.m +33 -0
- package/package.json +11 -11
- package/scripts/sentry-xcode-debug-files.sh +10 -1
- package/scripts/sentry-xcode.sh +10 -1
- package/src/js/NativeRNSentry.ts +8 -3
- package/ts3.8/dist/js/NativeRNSentry.d.ts +8 -3
- package/ts3.8/dist/js/client.d.ts +1 -1
- package/ts3.8/dist/js/tracing/nativeframes.d.ts +2 -2
- package/ts3.8/dist/js/tracing/reactnativeprofiler.d.ts +1 -0
- package/ts3.8/dist/js/tracing/reactnativetracing.d.ts +18 -0
- package/ts3.8/dist/js/tracing/timetodisplay.d.ts +1 -1
- package/ts3.8/dist/js/tracing/utils.d.ts +6 -0
- package/ts3.8/dist/js/utils/worldwide.d.ts +2 -0
- package/ts3.8/dist/js/version.d.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,46 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 5.24.0
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- Add native application start spans ([#3855](https://github.com/getsentry/sentry-react-native/pull/3855), [#3884](https://github.com/getsentry/sentry-react-native/pull/3884))
|
|
8
|
+
- This doesn't change the app start measurement length, but add child spans (more detail) into the existing app start span
|
|
9
|
+
- Added JS Bundle Execution start information to the application start measurements ([#3857](https://github.com/getsentry/sentry-react-native/pull/3857))
|
|
10
|
+
|
|
11
|
+
### Fixes
|
|
12
|
+
|
|
13
|
+
- Add more expressive debug logs to Native Frames Integration ([#3880](https://github.com/getsentry/sentry-react-native/pull/3880))
|
|
14
|
+
- Add missing tracing integrations when using `client.init()` ([#3882](https://github.com/getsentry/sentry-react-native/pull/3882))
|
|
15
|
+
- Ensure `sentry-cli` doesn't trigger Xcode `error:` prefix ([#3887](https://github.com/getsentry/sentry-react-native/pull/3887))
|
|
16
|
+
- Fixes `--allow-failure` failing Xcode builds
|
|
17
|
+
|
|
18
|
+
### Dependencies
|
|
19
|
+
|
|
20
|
+
- Bump Cocoa SDK from v8.27.0 to v8.28.0 ([#3866](https://github.com/getsentry/sentry-react-native/pull/3866))
|
|
21
|
+
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8280)
|
|
22
|
+
- [diff](https://github.com/getsentry/sentry-cocoa/compare/8.27.0...8.28.0)
|
|
23
|
+
- Bump Android SDK from v7.8.0 to v7.10.0 ([#3805](https://github.com/getsentry/sentry-react-native/pull/3805))
|
|
24
|
+
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#7100)
|
|
25
|
+
- [diff](https://github.com/getsentry/sentry-java/compare/7.8.0...7.10.0)
|
|
26
|
+
- Bump JavaScript SDK from v7.113.0 to v7.117.0 ([#3806](https://github.com/getsentry/sentry-react-native/pull/3806))
|
|
27
|
+
- [changelog](https://github.com/getsentry/sentry-javascript/blob/v7/CHANGELOG.md#71170)
|
|
28
|
+
- [diff](https://github.com/getsentry/sentry-javascript/compare/7.113.0...7.117.0)
|
|
29
|
+
|
|
30
|
+
## 5.23.1
|
|
31
|
+
|
|
32
|
+
### Fixes
|
|
33
|
+
|
|
34
|
+
- Fix failing iOS builds due to missing SentryLevel ([#3854](https://github.com/getsentry/sentry-react-native/pull/3854))
|
|
35
|
+
- Add missing logs to dropped App Start spans ([#3861](https://github.com/getsentry/sentry-react-native/pull/3861))
|
|
36
|
+
- Make all options of `startTimeToInitialDisplaySpan` optional ([#3867](https://github.com/getsentry/sentry-react-native/pull/3867))
|
|
37
|
+
- Add Span IDs to Time to Display debug logs ([#3868](https://github.com/getsentry/sentry-react-native/pull/3868))
|
|
38
|
+
- Use TTID end timestamp when TTFD should be updated with an earlier timestamp ([#3869](https://github.com/getsentry/sentry-react-native/pull/3869))
|
|
39
|
+
|
|
3
40
|
## 5.23.0
|
|
4
41
|
|
|
42
|
+
This release does *not* build on iOS. Please use `5.23.1` or newer.
|
|
43
|
+
|
|
5
44
|
### Features
|
|
6
45
|
|
|
7
46
|
- Functional integrations ([#3814](https://github.com/getsentry/sentry-react-native/pull/3814))
|
package/RNSentry.podspec
CHANGED
package/android/build.gradle
CHANGED
|
@@ -103,7 +103,7 @@ public class RNSentryModuleImpl {
|
|
|
103
103
|
private FrameMetricsAggregator frameMetricsAggregator = null;
|
|
104
104
|
private boolean androidXAvailable;
|
|
105
105
|
|
|
106
|
-
private static boolean
|
|
106
|
+
private static boolean hasFetchedAppStart;
|
|
107
107
|
|
|
108
108
|
// 700ms to constitute frozen frames.
|
|
109
109
|
private static final int FROZEN_FRAME_THRESHOLD = 700;
|
|
@@ -334,28 +334,17 @@ public class RNSentryModuleImpl {
|
|
|
334
334
|
}
|
|
335
335
|
|
|
336
336
|
public void fetchNativeAppStart(Promise promise) {
|
|
337
|
-
final
|
|
338
|
-
final SentryDate appStartTime = appStartInstance.getAppStartTimeSpan().getStartTimestamp();
|
|
339
|
-
final boolean isColdStart = appStartInstance.getAppStartType() == AppStartMetrics.AppStartType.COLD;
|
|
337
|
+
final Map<String, Object> measurement = InternalSentrySdk.getAppStartMeasurement();
|
|
340
338
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
promise.resolve(null);
|
|
344
|
-
} else {
|
|
345
|
-
final double appStartTimestampMs = DateUtils.nanosToMillis(appStartTime.nanoTimestamp());
|
|
346
|
-
|
|
347
|
-
WritableMap appStart = Arguments.createMap();
|
|
339
|
+
WritableMap mutableMeasurement = (WritableMap) RNSentryMapConverter.convertToWritable(measurement);
|
|
340
|
+
mutableMeasurement.putBoolean("has_fetched", hasFetchedAppStart);
|
|
348
341
|
|
|
349
|
-
appStart.putDouble("appStartTime", appStartTimestampMs);
|
|
350
|
-
appStart.putBoolean("isColdStart", isColdStart);
|
|
351
|
-
appStart.putBoolean("didFetchAppStart", didFetchAppStart);
|
|
352
|
-
|
|
353
|
-
promise.resolve(appStart);
|
|
354
|
-
}
|
|
355
342
|
// This is always set to true, as we would only allow an app start fetch to only
|
|
356
343
|
// happen once in the case of a JS bundle reload, we do not want it to be
|
|
357
344
|
// instrumented again.
|
|
358
|
-
|
|
345
|
+
hasFetchedAppStart = true;
|
|
346
|
+
|
|
347
|
+
promise.resolve(mutableMeasurement);
|
|
359
348
|
}
|
|
360
349
|
|
|
361
350
|
/**
|
|
@@ -81,9 +81,14 @@ export type NativeStackFrames = {
|
|
|
81
81
|
debugMetaImages?: NativeDebugImage[];
|
|
82
82
|
};
|
|
83
83
|
export type NativeAppStartResponse = {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
type: 'cold' | 'warm' | 'unknown';
|
|
85
|
+
has_fetched: boolean;
|
|
86
|
+
app_start_timestamp_ms?: number;
|
|
87
|
+
spans: {
|
|
88
|
+
description: string;
|
|
89
|
+
start_timestamp_ms: number;
|
|
90
|
+
end_timestamp_ms: number;
|
|
91
|
+
}[];
|
|
87
92
|
};
|
|
88
93
|
export type NativeFramesResponse = {
|
|
89
94
|
totalFrames: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeRNSentry.d.ts","sourceRoot":"","sources":["../../src/js/NativeRNSentry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAIjE,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,eAAe,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,aAAa,CAAC,UAAU,EAAE,YAAY,GAAG,IAAI,CAAC;IAC9C,eAAe,CACb,KAAK,EAAE,MAAM,EACb,OAAO,EAAE;QACP,KAAK,EAAE,OAAO,CAAC;KAChB,GACA,OAAO,CA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"NativeRNSentry.js","sourceRoot":"","sources":["../../src/js/NativeRNSentry.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"NativeRNSentry.js","sourceRoot":"","sources":["../../src/js/NativeRNSentry.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAsJnD,2DAA2D;AAC3D,eAAe,mBAAmB,CAAC,YAAY,CAAO,UAAU,CAAC,CAAC","sourcesContent":["import type { Package } from '@sentry/types';\nimport type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\n\nimport type { UnsafeObject } from './utils/rnlibrariesinterface';\n\n// There has to be only one interface and it has to be named `Spec`\n// Only extra allowed definitions are types (probably codegen bug)\nexport interface Spec extends TurboModule {\n addListener: (eventType: string) => void;\n removeListeners: (id: number) => void;\n addBreadcrumb(breadcrumb: UnsafeObject): void;\n captureEnvelope(\n bytes: string,\n options: {\n store: boolean;\n },\n ): Promise<boolean>;\n captureScreenshot(): Promise<NativeScreenshot[] | undefined | null>;\n clearBreadcrumbs(): void;\n crash(): void;\n closeNativeSdk(): Promise<void>;\n disableNativeFramesTracking(): void;\n fetchNativeRelease(): Promise<NativeReleaseResponse>;\n fetchNativeSdkInfo(): Promise<Package | null>;\n fetchNativeDeviceContexts(): Promise<NativeDeviceContextsResponse | null>;\n fetchNativeAppStart(): Promise<NativeAppStartResponse | null>;\n fetchNativeFrames(): Promise<NativeFramesResponse | null>;\n initNativeSdk(options: UnsafeObject): Promise<boolean>;\n setUser(defaultUserKeys: UnsafeObject | null, otherUserKeys: UnsafeObject | null): void;\n setContext(key: string, value: UnsafeObject | null): void;\n setExtra(key: string, value: string): void;\n setTag(key: string, value: string): void;\n enableNativeFramesTracking(): void;\n fetchModules(): Promise<string | undefined | null>;\n fetchViewHierarchy(): Promise<number[] | undefined | null>;\n startProfiling(): { started?: boolean; error?: string };\n stopProfiling(): {\n profile?: string;\n nativeProfile?: UnsafeObject;\n androidProfile?: UnsafeObject;\n error?: string;\n };\n fetchNativePackageName(): string | undefined | null;\n fetchNativeStackFramesBy(instructionsAddr: number[]): NativeStackFrames | undefined | null;\n initNativeReactNavigationNewFrameTracking(): Promise<void>;\n}\n\nexport type NativeStackFrame = {\n platform: string;\n /**\n * The instruction address of this frame.\n * Formatted as hex with 0x prefix.\n */\n instruction_addr: string;\n package?: string;\n /**\n * The debug image address of this frame.\n * Formatted as hex with 0x prefix.\n */\n image_addr?: string;\n in_app?: boolean;\n /**\n * The symbol name of this frame.\n * If symbolicated locally.\n */\n function?: string;\n /**\n * The symbol address of this frame.\n * If symbolicated locally.\n * Formatted as hex with 0x prefix.\n */\n symbol_addr?: string;\n};\n\nexport type NativeDebugImage = {\n name?: string;\n type?: string;\n uuid?: string;\n debug_id?: string;\n image_addr?: string;\n image_size?: number;\n code_file?: string;\n image_vmaddr?: string;\n};\n\nexport type NativeStackFrames = {\n frames: NativeStackFrame[];\n debugMetaImages?: NativeDebugImage[];\n};\n\nexport type NativeAppStartResponse = {\n type: 'cold' | 'warm' | 'unknown';\n has_fetched: boolean;\n app_start_timestamp_ms?: number;\n spans: {\n description: string;\n start_timestamp_ms: number;\n end_timestamp_ms: number;\n }[];\n};\n\nexport type NativeFramesResponse = {\n totalFrames: number;\n slowFrames: number;\n frozenFrames: number;\n};\n\nexport type NativeReleaseResponse = {\n build: string;\n id: string;\n version: string;\n};\n\n/**\n * This type describes serialized scope from sentry-cocoa and sentry-android\n * https://github.com/getsentry/sentry-cocoa/blob/master/Sources/Sentry/SentryScope.m\n * https://github.com/getsentry/sentry-java/blob/a461f7e125b65240004e6162b341f383ce2e1394/sentry-android-core/src/main/java/io/sentry/android/core/InternalSentrySdk.java#L32\n */\nexport type NativeDeviceContextsResponse = {\n [key: string]: unknown;\n tags?: Record<string, string>;\n extra?: Record<string, unknown>;\n contexts?: Record<string, Record<string, unknown>>;\n user?: {\n userId?: string;\n email?: string;\n username?: string;\n ipAddress?: string;\n segment?: string;\n data?: Record<string, unknown>;\n };\n dist?: string;\n environment?: string;\n fingerprint?: string[];\n level?: string;\n breadcrumbs?: {\n level?: string;\n timestamp?: string;\n category?: string;\n type?: string;\n message?: string;\n data?: Record<string, unknown>;\n }[];\n};\n\nexport type NativeScreenshot = {\n data: number[];\n contentType: string;\n filename: string;\n};\n\n// The export must be here to pass codegen even if not used\nexport default TurboModuleRegistry.getEnforcing<Spec>('RNSentry');\n"]}
|
package/dist/js/client.d.ts
CHANGED
package/dist/js/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/js/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EAGV,QAAQ,EACR,KAAK,EACL,SAAS,EAGT,aAAa,EAEb,YAAY,EACb,MAAM,eAAe,CAAC;AAMvB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAO1D;;;;;GAKG;AACH,qBAAa,iBAAkB,SAAQ,UAAU,CAAC,wBAAwB,CAAC;IACzE,OAAO,CAAC,eAAe,CAAY;IAEnC;;;OAGG;gBACgB,OAAO,EAAE,wBAAwB;IAUpD;;OAEG;IACI,kBAAkB,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,GAAE,SAAc,GAAG,WAAW,CAAC,KAAK,CAAC;IAIvF;;OAEG;IACI,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC;IAmBrG;;;OAGG;IACI,WAAW,IAAI,IAAI;IAI1B;;OAEG;IACI,KAAK,IAAI,WAAW,CAAC,OAAO,CAAC;IAOpC;;OAEG;IACI,mBAAmB,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI;IASxD;;OAEG;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/js/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EAGV,QAAQ,EACR,KAAK,EACL,SAAS,EAGT,aAAa,EAEb,YAAY,EACb,MAAM,eAAe,CAAC;AAMvB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAO1D;;;;;GAKG;AACH,qBAAa,iBAAkB,SAAQ,UAAU,CAAC,wBAAwB,CAAC;IACzE,OAAO,CAAC,eAAe,CAAY;IAEnC;;;OAGG;gBACgB,OAAO,EAAE,wBAAwB;IAUpD;;OAEG;IACI,kBAAkB,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,GAAE,SAAc,GAAG,WAAW,CAAC,KAAK,CAAC;IAIvF;;OAEG;IACI,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC;IAmBrG;;;OAGG;IACI,WAAW,IAAI,IAAI;IAI1B;;OAEG;IACI,KAAK,IAAI,WAAW,CAAC,OAAO,CAAC;IAOpC;;OAEG;IACI,mBAAmB,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI;IASxD;;OAEG;IACH,SAAS,CAAC,kBAAkB,IAAI,IAAI;IAapC;;OAEG;IACH,SAAS,CAAC,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IA+BjD;;OAEG;IACH,OAAO,CAAC,cAAc;IAmBtB;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAShC;;OAEG;IACH,OAAO,CAAC,qBAAqB;CAa9B"}
|
package/dist/js/client.js
CHANGED
|
@@ -82,9 +82,9 @@ export class ReactNativeClient extends BaseClient {
|
|
|
82
82
|
/**
|
|
83
83
|
* Sets up the integrations
|
|
84
84
|
*/
|
|
85
|
-
|
|
85
|
+
_setupIntegrations() {
|
|
86
86
|
var _a;
|
|
87
|
-
super.
|
|
87
|
+
super._setupIntegrations();
|
|
88
88
|
const tracing = this.getIntegration(ReactNativeTracing);
|
|
89
89
|
const routingName = (_a = tracing === null || tracing === void 0 ? void 0 : tracing.options.routingInstrumentation) === null || _a === void 0 ? void 0 : _a.name;
|
|
90
90
|
if (routingName) {
|
package/dist/js/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/js/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAa1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;;;GAKG;AACH,MAAM,OAAO,iBAAkB,SAAQ,UAAoC;IAGzE;;;OAGG;IACH,YAAmB,OAAiC;QAClD,sBAAsB,EAAE,CAAC;QACzB,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC;QAC5C,OAAO,CAAC,SAAS,CAAC,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI,cAAc,CA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,EAAE,KAAK,CAAC,EAAE;YACvB,MAAM,CAAC,KAAK,CAAC,uCAAuC,EAAE,KAAK,CAAC,CAAC;QAC/D,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;OAEG;IACK,wBAAwB;QAC9B,IAAI,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,EAAE;YAC/C,KAAK,CAAC,KAAK,CACT,QAAQ,EACR,6NAA6N,CAC9N,CAAC;SACH;IACH,CAAC;IAED;;OAEG;IACK,qBAAqB,CAAC,QAAmB,EAAE,QAA8B;QAC/E,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;YACvB,MAAM,gBAAgB,GAAqB;gBACzC,EAAE,IAAI,EAAE,eAAe,EAAE;gBACzB;oBACE,SAAS,EAAE,sBAAsB,EAAE;oBACnC,gBAAgB,EAAE,QAAQ;iBAC3B;aACF,CAAC;YAEF,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;SACxC;IACH,CAAC;CACF","sourcesContent":["import { eventFromException, eventFromMessage } from '@sentry/browser';\nimport { BaseClient } from '@sentry/core';\nimport type {\n ClientReportEnvelope,\n ClientReportItem,\n Envelope,\n Event,\n EventHint,\n Exception,\n Outcome,\n SeverityLevel,\n Thread,\n UserFeedback,\n} from '@sentry/types';\nimport { dateTimestampInSeconds, logger, SentryError } from '@sentry/utils';\nimport { Alert } from 'react-native';\n\nimport { createIntegration } from './integrations/factory';\nimport { defaultSdkInfo } from './integrations/sdkinfo';\nimport type { ReactNativeClientOptions } from './options';\nimport { ReactNativeTracing } from './tracing';\nimport { createUserFeedbackEnvelope, items } from './utils/envelope';\nimport { ignoreRequireCycleLogs } from './utils/ignorerequirecyclelogs';\nimport { mergeOutcomes } from './utils/outcome';\nimport { NATIVE } from './wrapper';\n\n/**\n * The Sentry React Native SDK Client.\n *\n * @see ReactNativeClientOptions for documentation on configuration options.\n * @see SentryClient for usage documentation.\n */\nexport class ReactNativeClient extends BaseClient<ReactNativeClientOptions> {\n private _outcomesBuffer: Outcome[];\n\n /**\n * Creates a new React Native SDK instance.\n * @param options Configuration options for this SDK.\n */\n public constructor(options: ReactNativeClientOptions) {\n ignoreRequireCycleLogs();\n options._metadata = options._metadata || {};\n options._metadata.sdk = options._metadata.sdk || defaultSdkInfo;\n super(options);\n\n this._outcomesBuffer = [];\n this._initNativeSdk();\n }\n\n /**\n * @inheritDoc\n */\n public eventFromException(exception: unknown, hint: EventHint = {}): PromiseLike<Event> {\n return eventFromException(this._options.stackParser, exception, hint, this._options.attachStacktrace);\n }\n\n /**\n * @inheritDoc\n */\n public eventFromMessage(message: string, level?: SeverityLevel, hint?: EventHint): PromiseLike<Event> {\n return eventFromMessage(this._options.stackParser, message, level, hint, this._options.attachStacktrace).then(\n (event: Event) => {\n // TMP! Remove this function once JS SDK uses threads for messages\n if (!event.exception?.values || event.exception.values.length <= 0) {\n return event;\n }\n const values = event.exception.values.map(\n (exception: Exception): Thread => ({\n stacktrace: exception.stacktrace,\n }),\n );\n (event as { threads?: { values: Thread[] } }).threads = { values };\n delete event.exception;\n return event;\n },\n );\n }\n\n /**\n * If native client is available it will trigger a native crash.\n * Use this only for testing purposes.\n */\n public nativeCrash(): void {\n NATIVE.nativeCrash();\n }\n\n /**\n * @inheritDoc\n */\n public close(): PromiseLike<boolean> {\n // As super.close() flushes queued events, we wait for that to finish before closing the native SDK.\n return super.close().then((result: boolean) => {\n return NATIVE.closeNativeSdk().then(() => result) as PromiseLike<boolean>;\n });\n }\n\n /**\n * Sends user feedback to Sentry.\n */\n public captureUserFeedback(feedback: UserFeedback): void {\n const envelope = createUserFeedbackEnvelope(feedback, {\n metadata: this._options._metadata,\n dsn: this.getDsn(),\n tunnel: undefined,\n });\n this._sendEnvelope(envelope);\n }\n\n /**\n * Sets up the integrations\n */\n public setupIntegrations(): void {\n super.setupIntegrations();\n const tracing = this.getIntegration(ReactNativeTracing);\n const routingName = tracing?.options.routingInstrumentation?.name;\n if (routingName) {\n this.addIntegration(createIntegration(routingName));\n }\n const enableUserInteractionTracing = tracing?.options.enableUserInteractionTracing;\n if (enableUserInteractionTracing) {\n this.addIntegration(createIntegration('ReactNativeUserInteractionTracing'));\n }\n }\n\n /**\n * @inheritdoc\n */\n protected _sendEnvelope(envelope: Envelope): void {\n const outcomes = this._clearOutcomes();\n this._outcomesBuffer = mergeOutcomes(this._outcomesBuffer, outcomes);\n\n if (this._options.sendClientReports) {\n this._attachClientReportTo(this._outcomesBuffer, envelope as ClientReportEnvelope);\n }\n\n let shouldClearOutcomesBuffer = true;\n if (this._isEnabled() && this._transport && this._dsn) {\n this.emit('beforeEnvelope', envelope);\n\n this._transport.send(envelope).then(null, reason => {\n if (reason instanceof SentryError) {\n // SentryError is thrown by SyncPromise\n shouldClearOutcomesBuffer = false;\n // If this is called asynchronously we want the _outcomesBuffer to be cleared\n logger.error('SentryError while sending event, keeping outcomes buffer:', reason);\n } else {\n logger.error('Error while sending event:', reason);\n }\n });\n } else {\n logger.error('Transport disabled');\n }\n\n if (shouldClearOutcomesBuffer) {\n this._outcomesBuffer = []; // if send fails synchronously the _outcomesBuffer will stay intact\n }\n }\n\n /**\n * Starts native client with dsn and options\n */\n private _initNativeSdk(): void {\n NATIVE.initNativeSdk(this._options)\n .then(\n (result: boolean) => {\n return result;\n },\n () => {\n this._showCannotConnectDialog();\n return false;\n },\n )\n .then((didCallNativeInit: boolean) => {\n this._options.onReady?.({ didCallNativeInit });\n })\n .then(undefined, error => {\n logger.error('The OnReady callback threw an error: ', error);\n });\n }\n\n /**\n * If the user is in development mode, and the native nagger is enabled then it will show an alert.\n */\n private _showCannotConnectDialog(): void {\n if (__DEV__ && this._options.enableNativeNagger) {\n Alert.alert(\n 'Sentry',\n 'Warning, could not connect to Sentry native SDK.\\nIf you do not want to use the native component please pass `enableNative: false` in the options.\\nVisit: https://docs.sentry.io/platforms/react-native/ for more details.',\n );\n }\n }\n\n /**\n * Attaches a client report from outcomes to the envelope.\n */\n private _attachClientReportTo(outcomes: Outcome[], envelope: ClientReportEnvelope): void {\n if (outcomes.length > 0) {\n const clientReportItem: ClientReportItem = [\n { type: 'client_report' },\n {\n timestamp: dateTimestampInSeconds(),\n discarded_events: outcomes,\n },\n ];\n\n envelope[items].push(clientReportItem);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/js/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAa1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;;;GAKG;AACH,MAAM,OAAO,iBAAkB,SAAQ,UAAoC;IAGzE;;;OAGG;IACH,YAAmB,OAAiC;QAClD,sBAAsB,EAAE,CAAC;QACzB,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC;QAC5C,OAAO,CAAC,SAAS,CAAC,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI,cAAc,CAAC;QAChE,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;QAC1B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;QAC/D,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;OAEG;IACK,wBAAwB;QAC9B,IAAI,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,EAAE;YAC/C,KAAK,CAAC,KAAK,CACT,QAAQ,EACR,6NAA6N,CAC9N,CAAC;SACH;IACH,CAAC;IAED;;OAEG;IACK,qBAAqB,CAAC,QAAmB,EAAE,QAA8B;QAC/E,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;YACvB,MAAM,gBAAgB,GAAqB;gBACzC,EAAE,IAAI,EAAE,eAAe,EAAE;gBACzB;oBACE,SAAS,EAAE,sBAAsB,EAAE;oBACnC,gBAAgB,EAAE,QAAQ;iBAC3B;aACF,CAAC;YAEF,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;SACxC;IACH,CAAC;CACF","sourcesContent":["import { eventFromException, eventFromMessage } from '@sentry/browser';\nimport { BaseClient } from '@sentry/core';\nimport type {\n ClientReportEnvelope,\n ClientReportItem,\n Envelope,\n Event,\n EventHint,\n Exception,\n Outcome,\n SeverityLevel,\n Thread,\n UserFeedback,\n} from '@sentry/types';\nimport { dateTimestampInSeconds, logger, SentryError } from '@sentry/utils';\nimport { Alert } from 'react-native';\n\nimport { createIntegration } from './integrations/factory';\nimport { defaultSdkInfo } from './integrations/sdkinfo';\nimport type { ReactNativeClientOptions } from './options';\nimport { ReactNativeTracing } from './tracing';\nimport { createUserFeedbackEnvelope, items } from './utils/envelope';\nimport { ignoreRequireCycleLogs } from './utils/ignorerequirecyclelogs';\nimport { mergeOutcomes } from './utils/outcome';\nimport { NATIVE } from './wrapper';\n\n/**\n * The Sentry React Native SDK Client.\n *\n * @see ReactNativeClientOptions for documentation on configuration options.\n * @see SentryClient for usage documentation.\n */\nexport class ReactNativeClient extends BaseClient<ReactNativeClientOptions> {\n private _outcomesBuffer: Outcome[];\n\n /**\n * Creates a new React Native SDK instance.\n * @param options Configuration options for this SDK.\n */\n public constructor(options: ReactNativeClientOptions) {\n ignoreRequireCycleLogs();\n options._metadata = options._metadata || {};\n options._metadata.sdk = options._metadata.sdk || defaultSdkInfo;\n super(options);\n\n this._outcomesBuffer = [];\n this._initNativeSdk();\n }\n\n /**\n * @inheritDoc\n */\n public eventFromException(exception: unknown, hint: EventHint = {}): PromiseLike<Event> {\n return eventFromException(this._options.stackParser, exception, hint, this._options.attachStacktrace);\n }\n\n /**\n * @inheritDoc\n */\n public eventFromMessage(message: string, level?: SeverityLevel, hint?: EventHint): PromiseLike<Event> {\n return eventFromMessage(this._options.stackParser, message, level, hint, this._options.attachStacktrace).then(\n (event: Event) => {\n // TMP! Remove this function once JS SDK uses threads for messages\n if (!event.exception?.values || event.exception.values.length <= 0) {\n return event;\n }\n const values = event.exception.values.map(\n (exception: Exception): Thread => ({\n stacktrace: exception.stacktrace,\n }),\n );\n (event as { threads?: { values: Thread[] } }).threads = { values };\n delete event.exception;\n return event;\n },\n );\n }\n\n /**\n * If native client is available it will trigger a native crash.\n * Use this only for testing purposes.\n */\n public nativeCrash(): void {\n NATIVE.nativeCrash();\n }\n\n /**\n * @inheritDoc\n */\n public close(): PromiseLike<boolean> {\n // As super.close() flushes queued events, we wait for that to finish before closing the native SDK.\n return super.close().then((result: boolean) => {\n return NATIVE.closeNativeSdk().then(() => result) as PromiseLike<boolean>;\n });\n }\n\n /**\n * Sends user feedback to Sentry.\n */\n public captureUserFeedback(feedback: UserFeedback): void {\n const envelope = createUserFeedbackEnvelope(feedback, {\n metadata: this._options._metadata,\n dsn: this.getDsn(),\n tunnel: undefined,\n });\n this._sendEnvelope(envelope);\n }\n\n /**\n * Sets up the integrations\n */\n protected _setupIntegrations(): void {\n super._setupIntegrations();\n const tracing = this.getIntegration(ReactNativeTracing);\n const routingName = tracing?.options.routingInstrumentation?.name;\n if (routingName) {\n this.addIntegration(createIntegration(routingName));\n }\n const enableUserInteractionTracing = tracing?.options.enableUserInteractionTracing;\n if (enableUserInteractionTracing) {\n this.addIntegration(createIntegration('ReactNativeUserInteractionTracing'));\n }\n }\n\n /**\n * @inheritdoc\n */\n protected _sendEnvelope(envelope: Envelope): void {\n const outcomes = this._clearOutcomes();\n this._outcomesBuffer = mergeOutcomes(this._outcomesBuffer, outcomes);\n\n if (this._options.sendClientReports) {\n this._attachClientReportTo(this._outcomesBuffer, envelope as ClientReportEnvelope);\n }\n\n let shouldClearOutcomesBuffer = true;\n if (this._isEnabled() && this._transport && this._dsn) {\n this.emit('beforeEnvelope', envelope);\n\n this._transport.send(envelope).then(null, reason => {\n if (reason instanceof SentryError) {\n // SentryError is thrown by SyncPromise\n shouldClearOutcomesBuffer = false;\n // If this is called asynchronously we want the _outcomesBuffer to be cleared\n logger.error('SentryError while sending event, keeping outcomes buffer:', reason);\n } else {\n logger.error('Error while sending event:', reason);\n }\n });\n } else {\n logger.error('Transport disabled');\n }\n\n if (shouldClearOutcomesBuffer) {\n this._outcomesBuffer = []; // if send fails synchronously the _outcomesBuffer will stay intact\n }\n }\n\n /**\n * Starts native client with dsn and options\n */\n private _initNativeSdk(): void {\n NATIVE.initNativeSdk(this._options)\n .then(\n (result: boolean) => {\n return result;\n },\n () => {\n this._showCannotConnectDialog();\n return false;\n },\n )\n .then((didCallNativeInit: boolean) => {\n this._options.onReady?.({ didCallNativeInit });\n })\n .then(undefined, error => {\n logger.error('The OnReady callback threw an error: ', error);\n });\n }\n\n /**\n * If the user is in development mode, and the native nagger is enabled then it will show an alert.\n */\n private _showCannotConnectDialog(): void {\n if (__DEV__ && this._options.enableNativeNagger) {\n Alert.alert(\n 'Sentry',\n 'Warning, could not connect to Sentry native SDK.\\nIf you do not want to use the native component please pass `enableNative: false` in the options.\\nVisit: https://docs.sentry.io/platforms/react-native/ for more details.',\n );\n }\n }\n\n /**\n * Attaches a client report from outcomes to the envelope.\n */\n private _attachClientReportTo(outcomes: Outcome[], envelope: ClientReportEnvelope): void {\n if (outcomes.length > 0) {\n const clientReportItem: ClientReportItem = [\n { type: 'client_report' },\n {\n timestamp: dateTimestampInSeconds(),\n discarded_events: outcomes,\n },\n ];\n\n envelope[items].push(clientReportItem);\n }\n }\n}\n"]}
|
|
@@ -46,11 +46,11 @@ export declare class NativeFramesInstrumentation {
|
|
|
46
46
|
/**
|
|
47
47
|
* Fetch finish frames for a transaction at the current time. Calls any awaiting listeners.
|
|
48
48
|
*/
|
|
49
|
-
private
|
|
49
|
+
private _fetchEndFramesForTransaction;
|
|
50
50
|
/**
|
|
51
51
|
* On a finish frames failure, we cancel the await.
|
|
52
52
|
*/
|
|
53
|
-
private
|
|
53
|
+
private _cancelEndFrames;
|
|
54
54
|
/**
|
|
55
55
|
* Adds frames measurements to an event. Called from a valid event processor.
|
|
56
56
|
* Awaits for finish frames if needed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nativeframes.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/nativeframes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,WAAW,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EAAS,cAAc,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"nativeframes.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/nativeframes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,WAAW,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EAAS,cAAc,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAc1F,MAAM,WAAW,kBAAmB,SAAQ,YAAY;IACtD,YAAY,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC;IACvD,WAAW,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC;IACtD,aAAa,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC;CACzD;AAcD;;GAEG;AACH,qBAAa,2BAA2B;IACtC,oEAAoE;IACpE,OAAO,CAAC,qBAAqB,CAAC,CAG5B;gBAEiB,uBAAuB,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,IAAI,EAAE,SAAS,EAAE,MAAM,OAAO;IAMjG;;;OAGG;IACI,kBAAkB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IA4BzD;;OAEG;IACI,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAS1D;;;OAGG;IACH,OAAO,CAAC,aAAa;IAiBrB;;OAEG;YACW,sBAAsB;IA4BpC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAiD5B;;OAEG;YACW,6BAA6B;IAoB3C;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAUxB;;;OAGG;YACW,aAAa;CAiD5B"}
|
|
@@ -2,6 +2,12 @@ import { __awaiter } from "tslib";
|
|
|
2
2
|
import { logger, timestampInSeconds } from '@sentry/utils';
|
|
3
3
|
import { NATIVE } from '../wrapper';
|
|
4
4
|
import { instrumentChildSpanFinish } from './utils';
|
|
5
|
+
/**
|
|
6
|
+
* Timeout from the final native frames fetch to processing the associated transaction.
|
|
7
|
+
* If the transaction is not processed by this time, the native frames will be dropped
|
|
8
|
+
* and not added to the event.
|
|
9
|
+
*/
|
|
10
|
+
const FINAL_FRAMES_TIMEOUT_MS = 2000;
|
|
5
11
|
/** The listeners for each native frames response, keyed by traceId. This must be global to avoid closure issues and reading outdated values. */
|
|
6
12
|
const _framesListeners = new Map();
|
|
7
13
|
/** The native frames at the transaction finish time, keyed by traceId. This must be global to avoid closure issues and reading outdated values. */
|
|
@@ -24,14 +30,18 @@ export class NativeFramesInstrumentation {
|
|
|
24
30
|
* Logs the native frames at this start point and instruments child span finishes.
|
|
25
31
|
*/
|
|
26
32
|
onTransactionStart(transaction) {
|
|
33
|
+
logger.debug(`[NativeFrames] Fetching frames for root span start (${transaction.spanContext().spanId}).`);
|
|
27
34
|
void NATIVE.fetchNativeFrames()
|
|
28
35
|
.then(framesMetrics => {
|
|
29
36
|
if (framesMetrics) {
|
|
30
37
|
transaction.setData('__startFrames', framesMetrics);
|
|
31
38
|
}
|
|
39
|
+
else {
|
|
40
|
+
logger.warn(`[NativeFrames] Fetched frames for root span start (${transaction.spanContext().spanId}), but no frames were returned.`);
|
|
41
|
+
}
|
|
32
42
|
})
|
|
33
43
|
.then(undefined, error => {
|
|
34
|
-
logger.error(`[
|
|
44
|
+
logger.error(`[NativeFrames] Error while fetching frames for root span start (${transaction.spanContext().spanId})`, error);
|
|
35
45
|
});
|
|
36
46
|
instrumentChildSpanFinish(transaction, (_, endTimestamp) => {
|
|
37
47
|
if (!endTimestamp) {
|
|
@@ -43,8 +53,8 @@ export class NativeFramesInstrumentation {
|
|
|
43
53
|
* To be called when a transaction is finished
|
|
44
54
|
*/
|
|
45
55
|
onTransactionFinish(transaction) {
|
|
46
|
-
this.
|
|
47
|
-
logger.error(`[
|
|
56
|
+
this._fetchEndFramesForTransaction(transaction).then(undefined, (reason) => {
|
|
57
|
+
logger.error(`[NativeFrames] Error while fetching frames for root span start (${transaction.spanContext().spanId})`, reason);
|
|
48
58
|
});
|
|
49
59
|
}
|
|
50
60
|
/**
|
|
@@ -63,7 +73,7 @@ export class NativeFramesInstrumentation {
|
|
|
63
73
|
}
|
|
64
74
|
})
|
|
65
75
|
.then(undefined, error => {
|
|
66
|
-
logger.error(`[
|
|
76
|
+
logger.error(`[NativeFrames] Error while fetching frames for child span end.`, error);
|
|
67
77
|
});
|
|
68
78
|
}
|
|
69
79
|
/**
|
|
@@ -72,14 +82,17 @@ export class NativeFramesInstrumentation {
|
|
|
72
82
|
_getFramesMeasurements(traceId, finalEndTimestamp, startFrames) {
|
|
73
83
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
84
|
if (_finishFrames.has(traceId)) {
|
|
85
|
+
logger.debug(`[NativeFrames] Native end frames already fetched for trace id (${traceId}).`);
|
|
75
86
|
return this._prepareMeasurements(traceId, finalEndTimestamp, startFrames);
|
|
76
87
|
}
|
|
77
88
|
return new Promise(resolve => {
|
|
78
89
|
const timeout = setTimeout(() => {
|
|
90
|
+
logger.debug(`[NativeFrames] Native end frames listener removed by timeout for trace id (${traceId}).`);
|
|
79
91
|
_framesListeners.delete(traceId);
|
|
80
92
|
resolve(null);
|
|
81
93
|
}, 2000);
|
|
82
94
|
_framesListeners.set(traceId, () => {
|
|
95
|
+
logger.debug(`[NativeFrames] Native end frames listener called for trace id (${traceId}).`);
|
|
83
96
|
resolve(this._prepareMeasurements(traceId, finalEndTimestamp, startFrames));
|
|
84
97
|
clearTimeout(timeout);
|
|
85
98
|
_framesListeners.delete(traceId);
|
|
@@ -98,15 +111,18 @@ export class NativeFramesInstrumentation {
|
|
|
98
111
|
finish.nativeFrames &&
|
|
99
112
|
// Must be in the margin of error of the actual transaction finish time (finalEndTimestamp)
|
|
100
113
|
Math.abs(finish.timestamp - finalEndTimestamp) < MARGIN_OF_ERROR_SECONDS) {
|
|
114
|
+
logger.debug(`[NativeFrames] Using frames from root span end (traceId, ${traceId}).`);
|
|
101
115
|
finalFinishFrames = finish.nativeFrames;
|
|
102
116
|
}
|
|
103
117
|
else if (this._lastSpanFinishFrames &&
|
|
104
118
|
Math.abs(this._lastSpanFinishFrames.timestamp - finalEndTimestamp) < MARGIN_OF_ERROR_SECONDS) {
|
|
105
119
|
// Fallback to the last span finish if it is within the margin of error of the actual finish timestamp.
|
|
106
120
|
// This should be the case for trimEnd.
|
|
121
|
+
logger.debug(`[NativeFrames] Using native frames from last span end (traceId, ${traceId}).`);
|
|
107
122
|
finalFinishFrames = this._lastSpanFinishFrames.nativeFrames;
|
|
108
123
|
}
|
|
109
124
|
else {
|
|
125
|
+
logger.warn(`[NativeFrames] Frames were collected within larger than margin of error delay for traceId (${traceId}). Dropping the inaccurate values.`);
|
|
110
126
|
return null;
|
|
111
127
|
}
|
|
112
128
|
const measurements = {
|
|
@@ -128,7 +144,7 @@ export class NativeFramesInstrumentation {
|
|
|
128
144
|
/**
|
|
129
145
|
* Fetch finish frames for a transaction at the current time. Calls any awaiting listeners.
|
|
130
146
|
*/
|
|
131
|
-
|
|
147
|
+
_fetchEndFramesForTransaction(transaction) {
|
|
132
148
|
var _a;
|
|
133
149
|
return __awaiter(this, void 0, void 0, function* () {
|
|
134
150
|
const startFrames = transaction.data.__startFrames;
|
|
@@ -143,13 +159,13 @@ export class NativeFramesInstrumentation {
|
|
|
143
159
|
timestamp,
|
|
144
160
|
});
|
|
145
161
|
(_a = _framesListeners.get(transaction.traceId)) === null || _a === void 0 ? void 0 : _a();
|
|
146
|
-
setTimeout(() => this.
|
|
162
|
+
setTimeout(() => this._cancelEndFrames(transaction), FINAL_FRAMES_TIMEOUT_MS);
|
|
147
163
|
});
|
|
148
164
|
}
|
|
149
165
|
/**
|
|
150
166
|
* On a finish frames failure, we cancel the await.
|
|
151
167
|
*/
|
|
152
|
-
|
|
168
|
+
_cancelEndFrames(transaction) {
|
|
153
169
|
if (_finishFrames.has(transaction.traceId)) {
|
|
154
170
|
_finishFrames.delete(transaction.traceId);
|
|
155
171
|
logger.log(`[NativeFrames] Native frames timed out for ${transaction.op} transaction ${transaction.name}. Not adding native frames measurements.`);
|
|
@@ -160,7 +176,7 @@ export class NativeFramesInstrumentation {
|
|
|
160
176
|
* Awaits for finish frames if needed.
|
|
161
177
|
*/
|
|
162
178
|
_processEvent(event, doesExist) {
|
|
163
|
-
var _a, _b;
|
|
179
|
+
var _a, _b, _c;
|
|
164
180
|
return __awaiter(this, void 0, void 0, function* () {
|
|
165
181
|
if (!doesExist()) {
|
|
166
182
|
return event;
|
|
@@ -168,14 +184,14 @@ export class NativeFramesInstrumentation {
|
|
|
168
184
|
if (event.type === 'transaction' && event.transaction && event.contexts && event.contexts.trace) {
|
|
169
185
|
const traceContext = event.contexts.trace;
|
|
170
186
|
const traceId = traceContext.trace_id;
|
|
171
|
-
if (
|
|
187
|
+
if (!((_a = traceContext.data) === null || _a === void 0 ? void 0 : _a.__startFrames)) {
|
|
188
|
+
logger.warn(`[NativeFrames] Start frames of transaction ${event.transaction} (eventId, ${event.event_id}) are missing, but it already ended.`);
|
|
189
|
+
}
|
|
190
|
+
if (traceId && ((_b = traceContext.data) === null || _b === void 0 ? void 0 : _b.__startFrames) && event.timestamp) {
|
|
172
191
|
const measurements = yield this._getFramesMeasurements(traceId, event.timestamp, traceContext.data.__startFrames);
|
|
173
|
-
if (
|
|
174
|
-
logger.log(`[NativeFrames] Could not fetch native frames for ${traceContext.op} transaction ${event.transaction}. Not adding native frames measurements.`);
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
192
|
+
if (measurements) {
|
|
177
193
|
logger.log(`[Measurements] Adding measurements to ${traceContext.op} transaction ${event.transaction}: ${JSON.stringify(measurements, undefined, 2)}`);
|
|
178
|
-
event.measurements = Object.assign(Object.assign({}, ((
|
|
194
|
+
event.measurements = Object.assign(Object.assign({}, ((_c = event.measurements) !== null && _c !== void 0 ? _c : {})), measurements);
|
|
179
195
|
_finishFrames.delete(traceId);
|
|
180
196
|
}
|
|
181
197
|
delete traceContext.data.__startFrames;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nativeframes.js","sourceRoot":"","sources":["../../../src/js/tracing/nativeframes.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAG3D,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAQpD,gJAAgJ;AAChJ,MAAM,gBAAgB,GAA4B,IAAI,GAAG,EAAE,CAAC;AAE5D,mJAAmJ;AACnJ,MAAM,aAAa,GAAkF,IAAI,GAAG,EAAE,CAAC;AAE/G;;;GAGG;AACH,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAErC;;GAEG;AACH,MAAM,OAAO,2BAA2B;IAOtC,YAAm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,CAAC;wBAEF,KAAK,CAAC,YAAY,mCACb,CAAC,MAAA,KAAK,CAAC,YAAY,mCAAI,EAAE,CAAC,GAC1B,YAAY,CAChB,CAAC;wBAEF,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;qBAC/B;oBAED,OAAO,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC;iBACxC;aACF;YAED,OAAO,KAAK,CAAC;;KACd;CACF","sourcesContent":["import type { Span, Transaction } from '@sentry/core';\nimport type { Event, EventProcessor, Measurements, MeasurementUnit } from '@sentry/types';\nimport { logger, timestampInSeconds } from '@sentry/utils';\n\nimport type { NativeFramesResponse } from '../NativeRNSentry';\nimport { NATIVE } from '../wrapper';\nimport { instrumentChildSpanFinish } from './utils';\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\n/** The listeners for each native frames response, keyed by traceId. This must be global to avoid closure issues and reading outdated values. */\nconst _framesListeners: Map<string, () => void> = new Map();\n\n/** The native frames at the transaction finish time, keyed by traceId. This must be global to avoid closure issues and reading outdated values. */\nconst _finishFrames: Map<string, { timestamp: number; nativeFrames: NativeFramesResponse | null }> = new Map();\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\n/**\n * Instrumentation to add native slow/frozen frames measurements onto transactions.\n */\nexport class NativeFramesInstrumentation {\n /** The native frames at the finish time of the most recent span. */\n private _lastSpanFinishFrames?: {\n timestamp: number;\n nativeFrames: NativeFramesResponse;\n };\n\n public constructor(addGlobalEventProcessor: (e: EventProcessor) => void, doesExist: () => boolean) {\n logger.log('[ReactNativeTracing] Native frames instrumentation initialized.');\n\n addGlobalEventProcessor(event => this._processEvent(event, doesExist));\n }\n\n /**\n * To be called when a transaction is started.\n * Logs the native frames at this start point and instruments child span finishes.\n */\n public onTransactionStart(transaction: Transaction): void {\n void NATIVE.fetchNativeFrames()\n .then(framesMetrics => {\n if (framesMetrics) {\n transaction.setData('__startFrames', framesMetrics);\n }\n })\n .then(undefined, error => {\n logger.error(`[ReactNativeTracing] Error while fetching native frames: ${error}`);\n });\n\n instrumentChildSpanFinish(transaction, (_: Span, endTimestamp?: number) => {\n if (!endTimestamp) {\n this._onSpanFinish();\n }\n });\n }\n\n /**\n * To be called when a transaction is finished\n */\n public onTransactionFinish(transaction: Transaction): void {\n this._fetchFramesForTransaction(transaction).then(undefined, (reason: unknown) => {\n logger.error(`[ReactNativeTracing] Error while fetching native frames:`, reason);\n });\n }\n\n /**\n * Called on a span finish to fetch native frames to support transactions with trimEnd.\n * Only to be called when a span does not have an end timestamp.\n */\n private _onSpanFinish(): void {\n const timestamp = timestampInSeconds();\n\n void NATIVE.fetchNativeFrames()\n .then(nativeFrames => {\n if (nativeFrames) {\n this._lastSpanFinishFrames = {\n timestamp,\n nativeFrames,\n };\n }\n })\n .then(undefined, error => {\n logger.error(`[ReactNativeTracing] Error while fetching native frames: ${error}`);\n });\n }\n\n /**\n * Returns the computed frames measurements and awaits for them if they are not ready yet.\n */\n private async _getFramesMeasurements(\n traceId: string,\n finalEndTimestamp: number,\n startFrames: NativeFramesResponse,\n ): Promise<FramesMeasurements | null> {\n if (_finishFrames.has(traceId)) {\n return this._prepareMeasurements(traceId, finalEndTimestamp, startFrames);\n }\n\n return new Promise(resolve => {\n const timeout = setTimeout(() => {\n _framesListeners.delete(traceId);\n\n resolve(null);\n }, 2000);\n\n _framesListeners.set(traceId, () => {\n resolve(this._prepareMeasurements(traceId, finalEndTimestamp, startFrames));\n\n clearTimeout(timeout);\n _framesListeners.delete(traceId);\n });\n });\n }\n\n /**\n * Returns the computed frames measurements given ready data\n */\n private _prepareMeasurements(\n traceId: string,\n finalEndTimestamp: number, // The actual transaction finish time.\n startFrames: NativeFramesResponse,\n ): FramesMeasurements | null {\n let finalFinishFrames: NativeFramesResponse | undefined;\n\n const finish = _finishFrames.get(traceId);\n if (\n finish &&\n finish.nativeFrames &&\n // Must be in the margin of error of the actual transaction finish time (finalEndTimestamp)\n Math.abs(finish.timestamp - finalEndTimestamp) < MARGIN_OF_ERROR_SECONDS\n ) {\n finalFinishFrames = finish.nativeFrames;\n } else if (\n this._lastSpanFinishFrames &&\n Math.abs(this._lastSpanFinishFrames.timestamp - finalEndTimestamp) < MARGIN_OF_ERROR_SECONDS\n ) {\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 finalFinishFrames = this._lastSpanFinishFrames.nativeFrames;\n } else {\n return null;\n }\n\n const measurements = {\n frames_total: {\n value: finalFinishFrames.totalFrames - startFrames.totalFrames,\n unit: 'none',\n },\n frames_frozen: {\n value: finalFinishFrames.frozenFrames - startFrames.frozenFrames,\n unit: 'none',\n },\n frames_slow: {\n value: finalFinishFrames.slowFrames - startFrames.slowFrames,\n unit: 'none',\n },\n };\n\n return measurements;\n }\n\n /**\n * Fetch finish frames for a transaction at the current time. Calls any awaiting listeners.\n */\n private async _fetchFramesForTransaction(transaction: Transaction): Promise<void> {\n const startFrames = transaction.data.__startFrames as NativeFramesResponse | undefined;\n\n // This timestamp marks when the finish frames were retrieved. It should be pretty close to the transaction finish.\n const timestamp = timestampInSeconds();\n let finishFrames: NativeFramesResponse | null = null;\n if (startFrames) {\n finishFrames = await NATIVE.fetchNativeFrames();\n }\n\n _finishFrames.set(transaction.traceId, {\n nativeFrames: finishFrames,\n timestamp,\n });\n\n _framesListeners.get(transaction.traceId)?.();\n\n setTimeout(() => this._cancelFinishFrames(transaction), 2000);\n }\n\n /**\n * On a finish frames failure, we cancel the await.\n */\n private _cancelFinishFrames(transaction: Transaction): void {\n if (_finishFrames.has(transaction.traceId)) {\n _finishFrames.delete(transaction.traceId);\n\n logger.log(\n `[NativeFrames] Native frames timed out for ${transaction.op} transaction ${transaction.name}. Not adding native frames measurements.`,\n );\n }\n }\n\n /**\n * Adds frames measurements to an event. Called from a valid event processor.\n * Awaits for finish frames if needed.\n */\n private async _processEvent(event: Event, doesExist: () => boolean): Promise<Event> {\n if (!doesExist()) {\n return event;\n }\n\n if (event.type === 'transaction' && event.transaction && event.contexts && event.contexts.trace) {\n const traceContext = event.contexts.trace as {\n data?: { [key: string]: unknown };\n trace_id: string;\n name?: string;\n op?: string;\n };\n\n const traceId = traceContext.trace_id;\n\n if (traceId && traceContext.data?.__startFrames && event.timestamp) {\n const measurements = await this._getFramesMeasurements(\n traceId,\n event.timestamp,\n traceContext.data.__startFrames as NativeFramesResponse,\n );\n\n if (!measurements) {\n logger.log(\n `[NativeFrames] Could not fetch native frames for ${traceContext.op} transaction ${event.transaction}. Not adding native frames measurements.`,\n );\n } else {\n logger.log(\n `[Measurements] Adding measurements to ${traceContext.op} transaction ${\n event.transaction\n }: ${JSON.stringify(measurements, undefined, 2)}`,\n );\n\n event.measurements = {\n ...(event.measurements ?? {}),\n ...measurements,\n };\n\n _finishFrames.delete(traceId);\n }\n\n delete traceContext.data.__startFrames;\n }\n }\n\n return event;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"nativeframes.js","sourceRoot":"","sources":["../../../src/js/tracing/nativeframes.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAG3D,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAEpD;;;;GAIG;AACH,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAQrC,gJAAgJ;AAChJ,MAAM,gBAAgB,GAA4B,IAAI,GAAG,EAAE,CAAC;AAE5D,mJAAmJ;AACnJ,MAAM,aAAa,GAAkF,IAAI,GAAG,EAAE,CAAC;AAE/G;;;GAGG;AACH,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAErC;;GAEG;AACH,MAAM,OAAO,2BAA2B;IAOtC,YAAmB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EAAE;gBAC/F,MAAM,YAAY,GAAG,KAAK,CAAC,QAAQ,CAAC,KAKnC,CAAC;gBAEF,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,CAAC;gBAEtC,IAAI,CAAC,CAAA,MAAA,YAAY,CAAC,IAAI,0CAAE,aAAa,CAAA,EAAE;oBACrC,MAAM,CAAC,IAAI,CACT,8CAA8C,KAAK,CAAC,WAAW,cAAc,KAAK,CAAC,QAAQ,sCAAsC,CAClI,CAAC;iBACH;gBAED,IAAI,OAAO,KAAI,MAAA,YAAY,CAAC,IAAI,0CAAE,aAAa,CAAA,IAAI,KAAK,CAAC,SAAS,EAAE;oBAClE,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,sBAAsB,CACpD,OAAO,EACP,KAAK,CAAC,SAAS,EACf,YAAY,CAAC,IAAI,CAAC,aAAqC,CACxD,CAAC;oBAEF,IAAI,YAAY,EAAE;wBAChB,MAAM,CAAC,GAAG,CACR,yCAAyC,YAAY,CAAC,EAAE,gBACtD,KAAK,CAAC,WACR,KAAK,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAClD,CAAC;wBAEF,KAAK,CAAC,YAAY,mCACb,CAAC,MAAA,KAAK,CAAC,YAAY,mCAAI,EAAE,CAAC,GAC1B,YAAY,CAChB,CAAC;wBAEF,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;qBAC/B;oBAED,OAAO,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC;iBACxC;aACF;YAED,OAAO,KAAK,CAAC;;KACd;CACF","sourcesContent":["import type { Span, Transaction } from '@sentry/core';\nimport type { Event, EventProcessor, Measurements, MeasurementUnit } from '@sentry/types';\nimport { logger, timestampInSeconds } from '@sentry/utils';\n\nimport type { NativeFramesResponse } from '../NativeRNSentry';\nimport { NATIVE } from '../wrapper';\nimport { instrumentChildSpanFinish } from './utils';\n\n/**\n * Timeout from the final native frames fetch to processing the associated transaction.\n * If the transaction is not processed by this time, the native frames will be dropped\n * and not added to the event.\n */\nconst FINAL_FRAMES_TIMEOUT_MS = 2000;\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\n/** The listeners for each native frames response, keyed by traceId. This must be global to avoid closure issues and reading outdated values. */\nconst _framesListeners: Map<string, () => void> = new Map();\n\n/** The native frames at the transaction finish time, keyed by traceId. This must be global to avoid closure issues and reading outdated values. */\nconst _finishFrames: Map<string, { timestamp: number; nativeFrames: NativeFramesResponse | null }> = new Map();\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\n/**\n * Instrumentation to add native slow/frozen frames measurements onto transactions.\n */\nexport class NativeFramesInstrumentation {\n /** The native frames at the finish time of the most recent span. */\n private _lastSpanFinishFrames?: {\n timestamp: number;\n nativeFrames: NativeFramesResponse;\n };\n\n public constructor(addGlobalEventProcessor: (e: EventProcessor) => void, doesExist: () => boolean) {\n logger.log('[ReactNativeTracing] Native frames instrumentation initialized.');\n\n addGlobalEventProcessor(event => this._processEvent(event, doesExist));\n }\n\n /**\n * To be called when a transaction is started.\n * Logs the native frames at this start point and instruments child span finishes.\n */\n public onTransactionStart(transaction: Transaction): void {\n logger.debug(`[NativeFrames] Fetching frames for root span start (${transaction.spanContext().spanId}).`);\n void NATIVE.fetchNativeFrames()\n .then(framesMetrics => {\n if (framesMetrics) {\n transaction.setData('__startFrames', framesMetrics);\n } else {\n logger.warn(\n `[NativeFrames] Fetched frames for root span start (${\n transaction.spanContext().spanId\n }), but no frames were returned.`,\n );\n }\n })\n .then(undefined, error => {\n logger.error(\n `[NativeFrames] Error while fetching frames for root span start (${transaction.spanContext().spanId})`,\n error,\n );\n });\n\n instrumentChildSpanFinish(transaction, (_: Span, endTimestamp?: number) => {\n if (!endTimestamp) {\n this._onSpanFinish();\n }\n });\n }\n\n /**\n * To be called when a transaction is finished\n */\n public onTransactionFinish(transaction: Transaction): void {\n this._fetchEndFramesForTransaction(transaction).then(undefined, (reason: unknown) => {\n logger.error(\n `[NativeFrames] Error while fetching frames for root span start (${transaction.spanContext().spanId})`,\n reason,\n );\n });\n }\n\n /**\n * Called on a span finish to fetch native frames to support transactions with trimEnd.\n * Only to be called when a span does not have an end timestamp.\n */\n private _onSpanFinish(): void {\n const timestamp = timestampInSeconds();\n\n void NATIVE.fetchNativeFrames()\n .then(nativeFrames => {\n if (nativeFrames) {\n this._lastSpanFinishFrames = {\n timestamp,\n nativeFrames,\n };\n }\n })\n .then(undefined, error => {\n logger.error(`[NativeFrames] Error while fetching frames for child span end.`, error);\n });\n }\n\n /**\n * Returns the computed frames measurements and awaits for them if they are not ready yet.\n */\n private async _getFramesMeasurements(\n traceId: string,\n finalEndTimestamp: number,\n startFrames: NativeFramesResponse,\n ): Promise<FramesMeasurements | null> {\n if (_finishFrames.has(traceId)) {\n logger.debug(`[NativeFrames] Native end frames already fetched for trace id (${traceId}).`);\n return this._prepareMeasurements(traceId, finalEndTimestamp, startFrames);\n }\n\n return new Promise(resolve => {\n const timeout = setTimeout(() => {\n logger.debug(`[NativeFrames] Native end frames listener removed by timeout for trace id (${traceId}).`);\n _framesListeners.delete(traceId);\n\n resolve(null);\n }, 2000);\n\n _framesListeners.set(traceId, () => {\n logger.debug(`[NativeFrames] Native end frames listener called for trace id (${traceId}).`);\n resolve(this._prepareMeasurements(traceId, finalEndTimestamp, startFrames));\n\n clearTimeout(timeout);\n _framesListeners.delete(traceId);\n });\n });\n }\n\n /**\n * Returns the computed frames measurements given ready data\n */\n private _prepareMeasurements(\n traceId: string,\n finalEndTimestamp: number, // The actual transaction finish time.\n startFrames: NativeFramesResponse,\n ): FramesMeasurements | null {\n let finalFinishFrames: NativeFramesResponse | undefined;\n\n const finish = _finishFrames.get(traceId);\n if (\n finish &&\n finish.nativeFrames &&\n // Must be in the margin of error of the actual transaction finish time (finalEndTimestamp)\n Math.abs(finish.timestamp - finalEndTimestamp) < MARGIN_OF_ERROR_SECONDS\n ) {\n logger.debug(`[NativeFrames] Using frames from root span end (traceId, ${traceId}).`);\n finalFinishFrames = finish.nativeFrames;\n } else if (\n this._lastSpanFinishFrames &&\n Math.abs(this._lastSpanFinishFrames.timestamp - finalEndTimestamp) < MARGIN_OF_ERROR_SECONDS\n ) {\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(`[NativeFrames] Using native frames from last span end (traceId, ${traceId}).`);\n finalFinishFrames = this._lastSpanFinishFrames.nativeFrames;\n } else {\n logger.warn(\n `[NativeFrames] Frames were collected within larger than margin of error delay for traceId (${traceId}). Dropping the inaccurate values.`,\n );\n return null;\n }\n\n const measurements = {\n frames_total: {\n value: finalFinishFrames.totalFrames - startFrames.totalFrames,\n unit: 'none',\n },\n frames_frozen: {\n value: finalFinishFrames.frozenFrames - startFrames.frozenFrames,\n unit: 'none',\n },\n frames_slow: {\n value: finalFinishFrames.slowFrames - startFrames.slowFrames,\n unit: 'none',\n },\n };\n\n return measurements;\n }\n\n /**\n * Fetch finish frames for a transaction at the current time. Calls any awaiting listeners.\n */\n private async _fetchEndFramesForTransaction(transaction: Transaction): Promise<void> {\n const startFrames = transaction.data.__startFrames as NativeFramesResponse | undefined;\n\n // This timestamp marks when the finish frames were retrieved. It should be pretty close to the transaction finish.\n const timestamp = timestampInSeconds();\n let finishFrames: NativeFramesResponse | null = null;\n if (startFrames) {\n finishFrames = await NATIVE.fetchNativeFrames();\n }\n\n _finishFrames.set(transaction.traceId, {\n nativeFrames: finishFrames,\n timestamp,\n });\n\n _framesListeners.get(transaction.traceId)?.();\n\n setTimeout(() => this._cancelEndFrames(transaction), FINAL_FRAMES_TIMEOUT_MS);\n }\n\n /**\n * On a finish frames failure, we cancel the await.\n */\n private _cancelEndFrames(transaction: Transaction): void {\n if (_finishFrames.has(transaction.traceId)) {\n _finishFrames.delete(transaction.traceId);\n\n logger.log(\n `[NativeFrames] Native frames timed out for ${transaction.op} transaction ${transaction.name}. Not adding native frames measurements.`,\n );\n }\n }\n\n /**\n * Adds frames measurements to an event. Called from a valid event processor.\n * Awaits for finish frames if needed.\n */\n private async _processEvent(event: Event, doesExist: () => boolean): Promise<Event> {\n if (!doesExist()) {\n return event;\n }\n\n if (event.type === 'transaction' && event.transaction && event.contexts && event.contexts.trace) {\n const traceContext = event.contexts.trace as {\n data?: { [key: string]: unknown };\n trace_id: string;\n name?: string;\n op?: string;\n };\n\n const traceId = traceContext.trace_id;\n\n if (!traceContext.data?.__startFrames) {\n logger.warn(\n `[NativeFrames] Start frames of transaction ${event.transaction} (eventId, ${event.event_id}) are missing, but it already ended.`,\n );\n }\n\n if (traceId && traceContext.data?.__startFrames && event.timestamp) {\n const measurements = await this._getFramesMeasurements(\n traceId,\n event.timestamp,\n traceContext.data.__startFrames as NativeFramesResponse,\n );\n\n if (measurements) {\n logger.log(\n `[Measurements] Adding measurements to ${traceContext.op} transaction ${\n event.transaction\n }: ${JSON.stringify(measurements, undefined, 2)}`,\n );\n\n event.measurements = {\n ...(event.measurements ?? {}),\n ...measurements,\n };\n\n _finishFrames.delete(traceId);\n }\n\n delete traceContext.data.__startFrames;\n }\n }\n\n return event;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactnativeprofiler.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/reactnativeprofiler.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"reactnativeprofiler.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/reactnativeprofiler.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA4B,QAAQ,EAAE,MAAM,eAAe,CAAC;AAUnE;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,QAAQ;IAC/C,SAAgB,IAAI,EAAE,MAAM,CAAyB;gBAElC,KAAK,EAAE,qBAAqB,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;IAOnE;;OAEG;IACI,iBAAiB,IAAI,IAAI;IAQhC;;OAEG;IACH,OAAO,CAAC,eAAe;CAoBxB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { getCurrentHub, Profiler } from '@sentry/react';
|
|
1
|
+
import { getClient, getCurrentHub, Profiler } from '@sentry/react';
|
|
2
|
+
import { timestampInSeconds } from '@sentry/utils';
|
|
2
3
|
import { createIntegration } from '../integrations/factory';
|
|
3
4
|
import { ReactNativeTracing } from './reactnativetracing';
|
|
4
5
|
const ReactNativeProfilerGlobalState = {
|
|
@@ -8,8 +9,11 @@ const ReactNativeProfilerGlobalState = {
|
|
|
8
9
|
* Custom profiler for the React Native app root.
|
|
9
10
|
*/
|
|
10
11
|
export class ReactNativeProfiler extends Profiler {
|
|
11
|
-
constructor() {
|
|
12
|
-
|
|
12
|
+
constructor(props) {
|
|
13
|
+
const client = getClient();
|
|
14
|
+
const integration = client && client.getIntegrationByName && client.getIntegrationByName('ReactNativeTracing');
|
|
15
|
+
integration && integration.setRootComponentFirstConstructorCallTimestampMs(timestampInSeconds() * 1000);
|
|
16
|
+
super(props);
|
|
13
17
|
this.name = 'ReactNativeProfiler';
|
|
14
18
|
}
|
|
15
19
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactnativeprofiler.js","sourceRoot":"","sources":["../../../src/js/tracing/reactnativeprofiler.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"reactnativeprofiler.js","sourceRoot":"","sources":["../../../src/js/tracing/reactnativeprofiler.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,OA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C,UAAU;eACf,OAAO,IAAI,CAAC,UAAU,CAAC,YAAY,KAAK,WAAW;YACtD,0DAA0D;eACvD,kBAAkB,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IACzE,CAAC;CACF","sourcesContent":["import { getClient, getCurrentHub, Profiler } from '@sentry/react';\nimport { timestampInSeconds } from '@sentry/utils';\n\nimport { createIntegration } from '../integrations/factory';\nimport { ReactNativeTracing } from './reactnativetracing';\n\nconst ReactNativeProfilerGlobalState = {\n appStartReported: false,\n};\n\n/**\n * Custom profiler for the React Native app root.\n */\nexport class ReactNativeProfiler extends Profiler {\n public readonly name: string = 'ReactNativeProfiler';\n\n public constructor(props: ConstructorParameters<typeof Profiler>[0]) {\n const client = getClient();\n const integration = client && client.getIntegrationByName && client.getIntegrationByName<ReactNativeTracing>('ReactNativeTracing');\n integration && integration.setRootComponentFirstConstructorCallTimestampMs(timestampInSeconds() * 1000);\n super(props);\n }\n\n /**\n * Get the app root mount time.\n */\n public componentDidMount(): void {\n super.componentDidMount();\n if (!ReactNativeProfilerGlobalState.appStartReported) {\n this._reportAppStart();\n ReactNativeProfilerGlobalState.appStartReported = true;\n }\n }\n\n /**\n * Notifies the Tracing integration that the app start has finished.\n */\n private _reportAppStart(): void {\n const hub = getCurrentHub();\n const client = hub.getClient();\n\n if (!client) {\n // We can't use logger here because this will be logged before the `Sentry.init`.\n // eslint-disable-next-line no-console\n __DEV__ && console.warn('App Start Span could not be finished. `Sentry.wrap` was called before `Sentry.init`.');\n return;\n }\n\n client.addIntegration && client.addIntegration(createIntegration(this.name));\n\n const tracingIntegration = hub.getIntegration(ReactNativeTracing);\n tracingIntegration\n && this._mountSpan\n && typeof this._mountSpan.endTimestamp !== 'undefined'\n // The first root component mount is the app start finish.\n && tracingIntegration.onAppStartFinish(this._mountSpan.endTimestamp);\n }\n}\n"]}
|
|
@@ -99,6 +99,7 @@ export declare class ReactNativeTracing implements Integration {
|
|
|
99
99
|
private _hasSetTracePropagationTargets;
|
|
100
100
|
private _hasSetTracingOrigins;
|
|
101
101
|
private _currentViewName;
|
|
102
|
+
private _firstConstructorCallTimestampMs;
|
|
102
103
|
constructor(options?: Partial<ReactNativeTracingOptions>);
|
|
103
104
|
/**
|
|
104
105
|
* Registers routing and request instrumentation.
|
|
@@ -116,6 +117,10 @@ export declare class ReactNativeTracing implements Integration {
|
|
|
116
117
|
* Called by the ReactNativeProfiler component on first component mount.
|
|
117
118
|
*/
|
|
118
119
|
onAppStartFinish(endTimestamp: number): void;
|
|
120
|
+
/**
|
|
121
|
+
* Sets the root component first constructor call timestamp.
|
|
122
|
+
*/
|
|
123
|
+
setRootComponentFirstConstructorCallTimestampMs(timestamp: number): void;
|
|
119
124
|
/**
|
|
120
125
|
* Starts a new transaction for a user interaction.
|
|
121
126
|
* @param userInteractionId Consists of `op` representation UI Event and `elementId` unique element identifier on current screen.
|
|
@@ -147,6 +152,19 @@ export declare class ReactNativeTracing implements Integration {
|
|
|
147
152
|
* Adds app start measurements and starts a child span on a transaction.
|
|
148
153
|
*/
|
|
149
154
|
private _addAppStartData;
|
|
155
|
+
/**
|
|
156
|
+
* Adds JS Execution before React Root. If `Sentry.wrap` is not used, create a span for the start of JS Bundle execution.
|
|
157
|
+
*/
|
|
158
|
+
private _addJSExecutionBeforeRoot;
|
|
159
|
+
/**
|
|
160
|
+
* Adds native spans to the app start span.
|
|
161
|
+
*/
|
|
162
|
+
private _addNativeSpansTo;
|
|
163
|
+
/**
|
|
164
|
+
* UIKit init is measured by the native layers till the native SDK start
|
|
165
|
+
* RN initializes the native SDK later, the end timestamp would be wrong
|
|
166
|
+
*/
|
|
167
|
+
private _createUIKitSpan;
|
|
150
168
|
/** To be called when the route changes, but BEFORE the components of the new route mount. */
|
|
151
169
|
private _onRouteWillChange;
|
|
152
170
|
/**
|