@sentry/react-native 5.34.0 → 5.35.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/CHANGELOG.md +10 -0
- package/android/src/main/java/io/sentry/react/RNSentryModuleImpl.java +20 -8
- package/android/src/main/java/io/sentry/react/RNSentryPackage.java +0 -1
- package/android/src/main/java/io/sentry/react/RNSentryTimeToDisplay.java +39 -0
- package/android/src/newarch/java/io/sentry/react/RNSentryModule.java +5 -0
- package/android/src/oldarch/java/io/sentry/react/RNSentryModule.java +5 -0
- package/dist/js/NativeRNSentry.d.ts +1 -0
- package/dist/js/NativeRNSentry.d.ts.map +1 -1
- package/dist/js/NativeRNSentry.js.map +1 -1
- package/dist/js/tracing/reactnavigation.d.ts.map +1 -1
- package/dist/js/tracing/reactnavigation.js +7 -7
- package/dist/js/tracing/reactnavigation.js.map +1 -1
- package/dist/js/tracing/timetodisplay.d.ts.map +1 -1
- package/dist/js/tracing/timetodisplay.js +3 -1
- package/dist/js/tracing/timetodisplay.js.map +1 -1
- package/dist/js/utils/sentryeventemitterfallback.d.ts +19 -0
- package/dist/js/utils/sentryeventemitterfallback.d.ts.map +1 -0
- package/dist/js/utils/sentryeventemitterfallback.js +78 -0
- package/dist/js/utils/sentryeventemitterfallback.js.map +1 -0
- 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 +2 -1
- package/dist/js/wrapper.d.ts.map +1 -1
- package/dist/js/wrapper.js +43 -5
- package/dist/js/wrapper.js.map +1 -1
- package/ios/RNSentry.mm +18 -1
- package/ios/RNSentryTimeToDisplay.h +7 -0
- package/ios/RNSentryTimeToDisplay.m +43 -0
- package/package.json +1 -1
- package/src/js/NativeRNSentry.ts +2 -0
- package/ts3.8/dist/js/NativeRNSentry.d.ts +1 -0
- package/ts3.8/dist/js/utils/sentryeventemitterfallback.d.ts +19 -0
- package/ts3.8/dist/js/version.d.ts +1 -1
- package/ts3.8/dist/js/wrapper.d.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 5.35.0-beta.0
|
|
4
|
+
|
|
5
|
+
### Fixes
|
|
6
|
+
|
|
7
|
+
- Enhanced accuracy of time-to-display spans. ([#4042](https://github.com/getsentry/sentry-react-native/pull/4042))
|
|
8
|
+
- TimetoTisplay correctly warns about not supporting the new React Native architecture ([#4160](https://github.com/getsentry/sentry-react-native/pull/4160))
|
|
9
|
+
- Native Wrapper method `setContext` ensures only values convertible to NativeMap are passed ([#4168](https://github.com/getsentry/sentry-react-native/pull/4168))
|
|
10
|
+
- Native Wrapper method `setExtra` ensures only stringified values are passed ([#4168](https://github.com/getsentry/sentry-react-native/pull/4168))
|
|
11
|
+
- `setContext('key', null)` removes the key value also from platform context ([#4168](https://github.com/getsentry/sentry-react-native/pull/4168))
|
|
12
|
+
|
|
3
13
|
## 5.34.0
|
|
4
14
|
|
|
5
15
|
### Fixes
|
|
@@ -41,15 +41,11 @@ import java.io.IOException;
|
|
|
41
41
|
import java.io.InputStream;
|
|
42
42
|
import java.nio.charset.Charset;
|
|
43
43
|
import java.util.HashMap;
|
|
44
|
-
import java.util.HashSet;
|
|
45
44
|
import java.util.List;
|
|
46
45
|
import java.util.Map;
|
|
47
46
|
import java.util.Properties;
|
|
48
|
-
import java.util.Set;
|
|
49
47
|
import java.util.concurrent.CountDownLatch;
|
|
50
48
|
|
|
51
|
-
import io.sentry.Breadcrumb;
|
|
52
|
-
import io.sentry.DateUtils;
|
|
53
49
|
import io.sentry.HubAdapter;
|
|
54
50
|
import io.sentry.ILogger;
|
|
55
51
|
import io.sentry.ISentryExecutorService;
|
|
@@ -135,10 +131,13 @@ public class RNSentryModuleImpl {
|
|
|
135
131
|
/** Max trace file size in bytes. */
|
|
136
132
|
private long maxTraceFileSize = 5 * 1024 * 1024;
|
|
137
133
|
|
|
134
|
+
private final @NotNull SentryDateProvider dateProvider;
|
|
135
|
+
|
|
138
136
|
public RNSentryModuleImpl(ReactApplicationContext reactApplicationContext) {
|
|
139
137
|
packageInfo = getPackageInfo(reactApplicationContext);
|
|
140
138
|
this.reactApplicationContext = reactApplicationContext;
|
|
141
139
|
this.emitNewFrameEvent = createEmitNewFrameEvent();
|
|
140
|
+
this.dateProvider = new SentryAndroidDateProvider();
|
|
142
141
|
}
|
|
143
142
|
|
|
144
143
|
private ReactApplicationContext getReactApplicationContext() {
|
|
@@ -150,8 +149,6 @@ public class RNSentryModuleImpl {
|
|
|
150
149
|
}
|
|
151
150
|
|
|
152
151
|
private @NotNull Runnable createEmitNewFrameEvent() {
|
|
153
|
-
final @NotNull SentryDateProvider dateProvider = new SentryAndroidDateProvider();
|
|
154
|
-
|
|
155
152
|
return () -> {
|
|
156
153
|
final SentryDate endDate = dateProvider.now();
|
|
157
154
|
WritableMap event = Arguments.createMap();
|
|
@@ -639,18 +636,29 @@ public class RNSentryModuleImpl {
|
|
|
639
636
|
}
|
|
640
637
|
|
|
641
638
|
public void setExtra(String key, String extra) {
|
|
639
|
+
if (key == null || extra == null) {
|
|
640
|
+
logger.log(SentryLevel.ERROR, "RNSentry.setExtra called with null key or value, can't change extra.");
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
643
|
+
|
|
642
644
|
Sentry.configureScope(scope -> {
|
|
643
645
|
scope.setExtra(key, extra);
|
|
644
646
|
});
|
|
645
647
|
}
|
|
646
648
|
|
|
647
649
|
public void setContext(final String key, final ReadableMap context) {
|
|
648
|
-
if (key == null
|
|
650
|
+
if (key == null) {
|
|
651
|
+
logger.log(SentryLevel.ERROR, "RNSentry.setContext called with null key, can't change context.");
|
|
649
652
|
return;
|
|
650
653
|
}
|
|
654
|
+
|
|
651
655
|
Sentry.configureScope(scope -> {
|
|
652
|
-
|
|
656
|
+
if (context == null) {
|
|
657
|
+
scope.removeContexts(key);
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
653
660
|
|
|
661
|
+
final HashMap<String, Object> contextHashMap = context.toHashMap();
|
|
654
662
|
scope.setContexts(key, contextHashMap);
|
|
655
663
|
});
|
|
656
664
|
}
|
|
@@ -701,6 +709,10 @@ public class RNSentryModuleImpl {
|
|
|
701
709
|
}
|
|
702
710
|
}
|
|
703
711
|
|
|
712
|
+
public void getNewScreenTimeToDisplay(Promise promise) {
|
|
713
|
+
RNSentryTimeToDisplay.GetTimeToDisplay(promise, dateProvider);
|
|
714
|
+
}
|
|
715
|
+
|
|
704
716
|
private String getProfilingTracesDirPath() {
|
|
705
717
|
if (cacheDirPath == null) {
|
|
706
718
|
cacheDirPath = new File(getReactApplicationContext().getCacheDir(), "sentry/react").getAbsolutePath();
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
package io.sentry.react;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Promise;
|
|
4
|
+
|
|
5
|
+
import android.os.Handler;
|
|
6
|
+
import android.os.Looper;
|
|
7
|
+
import android.view.Choreographer;
|
|
8
|
+
|
|
9
|
+
import org.jetbrains.annotations.NotNull;
|
|
10
|
+
import io.sentry.SentryDate;
|
|
11
|
+
import io.sentry.SentryDateProvider;
|
|
12
|
+
import io.sentry.android.core.SentryAndroidDateProvider;
|
|
13
|
+
|
|
14
|
+
public class RNSentryTimeToDisplay {
|
|
15
|
+
public static void GetTimeToDisplay(Promise promise, SentryDateProvider dateProvider) {
|
|
16
|
+
Looper mainLooper = Looper.getMainLooper();
|
|
17
|
+
|
|
18
|
+
if (mainLooper == null) {
|
|
19
|
+
promise.reject("GetTimeToDisplay is not able to measure the time to display: Main looper not available.");
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Ensure the code runs on the main thread
|
|
24
|
+
new Handler(mainLooper)
|
|
25
|
+
.post(() -> {
|
|
26
|
+
try {
|
|
27
|
+
Choreographer choreographer = Choreographer.getInstance();
|
|
28
|
+
|
|
29
|
+
// Invoke the callback after the frame is rendered
|
|
30
|
+
choreographer.postFrameCallback(frameTimeNanos -> {
|
|
31
|
+
final SentryDate endDate = dateProvider.now();
|
|
32
|
+
promise.resolve(endDate.nanoTimestamp() / 1e9);
|
|
33
|
+
});
|
|
34
|
+
} catch (Exception exception) {
|
|
35
|
+
promise.reject("Failed to receive the instance of Choreographer", exception);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -173,4 +173,9 @@ public class RNSentryModule extends NativeRNSentrySpec {
|
|
|
173
173
|
public void crashedLastRun(Promise promise) {
|
|
174
174
|
this.impl.crashedLastRun(promise);
|
|
175
175
|
}
|
|
176
|
+
|
|
177
|
+
@Override
|
|
178
|
+
public void getNewScreenTimeToDisplay(Promise promise) {
|
|
179
|
+
this.impl.getNewScreenTimeToDisplay(promise);
|
|
180
|
+
}
|
|
176
181
|
}
|
|
@@ -173,4 +173,9 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
|
|
|
173
173
|
public void crashedLastRun(Promise promise) {
|
|
174
174
|
this.impl.crashedLastRun(promise);
|
|
175
175
|
}
|
|
176
|
+
|
|
177
|
+
@ReactMethod()
|
|
178
|
+
public void getNewScreenTimeToDisplay(Promise promise) {
|
|
179
|
+
this.impl.getNewScreenTimeToDisplay(promise);
|
|
180
|
+
}
|
|
176
181
|
}
|
|
@@ -4,6 +4,7 @@ import type { UnsafeObject } from './utils/rnlibrariesinterface';
|
|
|
4
4
|
export interface Spec extends TurboModule {
|
|
5
5
|
addListener: (eventType: string) => void;
|
|
6
6
|
removeListeners: (id: number) => void;
|
|
7
|
+
getNewScreenTimeToDisplay(): Promise<number | undefined | null>;
|
|
7
8
|
addBreadcrumb(breadcrumb: UnsafeObject): void;
|
|
8
9
|
captureEnvelope(bytes: string, options: {
|
|
9
10
|
hardCrashed: boolean;
|
|
@@ -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,WAAW,EAAE,OAAO,CAAC;KACtB,GACA,OAAO,CAAC,OAAO,CAAC,CAAC;
|
|
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,yBAAyB,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC,CAAC;IAChE,aAAa,CAAC,UAAU,EAAE,YAAY,GAAG,IAAI,CAAC;IAC9C,eAAe,CACb,KAAK,EAAE,MAAM,EACb,OAAO,EAAE;QACP,WAAW,EAAE,OAAO,CAAC;KACtB,GACA,OAAO,CAAC,OAAO,CAAC,CAAC;IAEpB,iBAAiB,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AAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAChC,CAAC;IACF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE;QACZ,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAChC,EAAE,CAAC;CACL,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;;AAGF,wBAAkE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"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;AA2JnD,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 getNewScreenTimeToDisplay(): Promise<number | undefined | null>;\n addBreadcrumb(breadcrumb: UnsafeObject): void;\n captureEnvelope(\n bytes: string,\n options: {\n hardCrashed: boolean;\n },\n ): Promise<boolean>;\n\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(platformProfilers: boolean): { 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 captureReplay(isHardCrash: boolean): Promise<string | undefined | null>;\n getCurrentReplayId(): string | undefined | null;\n crashedLastRun(): Promise<boolean | undefined | null>;\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactnavigation.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/reactnavigation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reactnavigation.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/reactnavigation.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAC;AAE1E,OAAO,KAAK,EAAE,cAAc,EAA6D,MAAM,SAAS,CAAC;AAQzG,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IAEZ,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC9B;AAOD,UAAU,sBAAsB;IAC9B;;;;;;OAMG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAE7B;;;;;OAKG;IACH,0BAA0B,EAAE,OAAO,CAAC;CACrC;AAOD;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,aAC5B,QAAQ,sBAAsB,CAAC,KACvC,8BAEF,CAAC;AAEF;;GAEG;AACH,qBAAa,8BAA+B,SAAQ,8BAA8B;IAChF,OAAc,mBAAmB,EAAE,MAAM,CAAyB;IAElE,SAAgB,IAAI,EAAE,MAAM,CAAsD;IAElF,OAAO,CAAC,oBAAoB,CAAoC;IAChE,OAAO,CAAC,2BAA2B,CAA2C;IAC9E,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAe;IAElD,OAAO,CAAC,YAAY,CAAC,CAAkB;IACvC,OAAO,CAAC,kBAAkB,CAAC,CAAkB;IAC7C,OAAO,CAAC,yBAAyB,CAAC,CAAO;IAEzC,OAAO,CAAC,oBAAoB,CAAkB;IAC9C,OAAO,CAAC,mBAAmB,CAAC,CAA4C;IACxE,OAAO,CAAC,gBAAgB,CAAgB;IAExC,OAAO,CAAC,QAAQ,CAAyB;gBAEtB,OAAO,GAAE,OAAO,CAAC,sBAAsB,CAAM;IAiBhE;;OAEG;IACI,8BAA8B,CACnC,QAAQ,EAAE,kBAAkB,EAC5B,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,cAAc,GAC7B,IAAI;IAeP;;;OAGG;IAEI,2BAA2B,CAAC,sBAAsB,EAAE,GAAG,GAAG,IAAI;IAgDrE;;;;OAIG;IACH,OAAO,CAAC,WAAW;IA2BnB;;OAEG;IACH,OAAO,CAAC,cAAc;IAsGtB,4DAA4D;IAC5D,OAAO,CAAC,oBAAoB;IA4B5B,sGAAsG;IACtG,OAAO,CAAC,mBAAmB,CAMzB;IAEF,wEAAwE;IACxE,OAAO,CAAC,yBAAyB;IAWjC;;OAEG;IACH,OAAO,CAAC,wBAAwB;CAMjC;AAED;;;GAGG;AACH,eAAO,MAAM,gCAAgC,uCAAiC,CAAC;AAE/E,eAAO,MAAM,yBAAyB;;;;;;;CAOrC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable max-lines */
|
|
2
2
|
import { getActiveSpan, startInactiveSpan } from '@sentry/core';
|
|
3
3
|
import { logger, timestampInSeconds } from '@sentry/utils';
|
|
4
|
-
import {
|
|
4
|
+
import { createSentryFallbackEventEmitter } from '../utils/sentryeventemitterfallback';
|
|
5
5
|
import { RN_GLOBAL_OBJ } from '../utils/worldwide';
|
|
6
6
|
import { NATIVE } from '../wrapper';
|
|
7
7
|
import { InternalRoutingInstrumentation } from './routingInstrumentation';
|
|
@@ -43,8 +43,8 @@ export class ReactNavigationInstrumentation extends InternalRoutingInstrumentati
|
|
|
43
43
|
};
|
|
44
44
|
this._options = Object.assign(Object.assign({}, defaultOptions), options);
|
|
45
45
|
if (this._options.enableTimeToInitialDisplay) {
|
|
46
|
-
this._newScreenFrameEventEmitter =
|
|
47
|
-
this._newScreenFrameEventEmitter.initAsync(
|
|
46
|
+
this._newScreenFrameEventEmitter = createSentryFallbackEventEmitter();
|
|
47
|
+
this._newScreenFrameEventEmitter.initAsync();
|
|
48
48
|
NATIVE.initNativeReactNavigationNewFrameTracking().catch((reason) => {
|
|
49
49
|
logger.error(`[ReactNavigationInstrumentation] Failed to initialize native new frame tracking: ${reason}`);
|
|
50
50
|
});
|
|
@@ -155,9 +155,8 @@ export class ReactNavigationInstrumentation extends InternalRoutingInstrumentati
|
|
|
155
155
|
name: `${route.name} initial display`,
|
|
156
156
|
isAutoInstrumented: true,
|
|
157
157
|
});
|
|
158
|
-
!routeHasBeenSeen &&
|
|
159
|
-
|
|
160
|
-
((_a = this._newScreenFrameEventEmitter) === null || _a === void 0 ? void 0 : _a.once(NewFrameEventName, ({ newFrameTimestampInSeconds }) => {
|
|
158
|
+
if (!routeHasBeenSeen && latestTtidSpan) {
|
|
159
|
+
(_a = this._newScreenFrameEventEmitter) === null || _a === void 0 ? void 0 : _a.onceNewFrame(({ newFrameTimestampInSeconds }) => {
|
|
161
160
|
const activeSpan = getActiveSpan();
|
|
162
161
|
if (activeSpan && manualInitialDisplaySpans.has(activeSpan)) {
|
|
163
162
|
logger.warn('[ReactNavigationInstrumentation] Detected manual instrumentation for the current active span.');
|
|
@@ -166,7 +165,8 @@ export class ReactNavigationInstrumentation extends InternalRoutingInstrumentati
|
|
|
166
165
|
latestTtidSpan.setStatus('ok');
|
|
167
166
|
latestTtidSpan.end(newFrameTimestampInSeconds);
|
|
168
167
|
setSpanDurationAsMeasurementOnTransaction(latestTransaction, 'time_to_initial_display', latestTtidSpan);
|
|
169
|
-
})
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
170
|
(_b = this._navigationProcessingSpan) === null || _b === void 0 ? void 0 : _b.updateName(`Processing navigation to ${route.name}`);
|
|
171
171
|
(_c = this._navigationProcessingSpan) === null || _c === void 0 ? void 0 : _c.setStatus('ok');
|
|
172
172
|
(_d = this._navigationProcessingSpan) === null || _d === void 0 ? void 0 : _d.end(stateChangedTimestamp);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactnavigation.js","sourceRoot":"","sources":["../../../src/js/tracing/reactnavigation.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEhE,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAG3D,OAAO,EAA2B,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACnH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAAE,yBAAyB,EAAE,6BAA6B,EAAE,MAAM,iBAAiB,CAAC;AAE3F,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,EAC1B,yCAAyC,GAC1C,MAAM,SAAS,CAAC;AAiCjB,MAAM,cAAc,GAA2B;IAC7C,oBAAoB,EAAE,IAAI;IAC1B,0BAA0B,EAAE,KAAK;CAClC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,UAA2C,EAAE,EACb,EAAE;IAClC,OAAO,IAAI,8BAA8B,CAAC,OAAO,CAAC,CAAC;AACrD,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,OAAO,8BAA+B,SAAQ,8BAA8B;IAoBhF,YAAmB,UAA2C,EAAE;QAC9D,KAAK,EAAE,CAAC;QAlBM,SAAI,GAAW,8BAA8B,CAAC,mBAAmB,CAAC;QAE1E,yBAAoB,GAA+B,IAAI,CAAC;QACxD,gCAA2B,GAA8B,IAAI,CAAC;QAErD,uBAAkB,GAAW,GAAG,CAAC;QAM1C,yBAAoB,GAAY,KAAK,CAAC;QAEtC,qBAAgB,GAA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KAAK,KAAK,EAAE;YAClC,MAAM,CAAC,GAAG,CACR,+DAA+D,YAAY,CAAC,IAAI,0BAA0B,CAC3G,CAAC;SACH;aAAM;YACL,+DAA+D;YAC/D,IAAI,CAAC,wBAAwB,EAAE,CAAC;SACjC;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;IAWD,wEAAwE;IAChE,yBAAyB;QAC/B,IAAI,IAAI,CAAC,kBAAkB,EAAE;YAC3B,IAAI,CAAC,kBAAkB,CAAC,OAAO,GAAG,KAAK,CAAC;YACxC,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,CAAC;YACjC,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;SACrC;QACD,IAAI,IAAI,CAAC,yBAAyB,EAAE;YAClC,IAAI,CAAC,yBAAyB,GAAG,SAAS,CAAC;SAC5C;IACH,CAAC;IAED;;OAEG;IACK,wBAAwB;QAC9B,IAAI,OAAO,IAAI,CAAC,mBAAmB,KAAK,WAAW,EAAE;YACnD,YAAY,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;YACvC,IAAI,CAAC,mBAAmB,GAAG,SAAS,CAAC;SACtC;IACH,CAAC;;AArTa,kDAAmB,GAAW,qBAAqB,CAAC;AAwTpE;;;GAGG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,8BAA8B,CAAC;AAE/E,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,IAAI,EAAE,cAAc;IACpB,EAAE,EAAE,YAAY;IAChB,IAAI,EAAE;QACJ,yBAAyB,EAAE,8BAA8B,CAAC,mBAAmB;KAC9E;IACD,IAAI,EAAE,EAAE;CACT,CAAC","sourcesContent":["/* eslint-disable max-lines */\nimport { getActiveSpan, startInactiveSpan } from '@sentry/core';\nimport type { Span, Transaction as TransactionType, TransactionContext } from '@sentry/types';\nimport { logger, timestampInSeconds } from '@sentry/utils';\n\nimport type { NewFrameEvent } from '../utils/sentryeventemitter';\nimport { type SentryEventEmitter, createSentryEventEmitter, NewFrameEventName } from '../utils/sentryeventemitter';\nimport { RN_GLOBAL_OBJ } from '../utils/worldwide';\nimport { NATIVE } from '../wrapper';\nimport type { OnConfirmRoute, TransactionCreator } from './routingInstrumentation';\nimport { InternalRoutingInstrumentation } from './routingInstrumentation';\nimport { manualInitialDisplaySpans, startTimeToInitialDisplaySpan } from './timetodisplay';\nimport type { BeforeNavigate, ReactNavigationTransactionContext, RouteChangeContextData } from './types';\nimport {\n customTransactionSource,\n defaultTransactionSource,\n getBlankTransactionContext,\n setSpanDurationAsMeasurementOnTransaction,\n} from './utils';\n\nexport interface NavigationRoute {\n name: string;\n key: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n params?: Record<string, any>;\n}\n\ninterface NavigationContainer {\n addListener: (type: string, listener: () => void) => void;\n getCurrentRoute: () => NavigationRoute;\n}\n\ninterface ReactNavigationOptions {\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 * Time is in ms.\n *\n * @default 1000\n */\n routeChangeTimeoutMs: number;\n\n /**\n * Time to initial display measures the time it takes from\n * navigation dispatch to the render of the first frame of the new screen.\n *\n * @default false\n */\n enableTimeToInitialDisplay: boolean;\n}\n\nconst defaultOptions: ReactNavigationOptions = {\n routeChangeTimeoutMs: 1000,\n enableTimeToInitialDisplay: false,\n};\n\n/**\n * Instrumentation for React-Navigation V5 and above. See docs or sample app for usage.\n *\n * How this works:\n * - `_onDispatch` is called every time a dispatch happens and sets an IdleTransaction on the scope without any route context.\n * - `_onStateChange` is then called AFTER the state change happens due to a dispatch and sets the route context onto the active transaction.\n * - If `_onStateChange` isn't called within `STATE_CHANGE_TIMEOUT_DURATION` of the dispatch, then the transaction is not sampled and finished.\n */\nexport const reactNavigationIntegration = (\n options: Partial<ReactNavigationOptions> = {},\n): ReactNavigationInstrumentation => {\n return new ReactNavigationInstrumentation(options);\n};\n\n/**\n * @deprecated Please use `Sentry.reactNavigationIntegration()`\n */\nexport class ReactNavigationInstrumentation extends InternalRoutingInstrumentation {\n public static instrumentationName: string = 'react-navigation-v5';\n\n public readonly name: string = ReactNavigationInstrumentation.instrumentationName;\n\n private _navigationContainer: NavigationContainer | null = null;\n private _newScreenFrameEventEmitter: SentryEventEmitter | null = null;\n\n private readonly _maxRecentRouteLen: number = 200;\n\n private _latestRoute?: NavigationRoute;\n private _latestTransaction?: TransactionType;\n private _navigationProcessingSpan?: Span;\n\n private _initialStateHandled: boolean = false;\n private _stateChangeTimeout?: number | undefined;\n private _recentRouteKeys: string[] = [];\n\n private _options: ReactNavigationOptions;\n\n public constructor(options: Partial<ReactNavigationOptions> = {}) {\n super();\n\n this._options = {\n ...defaultOptions,\n ...options,\n };\n\n if (this._options.enableTimeToInitialDisplay) {\n this._newScreenFrameEventEmitter = createSentryEventEmitter();\n this._newScreenFrameEventEmitter.initAsync(NewFrameEventName);\n NATIVE.initNativeReactNavigationNewFrameTracking().catch((reason: unknown) => {\n logger.error(`[ReactNavigationInstrumentation] Failed to initialize native new frame tracking: ${reason}`);\n });\n }\n }\n\n /**\n * Extends by calling _handleInitialState at the end.\n */\n public registerRoutingInstrumentation(\n listener: TransactionCreator,\n beforeNavigate: BeforeNavigate,\n onConfirmRoute: OnConfirmRoute,\n ): void {\n super.registerRoutingInstrumentation(listener, beforeNavigate, onConfirmRoute);\n\n // We create an initial state here to ensure a transaction gets created before the first route mounts.\n if (!this._initialStateHandled) {\n this._onDispatch();\n if (this._navigationContainer) {\n // Navigation container already registered, just populate with route state\n this._onStateChange();\n\n this._initialStateHandled = true;\n }\n }\n }\n\n /**\n * Pass the ref to the navigation container to register it to the instrumentation\n * @param navigationContainerRef Ref to a `NavigationContainer`\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types\n public registerNavigationContainer(navigationContainerRef: any): void {\n /* We prevent duplicate routing instrumentation to be initialized on fast refreshes\n\n Explanation: If the user triggers a fast refresh on the file that the instrumentation is\n initialized in, it will initialize a new instance and will cause undefined behavior.\n */\n if (!RN_GLOBAL_OBJ.__sentry_rn_v5_registered) {\n if ('current' in navigationContainerRef) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n this._navigationContainer = navigationContainerRef.current;\n } else {\n this._navigationContainer = navigationContainerRef;\n }\n\n if (this._navigationContainer) {\n this._navigationContainer.addListener(\n '__unsafe_action__', // This action is emitted on every dispatch\n this._onDispatch.bind(this),\n );\n this._navigationContainer.addListener(\n 'state', // This action is emitted on every state change\n this._onStateChange.bind(this),\n );\n\n if (!this._initialStateHandled) {\n if (this._latestTransaction) {\n // If registerRoutingInstrumentation was called first _onDispatch has already been called\n this._onStateChange();\n\n this._initialStateHandled = true;\n } else {\n logger.log(\n '[ReactNavigationInstrumentation] Navigation container registered, but integration has not been setup yet.',\n );\n }\n }\n\n RN_GLOBAL_OBJ.__sentry_rn_v5_registered = true;\n } else {\n logger.warn('[ReactNavigationInstrumentation] Received invalid navigation container ref!');\n }\n } else {\n logger.log(\n '[ReactNavigationInstrumentation] Instrumentation already exists, but register has been called again, doing nothing.',\n );\n }\n }\n\n /**\n * To be called on every React-Navigation action dispatch.\n * It does not name the transaction or populate it with route information. Instead, it waits for the state to fully change\n * and gets the route information from there, @see _onStateChange\n */\n private _onDispatch(): void {\n if (this._latestTransaction) {\n logger.log(\n '[ReactNavigationInstrumentation] A transaction was detected that turned out to be a noop, discarding.',\n );\n this._discardLatestTransaction();\n this._clearStateChangeTimeout();\n }\n\n this._latestTransaction = this.onRouteWillChange(\n getBlankTransactionContext(ReactNavigationInstrumentation.instrumentationName),\n );\n\n if (this._options.enableTimeToInitialDisplay) {\n this._navigationProcessingSpan = startInactiveSpan({\n op: 'navigation.processing',\n name: 'Navigation processing',\n startTimestamp: this._latestTransaction?.startTimestamp,\n });\n }\n\n this._stateChangeTimeout = setTimeout(\n this._discardLatestTransaction.bind(this),\n this._options.routeChangeTimeoutMs,\n );\n }\n\n /**\n * To be called AFTER the state has been changed to populate the transaction with the current route.\n */\n private _onStateChange(): void {\n const stateChangedTimestamp = timestampInSeconds();\n\n // Use the getCurrentRoute method to be accurate.\n const previousRoute = this._latestRoute;\n\n if (!this._navigationContainer) {\n logger.warn(\n '[ReactNavigationInstrumentation] Missing navigation container ref. Route transactions will not be sent.',\n );\n\n return;\n }\n\n const route = this._navigationContainer.getCurrentRoute();\n\n if (route) {\n if (this._latestTransaction) {\n if (!previousRoute || previousRoute.key !== route.key) {\n const routeHasBeenSeen = this._recentRouteKeys.includes(route.key);\n const latestTransaction = this._latestTransaction;\n const latestTtidSpan =\n !routeHasBeenSeen &&\n this._options.enableTimeToInitialDisplay &&\n startTimeToInitialDisplaySpan({\n name: `${route.name} initial display`,\n isAutoInstrumented: true,\n });\n\n !routeHasBeenSeen &&\n latestTtidSpan &&\n this._newScreenFrameEventEmitter?.once(\n NewFrameEventName,\n ({ newFrameTimestampInSeconds }: NewFrameEvent) => {\n const activeSpan = getActiveSpan();\n if (activeSpan && manualInitialDisplaySpans.has(activeSpan)) {\n logger.warn(\n '[ReactNavigationInstrumentation] Detected manual instrumentation for the current active span.',\n );\n return;\n }\n\n latestTtidSpan.setStatus('ok');\n latestTtidSpan.end(newFrameTimestampInSeconds);\n setSpanDurationAsMeasurementOnTransaction(latestTransaction, 'time_to_initial_display', latestTtidSpan);\n },\n );\n\n this._navigationProcessingSpan?.updateName(`Processing navigation to ${route.name}`);\n this._navigationProcessingSpan?.setStatus('ok');\n this._navigationProcessingSpan?.end(stateChangedTimestamp);\n this._navigationProcessingSpan = undefined;\n\n const originalContext = latestTransaction.toContext() as typeof BLANK_TRANSACTION_CONTEXT;\n\n const data: RouteChangeContextData = {\n ...originalContext.data,\n route: {\n name: route.name,\n key: route.key,\n // TODO: filter PII params instead of dropping them all\n params: {},\n hasBeenSeen: routeHasBeenSeen,\n },\n previousRoute: previousRoute\n ? {\n name: previousRoute.name,\n key: previousRoute.key,\n // TODO: filter PII params instead of dropping them all\n params: {},\n }\n : null,\n };\n\n const updatedContext: ReactNavigationTransactionContext = {\n ...originalContext,\n name: route.name,\n tags: {\n ...originalContext.tags,\n 'routing.route.name': route.name,\n },\n data,\n };\n\n const finalContext = this._prepareFinalContext(updatedContext);\n latestTransaction.updateWithContext(finalContext);\n\n const isCustomName = updatedContext.name !== finalContext.name;\n latestTransaction.setName(\n finalContext.name,\n isCustomName ? customTransactionSource : defaultTransactionSource,\n );\n\n this._onConfirmRoute?.(finalContext);\n }\n\n this._pushRecentRouteKey(route.key);\n this._latestRoute = route;\n\n // Clear the latest transaction as it has been handled.\n this._latestTransaction = undefined;\n }\n }\n }\n\n /** Creates final transaction context before confirmation */\n private _prepareFinalContext(updatedContext: TransactionContext): TransactionContext {\n let finalContext = this._beforeNavigate?.({ ...updatedContext });\n\n // This block is to catch users not returning a transaction context\n if (!finalContext) {\n logger.error(\n `[ReactNavigationInstrumentation] beforeNavigate returned ${finalContext}, return context.sampled = false to not send transaction.`,\n );\n\n finalContext = {\n ...updatedContext,\n sampled: false,\n };\n }\n\n // Note: finalContext.sampled will be false at this point only if the user sets it to be so in beforeNavigate.\n if (finalContext.sampled === false) {\n logger.log(\n `[ReactNavigationInstrumentation] Will not send transaction \"${finalContext.name}\" due to beforeNavigate.`,\n );\n } else {\n // Clear the timeout so the transaction does not get cancelled.\n this._clearStateChangeTimeout();\n }\n\n return finalContext;\n }\n\n /** Pushes a recent route key, and removes earlier routes when there is greater than the max length */\n private _pushRecentRouteKey = (key: string): void => {\n this._recentRouteKeys.push(key);\n\n if (this._recentRouteKeys.length > this._maxRecentRouteLen) {\n this._recentRouteKeys = this._recentRouteKeys.slice(this._recentRouteKeys.length - this._maxRecentRouteLen);\n }\n };\n\n /** Cancels the latest transaction so it does not get sent to Sentry. */\n private _discardLatestTransaction(): void {\n if (this._latestTransaction) {\n this._latestTransaction.sampled = false;\n this._latestTransaction.finish();\n this._latestTransaction = undefined;\n }\n if (this._navigationProcessingSpan) {\n this._navigationProcessingSpan = undefined;\n }\n }\n\n /**\n *\n */\n private _clearStateChangeTimeout(): void {\n if (typeof this._stateChangeTimeout !== 'undefined') {\n clearTimeout(this._stateChangeTimeout);\n this._stateChangeTimeout = undefined;\n }\n }\n}\n\n/**\n * Backwards compatibility alias for ReactNavigationInstrumentation\n * @deprecated Use ReactNavigationInstrumentation\n */\nexport const ReactNavigationV5Instrumentation = ReactNavigationInstrumentation;\n\nexport const BLANK_TRANSACTION_CONTEXT = {\n name: 'Route Change',\n op: 'navigation',\n tags: {\n 'routing.instrumentation': ReactNavigationInstrumentation.instrumentationName,\n },\n data: {},\n};\n"]}
|
|
1
|
+
{"version":3,"file":"reactnavigation.js","sourceRoot":"","sources":["../../../src/js/tracing/reactnavigation.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEhE,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAI3D,OAAO,EAAE,gCAAgC,EAAE,MAAM,qCAAqC,CAAC;AACvF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAAE,yBAAyB,EAAE,6BAA6B,EAAE,MAAM,iBAAiB,CAAC;AAE3F,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,EAC1B,yCAAyC,GAC1C,MAAM,SAAS,CAAC;AAiCjB,MAAM,cAAc,GAA2B;IAC7C,oBAAoB,EAAE,IAAI;IAC1B,0BAA0B,EAAE,KAAK;CAClC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,UAA2C,EAAE,EACb,EAAE;IAClC,OAAO,IAAI,8BAA8B,CAAC,OAAO,CAAC,CAAC;AACrD,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,OAAO,8BAA+B,SAAQ,8BAA8B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IAAI,EAAE,EAAE;CACT,CAAC","sourcesContent":["/* eslint-disable max-lines */\nimport { getActiveSpan, startInactiveSpan } from '@sentry/core';\nimport type { Span, Transaction as TransactionType, TransactionContext } from '@sentry/types';\nimport { logger, timestampInSeconds } from '@sentry/utils';\n\nimport type { NewFrameEvent } from '../utils/sentryeventemitter';\nimport type { SentryEventEmitterFallback } from '../utils/sentryeventemitterfallback';\nimport { createSentryFallbackEventEmitter } from '../utils/sentryeventemitterfallback';\nimport { RN_GLOBAL_OBJ } from '../utils/worldwide';\nimport { NATIVE } from '../wrapper';\nimport type { OnConfirmRoute, TransactionCreator } from './routingInstrumentation';\nimport { InternalRoutingInstrumentation } from './routingInstrumentation';\nimport { manualInitialDisplaySpans, startTimeToInitialDisplaySpan } from './timetodisplay';\nimport type { BeforeNavigate, ReactNavigationTransactionContext, RouteChangeContextData } from './types';\nimport {\n customTransactionSource,\n defaultTransactionSource,\n getBlankTransactionContext,\n setSpanDurationAsMeasurementOnTransaction,\n} from './utils';\n\nexport interface NavigationRoute {\n name: string;\n key: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n params?: Record<string, any>;\n}\n\ninterface NavigationContainer {\n addListener: (type: string, listener: () => void) => void;\n getCurrentRoute: () => NavigationRoute;\n}\n\ninterface ReactNavigationOptions {\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 * Time is in ms.\n *\n * @default 1000\n */\n routeChangeTimeoutMs: number;\n\n /**\n * Time to initial display measures the time it takes from\n * navigation dispatch to the render of the first frame of the new screen.\n *\n * @default false\n */\n enableTimeToInitialDisplay: boolean;\n}\n\nconst defaultOptions: ReactNavigationOptions = {\n routeChangeTimeoutMs: 1000,\n enableTimeToInitialDisplay: false,\n};\n\n/**\n * Instrumentation for React-Navigation V5 and above. See docs or sample app for usage.\n *\n * How this works:\n * - `_onDispatch` is called every time a dispatch happens and sets an IdleTransaction on the scope without any route context.\n * - `_onStateChange` is then called AFTER the state change happens due to a dispatch and sets the route context onto the active transaction.\n * - If `_onStateChange` isn't called within `STATE_CHANGE_TIMEOUT_DURATION` of the dispatch, then the transaction is not sampled and finished.\n */\nexport const reactNavigationIntegration = (\n options: Partial<ReactNavigationOptions> = {},\n): ReactNavigationInstrumentation => {\n return new ReactNavigationInstrumentation(options);\n};\n\n/**\n * @deprecated Please use `Sentry.reactNavigationIntegration()`\n */\nexport class ReactNavigationInstrumentation extends InternalRoutingInstrumentation {\n public static instrumentationName: string = 'react-navigation-v5';\n\n public readonly name: string = ReactNavigationInstrumentation.instrumentationName;\n\n private _navigationContainer: NavigationContainer | null = null;\n private _newScreenFrameEventEmitter: SentryEventEmitterFallback | null = null;\n private readonly _maxRecentRouteLen: number = 200;\n\n private _latestRoute?: NavigationRoute;\n private _latestTransaction?: TransactionType;\n private _navigationProcessingSpan?: Span;\n\n private _initialStateHandled: boolean = false;\n private _stateChangeTimeout?: ReturnType<typeof setTimeout> | undefined;\n private _recentRouteKeys: string[] = [];\n\n private _options: ReactNavigationOptions;\n\n public constructor(options: Partial<ReactNavigationOptions> = {}) {\n super();\n\n this._options = {\n ...defaultOptions,\n ...options,\n };\n\n if (this._options.enableTimeToInitialDisplay) {\n this._newScreenFrameEventEmitter = createSentryFallbackEventEmitter();\n this._newScreenFrameEventEmitter.initAsync();\n NATIVE.initNativeReactNavigationNewFrameTracking().catch((reason: unknown) => {\n logger.error(`[ReactNavigationInstrumentation] Failed to initialize native new frame tracking: ${reason}`);\n });\n }\n }\n\n /**\n * Extends by calling _handleInitialState at the end.\n */\n public registerRoutingInstrumentation(\n listener: TransactionCreator,\n beforeNavigate: BeforeNavigate,\n onConfirmRoute: OnConfirmRoute,\n ): void {\n super.registerRoutingInstrumentation(listener, beforeNavigate, onConfirmRoute);\n\n // We create an initial state here to ensure a transaction gets created before the first route mounts.\n if (!this._initialStateHandled) {\n this._onDispatch();\n if (this._navigationContainer) {\n // Navigation container already registered, just populate with route state\n this._onStateChange();\n\n this._initialStateHandled = true;\n }\n }\n }\n\n /**\n * Pass the ref to the navigation container to register it to the instrumentation\n * @param navigationContainerRef Ref to a `NavigationContainer`\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types\n public registerNavigationContainer(navigationContainerRef: any): void {\n /* We prevent duplicate routing instrumentation to be initialized on fast refreshes\n\n Explanation: If the user triggers a fast refresh on the file that the instrumentation is\n initialized in, it will initialize a new instance and will cause undefined behavior.\n */\n if (!RN_GLOBAL_OBJ.__sentry_rn_v5_registered) {\n if ('current' in navigationContainerRef) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n this._navigationContainer = navigationContainerRef.current;\n } else {\n this._navigationContainer = navigationContainerRef;\n }\n\n if (this._navigationContainer) {\n this._navigationContainer.addListener(\n '__unsafe_action__', // This action is emitted on every dispatch\n this._onDispatch.bind(this),\n );\n this._navigationContainer.addListener(\n 'state', // This action is emitted on every state change\n this._onStateChange.bind(this),\n );\n\n if (!this._initialStateHandled) {\n if (this._latestTransaction) {\n // If registerRoutingInstrumentation was called first _onDispatch has already been called\n this._onStateChange();\n\n this._initialStateHandled = true;\n } else {\n logger.log(\n '[ReactNavigationInstrumentation] Navigation container registered, but integration has not been setup yet.',\n );\n }\n }\n\n RN_GLOBAL_OBJ.__sentry_rn_v5_registered = true;\n } else {\n logger.warn('[ReactNavigationInstrumentation] Received invalid navigation container ref!');\n }\n } else {\n logger.log(\n '[ReactNavigationInstrumentation] Instrumentation already exists, but register has been called again, doing nothing.',\n );\n }\n }\n\n /**\n * To be called on every React-Navigation action dispatch.\n * It does not name the transaction or populate it with route information. Instead, it waits for the state to fully change\n * and gets the route information from there, @see _onStateChange\n */\n private _onDispatch(): void {\n if (this._latestTransaction) {\n logger.log(\n '[ReactNavigationInstrumentation] A transaction was detected that turned out to be a noop, discarding.',\n );\n this._discardLatestTransaction();\n this._clearStateChangeTimeout();\n }\n\n this._latestTransaction = this.onRouteWillChange(\n getBlankTransactionContext(ReactNavigationInstrumentation.instrumentationName),\n );\n\n if (this._options.enableTimeToInitialDisplay) {\n this._navigationProcessingSpan = startInactiveSpan({\n op: 'navigation.processing',\n name: 'Navigation processing',\n startTimestamp: this._latestTransaction?.startTimestamp,\n });\n }\n\n this._stateChangeTimeout = setTimeout(\n this._discardLatestTransaction.bind(this),\n this._options.routeChangeTimeoutMs,\n );\n }\n\n /**\n * To be called AFTER the state has been changed to populate the transaction with the current route.\n */\n private _onStateChange(): void {\n const stateChangedTimestamp = timestampInSeconds();\n\n // Use the getCurrentRoute method to be accurate.\n const previousRoute = this._latestRoute;\n\n if (!this._navigationContainer) {\n logger.warn(\n '[ReactNavigationInstrumentation] Missing navigation container ref. Route transactions will not be sent.',\n );\n\n return;\n }\n\n const route = this._navigationContainer.getCurrentRoute();\n\n if (route) {\n if (this._latestTransaction) {\n if (!previousRoute || previousRoute.key !== route.key) {\n const routeHasBeenSeen = this._recentRouteKeys.includes(route.key);\n const latestTransaction = this._latestTransaction;\n const latestTtidSpan =\n !routeHasBeenSeen &&\n this._options.enableTimeToInitialDisplay &&\n startTimeToInitialDisplaySpan({\n name: `${route.name} initial display`,\n isAutoInstrumented: true,\n });\n\n if (!routeHasBeenSeen && latestTtidSpan) {\n this._newScreenFrameEventEmitter?.onceNewFrame(({ newFrameTimestampInSeconds }: NewFrameEvent) => {\n const activeSpan = getActiveSpan();\n if (activeSpan && manualInitialDisplaySpans.has(activeSpan)) {\n logger.warn(\n '[ReactNavigationInstrumentation] Detected manual instrumentation for the current active span.',\n );\n return;\n }\n\n latestTtidSpan.setStatus('ok');\n latestTtidSpan.end(newFrameTimestampInSeconds);\n setSpanDurationAsMeasurementOnTransaction(latestTransaction, 'time_to_initial_display', latestTtidSpan);\n });\n }\n\n this._navigationProcessingSpan?.updateName(`Processing navigation to ${route.name}`);\n this._navigationProcessingSpan?.setStatus('ok');\n this._navigationProcessingSpan?.end(stateChangedTimestamp);\n this._navigationProcessingSpan = undefined;\n\n const originalContext = latestTransaction.toContext() as typeof BLANK_TRANSACTION_CONTEXT;\n\n const data: RouteChangeContextData = {\n ...originalContext.data,\n route: {\n name: route.name,\n key: route.key,\n // TODO: filter PII params instead of dropping them all\n params: {},\n hasBeenSeen: routeHasBeenSeen,\n },\n previousRoute: previousRoute\n ? {\n name: previousRoute.name,\n key: previousRoute.key,\n // TODO: filter PII params instead of dropping them all\n params: {},\n }\n : null,\n };\n\n const updatedContext: ReactNavigationTransactionContext = {\n ...originalContext,\n name: route.name,\n tags: {\n ...originalContext.tags,\n 'routing.route.name': route.name,\n },\n data,\n };\n\n const finalContext = this._prepareFinalContext(updatedContext);\n latestTransaction.updateWithContext(finalContext);\n\n const isCustomName = updatedContext.name !== finalContext.name;\n latestTransaction.setName(\n finalContext.name,\n isCustomName ? customTransactionSource : defaultTransactionSource,\n );\n\n this._onConfirmRoute?.(finalContext);\n }\n\n this._pushRecentRouteKey(route.key);\n this._latestRoute = route;\n\n // Clear the latest transaction as it has been handled.\n this._latestTransaction = undefined;\n }\n }\n }\n\n /** Creates final transaction context before confirmation */\n private _prepareFinalContext(updatedContext: TransactionContext): TransactionContext {\n let finalContext = this._beforeNavigate?.({ ...updatedContext });\n\n // This block is to catch users not returning a transaction context\n if (!finalContext) {\n logger.error(\n `[ReactNavigationInstrumentation] beforeNavigate returned ${finalContext}, return context.sampled = false to not send transaction.`,\n );\n\n finalContext = {\n ...updatedContext,\n sampled: false,\n };\n }\n\n // Note: finalContext.sampled will be false at this point only if the user sets it to be so in beforeNavigate.\n if (finalContext.sampled === false) {\n logger.log(\n `[ReactNavigationInstrumentation] Will not send transaction \"${finalContext.name}\" due to beforeNavigate.`,\n );\n } else {\n // Clear the timeout so the transaction does not get cancelled.\n this._clearStateChangeTimeout();\n }\n\n return finalContext;\n }\n\n /** Pushes a recent route key, and removes earlier routes when there is greater than the max length */\n private _pushRecentRouteKey = (key: string): void => {\n this._recentRouteKeys.push(key);\n\n if (this._recentRouteKeys.length > this._maxRecentRouteLen) {\n this._recentRouteKeys = this._recentRouteKeys.slice(this._recentRouteKeys.length - this._maxRecentRouteLen);\n }\n };\n\n /** Cancels the latest transaction so it does not get sent to Sentry. */\n private _discardLatestTransaction(): void {\n if (this._latestTransaction) {\n this._latestTransaction.sampled = false;\n this._latestTransaction.finish();\n this._latestTransaction = undefined;\n }\n if (this._navigationProcessingSpan) {\n this._navigationProcessingSpan = undefined;\n }\n }\n\n /**\n *\n */\n private _clearStateChangeTimeout(): void {\n if (typeof this._stateChangeTimeout !== 'undefined') {\n clearTimeout(this._stateChangeTimeout);\n this._stateChangeTimeout = undefined;\n }\n }\n}\n\n/**\n * Backwards compatibility alias for ReactNavigationInstrumentation\n * @deprecated Use ReactNavigationInstrumentation\n */\nexport const ReactNavigationV5Instrumentation = ReactNavigationInstrumentation;\n\nexport const BLANK_TRANSACTION_CONTEXT = {\n name: 'Route Change',\n op: 'navigation',\n tags: {\n 'routing.instrumentation': ReactNavigationInstrumentation.instrumentationName,\n },\n data: {},\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timetodisplay.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/timetodisplay.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAC,gBAAgB,EAAG,MAAM,eAAe,CAAC;AAE5D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"timetodisplay.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/timetodisplay.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAC,gBAAgB,EAAG,MAAM,eAAe,CAAC;AAE5D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAS/B;;GAEG;AACH,eAAO,MAAM,yBAAyB,qBAA4B,CAAC;AAOnE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,kBAAkB,GAAG,KAAK,CAAC,YAAY,CAQlF;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,kBAAkB,GAAG,KAAK,CAAC,YAAY,CAG/E;AAgCD;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,GAAG,MAAM,CAAC,GAAG;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B,GACA,IAAI,GAAG,SAAS,CAiClB;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,GAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,GAAG,MAAM,CAAC,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAEnF,GACA,IAAI,GAAG,SAAS,CAoDlB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getActiveSpan, Span as SpanClass, spanToJSON, startInactiveSpan } from '@sentry/core';
|
|
2
2
|
import { fill, logger } from '@sentry/utils';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
+
import { isTurboModuleEnabled } from '../utils/environment';
|
|
4
5
|
import { getRNSentryOnDrawReporter, nativeComponentExists } from './timetodisplaynative';
|
|
5
6
|
import { setSpanDurationAsMeasurement } from './utils';
|
|
6
7
|
let nativeComponentMissingLogged = false;
|
|
@@ -40,7 +41,8 @@ export function TimeToFullDisplay(props) {
|
|
|
40
41
|
}
|
|
41
42
|
function TimeToDisplay(props) {
|
|
42
43
|
const RNSentryOnDrawReporter = getRNSentryOnDrawReporter();
|
|
43
|
-
|
|
44
|
+
const isNewArchitecture = isTurboModuleEnabled();
|
|
45
|
+
if (__DEV__ && (isNewArchitecture || (!nativeComponentExists && !nativeComponentMissingLogged))) {
|
|
44
46
|
nativeComponentMissingLogged = true;
|
|
45
47
|
// Using setTimeout with a delay of 0 milliseconds to defer execution and avoid printing the React stack trace.
|
|
46
48
|
setTimeout(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timetodisplay.js","sourceRoot":"","sources":["../../../src/js/tracing/timetodisplay.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,IAAI,IAAI,SAAS,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAE/F,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAEzF,OAAO,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAC;AAEvD,IAAI,4BAA4B,GAAG,KAAK,CAAC;AAEzC;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,OAAO,EAAc,CAAC;AAEnE;;GAEG;AACH,MAAM,+BAA+B,GAAG,IAAI,OAAO,EAAc,CAAC;AAOlE;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAyB;IAC5D,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IACnC,IAAI,UAAU,EAAE;QACd,yBAAyB,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAChD,6BAA6B,EAAE,CAAC;KACjC;IAED,OAAO,oBAAC,aAAa,IAAC,cAAc,EAAE,KAAK,CAAC,MAAM,IAAG,KAAK,CAAC,QAAQ,CAAiB,CAAC;AACvF,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAyB;IACzD,0BAA0B,EAAE,CAAC;IAC7B,OAAO,oBAAC,aAAa,IAAC,WAAW,EAAE,KAAK,CAAC,MAAM,IAAG,KAAK,CAAC,QAAQ,CAAiB,CAAC;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qB,EAAE;QACtD,MAAM,CAAC,IAAI,CAAC,4GAA4G,CAAC,CAAC;QAC1H,IAAI,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;KACtC;SAAM;QACL,IAAI,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;KACjC;IAED,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACrB,MAAM,CAAC,KAAK,CAAC,mBAAmB,QAAQ,CAAC,WAAW,KAAK,QAAQ,CAAC,OAAO,oCAAoC,CAAC,CAAC;IAE/G,4BAA4B,CAAC,sBAAsB,EAAE,IAAI,CAAC,CAAC;AAC7D,CAAC","sourcesContent":["import { getActiveSpan, Span as SpanClass, spanToJSON, startInactiveSpan } from '@sentry/core';\nimport type { Span,StartSpanOptions } from '@sentry/types';\nimport { fill, logger } from '@sentry/utils';\nimport * as React from 'react';\n\nimport { getRNSentryOnDrawReporter, nativeComponentExists } from './timetodisplaynative';\nimport type {RNSentryOnDrawNextFrameEvent } from './timetodisplaynative.types';\nimport { setSpanDurationAsMeasurement } from './utils';\n\nlet nativeComponentMissingLogged = false;\n\n/**\n * Flags of active spans with manual initial display.\n */\nexport const manualInitialDisplaySpans = new WeakMap<Span, true>();\n\n/**\n * Flag full display called before initial display for an active span.\n */\nconst fullDisplayBeforeInitialDisplay = new WeakMap<Span, true>();\n\nexport type TimeToDisplayProps = {\n children?: React.ReactNode;\n record?: boolean;\n};\n\n/**\n * Component to measure time to initial display.\n *\n * The initial display is recorded when the component prop `record` is true.\n *\n * <TimeToInitialDisplay record />\n */\nexport function TimeToInitialDisplay(props: TimeToDisplayProps): React.ReactElement {\n const activeSpan = getActiveSpan();\n if (activeSpan) {\n manualInitialDisplaySpans.set(activeSpan, true);\n startTimeToInitialDisplaySpan();\n }\n\n return <TimeToDisplay initialDisplay={props.record}>{props.children}</TimeToDisplay>;\n}\n\n/**\n * Component to measure time to full display.\n *\n * The initial display is recorded when the component prop `record` is true.\n *\n * <TimeToInitialDisplay record />\n */\nexport function TimeToFullDisplay(props: TimeToDisplayProps): React.ReactElement {\n startTimeToFullDisplaySpan();\n return <TimeToDisplay fullDisplay={props.record}>{props.children}</TimeToDisplay>;\n}\n\nfunction TimeToDisplay(props: {\n children?: React.ReactNode;\n initialDisplay?: boolean;\n fullDisplay?: boolean;\n}): React.ReactElement {\n const RNSentryOnDrawReporter = getRNSentryOnDrawReporter();\n\n if (__DEV__ && !nativeComponentMissingLogged && !nativeComponentExists) {\n nativeComponentMissingLogged = true;\n // Using setTimeout with a delay of 0 milliseconds to defer execution and avoid printing the React stack trace.\n setTimeout(() => {\n logger.warn('TimeToInitialDisplay and TimeToFullDisplay are not supported on the web, Expo Go and New Architecture. Run native build or report an issue at https://github.com/getsentry/sentry-react-native');\n }, 0);\n }\n\n const onDraw = (event: { nativeEvent: RNSentryOnDrawNextFrameEvent }): void => onDrawNextFrame(event);\n\n return (\n <>\n <RNSentryOnDrawReporter\n onDrawNextFrame={onDraw}\n initialDisplay={props.initialDisplay}\n fullDisplay={props.fullDisplay} />\n {props.children}\n </>\n );\n}\n\n/**\n * Starts a new span for the initial display.\n *\n * Returns current span if already exists in the currently active span.\n */\nexport function startTimeToInitialDisplaySpan(\n options?: Omit<StartSpanOptions, 'op' | 'name'> & {\n name?: string;\n isAutoInstrumented?: boolean\n },\n): Span | undefined {\n const activeSpan = getActiveSpan();\n if (!activeSpan) {\n logger.warn(`[TimeToDisplay] No active span found to attach ui.load.initial_display to.`);\n return;\n }\n\n if (!(activeSpan instanceof SpanClass)) {\n logger.warn(`[TimeToDisplay] Active span is not instance of Span class.`);\n return;\n }\n\n const existingSpan = activeSpan.spanRecorder?.spans.find((span) => spanToJSON(span).op === 'ui.load.initial_display');\n if (existingSpan) {\n logger.debug(`[TimeToDisplay] Found existing ui.load.initial_display span.`);\n return existingSpan\n }\n\n const initialDisplaySpan = startInactiveSpan({\n op: 'ui.load.initial_display',\n name: 'Time To Initial Display',\n startTimestamp: spanToJSON(activeSpan).start_timestamp,\n ...options,\n });\n\n if (!initialDisplaySpan) {\n return;\n }\n\n if (!options?.isAutoInstrumented) {\n manualInitialDisplaySpans.set(activeSpan, true);\n }\n return initialDisplaySpan;\n}\n\n/**\n * Starts a new span for the full display.\n *\n * Returns current span if already exists in the currently active span.\n */\nexport function startTimeToFullDisplaySpan(\n options: Omit<StartSpanOptions, 'op' | 'name'> & { name?: string, timeoutMs?: number } = {\n timeoutMs: 30_000,\n },\n): Span | undefined {\n const activeSpan = getActiveSpan();\n if (!activeSpan) {\n logger.warn(`[TimeToDisplay] No active span found to attach ui.load.full_display to.`);\n return;\n }\n\n if (!(activeSpan instanceof SpanClass)) {\n logger.warn(`[TimeToDisplay] Active span is not instance of Span class.`);\n return;\n }\n\n const descendantSpans = activeSpan.spanRecorder?.spans || [];\n\n const initialDisplaySpan = descendantSpans.find((span) => spanToJSON(span).op === 'ui.load.initial_display');\n if (!initialDisplaySpan) {\n logger.warn(`[TimeToDisplay] No initial display span found to attach ui.load.full_display to.`);\n return;\n }\n\n const existingSpan = descendantSpans.find((span) => spanToJSON(span).op === 'ui.load.full_display');\n if (existingSpan) {\n logger.debug(`[TimeToDisplay] Found existing ui.load.full_display span.`);\n return existingSpan;\n }\n\n const fullDisplaySpan = startInactiveSpan({\n op: 'ui.load.full_display',\n name: 'Time To Full Display',\n startTimestamp: spanToJSON(initialDisplaySpan).start_timestamp,\n ...options,\n });\n if (!fullDisplaySpan) {\n return;\n }\n\n const timeout = setTimeout(() => {\n if (spanToJSON(fullDisplaySpan).timestamp) {\n return;\n }\n fullDisplaySpan.setStatus('deadline_exceeded');\n fullDisplaySpan.end(spanToJSON(initialDisplaySpan).timestamp);\n setSpanDurationAsMeasurement('time_to_full_display', fullDisplaySpan);\n logger.warn(`[TimeToDisplay] Full display span deadline_exceeded.`);\n }, options.timeoutMs);\n\n fill(fullDisplaySpan, 'end', (originalEnd: SpanClass['end']) => (endTimestamp?: Parameters<SpanClass['end']>[0]) => {\n clearTimeout(timeout);\n originalEnd.call(fullDisplaySpan, endTimestamp);\n });\n\n return fullDisplaySpan;\n}\n\nfunction onDrawNextFrame(event: { nativeEvent: RNSentryOnDrawNextFrameEvent }): void {\n logger.debug(`[TimeToDisplay] onDrawNextFrame: ${JSON.stringify(event.nativeEvent)}`);\n if (event.nativeEvent.type === 'fullDisplay') {\n return updateFullDisplaySpan(event.nativeEvent.newFrameTimestampInSeconds);\n }\n if (event.nativeEvent.type === 'initialDisplay') {\n return updateInitialDisplaySpan(event.nativeEvent.newFrameTimestampInSeconds);\n }\n}\n\nfunction updateInitialDisplaySpan(frameTimestampSeconds: number): void {\n const span = startTimeToInitialDisplaySpan();\n if (!span) {\n logger.warn(`[TimeToDisplay] No span found or created, possibly performance is disabled.`);\n return;\n }\n\n const activeSpan = getActiveSpan();\n if (!activeSpan) {\n logger.warn(`[TimeToDisplay] No active span found to attach ui.load.initial_display to.`);\n return;\n }\n\n if (spanToJSON(span).parent_span_id !== spanToJSON(activeSpan).span_id) {\n logger.warn(`[TimeToDisplay] Initial display span is not a child of current active span.`);\n return;\n }\n\n if (spanToJSON(span).timestamp) {\n logger.warn(`[TimeToDisplay] ${spanToJSON(span).description} span already ended.`);\n return;\n }\n\n span.end(frameTimestampSeconds);\n span.setStatus('ok');\n logger.debug(`[TimeToDisplay] ${spanToJSON(span).description} span updated with end timestamp.`);\n\n if (fullDisplayBeforeInitialDisplay.has(activeSpan)) {\n fullDisplayBeforeInitialDisplay.delete(activeSpan);\n logger.debug(`[TimeToDisplay] Updating full display with initial display (${span.spanContext().spanId}) end.`);\n updateFullDisplaySpan(frameTimestampSeconds, span);\n }\n\n setSpanDurationAsMeasurement('time_to_initial_display', span);\n}\n\nfunction updateFullDisplaySpan(frameTimestampSeconds: number, passedInitialDisplaySpan?: Span): void {\n const activeSpan = getActiveSpan();\n if (!activeSpan) {\n logger.warn(`[TimeToDisplay] No active span found to update ui.load.full_display in.`);\n return;\n }\n\n if (!(activeSpan instanceof SpanClass)) {\n logger.warn(`[TimeToDisplay] Active span is not instance of Span class.`);\n return;\n }\n\n const existingInitialDisplaySpan = passedInitialDisplaySpan\n || activeSpan.spanRecorder?.spans.find((span) => spanToJSON(span).op === 'ui.load.initial_display');\n const initialDisplayEndTimestamp = existingInitialDisplaySpan && spanToJSON(existingInitialDisplaySpan).timestamp;\n if (!initialDisplayEndTimestamp) {\n fullDisplayBeforeInitialDisplay.set(activeSpan, true);\n logger.warn(`[TimeToDisplay] Full display called before initial display for active span (${activeSpan.spanContext().spanId}).`);\n return;\n }\n\n const span = startTimeToFullDisplaySpan();\n if (!span) {\n logger.warn(`[TimeToDisplay] No TimeToFullDisplay span found or created, possibly performance is disabled.`);\n return;\n }\n\n const spanJSON = spanToJSON(span);\n if (spanJSON.timestamp) {\n logger.warn(`[TimeToDisplay] ${spanJSON.description} (${spanJSON.span_id}) span already ended.`);\n return;\n }\n\n if (initialDisplayEndTimestamp > frameTimestampSeconds) {\n logger.warn(`[TimeToDisplay] Using initial display end. Full display end frame timestamp is before initial display end.`);\n span.end(initialDisplayEndTimestamp);\n } else {\n span.end(frameTimestampSeconds);\n }\n\n span.setStatus('ok');\n logger.debug(`[TimeToDisplay] ${spanJSON.description} (${spanJSON.span_id}) span updated with end timestamp.`);\n\n setSpanDurationAsMeasurement('time_to_full_display', span);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"timetodisplay.js","sourceRoot":"","sources":["../../../src/js/tracing/timetodisplay.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,IAAI,IAAI,SAAS,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAE/F,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAEzF,OAAO,EAA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Span as SpanClass, spanToJSON, startInactiveSpan } from '@sentry/core';\nimport type { Span,StartSpanOptions } from '@sentry/types';\nimport { fill, logger } from '@sentry/utils';\nimport * as React from 'react';\n\nimport { isTurboModuleEnabled } from '../utils/environment';\nimport { getRNSentryOnDrawReporter, nativeComponentExists } from './timetodisplaynative';\nimport type {RNSentryOnDrawNextFrameEvent } from './timetodisplaynative.types';\nimport { setSpanDurationAsMeasurement } from './utils';\n\nlet nativeComponentMissingLogged = false;\n\n/**\n * Flags of active spans with manual initial display.\n */\nexport const manualInitialDisplaySpans = new WeakMap<Span, true>();\n\n/**\n * Flag full display called before initial display for an active span.\n */\nconst fullDisplayBeforeInitialDisplay = new WeakMap<Span, true>();\n\nexport type TimeToDisplayProps = {\n children?: React.ReactNode;\n record?: boolean;\n};\n\n/**\n * Component to measure time to initial display.\n *\n * The initial display is recorded when the component prop `record` is true.\n *\n * <TimeToInitialDisplay record />\n */\nexport function TimeToInitialDisplay(props: TimeToDisplayProps): React.ReactElement {\n const activeSpan = getActiveSpan();\n if (activeSpan) {\n manualInitialDisplaySpans.set(activeSpan, true);\n startTimeToInitialDisplaySpan();\n }\n\n return <TimeToDisplay initialDisplay={props.record}>{props.children}</TimeToDisplay>;\n}\n\n/**\n * Component to measure time to full display.\n *\n * The initial display is recorded when the component prop `record` is true.\n *\n * <TimeToInitialDisplay record />\n */\nexport function TimeToFullDisplay(props: TimeToDisplayProps): React.ReactElement {\n startTimeToFullDisplaySpan();\n return <TimeToDisplay fullDisplay={props.record}>{props.children}</TimeToDisplay>;\n}\n\nfunction TimeToDisplay(props: {\n children?: React.ReactNode;\n initialDisplay?: boolean;\n fullDisplay?: boolean;\n}): React.ReactElement {\n const RNSentryOnDrawReporter = getRNSentryOnDrawReporter();\n const isNewArchitecture = isTurboModuleEnabled();\n\n if (__DEV__ && (isNewArchitecture || (!nativeComponentExists && !nativeComponentMissingLogged))){\n nativeComponentMissingLogged = true;\n // Using setTimeout with a delay of 0 milliseconds to defer execution and avoid printing the React stack trace.\n setTimeout(() => {\n logger.warn(\n 'TimeToInitialDisplay and TimeToFullDisplay are not supported on the web, Expo Go and New Architecture. Run native build or report an issue at https://github.com/getsentry/sentry-react-native');\n }, 0);\n }\n\n const onDraw = (event: { nativeEvent: RNSentryOnDrawNextFrameEvent }): void => onDrawNextFrame(event);\n\n return (\n <>\n <RNSentryOnDrawReporter\n onDrawNextFrame={onDraw}\n initialDisplay={props.initialDisplay}\n fullDisplay={props.fullDisplay} />\n {props.children}\n </>\n );\n}\n\n/**\n * Starts a new span for the initial display.\n *\n * Returns current span if already exists in the currently active span.\n */\nexport function startTimeToInitialDisplaySpan(\n options?: Omit<StartSpanOptions, 'op' | 'name'> & {\n name?: string;\n isAutoInstrumented?: boolean\n },\n): Span | undefined {\n const activeSpan = getActiveSpan();\n if (!activeSpan) {\n logger.warn(`[TimeToDisplay] No active span found to attach ui.load.initial_display to.`);\n return;\n }\n\n if (!(activeSpan instanceof SpanClass)) {\n logger.warn(`[TimeToDisplay] Active span is not instance of Span class.`);\n return;\n }\n\n const existingSpan = activeSpan.spanRecorder?.spans.find((span) => spanToJSON(span).op === 'ui.load.initial_display');\n if (existingSpan) {\n logger.debug(`[TimeToDisplay] Found existing ui.load.initial_display span.`);\n return existingSpan\n }\n\n const initialDisplaySpan = startInactiveSpan({\n op: 'ui.load.initial_display',\n name: 'Time To Initial Display',\n startTimestamp: spanToJSON(activeSpan).start_timestamp,\n ...options,\n });\n\n if (!initialDisplaySpan) {\n return;\n }\n\n if (!options?.isAutoInstrumented) {\n manualInitialDisplaySpans.set(activeSpan, true);\n }\n return initialDisplaySpan;\n}\n\n/**\n * Starts a new span for the full display.\n *\n * Returns current span if already exists in the currently active span.\n */\nexport function startTimeToFullDisplaySpan(\n options: Omit<StartSpanOptions, 'op' | 'name'> & { name?: string, timeoutMs?: number } = {\n timeoutMs: 30_000,\n },\n): Span | undefined {\n const activeSpan = getActiveSpan();\n if (!activeSpan) {\n logger.warn(`[TimeToDisplay] No active span found to attach ui.load.full_display to.`);\n return;\n }\n\n if (!(activeSpan instanceof SpanClass)) {\n logger.warn(`[TimeToDisplay] Active span is not instance of Span class.`);\n return;\n }\n\n const descendantSpans = activeSpan.spanRecorder?.spans || [];\n\n const initialDisplaySpan = descendantSpans.find((span) => spanToJSON(span).op === 'ui.load.initial_display');\n if (!initialDisplaySpan) {\n logger.warn(`[TimeToDisplay] No initial display span found to attach ui.load.full_display to.`);\n return;\n }\n\n const existingSpan = descendantSpans.find((span) => spanToJSON(span).op === 'ui.load.full_display');\n if (existingSpan) {\n logger.debug(`[TimeToDisplay] Found existing ui.load.full_display span.`);\n return existingSpan;\n }\n\n const fullDisplaySpan = startInactiveSpan({\n op: 'ui.load.full_display',\n name: 'Time To Full Display',\n startTimestamp: spanToJSON(initialDisplaySpan).start_timestamp,\n ...options,\n });\n if (!fullDisplaySpan) {\n return;\n }\n\n const timeout = setTimeout(() => {\n if (spanToJSON(fullDisplaySpan).timestamp) {\n return;\n }\n fullDisplaySpan.setStatus('deadline_exceeded');\n fullDisplaySpan.end(spanToJSON(initialDisplaySpan).timestamp);\n setSpanDurationAsMeasurement('time_to_full_display', fullDisplaySpan);\n logger.warn(`[TimeToDisplay] Full display span deadline_exceeded.`);\n }, options.timeoutMs);\n\n fill(fullDisplaySpan, 'end', (originalEnd: SpanClass['end']) => (endTimestamp?: Parameters<SpanClass['end']>[0]) => {\n clearTimeout(timeout);\n originalEnd.call(fullDisplaySpan, endTimestamp);\n });\n\n return fullDisplaySpan;\n}\n\nfunction onDrawNextFrame(event: { nativeEvent: RNSentryOnDrawNextFrameEvent }): void {\n logger.debug(`[TimeToDisplay] onDrawNextFrame: ${JSON.stringify(event.nativeEvent)}`);\n if (event.nativeEvent.type === 'fullDisplay') {\n return updateFullDisplaySpan(event.nativeEvent.newFrameTimestampInSeconds);\n }\n if (event.nativeEvent.type === 'initialDisplay') {\n return updateInitialDisplaySpan(event.nativeEvent.newFrameTimestampInSeconds);\n }\n}\n\nfunction updateInitialDisplaySpan(frameTimestampSeconds: number): void {\n const span = startTimeToInitialDisplaySpan();\n if (!span) {\n logger.warn(`[TimeToDisplay] No span found or created, possibly performance is disabled.`);\n return;\n }\n\n const activeSpan = getActiveSpan();\n if (!activeSpan) {\n logger.warn(`[TimeToDisplay] No active span found to attach ui.load.initial_display to.`);\n return;\n }\n\n if (spanToJSON(span).parent_span_id !== spanToJSON(activeSpan).span_id) {\n logger.warn(`[TimeToDisplay] Initial display span is not a child of current active span.`);\n return;\n }\n\n if (spanToJSON(span).timestamp) {\n logger.warn(`[TimeToDisplay] ${spanToJSON(span).description} span already ended.`);\n return;\n }\n\n span.end(frameTimestampSeconds);\n span.setStatus('ok');\n logger.debug(`[TimeToDisplay] ${spanToJSON(span).description} span updated with end timestamp.`);\n\n if (fullDisplayBeforeInitialDisplay.has(activeSpan)) {\n fullDisplayBeforeInitialDisplay.delete(activeSpan);\n logger.debug(`[TimeToDisplay] Updating full display with initial display (${span.spanContext().spanId}) end.`);\n updateFullDisplaySpan(frameTimestampSeconds, span);\n }\n\n setSpanDurationAsMeasurement('time_to_initial_display', span);\n}\n\nfunction updateFullDisplaySpan(frameTimestampSeconds: number, passedInitialDisplaySpan?: Span): void {\n const activeSpan = getActiveSpan();\n if (!activeSpan) {\n logger.warn(`[TimeToDisplay] No active span found to update ui.load.full_display in.`);\n return;\n }\n\n if (!(activeSpan instanceof SpanClass)) {\n logger.warn(`[TimeToDisplay] Active span is not instance of Span class.`);\n return;\n }\n\n const existingInitialDisplaySpan = passedInitialDisplaySpan\n || activeSpan.spanRecorder?.spans.find((span) => spanToJSON(span).op === 'ui.load.initial_display');\n const initialDisplayEndTimestamp = existingInitialDisplaySpan && spanToJSON(existingInitialDisplaySpan).timestamp;\n if (!initialDisplayEndTimestamp) {\n fullDisplayBeforeInitialDisplay.set(activeSpan, true);\n logger.warn(`[TimeToDisplay] Full display called before initial display for active span (${activeSpan.spanContext().spanId}).`);\n return;\n }\n\n const span = startTimeToFullDisplaySpan();\n if (!span) {\n logger.warn(`[TimeToDisplay] No TimeToFullDisplay span found or created, possibly performance is disabled.`);\n return;\n }\n\n const spanJSON = spanToJSON(span);\n if (spanJSON.timestamp) {\n logger.warn(`[TimeToDisplay] ${spanJSON.description} (${spanJSON.span_id}) span already ended.`);\n return;\n }\n\n if (initialDisplayEndTimestamp > frameTimestampSeconds) {\n logger.warn(`[TimeToDisplay] Using initial display end. Full display end frame timestamp is before initial display end.`);\n span.end(initialDisplayEndTimestamp);\n } else {\n span.end(frameTimestampSeconds);\n }\n\n span.setStatus('ok');\n logger.debug(`[TimeToDisplay] ${spanJSON.description} (${spanJSON.span_id}) span updated with end timestamp.`);\n\n setSpanDurationAsMeasurement('time_to_full_display', span);\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { SentryEventEmitter } from './sentryeventemitter';
|
|
2
|
+
export declare const FALLBACK_TIMEOUT_MS = 10000;
|
|
3
|
+
export type FallBackNewFrameEvent = {
|
|
4
|
+
newFrameTimestampInSeconds: number;
|
|
5
|
+
isFallback?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export interface SentryEventEmitterFallback {
|
|
8
|
+
/**
|
|
9
|
+
* Initializes the fallback event emitter
|
|
10
|
+
* This method is synchronous in JS but the event emitter starts asynchronously.
|
|
11
|
+
*/
|
|
12
|
+
initAsync: () => void;
|
|
13
|
+
onceNewFrame: (listener: (event: FallBackNewFrameEvent) => void) => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates emitter that allows to listen to UI Frame events when ready.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createSentryFallbackEventEmitter(emitter?: SentryEventEmitter, fallbackTimeoutMs?: number): SentryEventEmitterFallback;
|
|
19
|
+
//# sourceMappingURL=sentryeventemitterfallback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sentryeventemitterfallback.d.ts","sourceRoot":"","sources":["../../../src/js/utils/sentryeventemitterfallback.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAiB,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG9E,eAAO,MAAM,mBAAmB,QAAS,CAAC;AAE1C,MAAM,MAAM,qBAAqB,GAAG;IAAE,0BAA0B,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AACjG,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,YAAY,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,KAAK,IAAI,CAAC;CAC1E;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAC9C,OAAO,GAAE,kBAA+C,EACxD,iBAAiB,SAAsB,GACtC,0BAA0B,CAyE5B"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { logger, timestampInSeconds } from '@sentry/utils';
|
|
2
|
+
import { NATIVE } from '../wrapper';
|
|
3
|
+
import { createSentryEventEmitter, NewFrameEventName } from './sentryeventemitter';
|
|
4
|
+
export const FALLBACK_TIMEOUT_MS = 10000;
|
|
5
|
+
/**
|
|
6
|
+
* Creates emitter that allows to listen to UI Frame events when ready.
|
|
7
|
+
*/
|
|
8
|
+
export function createSentryFallbackEventEmitter(emitter = createSentryEventEmitter(), fallbackTimeoutMs = FALLBACK_TIMEOUT_MS) {
|
|
9
|
+
let fallbackTimeout;
|
|
10
|
+
let animationFrameTimestampSeconds;
|
|
11
|
+
let nativeNewFrameTimestampSeconds;
|
|
12
|
+
function getAnimationFrameTimestampSeconds() {
|
|
13
|
+
// https://reactnative.dev/docs/timers#timers
|
|
14
|
+
// NOTE: The current implementation of requestAnimationFrame is the same
|
|
15
|
+
// as setTimeout(0). This isn't exactly how requestAnimationFrame
|
|
16
|
+
// is supposed to work on web, so it doesn't get called when UI Frames are rendered.: https://github.com/facebook/react-native/blob/5106933c750fee2ce49fe1945c3e3763eebc92bc/packages/react-native/ReactCommon/react/runtime/TimerManager.cpp#L442-L443
|
|
17
|
+
requestAnimationFrame(() => {
|
|
18
|
+
if (fallbackTimeout === undefined) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
animationFrameTimestampSeconds = timestampInSeconds();
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function getNativeNewFrameTimestampSeconds() {
|
|
25
|
+
NATIVE.getNewScreenTimeToDisplay()
|
|
26
|
+
.then(resolve => {
|
|
27
|
+
if (fallbackTimeout === undefined) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
nativeNewFrameTimestampSeconds = resolve !== null && resolve !== void 0 ? resolve : undefined;
|
|
31
|
+
})
|
|
32
|
+
.catch(reason => {
|
|
33
|
+
logger.error('Failed to receive Native fallback timestamp.', reason);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
initAsync() {
|
|
38
|
+
emitter.initAsync(NewFrameEventName);
|
|
39
|
+
},
|
|
40
|
+
onceNewFrame(listener) {
|
|
41
|
+
animationFrameTimestampSeconds = undefined;
|
|
42
|
+
nativeNewFrameTimestampSeconds = undefined;
|
|
43
|
+
const internalListener = (event) => {
|
|
44
|
+
if (fallbackTimeout !== undefined) {
|
|
45
|
+
clearTimeout(fallbackTimeout);
|
|
46
|
+
fallbackTimeout = undefined;
|
|
47
|
+
}
|
|
48
|
+
animationFrameTimestampSeconds = undefined;
|
|
49
|
+
nativeNewFrameTimestampSeconds = undefined;
|
|
50
|
+
listener(event);
|
|
51
|
+
};
|
|
52
|
+
fallbackTimeout = setTimeout(() => {
|
|
53
|
+
if (nativeNewFrameTimestampSeconds) {
|
|
54
|
+
logger.log('Native event emitter did not reply in time');
|
|
55
|
+
return listener({
|
|
56
|
+
newFrameTimestampInSeconds: nativeNewFrameTimestampSeconds,
|
|
57
|
+
isFallback: true,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
else if (animationFrameTimestampSeconds) {
|
|
61
|
+
logger.log('[Sentry] Native event emitter did not reply in time. Using JavaScript fallback emitter.');
|
|
62
|
+
return listener({
|
|
63
|
+
newFrameTimestampInSeconds: animationFrameTimestampSeconds,
|
|
64
|
+
isFallback: true,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
emitter.removeListener(NewFrameEventName, internalListener);
|
|
69
|
+
logger.error('Failed to receive any fallback timestamp.');
|
|
70
|
+
}
|
|
71
|
+
}, fallbackTimeoutMs);
|
|
72
|
+
getNativeNewFrameTimestampSeconds();
|
|
73
|
+
getAnimationFrameTimestampSeconds();
|
|
74
|
+
emitter.once(NewFrameEventName, internalListener);
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=sentryeventemitterfallback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sentryeventemitterfallback.js","sourceRoot":"","sources":["../../../src/js/utils/sentryeventemitterfallback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEnF,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAM,CAAC;AAY1C;;GAEG;AACH,MAAM,UAAU,gCAAgC,CAC9C,UAA8B,wBAAwB,EAAE,EACxD,iBAAiB,GAAG,mBAAmB;IAEvC,IAAI,eAA0D,CAAC;IAC/D,IAAI,8BAAkD,CAAC;IACvD,IAAI,8BAAkD,CAAC;IAEvD,SAAS,iCAAiC;QACxC,6CAA6C;QAC7C,wEAAwE;QACxE,iEAAiE;QACjE,uPAAuP;QACvP,qBAAqB,CAAC,GAAG,EAAE;YACzB,IAAI,eAAe,KAAK,SAAS,EAAE;gBACjC,OAAO;aACR;YACD,8BAA8B,GAAG,kBAAkB,EAAE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;wBAC1D,UAAU,EAAE,IAAI;qBACjB,CAAC,CAAC;iBACJ;qBAAM;oBACL,OAAO,CAAC,cAAc,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,CAAC;oBAC5D,MAAM,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAC;iBAC3D;YACH,CAAC,EAAE,iBAAiB,CAAC,CAAC;YAEtB,iCAAiC,EAAE,CAAC;YACpC,iCAAiC,EAAE,CAAC;YACpC,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,CAAC;QACpD,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { logger, timestampInSeconds } from '@sentry/utils';\n\nimport { NATIVE } from '../wrapper';\nimport type { NewFrameEvent, SentryEventEmitter } from './sentryeventemitter';\nimport { createSentryEventEmitter, NewFrameEventName } from './sentryeventemitter';\n\nexport const FALLBACK_TIMEOUT_MS = 10_000;\n\nexport type FallBackNewFrameEvent = { newFrameTimestampInSeconds: number; isFallback?: boolean };\nexport interface SentryEventEmitterFallback {\n /**\n * Initializes the fallback event emitter\n * This method is synchronous in JS but the event emitter starts asynchronously.\n */\n initAsync: () => void;\n onceNewFrame: (listener: (event: FallBackNewFrameEvent) => void) => void;\n}\n\n/**\n * Creates emitter that allows to listen to UI Frame events when ready.\n */\nexport function createSentryFallbackEventEmitter(\n emitter: SentryEventEmitter = createSentryEventEmitter(),\n fallbackTimeoutMs = FALLBACK_TIMEOUT_MS,\n): SentryEventEmitterFallback {\n let fallbackTimeout: ReturnType<typeof setTimeout> | undefined;\n let animationFrameTimestampSeconds: number | undefined;\n let nativeNewFrameTimestampSeconds: number | undefined;\n\n function getAnimationFrameTimestampSeconds(): void {\n // https://reactnative.dev/docs/timers#timers\n // NOTE: The current implementation of requestAnimationFrame is the same\n // as setTimeout(0). This isn't exactly how requestAnimationFrame\n // is supposed to work on web, so it doesn't get called when UI Frames are rendered.: https://github.com/facebook/react-native/blob/5106933c750fee2ce49fe1945c3e3763eebc92bc/packages/react-native/ReactCommon/react/runtime/TimerManager.cpp#L442-L443\n requestAnimationFrame(() => {\n if (fallbackTimeout === undefined) {\n return;\n }\n animationFrameTimestampSeconds = timestampInSeconds();\n });\n }\n\n function getNativeNewFrameTimestampSeconds(): void {\n NATIVE.getNewScreenTimeToDisplay()\n .then(resolve => {\n if (fallbackTimeout === undefined) {\n return;\n }\n nativeNewFrameTimestampSeconds = resolve ?? undefined;\n })\n .catch(reason => {\n logger.error('Failed to receive Native fallback timestamp.', reason);\n });\n }\n\n return {\n initAsync() {\n emitter.initAsync(NewFrameEventName);\n },\n\n onceNewFrame(listener: (event: FallBackNewFrameEvent) => void) {\n animationFrameTimestampSeconds = undefined;\n nativeNewFrameTimestampSeconds = undefined;\n\n const internalListener = (event: NewFrameEvent): void => {\n if (fallbackTimeout !== undefined) {\n clearTimeout(fallbackTimeout);\n fallbackTimeout = undefined;\n }\n animationFrameTimestampSeconds = undefined;\n nativeNewFrameTimestampSeconds = undefined;\n listener(event);\n };\n fallbackTimeout = setTimeout(() => {\n if (nativeNewFrameTimestampSeconds) {\n logger.log('Native event emitter did not reply in time');\n return listener({\n newFrameTimestampInSeconds: nativeNewFrameTimestampSeconds,\n isFallback: true,\n });\n } else if (animationFrameTimestampSeconds) {\n logger.log('[Sentry] Native event emitter did not reply in time. Using JavaScript fallback emitter.');\n return listener({\n newFrameTimestampInSeconds: animationFrameTimestampSeconds,\n isFallback: true,\n });\n } else {\n emitter.removeListener(NewFrameEventName, internalListener);\n logger.error('Failed to receive any fallback timestamp.');\n }\n }, fallbackTimeoutMs);\n\n getNativeNewFrameTimestampSeconds();\n getAnimationFrameTimestampSeconds();\n emitter.once(NewFrameEventName, internalListener);\n },\n };\n}\n"]}
|
package/dist/js/version.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const SDK_PACKAGE_NAME = "npm:@sentry/react-native";
|
|
2
2
|
export declare const SDK_NAME = "sentry.javascript.react-native";
|
|
3
|
-
export declare const SDK_VERSION = "5.
|
|
3
|
+
export declare const SDK_VERSION = "5.35.0-beta.0";
|
|
4
4
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/js/version.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/js/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,6BAA6B,CAAC;AAC3D,eAAO,MAAM,QAAQ,mCAAmC,CAAC;AACzD,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/js/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,6BAA6B,CAAC;AAC3D,eAAO,MAAM,QAAQ,mCAAmC,CAAC;AACzD,eAAO,MAAM,WAAW,kBAAkB,CAAC"}
|
package/dist/js/version.js
CHANGED
package/dist/js/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/js/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AAC3D,MAAM,CAAC,MAAM,QAAQ,GAAG,gCAAgC,CAAC;AACzD,MAAM,CAAC,MAAM,WAAW,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/js/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AAC3D,MAAM,CAAC,MAAM,QAAQ,GAAG,gCAAgC,CAAC;AACzD,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAC","sourcesContent":["export const SDK_PACKAGE_NAME = 'npm:@sentry/react-native';\nexport const SDK_NAME = 'sentry.javascript.react-native';\nexport const SDK_VERSION = '5.35.0-beta.0';\n"]}
|
package/dist/js/wrapper.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ interface SentryNativeWrapper {
|
|
|
46
46
|
enableNativeFramesTracking(): void;
|
|
47
47
|
addBreadcrumb(breadcrumb: Breadcrumb): void;
|
|
48
48
|
setContext(key: string, context: {
|
|
49
|
-
[key: string]:
|
|
49
|
+
[key: string]: any;
|
|
50
50
|
} | null): void;
|
|
51
51
|
clearBreadcrumbs(): void;
|
|
52
52
|
setExtra(key: string, extra: unknown): void;
|
|
@@ -70,6 +70,7 @@ interface SentryNativeWrapper {
|
|
|
70
70
|
captureReplay(isHardCrash: boolean): Promise<string | null>;
|
|
71
71
|
getCurrentReplayId(): string | null;
|
|
72
72
|
crashedLastRun(): Promise<boolean | null>;
|
|
73
|
+
getNewScreenTimeToDisplay(): Promise<number | null | undefined>;
|
|
73
74
|
}
|
|
74
75
|
/**
|
|
75
76
|
* Our internal interface for calling native functions
|
package/dist/js/wrapper.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapper.d.ts","sourceRoot":"","sources":["../../src/js/wrapper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,KAAK,EACL,OAAO,EACP,aAAa,EACb,IAAI,EACL,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAiB,QAAQ,EAAE,MAAM,cAAc,CAAC;AAGvD,OAAO,KAAK,EACV,sBAAsB,EACtB,4BAA4B,EAC5B,oBAAoB,EACpB,qBAAqB,EAErB,iBAAiB,EACjB,IAAI,EACL,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,KAAK,KAAK,MAAM,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"wrapper.d.ts","sourceRoot":"","sources":["../../src/js/wrapper.ts"],"names":[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IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IACjC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzC,WAAW,IAAI,IAAI,CAAC;IAEpB,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;IACvD,kBAAkB,IAAI,WAAW,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IAErD,cAAc,CAAC,iBAAiB,EAAE,OAAO,GAAG,OAAO,CAAC;IACpD,aAAa,IAAI;QACf,aAAa,EAAE,MAAM,CAAC,OAAO,CAAC;QAC9B,aAAa,CAAC,EAAE,kBAAkB,CAAC;QACnC,cAAc,CAAC,EAAE,yBAAyB,CAAC;KAC5C,GAAG,IAAI,CAAC;IAET,sBAAsB,IAAI,MAAM,GAAG,IAAI,CAAC;IAExC;;OAEG;IACH,wBAAwB,CAAC,gBAAgB,EAAE,MAAM,EAAE,GAAG,iBAAiB,GAAG,IAAI,CAAC;IAC/E,yCAAyC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3D,aAAa,CAAC,WAAW,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC5D,kBAAkB,IAAI,MAAM,GAAG,IAAI,CAAC;IAEpC,cAAc,IAAI,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAC1C,yBAAyB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;CACjE;AAID;;GAEG;AACH,eAAO,MAAM,MAAM,EAAE,mBAopBpB,CAAC"}
|
package/dist/js/wrapper.js
CHANGED
|
@@ -3,6 +3,7 @@ import { logger, normalize, SentryError } from '@sentry/utils';
|
|
|
3
3
|
import { NativeModules, Platform } from 'react-native';
|
|
4
4
|
import { isHardCrash } from './misc';
|
|
5
5
|
import { isTurboModuleEnabled } from './utils/environment';
|
|
6
|
+
import { convertToNormalizedObject } from './utils/normalize';
|
|
6
7
|
import { ReactNativeLibraries } from './utils/rnlibraries';
|
|
7
8
|
import { base64StringFromByteArray, utf8ToBytes } from './vendor';
|
|
8
9
|
/**
|
|
@@ -264,9 +265,24 @@ export const NATIVE = {
|
|
|
264
265
|
if (!this._isModuleLoaded(RNSentry)) {
|
|
265
266
|
throw this._NativeClientError;
|
|
266
267
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
268
|
+
if (typeof extra === 'string') {
|
|
269
|
+
return RNSentry.setExtra(key, extra);
|
|
270
|
+
}
|
|
271
|
+
if (typeof extra === 'undefined') {
|
|
272
|
+
return RNSentry.setExtra(key, 'undefined');
|
|
273
|
+
}
|
|
274
|
+
let stringifiedExtra;
|
|
275
|
+
try {
|
|
276
|
+
const normalizedExtra = normalize(extra);
|
|
277
|
+
stringifiedExtra = JSON.stringify(normalizedExtra);
|
|
278
|
+
}
|
|
279
|
+
catch (e) {
|
|
280
|
+
logger.error('Extra for key ${key} not passed to native SDK, because it contains non-stringifiable values', e);
|
|
281
|
+
}
|
|
282
|
+
if (typeof stringifiedExtra === 'string') {
|
|
283
|
+
return RNSentry.setExtra(key, stringifiedExtra);
|
|
284
|
+
}
|
|
285
|
+
return RNSentry.setExtra(key, '**non-stringifiable**');
|
|
270
286
|
},
|
|
271
287
|
/**
|
|
272
288
|
* Adds breadcrumb to the native scope.
|
|
@@ -296,10 +312,11 @@ export const NATIVE = {
|
|
|
296
312
|
RNSentry.clearBreadcrumbs();
|
|
297
313
|
},
|
|
298
314
|
/**
|
|
299
|
-
* Sets context on the native scope.
|
|
315
|
+
* Sets context on the native scope.
|
|
300
316
|
* @param key string
|
|
301
317
|
* @param context key-value map
|
|
302
318
|
*/
|
|
319
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
303
320
|
setContext(key, context) {
|
|
304
321
|
if (!this.enableNative) {
|
|
305
322
|
return;
|
|
@@ -307,7 +324,22 @@ export const NATIVE = {
|
|
|
307
324
|
if (!this._isModuleLoaded(RNSentry)) {
|
|
308
325
|
throw this._NativeClientError;
|
|
309
326
|
}
|
|
310
|
-
|
|
327
|
+
if (context === null) {
|
|
328
|
+
return RNSentry.setContext(key, null);
|
|
329
|
+
}
|
|
330
|
+
let normalizedContext;
|
|
331
|
+
try {
|
|
332
|
+
normalizedContext = convertToNormalizedObject(context);
|
|
333
|
+
}
|
|
334
|
+
catch (e) {
|
|
335
|
+
logger.error('Context for key ${key} not passed to native SDK, because it contains non-serializable values', e);
|
|
336
|
+
}
|
|
337
|
+
if (normalizedContext) {
|
|
338
|
+
RNSentry.setContext(key, normalizedContext);
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
RNSentry.setContext(key, { error: '**non-serializable**' });
|
|
342
|
+
}
|
|
311
343
|
},
|
|
312
344
|
/**
|
|
313
345
|
* Closes the Native Layer SDK
|
|
@@ -494,6 +526,12 @@ export const NATIVE = {
|
|
|
494
526
|
return typeof result === 'boolean' ? result : null;
|
|
495
527
|
});
|
|
496
528
|
},
|
|
529
|
+
getNewScreenTimeToDisplay() {
|
|
530
|
+
if (!this.enableNative || !this._isModuleLoaded(RNSentry)) {
|
|
531
|
+
return Promise.resolve(null);
|
|
532
|
+
}
|
|
533
|
+
return RNSentry.getNewScreenTimeToDisplay();
|
|
534
|
+
},
|
|
497
535
|
/**
|
|
498
536
|
* Gets the event from envelopeItem and applies the level filter to the selected event.
|
|
499
537
|
* @param data An envelope item containing the event.
|
package/dist/js/wrapper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../../src/js/wrapper.ts"],"names":[],"mappings":";AAWA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,M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D,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACH,eAAe,CAAC,MAAwB;QACtC,OAAO,CAAC,CAAC,MAAM,CAAC;IAClB,CAAC;IAED,oBAAoB,EAAE,IAAI,WAAW,CAAC,oBAAoB,CAAC;IAE3D,kBAAkB,EAAE,IAAI,WAAW,CAAC,wDAAwD,CAAC;IAE7F,YAAY,EAAE,IAAI;IAClB,aAAa,EAAE,KAAK;IACpB,QAAQ,EAAE,QAAQ,CAAC,EAAE;CACtB,CAAC","sourcesContent":["/* eslint-disable max-lines */\nimport type {\n BaseEnvelopeItemHeaders,\n Breadcrumb,\n Envelope,\n EnvelopeItem,\n Event,\n Package,\n SeverityLevel,\n User,\n} from '@sentry/types';\nimport { logger, normalize, SentryError } from '@sentry/utils';\nimport { NativeModules, Platform } from 'react-native';\n\nimport { isHardCrash } from './misc';\nimport type {\n NativeAppStartResponse,\n NativeDeviceContextsResponse,\n NativeFramesResponse,\n NativeReleaseResponse,\n NativeScreenshot,\n NativeStackFrames,\n Spec,\n} from './NativeRNSentry';\nimport type { ReactNativeClientOptions } from './options';\nimport type * as Hermes from './profiling/hermes';\nimport type { NativeAndroidProfileEvent, NativeProfileEvent } from './profiling/nativeTypes';\nimport type { MobileReplayOptions } from './replay/mobilereplay';\nimport type { RequiredKeysUser } from './user';\nimport { isTurboModuleEnabled } from './utils/environment';\nimport { ReactNativeLibraries } from './utils/rnlibraries';\nimport { base64StringFromByteArray, utf8ToBytes } from './vendor';\n\n/**\n * Returns the RNSentry module. Dynamically resolves if NativeModule or TurboModule is used.\n */\nexport function getRNSentryModule(): Spec | undefined {\n return isTurboModuleEnabled()\n ? ReactNativeLibraries.TurboModuleRegistry && ReactNativeLibraries.TurboModuleRegistry.get<Spec>('RNSentry')\n : NativeModules.RNSentry;\n}\n\nconst RNSentry: Spec | undefined = getRNSentryModule();\n\nexport interface Screenshot {\n data: Uint8Array;\n contentType: string;\n filename: string;\n}\n\nexport type NativeSdkOptions = Partial<ReactNativeClientOptions> & {\n mobileReplayOptions: MobileReplayOptions | undefined;\n};\n\ninterface SentryNativeWrapper {\n enableNative: boolean;\n nativeIsReady: boolean;\n platform: typeof Platform.OS;\n\n _NativeClientError: Error;\n _DisabledNativeError: Error;\n\n _processItem(envelopeItem: EnvelopeItem): EnvelopeItem;\n _processLevels(event: Event): Event;\n _processLevel(level: SeverityLevel): SeverityLevel;\n _serializeObject(data: { [key: string]: unknown }): { [key: string]: string };\n _isModuleLoaded(module: Spec | undefined): module is Spec;\n\n isNativeAvailable(): boolean;\n\n initNativeSdk(options: NativeSdkOptions): PromiseLike<boolean>;\n closeNativeSdk(): PromiseLike<void>;\n\n sendEnvelope(envelope: Envelope): Promise<void>;\n captureScreenshot(): Promise<Screenshot[] | null>;\n\n fetchNativeRelease(): PromiseLike<NativeReleaseResponse>;\n fetchNativeDeviceContexts(): PromiseLike<NativeDeviceContextsResponse | null>;\n fetchNativeAppStart(): PromiseLike<NativeAppStartResponse | null>;\n fetchNativeFrames(): PromiseLike<NativeFramesResponse | null>;\n fetchNativeSdkInfo(): PromiseLike<Package | null>;\n\n disableNativeFramesTracking(): void;\n enableNativeFramesTracking(): void;\n\n addBreadcrumb(breadcrumb: Breadcrumb): void;\n setContext(key: string, context: { [key: string]: unknown } | null): void;\n clearBreadcrumbs(): void;\n setExtra(key: string, extra: unknown): void;\n setUser(user: User | null): void;\n setTag(key: string, value: string): void;\n\n nativeCrash(): void;\n\n fetchModules(): Promise<Record<string, string> | null>;\n fetchViewHierarchy(): PromiseLike<Uint8Array | null>;\n\n startProfiling(platformProfilers: boolean): boolean;\n stopProfiling(): {\n hermesProfile: Hermes.Profile;\n nativeProfile?: NativeProfileEvent;\n androidProfile?: NativeAndroidProfileEvent;\n } | null;\n\n fetchNativePackageName(): string | null;\n\n /**\n * Fetches native stack frames and debug images for the instructions addresses.\n */\n fetchNativeStackFramesBy(instructionsAddr: number[]): NativeStackFrames | null;\n initNativeReactNavigationNewFrameTracking(): Promise<void>;\n\n captureReplay(isHardCrash: boolean): Promise<string | null>;\n getCurrentReplayId(): string | null;\n\n crashedLastRun(): Promise<boolean | null>;\n}\n\nconst EOL = utf8ToBytes('\\n');\n\n/**\n * Our internal interface for calling native functions\n */\nexport const NATIVE: SentryNativeWrapper = {\n async fetchModules(): Promise<Record<string, string> | null> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n const raw = await RNSentry.fetchModules();\n if (raw) {\n return JSON.parse(raw);\n }\n return null;\n },\n /**\n * Sending the envelope over the bridge to native\n * @param envelope Envelope\n */\n async sendEnvelope(envelope: Envelope): Promise<void> {\n if (!this.enableNative) {\n logger.warn('Event was skipped as native SDK is not enabled.');\n return;\n }\n\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n const [envelopeHeader, envelopeItems] = envelope;\n\n const headerString = JSON.stringify(envelopeHeader);\n const headerBytes = utf8ToBytes(headerString);\n let envelopeBytes: Uint8Array = new Uint8Array(headerBytes.length + EOL.length);\n envelopeBytes.set(headerBytes);\n envelopeBytes.set(EOL, headerBytes.length);\n\n let hardCrashed: boolean = false;\n for (const rawItem of envelopeItems) {\n const [itemHeader, itemPayload] = this._processItem(rawItem);\n\n let bytesContentType: string;\n let bytesPayload: number[] | Uint8Array | undefined;\n if (typeof itemPayload === 'string') {\n bytesContentType = 'text/plain';\n bytesPayload = utf8ToBytes(itemPayload);\n } else if (itemPayload instanceof Uint8Array) {\n bytesContentType =\n typeof itemHeader.content_type === 'string' ? itemHeader.content_type : 'application/octet-stream';\n bytesPayload = itemPayload;\n } else {\n bytesContentType = 'application/json';\n bytesPayload = utf8ToBytes(JSON.stringify(itemPayload));\n if (!hardCrashed) {\n hardCrashed = isHardCrash(itemPayload);\n }\n }\n\n // Content type is not inside BaseEnvelopeItemHeaders.\n (itemHeader as BaseEnvelopeItemHeaders).content_type = bytesContentType;\n (itemHeader as BaseEnvelopeItemHeaders).length = bytesPayload.length;\n const serializedItemHeader = JSON.stringify(itemHeader);\n\n const bytesItemHeader = utf8ToBytes(serializedItemHeader);\n const newBytes = new Uint8Array(\n envelopeBytes.length + bytesItemHeader.length + EOL.length + bytesPayload.length + EOL.length,\n );\n newBytes.set(envelopeBytes);\n newBytes.set(bytesItemHeader, envelopeBytes.length);\n newBytes.set(EOL, envelopeBytes.length + bytesItemHeader.length);\n newBytes.set(bytesPayload, envelopeBytes.length + bytesItemHeader.length + EOL.length);\n newBytes.set(EOL, envelopeBytes.length + bytesItemHeader.length + EOL.length + bytesPayload.length);\n envelopeBytes = newBytes;\n }\n\n await RNSentry.captureEnvelope(base64StringFromByteArray(envelopeBytes), { hardCrashed });\n },\n\n /**\n * Starts native with the provided options.\n * @param options ReactNativeClientOptions\n */\n async initNativeSdk(originalOptions: NativeSdkOptions): Promise<boolean> {\n const options: NativeSdkOptions = {\n enableNative: true,\n autoInitializeNativeSdk: true,\n ...originalOptions,\n };\n\n if (!options.enableNative) {\n if (options.enableNativeNagger) {\n logger.warn('Note: Native Sentry SDK is disabled.');\n }\n this.enableNative = false;\n return false;\n }\n if (!options.autoInitializeNativeSdk) {\n if (options.enableNativeNagger) {\n logger.warn(\n 'Note: Native Sentry SDK was not initialized automatically, you will need to initialize it manually. If you wish to disable the native SDK and get rid of this warning, pass enableNative: false',\n );\n }\n this.enableNative = true;\n return false;\n }\n\n if (!options.dsn) {\n logger.warn(\n 'Warning: No DSN was provided. The Sentry SDK will be disabled. Native SDK will also not be initalized.',\n );\n this.enableNative = false;\n return false;\n }\n\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n // filter out all the options that would crash native.\n /* eslint-disable @typescript-eslint/unbound-method,@typescript-eslint/no-unused-vars */\n const { beforeSend, beforeBreadcrumb, beforeSendTransaction, integrations, ...filteredOptions } = options;\n /* eslint-enable @typescript-eslint/unbound-method,@typescript-eslint/no-unused-vars */\n const nativeIsReady = await RNSentry.initNativeSdk(filteredOptions);\n\n this.nativeIsReady = nativeIsReady;\n this.enableNative = true;\n\n return nativeIsReady;\n },\n\n /**\n * Fetches the release from native\n */\n async fetchNativeRelease(): Promise<NativeReleaseResponse> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n return RNSentry.fetchNativeRelease();\n },\n\n /**\n * Fetches the Sdk info for the native sdk.\n */\n async fetchNativeSdkInfo(): Promise<Package | null> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n return RNSentry.fetchNativeSdkInfo();\n },\n\n /**\n * Fetches the device contexts. Not used on Android.\n */\n async fetchNativeDeviceContexts(): Promise<NativeDeviceContextsResponse | null> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n return RNSentry.fetchNativeDeviceContexts();\n },\n\n async fetchNativeAppStart(): Promise<NativeAppStartResponse | null> {\n if (!this.enableNative) {\n logger.warn(this._DisabledNativeError);\n return null;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n logger.error(this._NativeClientError);\n return null;\n }\n\n return RNSentry.fetchNativeAppStart();\n },\n\n async fetchNativeFrames(): Promise<NativeFramesResponse | null> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n return RNSentry.fetchNativeFrames();\n },\n\n /**\n * Triggers a native crash.\n * Use this only for testing purposes.\n */\n nativeCrash(): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n RNSentry.crash();\n },\n\n /**\n * Sets the user in the native scope.\n * Passing null clears the user.\n */\n setUser(user: User | null): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n // separate and serialize all non-default user keys.\n let userKeys = null;\n let userDataKeys = null;\n if (user) {\n const { id, ip_address, email, username, segment, ...otherKeys } = user;\n const requiredUser: RequiredKeysUser = {\n id,\n ip_address,\n email,\n username,\n segment,\n };\n userKeys = this._serializeObject(requiredUser);\n userDataKeys = this._serializeObject(otherKeys);\n }\n\n RNSentry.setUser(userKeys, userDataKeys);\n },\n\n /**\n * Sets a tag in the native module.\n * @param key string\n * @param value string\n */\n setTag(key: string, value: string): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n const stringifiedValue = typeof value === 'string' ? value : JSON.stringify(value);\n\n RNSentry.setTag(key, stringifiedValue);\n },\n\n /**\n * Sets an extra in the native scope, will stringify\n * extra value if it isn't already a string.\n * @param key string\n * @param extra any\n */\n setExtra(key: string, extra: unknown): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n // we stringify the extra as native only takes in strings.\n const stringifiedExtra = typeof extra === 'string' ? extra : JSON.stringify(extra);\n\n RNSentry.setExtra(key, stringifiedExtra);\n },\n\n /**\n * Adds breadcrumb to the native scope.\n * @param breadcrumb Breadcrumb\n */\n addBreadcrumb(breadcrumb: Breadcrumb): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n RNSentry.addBreadcrumb({\n ...breadcrumb,\n // Process and convert deprecated levels\n level: breadcrumb.level ? this._processLevel(breadcrumb.level) : undefined,\n });\n },\n\n /**\n * Clears breadcrumbs on the native scope.\n */\n clearBreadcrumbs(): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n RNSentry.clearBreadcrumbs();\n },\n\n /**\n * Sets context on the native scope. Not implemented in Android yet.\n * @param key string\n * @param context key-value map\n */\n setContext(key: string, context: { [key: string]: unknown } | null): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n RNSentry.setContext(key, context !== null ? normalize(context) : null);\n },\n\n /**\n * Closes the Native Layer SDK\n */\n async closeNativeSdk(): Promise<void> {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n return;\n }\n\n return RNSentry.closeNativeSdk().then(() => {\n this.enableNative = false;\n });\n },\n\n disableNativeFramesTracking(): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n return;\n }\n\n RNSentry.disableNativeFramesTracking();\n },\n\n enableNativeFramesTracking(): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n return;\n }\n\n RNSentry.enableNativeFramesTracking();\n },\n\n isNativeAvailable(): boolean {\n return this._isModuleLoaded(RNSentry);\n },\n\n async captureScreenshot(): Promise<Screenshot[] | null> {\n if (!this.enableNative) {\n logger.warn(this._DisabledNativeError);\n return null;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n logger.error(this._NativeClientError);\n return null;\n }\n\n let raw: NativeScreenshot[] | null | undefined;\n try {\n raw = await RNSentry.captureScreenshot();\n } catch (e) {\n logger.warn('Failed to capture screenshot', e);\n }\n\n if (raw) {\n return raw.map((item: NativeScreenshot) => ({\n ...item,\n data: new Uint8Array(item.data),\n }));\n } else {\n return null;\n }\n },\n\n async fetchViewHierarchy(): Promise<Uint8Array | null> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n const raw = await RNSentry.fetchViewHierarchy();\n return raw ? new Uint8Array(raw) : null;\n },\n\n startProfiling(platformProfilers: boolean): boolean {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n const { started, error } = RNSentry.startProfiling(platformProfilers);\n if (started) {\n logger.log('[NATIVE] Start Profiling');\n } else {\n logger.error('[NATIVE] Start Profiling Failed', error);\n }\n\n return !!started;\n },\n\n stopProfiling(): {\n hermesProfile: Hermes.Profile;\n nativeProfile?: NativeProfileEvent;\n androidProfile?: NativeAndroidProfileEvent;\n } | null {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n const { profile, nativeProfile, androidProfile, error } = RNSentry.stopProfiling();\n if (!profile || error) {\n logger.error('[NATIVE] Stop Profiling Failed', error);\n return null;\n }\n if (Platform.OS === 'ios' && !nativeProfile) {\n logger.warn('[NATIVE] Stop Profiling Failed: No Native Profile');\n }\n if (Platform.OS === 'android' && !androidProfile) {\n logger.warn('[NATIVE] Stop Profiling Failed: No Android Profile');\n }\n\n try {\n return {\n hermesProfile: JSON.parse(profile) as Hermes.Profile,\n nativeProfile: nativeProfile as NativeProfileEvent | undefined,\n androidProfile: androidProfile as NativeAndroidProfileEvent | undefined,\n };\n } catch (e) {\n logger.error('[NATIVE] Failed to parse Hermes Profile JSON', e);\n return null;\n }\n },\n\n fetchNativePackageName(): string | null {\n if (!this.enableNative) {\n return null;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n return null;\n }\n\n return RNSentry.fetchNativePackageName() || null;\n },\n\n fetchNativeStackFramesBy(instructionsAddr: number[]): NativeStackFrames | null {\n if (!this.enableNative) {\n return null;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n return null;\n }\n\n return RNSentry.fetchNativeStackFramesBy(instructionsAddr) || null;\n },\n\n async initNativeReactNavigationNewFrameTracking(): Promise<void> {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n return;\n }\n\n return RNSentry.initNativeReactNavigationNewFrameTracking();\n },\n\n async captureReplay(isHardCrash: boolean): Promise<string | null> {\n if (!this.enableNative) {\n logger.warn(`[NATIVE] \\`${this.captureReplay.name}\\` is not available when native is disabled.`);\n return Promise.resolve(null);\n }\n if (!this._isModuleLoaded(RNSentry)) {\n logger.warn(`[NATIVE] \\`${this.captureReplay.name}\\` is not available when native is not available.`);\n return Promise.resolve(null);\n }\n\n return (await RNSentry.captureReplay(isHardCrash)) || null;\n },\n\n getCurrentReplayId(): string | null {\n if (!this.enableNative) {\n logger.warn(`[NATIVE] \\`${this.getCurrentReplayId.name}\\` is not available when native is disabled.`);\n return null;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n logger.warn(`[NATIVE] \\`${this.getCurrentReplayId.name}\\` is not available when native is not available.`);\n return null;\n }\n\n return RNSentry.getCurrentReplayId() || null;\n },\n\n async crashedLastRun(): Promise<boolean | null> {\n if (!this.enableNative) {\n return null;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n return null;\n }\n\n const result = RNSentry.crashedLastRun();\n return typeof result === 'boolean' ? result : null;\n },\n\n /**\n * Gets the event from envelopeItem and applies the level filter to the selected event.\n * @param data An envelope item containing the event.\n * @returns The event from envelopeItem or undefined.\n */\n _processItem(item: EnvelopeItem): EnvelopeItem {\n const [itemHeader, itemPayload] = item;\n\n if (itemHeader.type == 'event' || itemHeader.type == 'transaction') {\n const event = this._processLevels(itemPayload as Event);\n\n if (NATIVE.platform === 'android') {\n if ('message' in event) {\n // @ts-expect-error Android still uses the old message object, without this the serialization of events will break.\n event.message = { message: event.message };\n }\n }\n\n return [itemHeader, event];\n }\n\n return item;\n },\n\n /**\n * Serializes all values of root-level keys into strings.\n * @param data key-value map.\n * @returns An object where all root-level values are strings.\n */\n _serializeObject(data: { [key: string]: unknown }): { [key: string]: string } {\n const serialized: { [key: string]: string } = {};\n\n Object.keys(data).forEach(dataKey => {\n const value = data[dataKey];\n serialized[dataKey] = typeof value === 'string' ? value : JSON.stringify(value);\n });\n\n return serialized;\n },\n\n /**\n * Convert js severity level in event.level and event.breadcrumbs to more widely supported levels.\n * @param event\n * @returns Event with more widely supported Severity level strings\n */\n\n _processLevels(event: Event): Event {\n const processed: Event = {\n ...event,\n level: event.level ? this._processLevel(event.level) : undefined,\n breadcrumbs: event.breadcrumbs?.map(breadcrumb => ({\n ...breadcrumb,\n level: breadcrumb.level ? this._processLevel(breadcrumb.level) : undefined,\n })),\n };\n\n return processed;\n },\n\n /**\n * Convert js severity level which has critical and log to more widely supported levels.\n * @param level\n * @returns More widely supported Severity level strings\n */\n\n _processLevel(level: SeverityLevel): SeverityLevel {\n if (level == ('log' as SeverityLevel)) {\n return 'debug' as SeverityLevel;\n }\n return level;\n },\n\n /**\n * Checks whether the RNSentry module is loaded.\n */\n _isModuleLoaded(module: Spec | undefined): module is Spec {\n return !!module;\n },\n\n _DisabledNativeError: new SentryError('Native is disabled'),\n\n _NativeClientError: new SentryError(\"Native Client is not available, can't start on native.\"),\n\n enableNative: true,\n nativeIsReady: false,\n platform: Platform.OS,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../../src/js/wrapper.ts"],"names":[],"mappings":";AAWA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAerC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAElE;;GAEG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,oBAAoB,EAAE;QAC3B,CAAC,CAAC,oBAAoB,CAAC,mBAAmB,IAAI,oBAAoB,CAAC,mBAAmB,CAAC,GAAG,CAAO,UAAU,CAAC;QAC5G,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC;AAC7B,CAAC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AAC,CAAC;QAEH,OAAO,UAAU,CAAC;IACpB,CAAC;IAED;;;;OAIG;IAEH,cAAc,CAAC,KAAY;;QACzB,MAAM,SAAS,mCACV,KAAK,KACR,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,EAChE,WAAW,EAAE,MAAA,KAAK,CAAC,WAAW,0CAAE,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,iCAC7C,UAAU,KACb,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,IAC1E,CAAC,GACJ,CAAC;QAEF,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;OAIG;IAEH,aAAa,CAAC,KAAoB;QAChC,IAAI,KAAK,IAAK,KAAuB,EAAE;YACrC,OAAO,OAAwB,CAAC;SACjC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACH,eAAe,CAAC,MAAwB;QACtC,OAAO,CAAC,CAAC,MAAM,CAAC;IAClB,CAAC;IAED,oBAAoB,EAAE,IAAI,WAAW,CAAC,oBAAoB,CAAC;IAE3D,kBAAkB,EAAE,IAAI,WAAW,CAAC,wDAAwD,CAAC;IAE7F,YAAY,EAAE,IAAI;IAClB,aAAa,EAAE,KAAK;IACpB,QAAQ,EAAE,QAAQ,CAAC,EAAE;CACtB,CAAC","sourcesContent":["/* eslint-disable max-lines */\nimport type {\n BaseEnvelopeItemHeaders,\n Breadcrumb,\n Envelope,\n EnvelopeItem,\n Event,\n Package,\n SeverityLevel,\n User,\n} from '@sentry/types';\nimport { logger, normalize, SentryError } from '@sentry/utils';\nimport { NativeModules, Platform } from 'react-native';\n\nimport { isHardCrash } from './misc';\nimport type {\n NativeAppStartResponse,\n NativeDeviceContextsResponse,\n NativeFramesResponse,\n NativeReleaseResponse,\n NativeScreenshot,\n NativeStackFrames,\n Spec,\n} from './NativeRNSentry';\nimport type { ReactNativeClientOptions } from './options';\nimport type * as Hermes from './profiling/hermes';\nimport type { NativeAndroidProfileEvent, NativeProfileEvent } from './profiling/nativeTypes';\nimport type { MobileReplayOptions } from './replay/mobilereplay';\nimport type { RequiredKeysUser } from './user';\nimport { isTurboModuleEnabled } from './utils/environment';\nimport { convertToNormalizedObject } from './utils/normalize';\nimport { ReactNativeLibraries } from './utils/rnlibraries';\nimport { base64StringFromByteArray, utf8ToBytes } from './vendor';\n\n/**\n * Returns the RNSentry module. Dynamically resolves if NativeModule or TurboModule is used.\n */\nexport function getRNSentryModule(): Spec | undefined {\n return isTurboModuleEnabled()\n ? ReactNativeLibraries.TurboModuleRegistry && ReactNativeLibraries.TurboModuleRegistry.get<Spec>('RNSentry')\n : NativeModules.RNSentry;\n}\n\nconst RNSentry: Spec | undefined = getRNSentryModule();\n\nexport interface Screenshot {\n data: Uint8Array;\n contentType: string;\n filename: string;\n}\n\nexport type NativeSdkOptions = Partial<ReactNativeClientOptions> & {\n mobileReplayOptions: MobileReplayOptions | undefined;\n};\n\ninterface SentryNativeWrapper {\n enableNative: boolean;\n nativeIsReady: boolean;\n platform: typeof Platform.OS;\n\n _NativeClientError: Error;\n _DisabledNativeError: Error;\n\n _processItem(envelopeItem: EnvelopeItem): EnvelopeItem;\n _processLevels(event: Event): Event;\n _processLevel(level: SeverityLevel): SeverityLevel;\n _serializeObject(data: { [key: string]: unknown }): { [key: string]: string };\n _isModuleLoaded(module: Spec | undefined): module is Spec;\n\n isNativeAvailable(): boolean;\n\n initNativeSdk(options: NativeSdkOptions): PromiseLike<boolean>;\n closeNativeSdk(): PromiseLike<void>;\n\n sendEnvelope(envelope: Envelope): Promise<void>;\n captureScreenshot(): Promise<Screenshot[] | null>;\n\n fetchNativeRelease(): PromiseLike<NativeReleaseResponse>;\n fetchNativeDeviceContexts(): PromiseLike<NativeDeviceContextsResponse | null>;\n fetchNativeAppStart(): PromiseLike<NativeAppStartResponse | null>;\n fetchNativeFrames(): PromiseLike<NativeFramesResponse | null>;\n fetchNativeSdkInfo(): PromiseLike<Package | null>;\n\n disableNativeFramesTracking(): void;\n enableNativeFramesTracking(): void;\n\n addBreadcrumb(breadcrumb: Breadcrumb): void;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setContext(key: string, context: { [key: string]: any } | null): void;\n clearBreadcrumbs(): void;\n setExtra(key: string, extra: unknown): void;\n setUser(user: User | null): void;\n setTag(key: string, value: string): void;\n\n nativeCrash(): void;\n\n fetchModules(): Promise<Record<string, string> | null>;\n fetchViewHierarchy(): PromiseLike<Uint8Array | null>;\n\n startProfiling(platformProfilers: boolean): boolean;\n stopProfiling(): {\n hermesProfile: Hermes.Profile;\n nativeProfile?: NativeProfileEvent;\n androidProfile?: NativeAndroidProfileEvent;\n } | null;\n\n fetchNativePackageName(): string | null;\n\n /**\n * Fetches native stack frames and debug images for the instructions addresses.\n */\n fetchNativeStackFramesBy(instructionsAddr: number[]): NativeStackFrames | null;\n initNativeReactNavigationNewFrameTracking(): Promise<void>;\n\n captureReplay(isHardCrash: boolean): Promise<string | null>;\n getCurrentReplayId(): string | null;\n\n crashedLastRun(): Promise<boolean | null>;\n getNewScreenTimeToDisplay(): Promise<number | null | undefined>;\n}\n\nconst EOL = utf8ToBytes('\\n');\n\n/**\n * Our internal interface for calling native functions\n */\nexport const NATIVE: SentryNativeWrapper = {\n async fetchModules(): Promise<Record<string, string> | null> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n const raw = await RNSentry.fetchModules();\n if (raw) {\n return JSON.parse(raw);\n }\n return null;\n },\n /**\n * Sending the envelope over the bridge to native\n * @param envelope Envelope\n */\n async sendEnvelope(envelope: Envelope): Promise<void> {\n if (!this.enableNative) {\n logger.warn('Event was skipped as native SDK is not enabled.');\n return;\n }\n\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n const [envelopeHeader, envelopeItems] = envelope;\n\n const headerString = JSON.stringify(envelopeHeader);\n const headerBytes = utf8ToBytes(headerString);\n let envelopeBytes: Uint8Array = new Uint8Array(headerBytes.length + EOL.length);\n envelopeBytes.set(headerBytes);\n envelopeBytes.set(EOL, headerBytes.length);\n\n let hardCrashed: boolean = false;\n for (const rawItem of envelopeItems) {\n const [itemHeader, itemPayload] = this._processItem(rawItem);\n\n let bytesContentType: string;\n let bytesPayload: number[] | Uint8Array | undefined;\n if (typeof itemPayload === 'string') {\n bytesContentType = 'text/plain';\n bytesPayload = utf8ToBytes(itemPayload);\n } else if (itemPayload instanceof Uint8Array) {\n bytesContentType =\n typeof itemHeader.content_type === 'string' ? itemHeader.content_type : 'application/octet-stream';\n bytesPayload = itemPayload;\n } else {\n bytesContentType = 'application/json';\n bytesPayload = utf8ToBytes(JSON.stringify(itemPayload));\n if (!hardCrashed) {\n hardCrashed = isHardCrash(itemPayload);\n }\n }\n\n // Content type is not inside BaseEnvelopeItemHeaders.\n (itemHeader as BaseEnvelopeItemHeaders).content_type = bytesContentType;\n (itemHeader as BaseEnvelopeItemHeaders).length = bytesPayload.length;\n const serializedItemHeader = JSON.stringify(itemHeader);\n\n const bytesItemHeader = utf8ToBytes(serializedItemHeader);\n const newBytes = new Uint8Array(\n envelopeBytes.length + bytesItemHeader.length + EOL.length + bytesPayload.length + EOL.length,\n );\n newBytes.set(envelopeBytes);\n newBytes.set(bytesItemHeader, envelopeBytes.length);\n newBytes.set(EOL, envelopeBytes.length + bytesItemHeader.length);\n newBytes.set(bytesPayload, envelopeBytes.length + bytesItemHeader.length + EOL.length);\n newBytes.set(EOL, envelopeBytes.length + bytesItemHeader.length + EOL.length + bytesPayload.length);\n envelopeBytes = newBytes;\n }\n\n await RNSentry.captureEnvelope(base64StringFromByteArray(envelopeBytes), { hardCrashed });\n },\n\n /**\n * Starts native with the provided options.\n * @param options ReactNativeClientOptions\n */\n async initNativeSdk(originalOptions: NativeSdkOptions): Promise<boolean> {\n const options: NativeSdkOptions = {\n enableNative: true,\n autoInitializeNativeSdk: true,\n ...originalOptions,\n };\n\n if (!options.enableNative) {\n if (options.enableNativeNagger) {\n logger.warn('Note: Native Sentry SDK is disabled.');\n }\n this.enableNative = false;\n return false;\n }\n if (!options.autoInitializeNativeSdk) {\n if (options.enableNativeNagger) {\n logger.warn(\n 'Note: Native Sentry SDK was not initialized automatically, you will need to initialize it manually. If you wish to disable the native SDK and get rid of this warning, pass enableNative: false',\n );\n }\n this.enableNative = true;\n return false;\n }\n\n if (!options.dsn) {\n logger.warn(\n 'Warning: No DSN was provided. The Sentry SDK will be disabled. Native SDK will also not be initalized.',\n );\n this.enableNative = false;\n return false;\n }\n\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n // filter out all the options that would crash native.\n /* eslint-disable @typescript-eslint/unbound-method,@typescript-eslint/no-unused-vars */\n const { beforeSend, beforeBreadcrumb, beforeSendTransaction, integrations, ...filteredOptions } = options;\n /* eslint-enable @typescript-eslint/unbound-method,@typescript-eslint/no-unused-vars */\n const nativeIsReady = await RNSentry.initNativeSdk(filteredOptions);\n\n this.nativeIsReady = nativeIsReady;\n this.enableNative = true;\n\n return nativeIsReady;\n },\n\n /**\n * Fetches the release from native\n */\n async fetchNativeRelease(): Promise<NativeReleaseResponse> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n return RNSentry.fetchNativeRelease();\n },\n\n /**\n * Fetches the Sdk info for the native sdk.\n */\n async fetchNativeSdkInfo(): Promise<Package | null> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n return RNSentry.fetchNativeSdkInfo();\n },\n\n /**\n * Fetches the device contexts. Not used on Android.\n */\n async fetchNativeDeviceContexts(): Promise<NativeDeviceContextsResponse | null> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n return RNSentry.fetchNativeDeviceContexts();\n },\n\n async fetchNativeAppStart(): Promise<NativeAppStartResponse | null> {\n if (!this.enableNative) {\n logger.warn(this._DisabledNativeError);\n return null;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n logger.error(this._NativeClientError);\n return null;\n }\n\n return RNSentry.fetchNativeAppStart();\n },\n\n async fetchNativeFrames(): Promise<NativeFramesResponse | null> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n return RNSentry.fetchNativeFrames();\n },\n\n /**\n * Triggers a native crash.\n * Use this only for testing purposes.\n */\n nativeCrash(): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n RNSentry.crash();\n },\n\n /**\n * Sets the user in the native scope.\n * Passing null clears the user.\n */\n setUser(user: User | null): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n // separate and serialize all non-default user keys.\n let userKeys = null;\n let userDataKeys = null;\n if (user) {\n const { id, ip_address, email, username, segment, ...otherKeys } = user;\n const requiredUser: RequiredKeysUser = {\n id,\n ip_address,\n email,\n username,\n segment,\n };\n userKeys = this._serializeObject(requiredUser);\n userDataKeys = this._serializeObject(otherKeys);\n }\n\n RNSentry.setUser(userKeys, userDataKeys);\n },\n\n /**\n * Sets a tag in the native module.\n * @param key string\n * @param value string\n */\n setTag(key: string, value: string): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n const stringifiedValue = typeof value === 'string' ? value : JSON.stringify(value);\n\n RNSentry.setTag(key, stringifiedValue);\n },\n\n /**\n * Sets an extra in the native scope, will stringify\n * extra value if it isn't already a string.\n * @param key string\n * @param extra any\n */\n setExtra(key: string, extra: unknown): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n if (typeof extra === 'string') {\n return RNSentry.setExtra(key, extra);\n }\n if (typeof extra === 'undefined') {\n return RNSentry.setExtra(key, 'undefined');\n }\n\n let stringifiedExtra: string | undefined;\n try {\n const normalizedExtra = normalize(extra);\n stringifiedExtra = JSON.stringify(normalizedExtra);\n } catch (e) {\n logger.error('Extra for key ${key} not passed to native SDK, because it contains non-stringifiable values', e);\n }\n\n if (typeof stringifiedExtra === 'string') {\n return RNSentry.setExtra(key, stringifiedExtra);\n }\n return RNSentry.setExtra(key, '**non-stringifiable**');\n },\n\n /**\n * Adds breadcrumb to the native scope.\n * @param breadcrumb Breadcrumb\n */\n addBreadcrumb(breadcrumb: Breadcrumb): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n RNSentry.addBreadcrumb({\n ...breadcrumb,\n // Process and convert deprecated levels\n level: breadcrumb.level ? this._processLevel(breadcrumb.level) : undefined,\n });\n },\n\n /**\n * Clears breadcrumbs on the native scope.\n */\n clearBreadcrumbs(): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n RNSentry.clearBreadcrumbs();\n },\n\n /**\n * Sets context on the native scope.\n * @param key string\n * @param context key-value map\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setContext(key: string, context: { [key: string]: any } | null): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n if (context === null) {\n return RNSentry.setContext(key, null);\n }\n\n let normalizedContext: Record<string, unknown> | undefined;\n try {\n normalizedContext = convertToNormalizedObject(context);\n } catch (e) {\n logger.error('Context for key ${key} not passed to native SDK, because it contains non-serializable values', e);\n }\n\n if (normalizedContext) {\n RNSentry.setContext(key, normalizedContext);\n } else {\n RNSentry.setContext(key, { error: '**non-serializable**' });\n }\n },\n\n /**\n * Closes the Native Layer SDK\n */\n async closeNativeSdk(): Promise<void> {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n return;\n }\n\n return RNSentry.closeNativeSdk().then(() => {\n this.enableNative = false;\n });\n },\n\n disableNativeFramesTracking(): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n return;\n }\n\n RNSentry.disableNativeFramesTracking();\n },\n\n enableNativeFramesTracking(): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n return;\n }\n\n RNSentry.enableNativeFramesTracking();\n },\n\n isNativeAvailable(): boolean {\n return this._isModuleLoaded(RNSentry);\n },\n\n async captureScreenshot(): Promise<Screenshot[] | null> {\n if (!this.enableNative) {\n logger.warn(this._DisabledNativeError);\n return null;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n logger.error(this._NativeClientError);\n return null;\n }\n\n let raw: NativeScreenshot[] | null | undefined;\n try {\n raw = await RNSentry.captureScreenshot();\n } catch (e) {\n logger.warn('Failed to capture screenshot', e);\n }\n\n if (raw) {\n return raw.map((item: NativeScreenshot) => ({\n ...item,\n data: new Uint8Array(item.data),\n }));\n } else {\n return null;\n }\n },\n\n async fetchViewHierarchy(): Promise<Uint8Array | null> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n const raw = await RNSentry.fetchViewHierarchy();\n return raw ? new Uint8Array(raw) : null;\n },\n\n startProfiling(platformProfilers: boolean): boolean {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n const { started, error } = RNSentry.startProfiling(platformProfilers);\n if (started) {\n logger.log('[NATIVE] Start Profiling');\n } else {\n logger.error('[NATIVE] Start Profiling Failed', error);\n }\n\n return !!started;\n },\n\n stopProfiling(): {\n hermesProfile: Hermes.Profile;\n nativeProfile?: NativeProfileEvent;\n androidProfile?: NativeAndroidProfileEvent;\n } | null {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n const { profile, nativeProfile, androidProfile, error } = RNSentry.stopProfiling();\n if (!profile || error) {\n logger.error('[NATIVE] Stop Profiling Failed', error);\n return null;\n }\n if (Platform.OS === 'ios' && !nativeProfile) {\n logger.warn('[NATIVE] Stop Profiling Failed: No Native Profile');\n }\n if (Platform.OS === 'android' && !androidProfile) {\n logger.warn('[NATIVE] Stop Profiling Failed: No Android Profile');\n }\n\n try {\n return {\n hermesProfile: JSON.parse(profile) as Hermes.Profile,\n nativeProfile: nativeProfile as NativeProfileEvent | undefined,\n androidProfile: androidProfile as NativeAndroidProfileEvent | undefined,\n };\n } catch (e) {\n logger.error('[NATIVE] Failed to parse Hermes Profile JSON', e);\n return null;\n }\n },\n\n fetchNativePackageName(): string | null {\n if (!this.enableNative) {\n return null;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n return null;\n }\n\n return RNSentry.fetchNativePackageName() || null;\n },\n\n fetchNativeStackFramesBy(instructionsAddr: number[]): NativeStackFrames | null {\n if (!this.enableNative) {\n return null;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n return null;\n }\n\n return RNSentry.fetchNativeStackFramesBy(instructionsAddr) || null;\n },\n\n async initNativeReactNavigationNewFrameTracking(): Promise<void> {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n return;\n }\n\n return RNSentry.initNativeReactNavigationNewFrameTracking();\n },\n\n async captureReplay(isHardCrash: boolean): Promise<string | null> {\n if (!this.enableNative) {\n logger.warn(`[NATIVE] \\`${this.captureReplay.name}\\` is not available when native is disabled.`);\n return Promise.resolve(null);\n }\n if (!this._isModuleLoaded(RNSentry)) {\n logger.warn(`[NATIVE] \\`${this.captureReplay.name}\\` is not available when native is not available.`);\n return Promise.resolve(null);\n }\n\n return (await RNSentry.captureReplay(isHardCrash)) || null;\n },\n\n getCurrentReplayId(): string | null {\n if (!this.enableNative) {\n logger.warn(`[NATIVE] \\`${this.getCurrentReplayId.name}\\` is not available when native is disabled.`);\n return null;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n logger.warn(`[NATIVE] \\`${this.getCurrentReplayId.name}\\` is not available when native is not available.`);\n return null;\n }\n\n return RNSentry.getCurrentReplayId() || null;\n },\n\n async crashedLastRun(): Promise<boolean | null> {\n if (!this.enableNative) {\n return null;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n return null;\n }\n\n const result = RNSentry.crashedLastRun();\n return typeof result === 'boolean' ? result : null;\n },\n\n getNewScreenTimeToDisplay(): Promise<number | null | undefined> {\n if (!this.enableNative || !this._isModuleLoaded(RNSentry)) {\n return Promise.resolve(null);\n }\n\n return RNSentry.getNewScreenTimeToDisplay();\n },\n\n /**\n * Gets the event from envelopeItem and applies the level filter to the selected event.\n * @param data An envelope item containing the event.\n * @returns The event from envelopeItem or undefined.\n */\n _processItem(item: EnvelopeItem): EnvelopeItem {\n const [itemHeader, itemPayload] = item;\n\n if (itemHeader.type == 'event' || itemHeader.type == 'transaction') {\n const event = this._processLevels(itemPayload as Event);\n\n if (NATIVE.platform === 'android') {\n if ('message' in event) {\n // @ts-expect-error Android still uses the old message object, without this the serialization of events will break.\n event.message = { message: event.message };\n }\n }\n\n return [itemHeader, event];\n }\n\n return item;\n },\n\n /**\n * Serializes all values of root-level keys into strings.\n * @param data key-value map.\n * @returns An object where all root-level values are strings.\n */\n _serializeObject(data: { [key: string]: unknown }): { [key: string]: string } {\n const serialized: { [key: string]: string } = {};\n\n Object.keys(data).forEach(dataKey => {\n const value = data[dataKey];\n serialized[dataKey] = typeof value === 'string' ? value : JSON.stringify(value);\n });\n\n return serialized;\n },\n\n /**\n * Convert js severity level in event.level and event.breadcrumbs to more widely supported levels.\n * @param event\n * @returns Event with more widely supported Severity level strings\n */\n\n _processLevels(event: Event): Event {\n const processed: Event = {\n ...event,\n level: event.level ? this._processLevel(event.level) : undefined,\n breadcrumbs: event.breadcrumbs?.map(breadcrumb => ({\n ...breadcrumb,\n level: breadcrumb.level ? this._processLevel(breadcrumb.level) : undefined,\n })),\n };\n\n return processed;\n },\n\n /**\n * Convert js severity level which has critical and log to more widely supported levels.\n * @param level\n * @returns More widely supported Severity level strings\n */\n\n _processLevel(level: SeverityLevel): SeverityLevel {\n if (level == ('log' as SeverityLevel)) {\n return 'debug' as SeverityLevel;\n }\n return level;\n },\n\n /**\n * Checks whether the RNSentry module is loaded.\n */\n _isModuleLoaded(module: Spec | undefined): module is Spec {\n return !!module;\n },\n\n _DisabledNativeError: new SentryError('Native is disabled'),\n\n _NativeClientError: new SentryError(\"Native Client is not available, can't start on native.\"),\n\n enableNative: true,\n nativeIsReady: false,\n platform: Platform.OS,\n};\n"]}
|
package/ios/RNSentry.mm
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#import <dlfcn.h>
|
|
2
2
|
#import "RNSentry.h"
|
|
3
|
+
#import "RNSentryTimeToDisplay.h"
|
|
3
4
|
|
|
4
5
|
#if __has_include(<React/RCTConvert.h>)
|
|
5
6
|
#import <React/RCTConvert.h>
|
|
@@ -62,6 +63,7 @@ static NSString* const nativeSdkName = @"sentry.cocoa.react-native";
|
|
|
62
63
|
@implementation RNSentry {
|
|
63
64
|
bool sentHybridSdkDidBecomeActive;
|
|
64
65
|
bool hasListeners;
|
|
66
|
+
RNSentryTimeToDisplay *_timeToDisplay;
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
- (dispatch_queue_t)methodQueue
|
|
@@ -106,6 +108,8 @@ RCT_EXPORT_METHOD(initNativeSdk:(NSDictionary *_Nonnull)options
|
|
|
106
108
|
sentHybridSdkDidBecomeActive = true;
|
|
107
109
|
}
|
|
108
110
|
|
|
111
|
+
_timeToDisplay = [[RNSentryTimeToDisplay alloc] init];
|
|
112
|
+
|
|
109
113
|
#if SENTRY_TARGET_REPLAY_SUPPORTED
|
|
110
114
|
[RNSentryReplay postInit];
|
|
111
115
|
#endif
|
|
@@ -587,8 +591,16 @@ RCT_EXPORT_METHOD(setContext:(NSString *)key
|
|
|
587
591
|
context:(NSDictionary *)context
|
|
588
592
|
)
|
|
589
593
|
{
|
|
594
|
+
if (key == nil) {
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
|
|
590
598
|
[SentrySDK configureScope:^(SentryScope * _Nonnull scope) {
|
|
591
|
-
|
|
599
|
+
if (context == nil) {
|
|
600
|
+
[scope removeContextForKey:key];
|
|
601
|
+
} else {
|
|
602
|
+
[scope setContextValue:context forKey:key];
|
|
603
|
+
}
|
|
592
604
|
}];
|
|
593
605
|
}
|
|
594
606
|
|
|
@@ -778,4 +790,9 @@ RCT_EXPORT_METHOD(crashedLastRun:(RCTPromiseResolveBlock)resolve
|
|
|
778
790
|
}
|
|
779
791
|
#endif
|
|
780
792
|
|
|
793
|
+
RCT_EXPORT_METHOD(getNewScreenTimeToDisplay:(RCTPromiseResolveBlock)resolve
|
|
794
|
+
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
795
|
+
[_timeToDisplay getTimeToDisplay:resolve];
|
|
796
|
+
}
|
|
797
|
+
|
|
781
798
|
@end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#import "RNSentryTimeToDisplay.h"
|
|
2
|
+
#import <QuartzCore/QuartzCore.h>
|
|
3
|
+
#import <React/RCTLog.h>
|
|
4
|
+
|
|
5
|
+
@implementation RNSentryTimeToDisplay
|
|
6
|
+
{
|
|
7
|
+
CADisplayLink *displayLink;
|
|
8
|
+
RCTResponseSenderBlock resolveBlock;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Rename requestAnimationFrame to getTimeToDisplay
|
|
12
|
+
- (void)getTimeToDisplay:(RCTResponseSenderBlock)callback
|
|
13
|
+
{
|
|
14
|
+
// Store the resolve block to use in the callback.
|
|
15
|
+
resolveBlock = callback;
|
|
16
|
+
|
|
17
|
+
#if TARGET_OS_IOS
|
|
18
|
+
// Create and add a display link to get the callback after the screen is rendered.
|
|
19
|
+
displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(handleDisplayLink:)];
|
|
20
|
+
[displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
|
|
21
|
+
#else
|
|
22
|
+
resolveBlock(@[]); // Return nothing if not iOS.
|
|
23
|
+
#endif
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#if TARGET_OS_IOS
|
|
27
|
+
- (void)handleDisplayLink:(CADisplayLink *)link {
|
|
28
|
+
// Get the current time
|
|
29
|
+
NSTimeInterval currentTime = [[NSDate date] timeIntervalSince1970] * 1000.0; // Convert to milliseconds
|
|
30
|
+
|
|
31
|
+
// Ensure the callback is valid and pass the current time back
|
|
32
|
+
if (resolveBlock) {
|
|
33
|
+
resolveBlock(@[@(currentTime)]); // Call the callback with the current time
|
|
34
|
+
resolveBlock = nil; // Clear the block after it's called
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Invalidate the display link to stop future callbacks
|
|
38
|
+
[displayLink invalidate];
|
|
39
|
+
displayLink = nil;
|
|
40
|
+
}
|
|
41
|
+
#endif
|
|
42
|
+
|
|
43
|
+
@end
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@sentry/react-native",
|
|
3
3
|
"homepage": "https://github.com/getsentry/sentry-react-native",
|
|
4
4
|
"repository": "https://github.com/getsentry/sentry-react-native",
|
|
5
|
-
"version": "5.
|
|
5
|
+
"version": "5.35.0-beta.0",
|
|
6
6
|
"description": "Official Sentry SDK for react-native",
|
|
7
7
|
"typings": "dist/js/index.d.ts",
|
|
8
8
|
"types": "dist/js/index.d.ts",
|
package/src/js/NativeRNSentry.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type { UnsafeObject } from './utils/rnlibrariesinterface';
|
|
|
9
9
|
export interface Spec extends TurboModule {
|
|
10
10
|
addListener: (eventType: string) => void;
|
|
11
11
|
removeListeners: (id: number) => void;
|
|
12
|
+
getNewScreenTimeToDisplay(): Promise<number | undefined | null>;
|
|
12
13
|
addBreadcrumb(breadcrumb: UnsafeObject): void;
|
|
13
14
|
captureEnvelope(
|
|
14
15
|
bytes: string,
|
|
@@ -16,6 +17,7 @@ export interface Spec extends TurboModule {
|
|
|
16
17
|
hardCrashed: boolean;
|
|
17
18
|
},
|
|
18
19
|
): Promise<boolean>;
|
|
20
|
+
|
|
19
21
|
captureScreenshot(): Promise<NativeScreenshot[] | undefined | null>;
|
|
20
22
|
clearBreadcrumbs(): void;
|
|
21
23
|
crash(): void;
|
|
@@ -4,6 +4,7 @@ import type { UnsafeObject } from './utils/rnlibrariesinterface';
|
|
|
4
4
|
export interface Spec extends TurboModule {
|
|
5
5
|
addListener: (eventType: string) => void;
|
|
6
6
|
removeListeners: (id: number) => void;
|
|
7
|
+
getNewScreenTimeToDisplay(): Promise<number | undefined | null>;
|
|
7
8
|
addBreadcrumb(breadcrumb: UnsafeObject): void;
|
|
8
9
|
captureEnvelope(bytes: string, options: {
|
|
9
10
|
hardCrashed: boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { SentryEventEmitter } from './sentryeventemitter';
|
|
2
|
+
export declare const FALLBACK_TIMEOUT_MS = 10000;
|
|
3
|
+
export type FallBackNewFrameEvent = {
|
|
4
|
+
newFrameTimestampInSeconds: number;
|
|
5
|
+
isFallback?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export interface SentryEventEmitterFallback {
|
|
8
|
+
/**
|
|
9
|
+
* Initializes the fallback event emitter
|
|
10
|
+
* This method is synchronous in JS but the event emitter starts asynchronously.
|
|
11
|
+
*/
|
|
12
|
+
initAsync: () => void;
|
|
13
|
+
onceNewFrame: (listener: (event: FallBackNewFrameEvent) => void) => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates emitter that allows to listen to UI Frame events when ready.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createSentryFallbackEventEmitter(emitter?: SentryEventEmitter, fallbackTimeoutMs?: number): SentryEventEmitterFallback;
|
|
19
|
+
//# sourceMappingURL=sentryeventemitterfallback.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const SDK_PACKAGE_NAME = "npm:@sentry/react-native";
|
|
2
2
|
export declare const SDK_NAME = "sentry.javascript.react-native";
|
|
3
|
-
export declare const SDK_VERSION = "5.
|
|
3
|
+
export declare const SDK_VERSION = "5.35.0-beta.0";
|
|
4
4
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -46,7 +46,7 @@ interface SentryNativeWrapper {
|
|
|
46
46
|
enableNativeFramesTracking(): void;
|
|
47
47
|
addBreadcrumb(breadcrumb: Breadcrumb): void;
|
|
48
48
|
setContext(key: string, context: {
|
|
49
|
-
[key: string]:
|
|
49
|
+
[key: string]: any;
|
|
50
50
|
} | null): void;
|
|
51
51
|
clearBreadcrumbs(): void;
|
|
52
52
|
setExtra(key: string, extra: unknown): void;
|
|
@@ -70,6 +70,7 @@ interface SentryNativeWrapper {
|
|
|
70
70
|
captureReplay(isHardCrash: boolean): Promise<string | null>;
|
|
71
71
|
getCurrentReplayId(): string | null;
|
|
72
72
|
crashedLastRun(): Promise<boolean | null>;
|
|
73
|
+
getNewScreenTimeToDisplay(): Promise<number | null | undefined>;
|
|
73
74
|
}
|
|
74
75
|
/**
|
|
75
76
|
* Our internal interface for calling native functions
|