@sentry/react-native 3.3.1 → 3.3.4
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 +16 -0
- package/RNSentry.podspec +1 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/io/sentry/react/RNSentryModule.java +20 -0
- package/dist/js/integrations/devicecontext.d.ts.map +1 -1
- package/dist/js/integrations/devicecontext.js +8 -2
- package/dist/js/integrations/devicecontext.js.map +1 -1
- package/dist/js/options.d.ts +0 -2
- package/dist/js/options.d.ts.map +1 -1
- package/dist/js/options.js.map +1 -1
- package/dist/js/tracing/reactnavigation.d.ts +1 -1
- package/dist/js/tracing/reactnavigation.js +7 -7
- package/dist/js/tracing/reactnavigation.js.map +1 -1
- package/dist/js/version.d.ts +1 -1
- package/dist/js/version.js +1 -1
- package/dist/js/version.js.map +1 -1
- package/dist/js/wrapper.d.ts.map +1 -1
- package/dist/js/wrapper.js +3 -9
- package/dist/js/wrapper.js.map +1 -1
- package/ios/RNSentry.m +37 -9
- package/package.json +1 -1
- package/sentry.gradle +12 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.3.4
|
|
4
|
+
|
|
5
|
+
- fix(android): setContext serializes as context for Android instead of extra (#2155)
|
|
6
|
+
- fix(android): Duplicate Breadcrumbs when captuing messages #2153
|
|
7
|
+
|
|
8
|
+
## 3.3.3
|
|
9
|
+
|
|
10
|
+
- Bump: Sentry Cocoa to 7.10.2 and Sentry Android to 5.6.3 (#2145)
|
|
11
|
+
- fix(android): Upload source maps correctly regardless of version codes #2144
|
|
12
|
+
|
|
13
|
+
## 3.3.2
|
|
14
|
+
|
|
15
|
+
- fix: Do not report empty measurements #1983
|
|
16
|
+
- fix(iOS): Bump Sentry Cocoa to 7.10.1 and report slow and frozen measurements (#2132)
|
|
17
|
+
- fix(iOS): Missing userId on iOS when the user is not set in the Scope (#2133)
|
|
18
|
+
|
|
3
19
|
## 3.3.1
|
|
4
20
|
|
|
5
21
|
- feat: Support setting maxCacheItems #2102
|
package/RNSentry.podspec
CHANGED
package/android/build.gradle
CHANGED
|
@@ -118,6 +118,9 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
|
|
|
118
118
|
if (rnOptions.hasKey("sessionTrackingIntervalMillis")) {
|
|
119
119
|
options.setSessionTrackingIntervalMillis(rnOptions.getInt("sessionTrackingIntervalMillis"));
|
|
120
120
|
}
|
|
121
|
+
if (rnOptions.hasKey("shutdownTimeout")) {
|
|
122
|
+
options.setShutdownTimeout(rnOptions.getInt("shutdownTimeout"));
|
|
123
|
+
}
|
|
121
124
|
if (rnOptions.hasKey("enableNdkScopeSync")) {
|
|
122
125
|
options.setEnableScopeSync(rnOptions.getBoolean("enableNdkScopeSync"));
|
|
123
126
|
}
|
|
@@ -269,6 +272,11 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
|
|
|
269
272
|
}
|
|
270
273
|
}
|
|
271
274
|
|
|
275
|
+
if (totalFrames == 0 && slowFrames == 0 && frozenFrames == 0) {
|
|
276
|
+
promise.resolve(null);
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
|
|
272
280
|
WritableMap map = Arguments.createMap();
|
|
273
281
|
map.putInt("totalFrames", totalFrames);
|
|
274
282
|
map.putInt("slowFrames", slowFrames);
|
|
@@ -433,6 +441,18 @@ public class RNSentryModule extends ReactContextBaseJavaModule {
|
|
|
433
441
|
});
|
|
434
442
|
}
|
|
435
443
|
|
|
444
|
+
@ReactMethod
|
|
445
|
+
public void setContext(final String key, final ReadableMap context) {
|
|
446
|
+
if (key == null || context == null) {
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
Sentry.configureScope(scope -> {
|
|
450
|
+
final HashMap<String, Object> contextHashMap = context.toHashMap();
|
|
451
|
+
|
|
452
|
+
scope.setContexts(key, contextHashMap);
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
|
|
436
456
|
@ReactMethod
|
|
437
457
|
public void setTag(String key, String value) {
|
|
438
458
|
Sentry.configureScope(scope -> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devicecontext.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/devicecontext.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"devicecontext.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/devicecontext.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,WAAW,EAAE,MAAM,eAAe,CAAC;AAK7D,uCAAuC;AACvC,qBAAa,aAAc,YAAW,WAAW;IAC/C;;OAEG;IACH,OAAc,EAAE,EAAE,MAAM,CAAmB;IAE3C;;OAEG;IACI,IAAI,EAAE,MAAM,CAAoB;IAEvC;;OAEG;IACI,SAAS,IAAI,IAAI;CAyBzB"}
|
|
@@ -15,13 +15,19 @@ export class DeviceContext {
|
|
|
15
15
|
*/
|
|
16
16
|
setupOnce() {
|
|
17
17
|
addGlobalEventProcessor((event) => __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
var _a, _b;
|
|
18
19
|
const self = getCurrentHub().getIntegration(DeviceContext);
|
|
19
20
|
if (!self) {
|
|
20
21
|
return event;
|
|
21
22
|
}
|
|
22
23
|
try {
|
|
23
|
-
const
|
|
24
|
-
|
|
24
|
+
const contexts = yield NATIVE.fetchNativeDeviceContexts();
|
|
25
|
+
const context = (_a = contexts['context']) !== null && _a !== void 0 ? _a : {};
|
|
26
|
+
const user = (_b = contexts['user']) !== null && _b !== void 0 ? _b : {};
|
|
27
|
+
event.contexts = Object.assign(Object.assign({}, context), event.contexts);
|
|
28
|
+
if (!event.user) {
|
|
29
|
+
event.user = Object.assign({}, user);
|
|
30
|
+
}
|
|
25
31
|
}
|
|
26
32
|
catch (e) {
|
|
27
33
|
logger.log(`Failed to get device context from native: ${e}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devicecontext.js","sourceRoot":"","sources":["../../../src/js/integrations/devicecontext.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAEtE,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,uCAAuC;AACvC,MAAM,OAAO,aAAa;IAA1B;QAME;;WAEG;QACI,SAAI,GAAW,aAAa,CAAC,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"devicecontext.js","sourceRoot":"","sources":["../../../src/js/integrations/devicecontext.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAEtE,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,uCAAuC;AACvC,MAAM,OAAO,aAAa;IAA1B;QAME;;WAEG;QACI,SAAI,GAAW,aAAa,CAAC,EAAE,CAAC;IA8BzC,CAAC;IA5BC;;OAEG;IACI,SAAS;QACd,uBAAuB,CAAC,CAAO,KAAY,EAAE,EAAE;;YAC7C,MAAM,IAAI,GAAG,aAAa,EAAE,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;YAC3D,IAAI,CAAC,IAAI,EAAE;gBACT,OAAO,KAAK,CAAC;aACd;YAED,IAAI;gBACF,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,yBAAyB,EAAE,CAAC;gBAE1D,MAAM,OAAO,SAAG,QAAQ,CAAC,SAAS,CAAa,mCAAI,EAAE,CAAC;gBACtD,MAAM,IAAI,SAAG,QAAQ,CAAC,MAAM,CAAC,mCAAI,EAAE,CAAC;gBAEpC,KAAK,CAAC,QAAQ,mCAAQ,OAAO,GAAK,KAAK,CAAC,QAAQ,CAAE,CAAC;gBAEnD,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;oBACf,KAAK,CAAC,IAAI,qBAAQ,IAAI,CAAE,CAAC;iBAC1B;aACF;YAAC,OAAO,CAAC,EAAE;gBACV,MAAM,CAAC,GAAG,CAAC,6CAA6C,CAAC,EAAE,CAAC,CAAC;aAC9D;YAED,OAAO,KAAK,CAAC;QACf,CAAC,CAAA,CAAC,CAAC;IACL,CAAC;;AArCD;;GAEG;AACW,gBAAE,GAAW,eAAe,CAAC","sourcesContent":["import { addGlobalEventProcessor, getCurrentHub } from \"@sentry/core\";\nimport { Contexts, Event, Integration } from \"@sentry/types\";\nimport { logger } from \"@sentry/utils\";\n\nimport { NATIVE } from \"../wrapper\";\n\n/** Load device context from native. */\nexport class DeviceContext implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = \"DeviceContext\";\n\n /**\n * @inheritDoc\n */\n public name: string = DeviceContext.id;\n\n /**\n * @inheritDoc\n */\n public setupOnce(): void {\n addGlobalEventProcessor(async (event: Event) => {\n const self = getCurrentHub().getIntegration(DeviceContext);\n if (!self) {\n return event;\n }\n\n try {\n const contexts = await NATIVE.fetchNativeDeviceContexts();\n\n const context = contexts['context'] as Contexts ?? {};\n const user = contexts['user'] ?? {};\n\n event.contexts = { ...context, ...event.contexts };\n\n if (!event.user) {\n event.user = { ...user };\n }\n } catch (e) {\n logger.log(`Failed to get device context from native: ${e}`);\n }\n\n return event;\n });\n }\n}\n"]}
|
package/dist/js/options.d.ts
CHANGED
|
@@ -31,8 +31,6 @@ export interface ReactNativeOptions extends BrowserOptions {
|
|
|
31
31
|
* @default true
|
|
32
32
|
*/
|
|
33
33
|
autoInitializeNativeSdk?: boolean;
|
|
34
|
-
/** Maximum time to wait to drain the request queue, before the process is allowed to exit. */
|
|
35
|
-
shutdownTimeout?: number;
|
|
36
34
|
/** Should the native nagger alert be shown or not. */
|
|
37
35
|
enableNativeNagger?: boolean;
|
|
38
36
|
/** Should sessions be tracked to Sentry Health or not. */
|
package/dist/js/options.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/js/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAExD;;;GAGG;AAEH,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD;;;;;OAKG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;OAGG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;IAEpC;;;;;;;;;;OAUG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAElC,
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/js/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAExD;;;GAGG;AAEH,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD;;;;;OAKG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;OAGG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;IAEpC;;;;;;;;;;OAUG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAElC,sDAAsD;IACtD,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B,0DAA0D;IAC1D,yBAAyB,CAAC,EAAE,OAAO,CAAC;IAEpC,uEAAuE;IACvE,6BAA6B,CAAC,EAAE,MAAM,CAAC;IAEvC,oDAAoD;IACpD,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B,+FAA+F;IAC/F,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;;SAIK;IACL,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE;QACnB,yEAAyE;QACzE,iBAAiB,EAAE,OAAO,CAAC;KAC5B,KAAK,IAAI,CAAC;IAEX,mDAAmD;IACnD,6BAA6B,CAAC,EAAE,OAAO,CAAC;IAExC;;;;;;SAMK;IACL,yBAAyB,CAAC,EAAE,OAAO,CAAC;IAEpC;;;OAGG;IACH,YAAY,CAAC,EAAE,cAAc,CAAC;IAE9B;;;;;;;OAOG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;;KAIC;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,yBAAyB;IACxC,wCAAwC;IACxC,aAAa,CAAC,EAAE,aAAa,CAAC;IAE9B,8CAA8C;IAC9C,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;CACnD"}
|
package/dist/js/options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/js/options.ts"],"names":[],"mappings":"","sourcesContent":["import { BrowserOptions } from \"@sentry/react\";\nimport { ProfilerProps } from \"@sentry/react/dist/profiler\";\nimport { CaptureContext } from \"@sentry/types/dist/scope\";\n\nimport { TouchEventBoundaryProps } from \"./touchevents\";\n\n/**\n * Configuration options for the Sentry ReactNative SDK.\n * @see ReactNativeFrontend for more information.\n */\n\nexport interface ReactNativeOptions extends BrowserOptions {\n /**\n * Enables native transport + device info + offline caching.\n * Be careful, disabling this also breaks automatic release setting.\n * This means you have to manage setting the release yourself.\n * Defaults to `true`.\n */\n enableNative?: boolean;\n\n /**\n * Enables native crashHandling. This only works if `enableNative` is `true`.\n * Defaults to `true`.\n */\n enableNativeCrashHandling?: boolean;\n\n /**\n * Initializes the native SDK on init.\n * Set this to `false` if you have an existing native SDK and don't want to re-initialize.\n *\n * NOTE: Be careful and only use this if you know what you are doing.\n * If you use this flag, make sure a native SDK is running before the JS Engine initializes or events might not be captured.\n * Also, make sure the DSN on both the React Native side and the native side are the same one.\n * We strongly recommend checking the documentation if you need to use this.\n *\n * @default true\n */\n autoInitializeNativeSdk?: boolean;\n\n /**
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/js/options.ts"],"names":[],"mappings":"","sourcesContent":["import { BrowserOptions } from \"@sentry/react\";\nimport { ProfilerProps } from \"@sentry/react/dist/profiler\";\nimport { CaptureContext } from \"@sentry/types/dist/scope\";\n\nimport { TouchEventBoundaryProps } from \"./touchevents\";\n\n/**\n * Configuration options for the Sentry ReactNative SDK.\n * @see ReactNativeFrontend for more information.\n */\n\nexport interface ReactNativeOptions extends BrowserOptions {\n /**\n * Enables native transport + device info + offline caching.\n * Be careful, disabling this also breaks automatic release setting.\n * This means you have to manage setting the release yourself.\n * Defaults to `true`.\n */\n enableNative?: boolean;\n\n /**\n * Enables native crashHandling. This only works if `enableNative` is `true`.\n * Defaults to `true`.\n */\n enableNativeCrashHandling?: boolean;\n\n /**\n * Initializes the native SDK on init.\n * Set this to `false` if you have an existing native SDK and don't want to re-initialize.\n *\n * NOTE: Be careful and only use this if you know what you are doing.\n * If you use this flag, make sure a native SDK is running before the JS Engine initializes or events might not be captured.\n * Also, make sure the DSN on both the React Native side and the native side are the same one.\n * We strongly recommend checking the documentation if you need to use this.\n *\n * @default true\n */\n autoInitializeNativeSdk?: boolean;\n\n /** Should the native nagger alert be shown or not. */\n enableNativeNagger?: boolean;\n\n /** Should sessions be tracked to Sentry Health or not. */\n enableAutoSessionTracking?: boolean;\n\n /** The interval to end a session if the App goes to the background. */\n sessionTrackingIntervalMillis?: number;\n\n /** Enable scope sync from Java to NDK on Android */\n enableNdkScopeSync?: boolean;\n\n /** When enabled, all the threads are automatically attached to all logged events on Android */\n attachThreads?: boolean;\n\n /**\n * When enabled, certain personally identifiable information (PII) is added by active integrations.\n *\n * @default false\n * */\n sendDefaultPii?: boolean;\n\n /**\n * Callback that is called after the RN SDK on the JS Layer has made contact with the Native Layer.\n */\n onReady?: (response: {\n /** `true` if the native SDK has been initialized, `false` otherwise. */\n didCallNativeInit: boolean;\n }) => void;\n\n /** Enable auto performance tracking by default. */\n enableAutoPerformanceTracking?: boolean;\n\n /**\n * Enables Out of Memory Tracking for iOS and macCatalyst.\n * See the following link for more information and possible restrictions:\n * https://docs.sentry.io/platforms/apple/guides/ios/configuration/out-of-memory/\n *\n * @default true\n * */\n enableOutOfMemoryTracking?: boolean;\n\n /**\n * Set data to the inital scope\n * @deprecated Use `Sentry.configureScope(...)`\n */\n initialScope?: CaptureContext;\n\n /**\n * When enabled, Sentry will overwrite the global Promise instance to ensure that unhandled rejections are correctly tracked.\n * If you run into issues with Promise polyfills such as `core-js`, make sure you polyfill after Sentry is initialized.\n * Read more at https://docs.sentry.io/platforms/react-native/troubleshooting/#unhandled-promise-rejections\n *\n * When disabled, this option will not disable unhandled rejection tracking. Set `onunhandledrejection: false` on the `ReactNativeErrorHandlers` integration instead.\n * @default true\n */\n patchGlobalPromise?: boolean;\n\n /**\n * The max cache items for capping the number of envelopes.\n *\n * @default 30\n */\n maxCacheItems?: number;\n}\n\nexport interface ReactNativeWrapperOptions {\n /** Props for the root React profiler */\n profilerProps?: ProfilerProps;\n\n /** Props for the root touch event boundary */\n touchEventBoundaryProps?: TouchEventBoundaryProps;\n}\n"]}
|
|
@@ -12,7 +12,7 @@ interface ReactNavigationOptions {
|
|
|
12
12
|
routeChangeTimeoutMs: number;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* Instrumentation for React-Navigation V5. See docs or sample app for usage.
|
|
15
|
+
* Instrumentation for React-Navigation V5 and above. See docs or sample app for usage.
|
|
16
16
|
*
|
|
17
17
|
* How this works:
|
|
18
18
|
* - `_onDispatch` is called every time a dispatch happens and sets an IdleTransaction on the scope without any route context.
|
|
@@ -5,7 +5,7 @@ const defaultOptions = {
|
|
|
5
5
|
routeChangeTimeoutMs: 1000,
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
|
-
* Instrumentation for React-Navigation V5. See docs or sample app for usage.
|
|
8
|
+
* Instrumentation for React-Navigation V5 and above. See docs or sample app for usage.
|
|
9
9
|
*
|
|
10
10
|
* How this works:
|
|
11
11
|
* - `_onDispatch` is called every time a dispatch happens and sets an IdleTransaction on the scope without any route context.
|
|
@@ -75,17 +75,17 @@ export class ReactNavigationInstrumentation extends InternalRoutingInstrumentati
|
|
|
75
75
|
this._initialStateHandled = true;
|
|
76
76
|
}
|
|
77
77
|
else {
|
|
78
|
-
logger.log("[
|
|
78
|
+
logger.log("[ReactNavigationInstrumentation] Navigation container registered, but integration has not been setup yet.");
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
_global.__sentry_rn_v5_registered = true;
|
|
82
82
|
}
|
|
83
83
|
else {
|
|
84
|
-
logger.warn("[
|
|
84
|
+
logger.warn("[ReactNavigationInstrumentation] Received invalid navigation container ref!");
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
else {
|
|
88
|
-
logger.log("[
|
|
88
|
+
logger.log("[ReactNavigationInstrumentation] Instrumentation already exists, but register has been called again, doing nothing.");
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
@@ -110,7 +110,7 @@ export class ReactNavigationInstrumentation extends InternalRoutingInstrumentati
|
|
|
110
110
|
// Use the getCurrentRoute method to be accurate.
|
|
111
111
|
const previousRoute = this._latestRoute;
|
|
112
112
|
if (!this._navigationContainer) {
|
|
113
|
-
logger.warn("[
|
|
113
|
+
logger.warn("[ReactNavigationInstrumentation] Missing navigation container ref. Route transactions will not be sent.");
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
116
116
|
const route = this._navigationContainer.getCurrentRoute();
|
|
@@ -135,12 +135,12 @@ export class ReactNavigationInstrumentation extends InternalRoutingInstrumentati
|
|
|
135
135
|
let finalContext = (_c = this._beforeNavigate) === null || _c === void 0 ? void 0 : _c.call(this, updatedContext);
|
|
136
136
|
// This block is to catch users not returning a transaction context
|
|
137
137
|
if (!finalContext) {
|
|
138
|
-
logger.error(`[
|
|
138
|
+
logger.error(`[ReactNavigationInstrumentation] beforeNavigate returned ${finalContext}, return context.sampled = false to not send transaction.`);
|
|
139
139
|
finalContext = Object.assign(Object.assign({}, updatedContext), { sampled: false });
|
|
140
140
|
}
|
|
141
141
|
// Note: finalContext.sampled will be false at this point only if the user sets it to be so in beforeNavigate.
|
|
142
142
|
if (finalContext.sampled === false) {
|
|
143
|
-
logger.log(`[
|
|
143
|
+
logger.log(`[ReactNavigationInstrumentation] Will not send transaction "${finalContext.name}" due to beforeNavigate.`);
|
|
144
144
|
}
|
|
145
145
|
else {
|
|
146
146
|
// Clear the timeout so the transaction does not get cancelled.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactnavigation.js","sourceRoot":"","sources":["../../../src/js/tracing/reactnavigation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGxD,OAAO,EACL,8BAA8B,GAG/B,MAAM,0BAA0B,CAAC;AAKlC,OAAO,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAqBrD,MAAM,cAAc,GAA2B;IAC7C,oBAAoB,EAAE,IAAI;CAC3B,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,OAAO,8BAA+B,SAAQ,8BAA8B;IAehF,YAAmB,UAA2C,EAAE;QAC9D,KAAK,EAAE,CAAC;QAbF,yBAAoB,GAA+B,IAAI,CAAC;QAE/C,uBAAkB,GAAW,GAAG,CAAC;QAI1C,yBAAoB,GAAY,KAAK,CAAC;QAEtC,qBAAgB,GAAa,EAAE,CAAC;QAiNxC,sGAAsG;QAC9F,wBAAmB,GAAG,CAAC,GAAW,EAAQ,EAAE;YAClD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAE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,8BAA8B,CAAC,mBAAmB;KACrD;IACD,IAAI,EAAE,EAAE;CACT,CAAC","sourcesContent":["/* eslint-disable max-lines */\nimport { Transaction as TransactionType } from \"@sentry/types\";\nimport { getGlobalObject, logger } from \"@sentry/utils\";\n\nimport { BeforeNavigate } from \"./reactnativetracing\";\nimport {\n InternalRoutingInstrumentation,\n OnConfirmRoute,\n TransactionCreator,\n} from \"./routingInstrumentation\";\nimport {\n ReactNavigationTransactionContext,\n RouteChangeContextData,\n} from \"./types\";\nimport { getBlankTransactionContext } 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 * The time the transaction will wait for route to mount before it is discarded.\n */\n routeChangeTimeoutMs: number;\n}\n\nconst defaultOptions: ReactNavigationOptions = {\n routeChangeTimeoutMs: 1000,\n};\n\n/**\n * Instrumentation for React-Navigation V5. 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 class ReactNavigationInstrumentation extends InternalRoutingInstrumentation {\n public static instrumentationName: string = \"react-navigation-v5\";\n\n private _navigationContainer: NavigationContainer | null = null;\n\n private readonly _maxRecentRouteLen: number = 200;\n\n private _latestRoute?: NavigationRoute;\n private _latestTransaction?: TransactionType;\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\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(\n listener,\n beforeNavigate,\n onConfirmRoute\n );\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 const _global = getGlobalObject<{ __sentry_rn_v5_registered?: boolean }>();\n\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 (!_global.__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 \"[ReactNavigationV5Instrumentation] Navigation container registered, but integration has not been setup yet.\"\n );\n }\n }\n\n _global.__sentry_rn_v5_registered = true;\n } else {\n logger.warn(\n \"[ReactNavigationV5Instrumentation] Received invalid navigation container ref!\"\n );\n }\n } else {\n logger.log(\n \"[ReactNavigationV5Instrumentation] 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(\n ReactNavigationInstrumentation.instrumentationName\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 // Use the getCurrentRoute method to be accurate.\n const previousRoute = this._latestRoute;\n\n if (!this._navigationContainer) {\n logger.warn(\n \"[ReactNavigationV5Instrumentation] 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 originalContext = this._latestTransaction.toContext() as typeof BLANK_TRANSACTION_CONTEXT;\n const routeHasBeenSeen = this._recentRouteKeys.includes(route.key);\n\n const data: RouteChangeContextData = {\n ...originalContext.data,\n route: {\n name: route.name,\n key: route.key,\n params: route.params ?? {},\n hasBeenSeen: routeHasBeenSeen,\n },\n previousRoute: previousRoute\n ? {\n name: previousRoute.name,\n key: previousRoute.key,\n params: previousRoute.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 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 `[ReactNavigationV5Instrumentation] 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 `[ReactNavigationV5Instrumentation] 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 this._latestTransaction.updateWithContext(finalContext);\n this._onConfirmRoute?.(finalContext);\n }\n\n this._pushRecentRouteKey(route.key);\n this._latestRoute = route;\n }\n }\n\n // Clear the latest transaction as it has been handled.\n this._latestTransaction = undefined;\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(\n this._recentRouteKeys.length - this._maxRecentRouteLen\n );\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 }\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\":\n ReactNavigationInstrumentation.instrumentationName,\n },\n data: {},\n};\n"]}
|
|
1
|
+
{"version":3,"file":"reactnavigation.js","sourceRoot":"","sources":["../../../src/js/tracing/reactnav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AC/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;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;;AAvPa,kDAAmB,GAAW,qBAAqB,CAAC;AA0PpE;;;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,EACvB,8BAA8B,CAAC,mBAAmB;KACrD;IACD,IAAI,EAAE,EAAE;CACT,CAAC","sourcesContent":["/* eslint-disable max-lines */\nimport { Transaction as TransactionType } from \"@sentry/types\";\nimport { getGlobalObject, logger } from \"@sentry/utils\";\n\nimport { BeforeNavigate } from \"./reactnativetracing\";\nimport {\n InternalRoutingInstrumentation,\n OnConfirmRoute,\n TransactionCreator,\n} from \"./routingInstrumentation\";\nimport {\n ReactNavigationTransactionContext,\n RouteChangeContextData,\n} from \"./types\";\nimport { getBlankTransactionContext } 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 * The time the transaction will wait for route to mount before it is discarded.\n */\n routeChangeTimeoutMs: number;\n}\n\nconst defaultOptions: ReactNavigationOptions = {\n routeChangeTimeoutMs: 1000,\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 class ReactNavigationInstrumentation extends InternalRoutingInstrumentation {\n public static instrumentationName: string = \"react-navigation-v5\";\n\n private _navigationContainer: NavigationContainer | null = null;\n\n private readonly _maxRecentRouteLen: number = 200;\n\n private _latestRoute?: NavigationRoute;\n private _latestTransaction?: TransactionType;\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\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(\n listener,\n beforeNavigate,\n onConfirmRoute\n );\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 const _global = getGlobalObject<{ __sentry_rn_v5_registered?: boolean }>();\n\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 (!_global.__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 _global.__sentry_rn_v5_registered = true;\n } else {\n logger.warn(\n \"[ReactNavigationInstrumentation] Received invalid navigation container ref!\"\n );\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(\n ReactNavigationInstrumentation.instrumentationName\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 // 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 originalContext = this._latestTransaction.toContext() as typeof BLANK_TRANSACTION_CONTEXT;\n const routeHasBeenSeen = this._recentRouteKeys.includes(route.key);\n\n const data: RouteChangeContextData = {\n ...originalContext.data,\n route: {\n name: route.name,\n key: route.key,\n params: route.params ?? {},\n hasBeenSeen: routeHasBeenSeen,\n },\n previousRoute: previousRoute\n ? {\n name: previousRoute.name,\n key: previousRoute.key,\n params: previousRoute.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 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 this._latestTransaction.updateWithContext(finalContext);\n this._onConfirmRoute?.(finalContext);\n }\n\n this._pushRecentRouteKey(route.key);\n this._latestRoute = route;\n }\n }\n\n // Clear the latest transaction as it has been handled.\n this._latestTransaction = undefined;\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(\n this._recentRouteKeys.length - this._maxRecentRouteLen\n );\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 }\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\":\n ReactNavigationInstrumentation.instrumentationName,\n },\n data: {},\n};\n"]}
|
package/dist/js/version.d.ts
CHANGED
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,QAAQ,GAAG,gCAAgC,CAAC;AACzD,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC","sourcesContent":["export const SDK_NAME = \"sentry.javascript.react-native\";\nexport const SDK_VERSION = \"3.3.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/js/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,gCAAgC,CAAC;AACzD,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC","sourcesContent":["export const SDK_NAME = \"sentry.javascript.react-native\";\nexport const SDK_VERSION = \"3.3.4\";\n"]}
|
package/dist/js/wrapper.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapper.d.ts","sourceRoot":"","sources":["../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;IAC1E,gBAAgB,IAAI,IAAI,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5C,OAAO,CAAC,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;CACrB;AAED;;GAEG;AACH,eAAO,MAAM,MAAM,EAAE,mBA+dpB,CAAC"}
|
package/dist/js/wrapper.js
CHANGED
|
@@ -39,11 +39,11 @@ export const NATIVE = {
|
|
|
39
39
|
We do this to avoid duplicate breadcrumbs on Android as sentry-android applies the breadcrumbs
|
|
40
40
|
from the native scope onto every envelope sent through it. This scope will contain the breadcrumbs
|
|
41
41
|
sent through the scope sync feature. This causes duplicate breadcrumbs.
|
|
42
|
-
We then remove the breadcrumbs
|
|
42
|
+
We then remove the breadcrumbs in all cases but if it is handled == false,
|
|
43
43
|
this is a signal that the app would crash and android would lose the breadcrumbs by the time the app is restarted to read
|
|
44
44
|
the envelope.
|
|
45
45
|
*/
|
|
46
|
-
if ((_d = (_c = (_b = (_a = event.exception) === null || _a === void 0 ? void 0 : _a.values) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.mechanism) === null || _d === void 0 ? void 0 : _d.handled) {
|
|
46
|
+
if (((_d = (_c = (_b = (_a = event.exception) === null || _a === void 0 ? void 0 : _a.values) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.mechanism) === null || _d === void 0 ? void 0 : _d.handled) != false && event.breadcrumbs) {
|
|
47
47
|
event.breadcrumbs = [];
|
|
48
48
|
}
|
|
49
49
|
const payload = Object.assign(Object.assign({}, event), { message: {
|
|
@@ -312,13 +312,7 @@ export const NATIVE = {
|
|
|
312
312
|
if (!this._isModuleLoaded(RNSentry)) {
|
|
313
313
|
throw this._NativeClientError;
|
|
314
314
|
}
|
|
315
|
-
|
|
316
|
-
// setContext not available on the Android SDK yet.
|
|
317
|
-
this.setExtra(key, context);
|
|
318
|
-
}
|
|
319
|
-
else {
|
|
320
|
-
RNSentry.setContext(key, context !== null ? this._serializeObject(context) : null);
|
|
321
|
-
}
|
|
315
|
+
RNSentry.setContext(key, context !== null ? this._serializeObject(context) : null);
|
|
322
316
|
},
|
|
323
317
|
/**
|
|
324
318
|
* Closes the Native Layer SDK
|
package/dist/js/wrapper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../../src/js/wrapper.ts"],"names":[],"mappings":";AAAA,8BAA8B;AAC9B,OAAO,EAKL,QAAQ,GAET,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAWvD,MAAM,QAAQ,GAAG,aAAa,CAAC,QAAgD,CAAC;AA0ChF;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAwB;IACzC;;;OAGG;IACG,SAAS,CAAC,MAAa;;;YAC3B,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;gBACtB,OAAO;oBACL,MAAM,EAAE,iDAAiD;oBACzD,MAAM,EAAE,SAAS;iBAClB,CAAC;aACH;YAED,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE;gBACnC,MAAM,IAAI,CAAC,kBAAkB,CAAC;aAC/B;YAED,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;YAE1C,6DAA6D;YAC7D,OAAO,KAAK,CAAC,qBAAqB,CAAC;YAEnC,MAAM,MAAM,GAAG;gBACb,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,GAAG,EAAE,KAAK,CAAC,GAAG;aACf,CAAC;YAEF,IA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AU,KACb,KAAK,EAAE,UAAU,CAAC,KAAK;oBACrB,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,KAAK,CAAC;oBACtC,CAAC,CAAC,SAAS,IACb,IACH,CAAC;QAEF,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;OAIG;IACH,aAAa,CAAC,KAAe;QAC3B,IAAI,KAAK,KAAK,QAAQ,CAAC,QAAQ,EAAE;YAC/B,OAAO,QAAQ,CAAC,KAAK,CAAC;SACvB;QACD,IAAI,KAAK,KAAK,QAAQ,CAAC,GAAG,EAAE;YAC1B,OAAO,QAAQ,CAAC,KAAK,CAAC;SACvB;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACH,eAAe,CACb,MAA4C;QAE5C,OAAO,CAAC,CAAC,MAAM,CAAC;IAClB,CAAC;IAED,oBAAoB,EAAE,IAAI,WAAW,CAAC,oBAAoB,CAAC;IAE3D,kBAAkB,EAAE,IAAI,WAAW,CACjC,wDAAwD,CACzD;IAED,YAAY,EAAE,IAAI;IAClB,aAAa,EAAE,KAAK;IACpB,QAAQ,EAAE,QAAQ,CAAC,EAAE;CACtB,CAAC","sourcesContent":["/* eslint-disable max-lines */\nimport {\n Breadcrumb,\n Event,\n Package,\n Response,\n Severity,\n User,\n} from \"@sentry/types\";\nimport { logger, SentryError } from \"@sentry/utils\";\nimport { NativeModules, Platform } from \"react-native\";\n\nimport {\n NativeAppStartResponse,\n NativeDeviceContextsResponse,\n NativeFramesResponse,\n NativeReleaseResponse,\n SentryNativeBridgeModule,\n} from \"./definitions\";\nimport { ReactNativeOptions } from \"./options\";\n\nconst RNSentry = NativeModules.RNSentry as SentryNativeBridgeModule | undefined;\n\ninterface SentryNativeWrapper {\n enableNative: boolean;\n nativeIsReady: boolean;\n platform: typeof Platform.OS;\n\n _NativeClientError: Error;\n _DisabledNativeError: Error;\n\n _processLevels(event: Event): Event;\n _processLevel(level: Severity): Severity;\n _serializeObject(data: { [key: string]: unknown }): { [key: string]: string };\n _isModuleLoaded(\n module: SentryNativeBridgeModule | undefined\n ): module is SentryNativeBridgeModule;\n\n isNativeTransportAvailable(): boolean;\n\n initNativeSdk(options: ReactNativeOptions): PromiseLike<boolean>;\n closeNativeSdk(): PromiseLike<void>;\n\n sendEvent(event: Event): PromiseLike<Response>;\n\n fetchNativeRelease(): PromiseLike<NativeReleaseResponse>;\n fetchNativeDeviceContexts(): PromiseLike<NativeDeviceContextsResponse>;\n fetchNativeAppStart(): PromiseLike<NativeAppStartResponse | null>;\n fetchNativeFrames(): PromiseLike<NativeFramesResponse | null>;\n fetchNativeSdkInfo(): PromiseLike<Package | null>;\n\n disableNativeFramesTracking(): 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\n/**\n * Our internal interface for calling native functions\n */\nexport const NATIVE: SentryNativeWrapper = {\n /**\n * Sending the event over the bridge to native\n * @param event Event\n */\n async sendEvent(_event: Event): Promise<Response> {\n if (!this.enableNative) {\n return {\n reason: `Event was skipped as native SDK is not enabled.`,\n status: \"skipped\",\n };\n }\n\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n const event = this._processLevels(_event);\n\n // Delete this metadata as this should not be sent to Sentry.\n delete event.sdkProcessingMetadata;\n\n const header = {\n event_id: event.event_id,\n sdk: event.sdk,\n };\n\n let envelopeWasSent = false;\n if (NATIVE.platform === \"android\") {\n // Android\n\n const headerString = JSON.stringify(header);\n\n /*\n We do this to avoid duplicate breadcrumbs on Android as sentry-android applies the breadcrumbs\n from the native scope onto every envelope sent through it. This scope will contain the breadcrumbs\n sent through the scope sync feature. This causes duplicate breadcrumbs.\n We then remove the breadcrumbs here but only when mechanism.handled is true. If it is handled == false,\n this is a signal that the app would crash and android would lose the breadcrumbs by the time the app is restarted to read\n the envelope.\n */\n if (event.exception?.values?.[0]?.mechanism?.handled) {\n event.breadcrumbs = [];\n }\n\n const payload = {\n ...event,\n message: {\n message: event.message,\n },\n };\n\n const payloadString = JSON.stringify(payload);\n let length = payloadString.length;\n try {\n length = await RNSentry.getStringBytesLength(payloadString);\n } catch {\n // The native call failed, we do nothing, we have payload.length as a fallback\n }\n\n const item = {\n content_type: \"application/json\",\n length,\n type: payload.type ?? \"event\",\n };\n\n const itemString = JSON.stringify(item);\n\n const envelopeString = `${headerString}\\n${itemString}\\n${payloadString}`;\n\n envelopeWasSent = await RNSentry.captureEnvelope(envelopeString);\n } else {\n // iOS/Mac\n\n const payload = {\n ...event,\n message: {\n message: event.message,\n },\n };\n\n // Serialize and remove any instances that will crash the native bridge such as Spans\n const serializedPayload = JSON.parse(JSON.stringify(payload));\n\n // The envelope item is created (and its length determined) on the iOS side of the native bridge.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n envelopeWasSent = await RNSentry.captureEnvelope({\n header,\n payload: serializedPayload,\n });\n }\n\n if (envelopeWasSent) {\n return {\n status: \"success\",\n };\n }\n\n return {\n status: \"failed\",\n };\n },\n\n /**\n * Starts native with the provided options.\n * @param options ReactNativeOptions\n */\n async initNativeSdk(originalOptions: ReactNativeOptions): Promise<boolean> {\n const options = {\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 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 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 {\n beforeSend,\n beforeBreadcrumb,\n integrations,\n defaultIntegrations,\n transport,\n ...filteredOptions\n } = options;\n /* eslint-enable @typescript-eslint/unbound-method,@typescript-eslint/no-unused-vars */\n\n const nativeIsReady = await RNSentry.initNativeSdk(filteredOptions);\n\n this.nativeIsReady = nativeIsReady;\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 * NOTE: Only available on iOS.\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 if (this.platform !== \"ios\") {\n return null;\n }\n\n return RNSentry.fetchNativeSdkInfo();\n },\n\n /**\n * Fetches the device contexts. Not used on Android.\n */\n async fetchNativeDeviceContexts(): Promise<NativeDeviceContextsResponse> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n if (this.platform !== \"ios\") {\n // Only ios uses deviceContexts, return an empty object.\n return {};\n }\n\n return RNSentry.fetchNativeDeviceContexts();\n },\n\n async fetchNativeAppStart(): Promise<NativeAppStartResponse | null> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\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 serialze all non-default user keys.\n let defaultUserKeys = null;\n let otherUserKeys = null;\n if (user) {\n const { id, ip_address, email, username, ...otherKeys } = user;\n defaultUserKeys = this._serializeObject({\n email,\n id,\n ip_address,\n username,\n });\n otherUserKeys = this._serializeObject(otherKeys);\n }\n\n RNSentry.setUser(defaultUserKeys, otherUserKeys);\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 =\n 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 =\n 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\n ? this._processLevel(breadcrumb.level)\n : undefined,\n data: breadcrumb.data\n ? this._serializeObject(breadcrumb.data)\n : 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 if (this.platform === \"android\") {\n // setContext not available on the Android SDK yet.\n this.setExtra(key, context);\n } else {\n RNSentry.setContext(\n key,\n context !== null ? this._serializeObject(context) : null\n );\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 isNativeTransportAvailable(): boolean {\n return this.enableNative && this._isModuleLoaded(RNSentry);\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: {\n [key: string]: unknown;\n }): { [key: string]: string } {\n const serialized: { [key: string]: string } = {};\n\n Object.keys(data).forEach((dataKey) => {\n const value = data[dataKey];\n serialized[dataKey] =\n 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 _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\n ? this._processLevel(breadcrumb.level)\n : 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 _processLevel(level: Severity): Severity {\n if (level === Severity.Critical) {\n return Severity.Fatal;\n }\n if (level === Severity.Log) {\n return Severity.Debug;\n }\n\n return level;\n },\n\n /**\n * Checks whether the RNSentry module is loaded.\n */\n _isModuleLoaded(\n module: SentryNativeBridgeModule | undefined\n ): module is SentryNativeBridgeModule {\n return !!module;\n },\n\n _DisabledNativeError: new SentryError(\"Native is disabled\"),\n\n _NativeClientError: new SentryError(\n \"Native Client is not available, can't start on native.\"\n ),\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":";AAAA,8BAA8B;AAC9B,OAAO,EAKL,QAAQ,GAET,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAWvD,MAAM,QAAQ,GAAG,aAAa,CAAC,QAAgD,CAAC;AA0ChF;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAwB;IACzC;;;OAGG;IACG,SAAS,CAAC,MAAa;;;YAC3B,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;gBACtB,OAAO;oBACL,MAAM,EAAE,iDAAiD;oBACzD,MAAM,EAAE,SAAS;iBAClB,CAAC;aACH;YAED,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE;gBACnC,MAAM,IAAI,CA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AI,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,EAChE,WAAW,QAAE,KAAK,CAAC,WAAW,0CAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,iCAC/C,UAAU,KACb,KAAK,EAAE,UAAU,CAAC,KAAK;oBACrB,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,KAAK,CAAC;oBACtC,CAAC,CAAC,SAAS,IACb,IACH,CAAC;QAEF,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;OAIG;IACH,aAAa,CAAC,KAAe;QAC3B,IAAI,KAAK,KAAK,QAAQ,CAAC,QAAQ,EAAE;YAC/B,OAAO,QAAQ,CAAC,KAAK,CAAC;SACvB;QACD,IAAI,KAAK,KAAK,QAAQ,CAAC,GAAG,EAAE;YAC1B,OAAO,QAAQ,CAAC,KAAK,CAAC;SACvB;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACH,eAAe,CACb,MAA4C;QAE5C,OAAO,CAAC,CAAC,MAAM,CAAC;IAClB,CAAC;IAED,oBAAoB,EAAE,IAAI,WAAW,CAAC,oBAAoB,CAAC;IAE3D,kBAAkB,EAAE,IAAI,WAAW,CACjC,wDAAwD,CACzD;IAED,YAAY,EAAE,IAAI;IAClB,aAAa,EAAE,KAAK;IACpB,QAAQ,EAAE,QAAQ,CAAC,EAAE;CACtB,CAAC","sourcesContent":["/* eslint-disable max-lines */\nimport {\n Breadcrumb,\n Event,\n Package,\n Response,\n Severity,\n User,\n} from \"@sentry/types\";\nimport { logger, SentryError } from \"@sentry/utils\";\nimport { NativeModules, Platform } from \"react-native\";\n\nimport {\n NativeAppStartResponse,\n NativeDeviceContextsResponse,\n NativeFramesResponse,\n NativeReleaseResponse,\n SentryNativeBridgeModule,\n} from \"./definitions\";\nimport { ReactNativeOptions } from \"./options\";\n\nconst RNSentry = NativeModules.RNSentry as SentryNativeBridgeModule | undefined;\n\ninterface SentryNativeWrapper {\n enableNative: boolean;\n nativeIsReady: boolean;\n platform: typeof Platform.OS;\n\n _NativeClientError: Error;\n _DisabledNativeError: Error;\n\n _processLevels(event: Event): Event;\n _processLevel(level: Severity): Severity;\n _serializeObject(data: { [key: string]: unknown }): { [key: string]: string };\n _isModuleLoaded(\n module: SentryNativeBridgeModule | undefined\n ): module is SentryNativeBridgeModule;\n\n isNativeTransportAvailable(): boolean;\n\n initNativeSdk(options: ReactNativeOptions): PromiseLike<boolean>;\n closeNativeSdk(): PromiseLike<void>;\n\n sendEvent(event: Event): PromiseLike<Response>;\n\n fetchNativeRelease(): PromiseLike<NativeReleaseResponse>;\n fetchNativeDeviceContexts(): PromiseLike<NativeDeviceContextsResponse>;\n fetchNativeAppStart(): PromiseLike<NativeAppStartResponse | null>;\n fetchNativeFrames(): PromiseLike<NativeFramesResponse | null>;\n fetchNativeSdkInfo(): PromiseLike<Package | null>;\n\n disableNativeFramesTracking(): 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\n/**\n * Our internal interface for calling native functions\n */\nexport const NATIVE: SentryNativeWrapper = {\n /**\n * Sending the event over the bridge to native\n * @param event Event\n */\n async sendEvent(_event: Event): Promise<Response> {\n if (!this.enableNative) {\n return {\n reason: `Event was skipped as native SDK is not enabled.`,\n status: \"skipped\",\n };\n }\n\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n const event = this._processLevels(_event);\n\n // Delete this metadata as this should not be sent to Sentry.\n delete event.sdkProcessingMetadata;\n\n const header = {\n event_id: event.event_id,\n sdk: event.sdk,\n };\n\n let envelopeWasSent = false;\n if (NATIVE.platform === \"android\") {\n // Android\n\n const headerString = JSON.stringify(header);\n\n /*\n We do this to avoid duplicate breadcrumbs on Android as sentry-android applies the breadcrumbs\n from the native scope onto every envelope sent through it. This scope will contain the breadcrumbs\n sent through the scope sync feature. This causes duplicate breadcrumbs.\n We then remove the breadcrumbs in all cases but if it is handled == false,\n this is a signal that the app would crash and android would lose the breadcrumbs by the time the app is restarted to read\n the envelope.\n */\n if (event.exception?.values?.[0]?.mechanism?.handled != false && event.breadcrumbs) {\n event.breadcrumbs = [];\n }\n\n const payload = {\n ...event,\n message: {\n message: event.message,\n },\n };\n\n const payloadString = JSON.stringify(payload);\n let length = payloadString.length;\n try {\n length = await RNSentry.getStringBytesLength(payloadString);\n } catch {\n // The native call failed, we do nothing, we have payload.length as a fallback\n }\n\n const item = {\n content_type: \"application/json\",\n length,\n type: payload.type ?? \"event\",\n };\n\n const itemString = JSON.stringify(item);\n\n const envelopeString = `${headerString}\\n${itemString}\\n${payloadString}`;\n\n envelopeWasSent = await RNSentry.captureEnvelope(envelopeString);\n } else {\n // iOS/Mac\n\n const payload = {\n ...event,\n message: {\n message: event.message,\n },\n };\n\n // Serialize and remove any instances that will crash the native bridge such as Spans\n const serializedPayload = JSON.parse(JSON.stringify(payload));\n\n // The envelope item is created (and its length determined) on the iOS side of the native bridge.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n envelopeWasSent = await RNSentry.captureEnvelope({\n header,\n payload: serializedPayload,\n });\n }\n\n if (envelopeWasSent) {\n return {\n status: \"success\",\n };\n }\n\n return {\n status: \"failed\",\n };\n },\n\n /**\n * Starts native with the provided options.\n * @param options ReactNativeOptions\n */\n async initNativeSdk(originalOptions: ReactNativeOptions): Promise<boolean> {\n const options = {\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 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 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 {\n beforeSend,\n beforeBreadcrumb,\n integrations,\n defaultIntegrations,\n transport,\n ...filteredOptions\n } = options;\n /* eslint-enable @typescript-eslint/unbound-method,@typescript-eslint/no-unused-vars */\n\n const nativeIsReady = await RNSentry.initNativeSdk(filteredOptions);\n\n this.nativeIsReady = nativeIsReady;\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 * NOTE: Only available on iOS.\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 if (this.platform !== \"ios\") {\n return null;\n }\n\n return RNSentry.fetchNativeSdkInfo();\n },\n\n /**\n * Fetches the device contexts. Not used on Android.\n */\n async fetchNativeDeviceContexts(): Promise<NativeDeviceContextsResponse> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n if (this.platform !== \"ios\") {\n // Only ios uses deviceContexts, return an empty object.\n return {};\n }\n\n return RNSentry.fetchNativeDeviceContexts();\n },\n\n async fetchNativeAppStart(): Promise<NativeAppStartResponse | null> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\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 serialze all non-default user keys.\n let defaultUserKeys = null;\n let otherUserKeys = null;\n if (user) {\n const { id, ip_address, email, username, ...otherKeys } = user;\n defaultUserKeys = this._serializeObject({\n email,\n id,\n ip_address,\n username,\n });\n otherUserKeys = this._serializeObject(otherKeys);\n }\n\n RNSentry.setUser(defaultUserKeys, otherUserKeys);\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 =\n 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 =\n 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\n ? this._processLevel(breadcrumb.level)\n : undefined,\n data: breadcrumb.data\n ? this._serializeObject(breadcrumb.data)\n : 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(\n key,\n context !== null ? this._serializeObject(context) : null\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 isNativeTransportAvailable(): boolean {\n return this.enableNative && this._isModuleLoaded(RNSentry);\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: {\n [key: string]: unknown;\n }): { [key: string]: string } {\n const serialized: { [key: string]: string } = {};\n\n Object.keys(data).forEach((dataKey) => {\n const value = data[dataKey];\n serialized[dataKey] =\n 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 _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\n ? this._processLevel(breadcrumb.level)\n : 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 _processLevel(level: Severity): Severity {\n if (level === Severity.Critical) {\n return Severity.Fatal;\n }\n if (level === Severity.Log) {\n return Severity.Debug;\n }\n\n return level;\n },\n\n /**\n * Checks whether the RNSentry module is loaded.\n */\n _isModuleLoaded(\n module: SentryNativeBridgeModule | undefined\n ): module is SentryNativeBridgeModule {\n return !!module;\n },\n\n _DisabledNativeError: new SentryError(\"Native is disabled\"),\n\n _NativeClientError: new SentryError(\n \"Native Client is not available, can't start on native.\"\n ),\n\n enableNative: true,\n nativeIsReady: false,\n platform: Platform.OS,\n};\n"]}
|
package/ios/RNSentry.m
CHANGED
|
@@ -44,8 +44,6 @@ RCT_EXPORT_METHOD(initNativeSdk:(NSDictionary *_Nonnull)options
|
|
|
44
44
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
45
45
|
rejecter:(RCTPromiseRejectBlock)reject)
|
|
46
46
|
{
|
|
47
|
-
PrivateSentrySDKOnly.appStartMeasurementHybridSDKMode = true;
|
|
48
|
-
|
|
49
47
|
NSError *error = nil;
|
|
50
48
|
|
|
51
49
|
SentryBeforeSendEventCallback beforeSend = ^SentryEvent*(SentryEvent *event) {
|
|
@@ -76,17 +74,25 @@ RCT_EXPORT_METHOD(initNativeSdk:(NSDictionary *_Nonnull)options
|
|
|
76
74
|
reject(@"SentryReactNative", error.localizedDescription, error);
|
|
77
75
|
return;
|
|
78
76
|
}
|
|
79
|
-
|
|
77
|
+
|
|
80
78
|
if ([mutableOptions valueForKey:@"enableNativeCrashHandling"] != nil) {
|
|
81
79
|
BOOL enableNativeCrashHandling = (BOOL)[mutableOptions valueForKey:@"enableNativeCrashHandling"];
|
|
82
|
-
|
|
80
|
+
|
|
83
81
|
if (!enableNativeCrashHandling) {
|
|
84
82
|
NSMutableArray *integrations = sentryOptions.integrations.mutableCopy;
|
|
85
83
|
[integrations removeObject:@"SentryCrashIntegration"];
|
|
86
84
|
sentryOptions.integrations = integrations;
|
|
87
85
|
}
|
|
88
86
|
}
|
|
89
|
-
|
|
87
|
+
|
|
88
|
+
// Enable the App start and Frames tracking measurements
|
|
89
|
+
if ([mutableOptions valueForKey:@"enableAutoPerformanceTracking"] != nil) {
|
|
90
|
+
BOOL enableAutoPerformanceTracking = (BOOL)[mutableOptions valueForKey:@"enableAutoPerformanceTracking"];
|
|
91
|
+
|
|
92
|
+
PrivateSentrySDKOnly.appStartMeasurementHybridSDKMode = enableAutoPerformanceTracking;
|
|
93
|
+
PrivateSentrySDKOnly.framesTrackingMeasurementHybridSDKMode = enableAutoPerformanceTracking;
|
|
94
|
+
}
|
|
95
|
+
|
|
90
96
|
[SentrySDK startWithOptionsObject:sentryOptions];
|
|
91
97
|
|
|
92
98
|
// If the app is active/in foreground, and we have not sent the SentryHybridSdkDidBecomeActive notification, send it.
|
|
@@ -158,8 +164,19 @@ RCT_EXPORT_METHOD(fetchNativeDeviceContexts:(RCTPromiseResolveBlock)resolve
|
|
|
158
164
|
NSDictionary<NSString *, id> *serializedScope = [scope serialize];
|
|
159
165
|
// Scope serializes as 'context' instead of 'contexts' as it does for the event.
|
|
160
166
|
NSDictionary<NSString *, id> *tempContexts = [serializedScope valueForKey:@"context"];
|
|
167
|
+
|
|
168
|
+
NSMutableDictionary<NSString *, id> *user = [NSMutableDictionary new];
|
|
169
|
+
|
|
170
|
+
NSDictionary<NSString *, id> *tempUser = [serializedScope valueForKey:@"user"];
|
|
171
|
+
if (tempUser != nil) {
|
|
172
|
+
[user addEntriesFromDictionary:[tempUser valueForKey:@"user"]];
|
|
173
|
+
} else {
|
|
174
|
+
[user setValue:PrivateSentrySDKOnly.installationID forKey:@"id"];
|
|
175
|
+
}
|
|
176
|
+
[contexts setValue:user forKey:@"user"];
|
|
177
|
+
|
|
161
178
|
if (tempContexts != nil) {
|
|
162
|
-
[contexts
|
|
179
|
+
[contexts setValue:tempContexts forKey:@"context"];
|
|
163
180
|
}
|
|
164
181
|
if (sentryOptions != nil && sentryOptions.debug) {
|
|
165
182
|
NSData *data = [NSJSONSerialization dataWithJSONObject:contexts options:0 error:nil];
|
|
@@ -203,12 +220,23 @@ RCT_EXPORT_METHOD(fetchNativeFrames:(RCTPromiseResolveBlock)resolve
|
|
|
203
220
|
|
|
204
221
|
if (frames == nil) {
|
|
205
222
|
resolve(nil);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
NSNumber *total = [NSNumber numberWithLong:frames.total];
|
|
227
|
+
NSNumber *frozen = [NSNumber numberWithLong:frames.frozen];
|
|
228
|
+
NSNumber *slow = [NSNumber numberWithLong:frames.slow];
|
|
229
|
+
NSNumber *zero = [NSNumber numberWithLong:0L];
|
|
230
|
+
|
|
231
|
+
if ([total isEqualToNumber:zero] && [frozen isEqualToNumber:zero] && [slow isEqualToNumber:zero]) {
|
|
232
|
+
resolve(nil);
|
|
233
|
+
return;
|
|
206
234
|
}
|
|
207
235
|
|
|
208
236
|
resolve(@{
|
|
209
|
-
@"totalFrames":
|
|
210
|
-
@"frozenFrames":
|
|
211
|
-
@"slowFrames":
|
|
237
|
+
@"totalFrames": total,
|
|
238
|
+
@"frozenFrames": frozen,
|
|
239
|
+
@"slowFrames": slow,
|
|
212
240
|
});
|
|
213
241
|
} else {
|
|
214
242
|
resolve(nil);
|
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": "3.3.
|
|
5
|
+
"version": "3.3.4",
|
|
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/sentry.gradle
CHANGED
|
@@ -60,16 +60,23 @@ gradle.projectsEvaluated {
|
|
|
60
60
|
def previousCliTask = null
|
|
61
61
|
|
|
62
62
|
def nameCleanup = "${bundleTask.name}_SentryUploadCleanUp"
|
|
63
|
-
//
|
|
63
|
+
// Upload the source map several times if necessary: once for each release and versionCode.
|
|
64
64
|
currentVariants.each { key, currentVariant ->
|
|
65
65
|
variant = currentVariant[0]
|
|
66
66
|
releaseName = currentVariant[1]
|
|
67
67
|
versionCode = currentVariant[2]
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
// The Sentry server distinguishes source maps by release (`--release` in the command
|
|
70
|
+
// below) and distribution identifier (`--dist` below). Give the task a unique name
|
|
71
|
+
// based on where we're uploading to.
|
|
72
|
+
def nameCliTask = "${bundleTask.name}_SentryUpload_${releaseName}_${versionCode}"
|
|
73
|
+
|
|
74
|
+
// If several outputs have the same releaseName and versionCode, we'd do the exact same
|
|
75
|
+
// upload for each of them. No need to repeat.
|
|
76
|
+
try { tasks.named(nameCliTask); return } catch (Exception e) {}
|
|
70
77
|
|
|
71
78
|
/** Upload source map file to the sentry server via CLI call. */
|
|
72
|
-
def cliTask = tasks.create(
|
|
79
|
+
def cliTask = tasks.create(nameCliTask, Exec) {
|
|
73
80
|
description = "upload debug symbols to sentry"
|
|
74
81
|
group = 'sentry.io'
|
|
75
82
|
|
|
@@ -135,7 +142,8 @@ gradle.projectsEvaluated {
|
|
|
135
142
|
commandLine(*osCompatibility, *args)
|
|
136
143
|
|
|
137
144
|
enabled true
|
|
138
|
-
|
|
145
|
+
}
|
|
146
|
+
|
|
139
147
|
// chain the upload tasks so they run sequentially in order to run
|
|
140
148
|
// the cliCleanUpTask after the final upload task is run
|
|
141
149
|
if (previousCliTask != null) {
|