@sentry/react-native 5.0.0 → 5.1.1

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.
Files changed (36) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/RNSentry.podspec +1 -1
  3. package/android/build.gradle +1 -1
  4. package/dist/js/integrations/devicecontext.d.ts.map +1 -1
  5. package/dist/js/integrations/devicecontext.js +6 -1
  6. package/dist/js/integrations/devicecontext.js.map +1 -1
  7. package/dist/js/integrations/rewriteframes.d.ts +8 -0
  8. package/dist/js/integrations/rewriteframes.d.ts.map +1 -0
  9. package/dist/js/integrations/rewriteframes.js +30 -0
  10. package/dist/js/integrations/rewriteframes.js.map +1 -0
  11. package/dist/js/measurements.d.ts +5 -0
  12. package/dist/js/measurements.d.ts.map +1 -1
  13. package/dist/js/measurements.js +8 -4
  14. package/dist/js/measurements.js.map +1 -1
  15. package/dist/js/sdk.d.ts.map +1 -1
  16. package/dist/js/sdk.js +2 -21
  17. package/dist/js/sdk.js.map +1 -1
  18. package/dist/js/tracing/index.d.ts +1 -0
  19. package/dist/js/tracing/index.d.ts.map +1 -1
  20. package/dist/js/tracing/index.js +1 -0
  21. package/dist/js/tracing/index.js.map +1 -1
  22. package/dist/js/tracing/ops.d.ts +6 -0
  23. package/dist/js/tracing/ops.d.ts.map +1 -0
  24. package/dist/js/tracing/ops.js +6 -0
  25. package/dist/js/tracing/ops.js.map +1 -0
  26. package/dist/js/tracing/reactnativetracing.d.ts.map +1 -1
  27. package/dist/js/tracing/reactnativetracing.js +7 -4
  28. package/dist/js/tracing/reactnativetracing.js.map +1 -1
  29. package/dist/js/tracing/stalltracking.d.ts +4 -3
  30. package/dist/js/tracing/stalltracking.d.ts.map +1 -1
  31. package/dist/js/tracing/stalltracking.js +4 -3
  32. package/dist/js/tracing/stalltracking.js.map +1 -1
  33. package/dist/js/version.d.ts +1 -1
  34. package/dist/js/version.js +1 -1
  35. package/dist/js/version.js.map +1 -1
  36. package/package.json +13 -13
package/CHANGELOG.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.1.1
4
+
5
+ ### Fixes
6
+
7
+ - Remove non URL `frame.abs_path` which was causing source maps to fail ([#2891](https://github.com/getsentry/sentry-react-native/pull/2891))
8
+
9
+ ### Dependencies
10
+
11
+ - Bump Cocoa SDK from v8.2.0 to v8.3.0 ([#2876](https://github.com/getsentry/sentry-react-native/pull/2876))
12
+ - [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#830)
13
+ - [diff](https://github.com/getsentry/sentry-cocoa/compare/8.2.0...8.3.0)
14
+ - Bump CLI from v2.14.3 to v2.14.4 ([#2873](https://github.com/getsentry/sentry-react-native/pull/2873))
15
+ - [changelog](https://github.com/getsentry/sentry-cli/blob/master/CHANGELOG.md#2144)
16
+ - [diff](https://github.com/getsentry/sentry-cli/compare/2.14.3...2.14.4)
17
+
18
+ ## 5.1.0
19
+
20
+ ### Features
21
+
22
+ - Add App Context `in_foreground` ([#2826](https://github.com/getsentry/sentry-react-native/pull/2826))
23
+
24
+ ### Fixes
25
+
26
+ - Match app start measurements naming with other SDKs ([#2855](https://github.com/getsentry/sentry-react-native/pull/2855))
27
+ - `app.start.cold` to `app_start_cold`
28
+ - `app.start.warm` to `app_start_warm`
29
+
30
+ ### Dependencies
31
+
32
+ - Bump Cocoa SDK from v8.0.0 to v8.2.0 ([#2776](https://github.com/getsentry/sentry-react-native/pull/2776))
33
+ - [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#820)
34
+ - [diff](https://github.com/getsentry/sentry-cocoa/compare/8.0.0...8.2.0)
35
+ - Bump JavaScript SDK from v7.37.2 to v7.40.0 ([#2836](https://github.com/getsentry/sentry-react-native/pull/2836), [#2864](https://github.com/getsentry/sentry-react-native/pull/2864))
36
+ - [changelog](https://github.com/getsentry/sentry-javascript/blob/develop/CHANGELOG.md#7400)
37
+ - [diff](https://github.com/getsentry/sentry-javascript/compare/7.37.2...7.40.0)
38
+ - Bump CLI from v2.10.0 to v2.14.3 ([#2848](https://github.com/getsentry/sentry-react-native/pull/2848), [#2869](https://github.com/getsentry/sentry-react-native/pull/2869))
39
+ - [changelog](https://github.com/getsentry/sentry-cli/blob/master/CHANGELOG.md#2143)
40
+ - [diff](https://github.com/getsentry/sentry-cli/compare/2.10.0...2.14.3)
41
+ - Bump Android SDK from v6.14.0 to v6.15.0 ([#2868](https://github.com/getsentry/sentry-react-native/pull/2868))
42
+ - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#6150)
43
+ - [diff](https://github.com/getsentry/sentry-java/compare/6.14.0...6.15.0)
44
+
3
45
  ## 5.0.0
4
46
 
5
47
  The React Native SDK version 5 supports both Legacy (from RN 0.65 and above) and New Architecture (from RN 0.69 and above) as well as the new React Native Gradle Plugin (introduced in RN 0.71). For detailed [migration guide visit our docs](https://docs.sentry.io/platforms/react-native/migration/#from-4x-to-5x).
package/RNSentry.podspec CHANGED
@@ -19,7 +19,7 @@ Pod::Spec.new do |s|
19
19
  s.preserve_paths = '*.js'
20
20
 
21
21
  s.dependency 'React-Core'
22
- s.dependency 'Sentry/HybridSDK', '8.0.0'
22
+ s.dependency 'Sentry/HybridSDK', '8.3.0'
23
23
 
24
24
  s.source_files = 'ios/**/*.{h,mm}'
25
25
  s.public_header_files = 'ios/RNSentry.h'
@@ -42,5 +42,5 @@ android {
42
42
 
43
43
  dependencies {
44
44
  implementation 'com.facebook.react:react-native:+'
45
- api 'io.sentry:sentry-android:6.14.0'
45
+ api 'io.sentry:sentry-android:6.15.0'
46
46
  }
@@ -1 +1 @@
1
- {"version":3,"file":"devicecontext.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/devicecontext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAS,cAAc,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAO7E,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,CACd,uBAAuB,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,EAC3D,aAAa,EAAE,MAAM,GAAG,GACvB,IAAI;CAmER"}
1
+ {"version":3,"file":"devicecontext.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/devicecontext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAS,cAAc,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAQ7E,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,CACd,uBAAuB,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,EAC3D,aAAa,EAAE,MAAM,GAAG,GACvB,IAAI;CA0ER"}
@@ -1,5 +1,6 @@
1
1
  import { __awaiter } from "tslib";
2
2
  import { logger, severityLevelFromString } from '@sentry/utils';
3
+ import { AppState } from 'react-native';
3
4
  import { breadcrumbFromObject } from '../breadcrumb';
4
5
  import { NATIVE } from '../wrapper';
5
6
  /** Load device context from native. */
@@ -34,7 +35,11 @@ export class DeviceContext {
34
35
  if (!event.user && nativeUser) {
35
36
  event.user = nativeUser;
36
37
  }
37
- const nativeContext = native.context;
38
+ let nativeContext = native.context;
39
+ if (AppState.currentState !== 'unknown') {
40
+ nativeContext = nativeContext || {};
41
+ nativeContext.app = Object.assign(Object.assign({}, nativeContext.app), { in_foreground: AppState.currentState === 'active' });
42
+ }
38
43
  if (nativeContext) {
39
44
  event.contexts = Object.assign(Object.assign({}, nativeContext), event.contexts);
40
45
  }
@@ -1 +1 @@
1
- {"version":3,"file":"devicecontext.js","sourceRoot":"","sources":["../../../src/js/integrations/devicecontext.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AAK,CAAC;QACf,CAAC,CAAA,CAAC,CAAC;IACL,CAAC;;AAlFD;;GAEG;AACW,gBAAE,GAAW,eAAe,CAAC","sourcesContent":["/* eslint-disable complexity */\nimport type { Event, EventProcessor, Hub, Integration } from '@sentry/types';\nimport { logger, severityLevelFromString } from '@sentry/utils';\n\nimport { breadcrumbFromObject } from '../breadcrumb';\nimport type { NativeDeviceContextsResponse } from '../NativeRNSentry';\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(\n addGlobalEventProcessor: (callback: EventProcessor) => void,\n getCurrentHub: () => Hub,\n ): void {\n addGlobalEventProcessor(async (event: Event) => {\n const self = getCurrentHub().getIntegration(DeviceContext);\n if (!self) {\n return event;\n }\n\n let native: NativeDeviceContextsResponse | null = null;\n try {\n native = await NATIVE.fetchNativeDeviceContexts();\n } catch (e) {\n logger.log(`Failed to get device context from native: ${e}`);\n }\n\n if (!native) {\n return event;\n }\n\n const nativeUser = native.user;\n if (!event.user && nativeUser) {\n event.user = nativeUser;\n }\n\n const nativeContext = native.context;\n if (nativeContext) {\n event.contexts = { ...nativeContext, ...event.contexts };\n }\n\n const nativeTags = native.tags;\n if (nativeTags) {\n event.tags = { ...nativeTags, ...event.tags };\n }\n\n const nativeExtra = native.extra;\n if (nativeExtra) {\n event.extra = { ...nativeExtra, ...event.extra };\n }\n\n const nativeFingerprint = native.fingerprint;\n if (nativeFingerprint) {\n event.fingerprint = (event.fingerprint ?? []).concat(\n nativeFingerprint.filter((item) => (event.fingerprint ?? []).indexOf(item) < 0),\n )\n }\n\n const nativeLevel = typeof native['level'] === 'string'\n ? severityLevelFromString(native['level'])\n : undefined;\n if (!event.level && nativeLevel) {\n event.level = nativeLevel;\n }\n\n const nativeEnvironment = native['environment'];\n if (!event.environment && nativeEnvironment) {\n event.environment = nativeEnvironment;\n }\n\n const nativeBreadcrumbs = Array.isArray(native['breadcrumbs'])\n ? native['breadcrumbs'].map(breadcrumbFromObject)\n : undefined;\n if (nativeBreadcrumbs) {\n event.breadcrumbs = nativeBreadcrumbs;\n }\n\n return event;\n });\n }\n}\n"]}
1
+ {"version":3,"file":"devicecontext.js","sourceRoot":"","sources":["../../../src/js/integrations/devicecontext.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,uCAAuC;AACvC,MAAM,OAAO,aAAa;IAA1B;QAME;;WAEG;QACI,SAAI,GAAW,aAAa,CAAC,EAAE,CAAC;IAkFzC,CAAC;IAhFC;;OAEG;IACI,SAAS,CACd,uBAA2D,EAC3D,aAAwB;QAExB,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,MAAM,GAAwC,IAAI,CAAC;YACvD,IAAI;gBACF,MAAM,GAAG,MAAM,MAAM,CAAC,yBAAyB,EAAE,CAAC;aACnD;YAAC,OAAO,CAAC,EAAE;gBACV,MAAM,CAAC,GAAG,CAAC,6CAA6C,CAAC,EAAE,CAAC,CAAC;aAC9D;YAED,IAAI,CAAC,MAAM,EAAE;gBACX,OAAO,KAAK,CAAC;aACd;YAED,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC;YAC/B,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,UAAU,EAAE;gBAC7B,KAAK,CAAC,IAAI,GAAG,UA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AAK,IAAI,WAAW,EAAE;gBAC/B,KAAK,CAAC,KAAK,GAAG,WAAW,CAAC;aAC3B;YAED,MAAM,iBAAiB,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;YAChD,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,iBAAiB,EAAE;gBAC3C,KAAK,CAAC,WAAW,GAAG,iBAAiB,CAAC;aACvC;YAED,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;gBAC5D,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,oBAAoB,CAAC;gBACjD,CAAC,CAAC,SAAS,CAAC;YACd,IAAI,iBAAiB,EAAE;gBACrB,KAAK,CAAC,WAAW,GAAG,iBAAiB,CAAC;aACvC;YAED,OAAO,KAAK,CAAC;QACf,CAAC,CAAA,CAAC,CAAC;IACL,CAAC;;AAzFD;;GAEG;AACW,gBAAE,GAAW,eAAe,CAAC","sourcesContent":["/* eslint-disable complexity */\nimport type { Event, EventProcessor, Hub, Integration } from '@sentry/types';\nimport { logger, severityLevelFromString } from '@sentry/utils';\nimport { AppState } from 'react-native';\n\nimport { breadcrumbFromObject } from '../breadcrumb';\nimport type { NativeDeviceContextsResponse } from '../NativeRNSentry';\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(\n addGlobalEventProcessor: (callback: EventProcessor) => void,\n getCurrentHub: () => Hub,\n ): void {\n addGlobalEventProcessor(async (event: Event) => {\n const self = getCurrentHub().getIntegration(DeviceContext);\n if (!self) {\n return event;\n }\n\n let native: NativeDeviceContextsResponse | null = null;\n try {\n native = await NATIVE.fetchNativeDeviceContexts();\n } catch (e) {\n logger.log(`Failed to get device context from native: ${e}`);\n }\n\n if (!native) {\n return event;\n }\n\n const nativeUser = native.user;\n if (!event.user && nativeUser) {\n event.user = nativeUser;\n }\n\n let nativeContext = native.context;\n if (AppState.currentState !== 'unknown') {\n nativeContext = nativeContext || {};\n nativeContext.app = {\n ...nativeContext.app,\n in_foreground: AppState.currentState === 'active',\n }\n }\n if (nativeContext) {\n event.contexts = { ...nativeContext, ...event.contexts };\n }\n\n const nativeTags = native.tags;\n if (nativeTags) {\n event.tags = { ...nativeTags, ...event.tags };\n }\n\n const nativeExtra = native.extra;\n if (nativeExtra) {\n event.extra = { ...nativeExtra, ...event.extra };\n }\n\n const nativeFingerprint = native.fingerprint;\n if (nativeFingerprint) {\n event.fingerprint = (event.fingerprint ?? []).concat(\n nativeFingerprint.filter((item) => (event.fingerprint ?? []).indexOf(item) < 0),\n )\n }\n\n const nativeLevel = typeof native['level'] === 'string'\n ? severityLevelFromString(native['level'])\n : undefined;\n if (!event.level && nativeLevel) {\n event.level = nativeLevel;\n }\n\n const nativeEnvironment = native['environment'];\n if (!event.environment && nativeEnvironment) {\n event.environment = nativeEnvironment;\n }\n\n const nativeBreadcrumbs = Array.isArray(native['breadcrumbs'])\n ? native['breadcrumbs'].map(breadcrumbFromObject)\n : undefined;\n if (nativeBreadcrumbs) {\n event.breadcrumbs = nativeBreadcrumbs;\n }\n\n return event;\n });\n }\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import { RewriteFrames } from '@sentry/integrations';
2
+ /**
3
+ * Creates React Native default rewrite frames integration
4
+ * which appends app:// to the beginning of the filename
5
+ * and removes file://, 'address at' prefixes and CodePush postfix.
6
+ */
7
+ export declare function createReactNativeRewriteFrames(): RewriteFrames;
8
+ //# sourceMappingURL=rewriteframes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rewriteframes.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/rewriteframes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD;;;;GAIG;AACH,wBAAgB,8BAA8B,IAAI,aAAa,CAyB9D"}
@@ -0,0 +1,30 @@
1
+ import { RewriteFrames } from '@sentry/integrations';
2
+ /**
3
+ * Creates React Native default rewrite frames integration
4
+ * which appends app:// to the beginning of the filename
5
+ * and removes file://, 'address at' prefixes and CodePush postfix.
6
+ */
7
+ export function createReactNativeRewriteFrames() {
8
+ return new RewriteFrames({
9
+ iteratee: (frame) => {
10
+ if (frame.filename) {
11
+ frame.filename = frame.filename
12
+ .replace(/^file:\/\//, '')
13
+ .replace(/^address at /, '')
14
+ .replace(/^.*\/[^.]+(\.app|CodePush|.*(?=\/))/, '');
15
+ if (frame.filename !== '[native code]' &&
16
+ frame.filename !== 'native') {
17
+ const appPrefix = 'app://';
18
+ // We always want to have a triple slash
19
+ frame.filename =
20
+ frame.filename.indexOf('/') === 0
21
+ ? `${appPrefix}${frame.filename}`
22
+ : `${appPrefix}/${frame.filename}`;
23
+ }
24
+ delete frame.abs_path;
25
+ }
26
+ return frame;
27
+ },
28
+ });
29
+ }
30
+ //# sourceMappingURL=rewriteframes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rewriteframes.js","sourceRoot":"","sources":["../../../src/js/integrations/rewriteframes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD;;;;GAIG;AACH,MAAM,UAAU,8BAA8B;IAC5C,OAAO,IAAI,aAAa,CAAC;QACvB,QAAQ,EAAE,CAAC,KAAiB,EAAE,EAAE;YAC9B,IAAI,KAAK,CAAC,QAAQ,EAAE;gBAClB,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ;qBAC5B,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;qBACzB,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;qBAC3B,OAAO,CAAC,qCAAqC,EAAE,EAAE,CAAC,CAAC;gBAEtD,IACE,KAAK,CAAC,QAAQ,KAAK,eAAe;oBAClC,KAAK,CAAC,QAAQ,KAAK,QAAQ,EAC3B;oBACA,MAAM,SAAS,GAAG,QAAQ,CAAC;oBAC3B,wCAAwC;oBACxC,KAAK,CAAC,QAAQ;wBACZ,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC;4BAC/B,CAAC,CAAC,GAAG,SAAS,GAAG,KAAK,CAAC,QAAQ,EAAE;4BACjC,CAAC,CAAC,GAAG,SAAS,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;iBACxC;gBACD,OAAO,KAAK,CAAC,QAAQ,CAAC;aACvB;YACD,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { RewriteFrames } from '@sentry/integrations';\nimport type { StackFrame } from '@sentry/types';\n\n/**\n * Creates React Native default rewrite frames integration\n * which appends app:// to the beginning of the filename\n * and removes file://, 'address at' prefixes and CodePush postfix.\n */\nexport function createReactNativeRewriteFrames(): RewriteFrames {\n return new RewriteFrames({\n iteratee: (frame: StackFrame) => {\n if (frame.filename) {\n frame.filename = frame.filename\n .replace(/^file:\\/\\//, '')\n .replace(/^address at /, '')\n .replace(/^.*\\/[^.]+(\\.app|CodePush|.*(?=\\/))/, '');\n\n if (\n frame.filename !== '[native code]' &&\n frame.filename !== 'native'\n ) {\n const appPrefix = 'app://';\n // We always want to have a triple slash\n frame.filename =\n frame.filename.indexOf('/') === 0\n ? `${appPrefix}${frame.filename}`\n : `${appPrefix}/${frame.filename}`;\n }\n delete frame.abs_path;\n }\n return frame;\n },\n });\n}\n"]}
@@ -1,6 +1,11 @@
1
1
  import type { Hub } from '@sentry/core';
2
2
  import type { Transaction } from '@sentry/tracing';
3
3
  import type { CustomSamplingContext, TransactionContext } from '@sentry/types';
4
+ export declare const APP_START_WARM = "app_start_warm";
5
+ export declare const APP_START_COLD = "app_start_cold";
6
+ export declare const STALL_COUNT = "stall_count";
7
+ export declare const STALL_TOTAL_TIME = "stall_total_time";
8
+ export declare const STALL_LONGEST_TIME = "stall_longest_time";
4
9
  /**
5
10
  * Adds React Native's extensions. Needs to be called after @sentry/tracing's extension methods are added
6
11
  */
@@ -1 +1 @@
1
- {"version":3,"file":"measurements.d.ts","sourceRoot":"","sources":["../../src/js/measurements.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,qBAAqB,EAAqB,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAMlG;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAmB5C;AAED,oBAAY,wBAAwB,GAAG,CACrC,IAAI,EAAE,GAAG,EACT,kBAAkB,EAAE,kBAAkB,EACtC,qBAAqB,CAAC,EAAE,qBAAqB,KAC1C,WAAW,CAAC"}
1
+ {"version":3,"file":"measurements.d.ts","sourceRoot":"","sources":["../../src/js/measurements.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,qBAAqB,EAAqB,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAIlG,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAC/C,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAE/C,eAAO,MAAM,WAAW,gBAAgB,CAAC;AACzC,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AACnD,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AAEvD;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAmB5C;AAED,oBAAY,wBAAwB,GAAG,CACrC,IAAI,EAAE,GAAG,EACT,kBAAkB,EAAE,kBAAkB,EACtC,qBAAqB,CAAC,EAAE,qBAAqB,KAC1C,WAAW,CAAC"}
@@ -1,6 +1,10 @@
1
1
  import { getCurrentHub, getMainCarrier } from '@sentry/core';
2
- import { ReactNativeTracing } from './tracing';
3
- const SPAN_OP_DEFAULT = 'default';
2
+ import { DEFAULT, ReactNativeTracing } from './tracing';
3
+ export const APP_START_WARM = 'app_start_warm';
4
+ export const APP_START_COLD = 'app_start_cold';
5
+ export const STALL_COUNT = 'stall_count';
6
+ export const STALL_TOTAL_TIME = 'stall_total_time';
7
+ export const STALL_LONGEST_TIME = 'stall_longest_time';
4
8
  /**
5
9
  * Adds React Native's extensions. Needs to be called after @sentry/tracing's extension methods are added
6
10
  */
@@ -30,7 +34,7 @@ const _patchStartTransaction = (originalStartTransaction) => {
30
34
  function _startTransaction(transactionContext, customSamplingContext) {
31
35
  // Native SDKs require op to be set - for JS Relay sets `default`
32
36
  if (!transactionContext.op) {
33
- transactionContext.op = SPAN_OP_DEFAULT;
37
+ transactionContext.op = DEFAULT;
34
38
  }
35
39
  const transaction = originalStartTransaction.apply(this, [
36
40
  transactionContext,
@@ -40,7 +44,7 @@ const _patchStartTransaction = (originalStartTransaction) => {
40
44
  transaction.startChild = (spanContext) => {
41
45
  return originalStartChild(Object.assign(Object.assign({}, spanContext), {
42
46
  // Native SDKs require op to be set
43
- op: (spanContext === null || spanContext === void 0 ? void 0 : spanContext.op) || SPAN_OP_DEFAULT }));
47
+ op: (spanContext === null || spanContext === void 0 ? void 0 : spanContext.op) || DEFAULT }));
44
48
  };
45
49
  const reactNativeTracing = getCurrentHub().getIntegration(ReactNativeTracing);
46
50
  if (reactNativeTracing) {
@@ -1 +1 @@
1
- {"version":3,"file":"measurements.js","sourceRoot":"","sources":["../../src/js/measurements.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAI7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,MAAM,eAAe,GAAG,SAAS,CAAC;AAElC;;GAEG;AACH,MAAM,UAAU,qBAAqB;IACnC,MAAM,OAAO,GAAG,cAAc,EAA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AW,CAAC,CAAC;YAEnD,6DAA6D;YAC7D,MAAM,cAAc,GAAG,WAAW,CAAC,MAAM,CAAC;YAE1C,WAAW,CAAC,MAAM,GAAG,CAAC,YAAgC,EAAE,EAAE;gBACxD,IAAI,kBAAkB,EAAE;oBACtB,kBAAkB,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC;iBACrD;gBAED,OAAO,cAAc,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;YAC3D,CAAC,CAAC;SACH;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC","sourcesContent":["import type { Hub } from '@sentry/core';\nimport { getCurrentHub, getMainCarrier } from '@sentry/core';\nimport type { Transaction } from '@sentry/tracing';\nimport type { CustomSamplingContext, Span, SpanContext, TransactionContext } from '@sentry/types';\n\nimport { ReactNativeTracing } from './tracing';\n\nconst SPAN_OP_DEFAULT = 'default';\n\n/**\n * Adds React Native's extensions. Needs to be called after @sentry/tracing's extension methods are added\n */\nexport function _addTracingExtensions(): void {\n const carrier = getMainCarrier();\n if (carrier.__SENTRY__) {\n carrier.__SENTRY__.extensions = carrier.__SENTRY__.extensions || {};\n if (carrier.__SENTRY__.extensions.startTransaction) {\n const originalStartTransaction = carrier.__SENTRY__.extensions\n .startTransaction as StartTransactionFunction;\n\n /*\n Overwrites the transaction start and finish to start and finish stall tracking.\n Preferably instead of overwriting add a callback method for this in the Transaction itself.\n */\n const _startTransaction = _patchStartTransaction(\n originalStartTransaction\n );\n\n carrier.__SENTRY__.extensions.startTransaction = _startTransaction;\n }\n }\n}\n\nexport type StartTransactionFunction = (\n this: Hub,\n transactionContext: TransactionContext,\n customSamplingContext?: CustomSamplingContext\n) => Transaction;\n\n/**\n * Overwrite the startTransaction extension method to start and end stall tracking.\n */\nconst _patchStartTransaction = (\n originalStartTransaction: StartTransactionFunction\n): StartTransactionFunction => {\n /**\n * Method to overwrite with\n */\n function _startTransaction(\n this: Hub,\n transactionContext: TransactionContext,\n customSamplingContext?: CustomSamplingContext\n ): Transaction {\n // Native SDKs require op to be set - for JS Relay sets `default`\n if (!transactionContext.op) {\n transactionContext.op = SPAN_OP_DEFAULT;\n }\n\n const transaction: Transaction = originalStartTransaction.apply(this, [\n transactionContext,\n customSamplingContext,\n ]);\n const originalStartChild: Transaction['startChild'] = transaction.startChild.bind(transaction);\n transaction.startChild = (\n spanContext?: Pick<SpanContext, Exclude<keyof SpanContext, 'sampled' | 'traceId' | 'parentSpanId'>>,\n ): Span => {\n return originalStartChild({\n ...spanContext,\n // Native SDKs require op to be set\n op: spanContext?.op || SPAN_OP_DEFAULT,\n });\n };\n\n const reactNativeTracing = getCurrentHub().getIntegration(\n ReactNativeTracing\n );\n\n if (reactNativeTracing) {\n reactNativeTracing.onTransactionStart(transaction);\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const originalFinish = transaction.finish;\n\n transaction.finish = (endTimestamp: number | undefined) => {\n if (reactNativeTracing) {\n reactNativeTracing.onTransactionFinish(transaction);\n }\n\n return originalFinish.apply(transaction, [endTimestamp]);\n };\n }\n\n return transaction;\n }\n\n return _startTransaction;\n};\n"]}
1
+ {"version":3,"file":"measurements.js","sourceRoot":"","sources":["../../src/js/measurements.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAI7D,OAAO,EAAE,OAAO,EAAC,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAEvD,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAC/C,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAE/C,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAC;AACzC,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AACnD,MAAM,CAAC,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AAEvD;;GAEG;AACH,MAAM,UAAU,qBAAqB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ACtB,kBAAkB,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;YAEnD,6DAA6D;YAC7D,MAAM,cAAc,GAAG,WAAW,CAAC,MAAM,CAAC;YAE1C,WAAW,CAAC,MAAM,GAAG,CAAC,YAAgC,EAAE,EAAE;gBACxD,IAAI,kBAAkB,EAAE;oBACtB,kBAAkB,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC;iBACrD;gBAED,OAAO,cAAc,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;YAC3D,CAAC,CAAC;SACH;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC","sourcesContent":["import type { Hub } from '@sentry/core';\nimport { getCurrentHub, getMainCarrier } from '@sentry/core';\nimport type { Transaction } from '@sentry/tracing';\nimport type { CustomSamplingContext, Span, SpanContext, TransactionContext } from '@sentry/types';\n\nimport { DEFAULT,ReactNativeTracing } from './tracing';\n\nexport const APP_START_WARM = 'app_start_warm';\nexport const APP_START_COLD = 'app_start_cold';\n\nexport const STALL_COUNT = 'stall_count';\nexport const STALL_TOTAL_TIME = 'stall_total_time';\nexport const STALL_LONGEST_TIME = 'stall_longest_time';\n\n/**\n * Adds React Native's extensions. Needs to be called after @sentry/tracing's extension methods are added\n */\nexport function _addTracingExtensions(): void {\n const carrier = getMainCarrier();\n if (carrier.__SENTRY__) {\n carrier.__SENTRY__.extensions = carrier.__SENTRY__.extensions || {};\n if (carrier.__SENTRY__.extensions.startTransaction) {\n const originalStartTransaction = carrier.__SENTRY__.extensions\n .startTransaction as StartTransactionFunction;\n\n /*\n Overwrites the transaction start and finish to start and finish stall tracking.\n Preferably instead of overwriting add a callback method for this in the Transaction itself.\n */\n const _startTransaction = _patchStartTransaction(\n originalStartTransaction\n );\n\n carrier.__SENTRY__.extensions.startTransaction = _startTransaction;\n }\n }\n}\n\nexport type StartTransactionFunction = (\n this: Hub,\n transactionContext: TransactionContext,\n customSamplingContext?: CustomSamplingContext\n) => Transaction;\n\n/**\n * Overwrite the startTransaction extension method to start and end stall tracking.\n */\nconst _patchStartTransaction = (\n originalStartTransaction: StartTransactionFunction\n): StartTransactionFunction => {\n /**\n * Method to overwrite with\n */\n function _startTransaction(\n this: Hub,\n transactionContext: TransactionContext,\n customSamplingContext?: CustomSamplingContext\n ): Transaction {\n // Native SDKs require op to be set - for JS Relay sets `default`\n if (!transactionContext.op) {\n transactionContext.op = DEFAULT;\n }\n\n const transaction: Transaction = originalStartTransaction.apply(this, [\n transactionContext,\n customSamplingContext,\n ]);\n const originalStartChild: Transaction['startChild'] = transaction.startChild.bind(transaction);\n transaction.startChild = (\n spanContext?: Pick<SpanContext, Exclude<keyof SpanContext, 'sampled' | 'traceId' | 'parentSpanId'>>,\n ): Span => {\n return originalStartChild({\n ...spanContext,\n // Native SDKs require op to be set\n op: spanContext?.op || DEFAULT,\n });\n };\n\n const reactNativeTracing = getCurrentHub().getIntegration(\n ReactNativeTracing\n );\n\n if (reactNativeTracing) {\n reactNativeTracing.onTransactionStart(transaction);\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const originalFinish = transaction.finish;\n\n transaction.finish = (endTimestamp: number | undefined) => {\n if (reactNativeTracing) {\n reactNativeTracing.onTransactionFinish(transaction);\n }\n\n return originalFinish.apply(transaction, [endTimestamp]);\n };\n }\n\n return transaction;\n }\n\n return _startTransaction;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/js/sdk.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAA0B,GAAG,EAAmC,MAAM,cAAc,CAAC;AAQ5F,OAAO,KAAK,EAA2B,YAAY,EAAE,MAAM,eAAe,CAAC;AAE3E,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAe/B,OAAO,KAAK,EAA4B,kBAAkB,EAAE,yBAA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@sentry/core';
3
- import { RewriteFrames } from '@sentry/integrations';
4
3
  import { defaultIntegrations as reactDefaultIntegrations, defaultStackParser, getCurrentHub, makeFetchTransport, } from '@sentry/react';
5
4
  import { logger, stackParserFromStackParserOptions } from '@sentry/utils';
6
5
  import * as React from 'react';
7
6
  import { ReactNativeClient } from './client';
8
7
  import { DebugSymbolicator, DeviceContext, EventOrigin, ModulesLoader, ReactNativeErrorHandlers, ReactNativeInfo, Release, SdkInfo, } from './integrations';
8
+ import { createReactNativeRewriteFrames } from './integrations/rewriteframes';
9
9
  import { Screenshot } from './integrations/screenshot';
10
10
  import { ViewHierarchy } from './integrations/viewhierarchy';
11
11
  import { ReactNativeScope } from './scope';
@@ -63,26 +63,7 @@ export function init(passedOptions) {
63
63
  if (__DEV__) {
64
64
  defaultIntegrations.push(new DebugSymbolicator());
65
65
  }
66
- defaultIntegrations.push(new RewriteFrames({
67
- iteratee: (frame) => {
68
- if (frame.filename) {
69
- frame.filename = frame.filename
70
- .replace(/^file:\/\//, '')
71
- .replace(/^address at /, '')
72
- .replace(/^.*\/[^.]+(\.app|CodePush|.*(?=\/))/, '');
73
- if (frame.filename !== '[native code]' &&
74
- frame.filename !== 'native') {
75
- const appPrefix = 'app://';
76
- // We always want to have a triple slash
77
- frame.filename =
78
- frame.filename.indexOf('/') === 0
79
- ? `${appPrefix}${frame.filename}`
80
- : `${appPrefix}/${frame.filename}`;
81
- }
82
- }
83
- return frame;
84
- },
85
- }));
66
+ defaultIntegrations.push(createReactNativeRewriteFrames());
86
67
  if (options.enableNative) {
87
68
  defaultIntegrations.push(new DeviceContext());
88
69
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/js/sdk.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,sBAAsB,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC5F,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,C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AED;;GAEG;AACH,MAAM,UAAgB,KAAK;;QACzB,IAAI;YACF,MAAM,MAAM,GAAG,aAAa,EAAE,CAAC,SAAS,EAAqB,CAAC;YAE9D,IAAI,MAAM,EAAE;gBACV,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;aACtB;SACF;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;SACzC;IACH,CAAC;CAAA;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAAsB;;IACxD,MAAA,aAAa,EAAE,CAAC,SAAS,EAAqB,0CAAE,mBAAmB,CAAC,QAAQ,EAAE;AAChF,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,SAAS,CAAC,QAAgC;IACxD,MAAM,YAAY,GAAG,CAAC,KAAY,EAAQ,EAAE;QAC1C,IAAI;YACF,QAAQ,CAAC,KAAK,CAAC,CAAC;SACjB;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,KAAK,CAAC,wCAAwC,EAAE,CAAC,CAAC,CAAC;SAC3D;IACH,CAAC,CAAC;IACF,aAAa,EAAE,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;AAC1C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,QAAgC;IAC7D,MAAM,YAAY,GAAG,CAAC,KAAY,EAAQ,EAAE;QAC1C,IAAI;YACF,QAAQ,CAAC,KAAK,CAAC,CAAC;SACjB;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,KAAK,CAAC,6CAA6C,EAAE,CAAC,CAAC,CAAC;SAChE;IACH,CAAC,CAAC;IACF,aAAa,EAAE,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["import type { Scope } from '@sentry/core';\nimport { getIntegrationsToSetup, Hub, initAndBind, makeMain, setExtra } from '@sentry/core';\nimport { RewriteFrames } from '@sentry/integrations';\nimport {\n defaultIntegrations as reactDefaultIntegrations,\n defaultStackParser,\n getCurrentHub,\n makeFetchTransport,\n} from '@sentry/react';\nimport type { Integration, StackFrame, UserFeedback } from '@sentry/types';\nimport { logger, stackParserFromStackParserOptions } from '@sentry/utils';\nimport * as React from 'react';\n\nimport { ReactNativeClient } from './client';\nimport {\n DebugSymbolicator,\n DeviceContext,\n EventOrigin,\n ModulesLoader,\n ReactNativeErrorHandlers,\n ReactNativeInfo,\n Release,\n SdkInfo,\n} from './integrations';\nimport { Screenshot } from './integrations/screenshot';\nimport { ViewHierarchy } from './integrations/viewhierarchy';\nimport type { ReactNativeClientOptions, ReactNativeOptions, ReactNativeWrapperOptions } from './options';\nimport { ReactNativeScope } from './scope';\nimport { TouchEventBoundary } from './touchevents';\nimport { ReactNativeProfiler, ReactNativeTracing } from './tracing';\nimport { DEFAULT_BUFFER_SIZE, makeNativeTransportFactory } from './transports/native';\nimport { makeUtf8TextEncoder } from './transports/TextEncoder';\nimport { safeFactory, safeTracesSampler } from './utils/safe';\n\nconst IGNORED_DEFAULT_INTEGRATIONS = [\n 'GlobalHandlers', // We will use the react-native internal handlers\n 'TryCatch', // We don't need this\n];\nconst DEFAULT_OPTIONS: ReactNativeOptions = {\n enableNative: true,\n enableNativeCrashHandling: true,\n enableNativeNagger: true,\n autoInitializeNativeSdk: true,\n enableAutoPerformanceTracing: true,\n enableWatchdogTerminationTracking: true,\n patchGlobalPromise: true,\n transportOptions: {\n textEncoder: makeUtf8TextEncoder(),\n },\n sendClientReports: true,\n maxQueueSize: DEFAULT_BUFFER_SIZE,\n attachStacktrace: true,\n};\n\n/**\n * Inits the SDK and returns the final options.\n */\nexport function init(passedOptions: ReactNativeOptions): void {\n const reactNativeHub = new Hub(undefined, new ReactNativeScope());\n makeMain(reactNativeHub);\n\n const maxQueueSize = passedOptions.maxQueueSize\n // eslint-disable-next-line deprecation/deprecation\n ?? passedOptions.transportOptions?.bufferSize\n ?? DEFAULT_OPTIONS.maxQueueSize;\n const options: ReactNativeClientOptions = {\n ...DEFAULT_OPTIONS,\n ...passedOptions,\n // If custom transport factory fails the SDK won't initialize\n transport: passedOptions.transport || makeNativeTransportFactory() || makeFetchTransport,\n transportOptions: {\n ...DEFAULT_OPTIONS.transportOptions,\n ...(passedOptions.transportOptions ?? {}),\n bufferSize: maxQueueSize,\n },\n maxQueueSize,\n integrations: [],\n stackParser: stackParserFromStackParserOptions(passedOptions.stackParser || defaultStackParser),\n beforeBreadcrumb: safeFactory(passedOptions.beforeBreadcrumb, { loggerMessage: 'The beforeBreadcrumb threw an error' }),\n initialScope: safeFactory(passedOptions.initialScope, { loggerMessage: 'The initialScope threw an error' }),\n tracesSampler: safeTracesSampler(passedOptions.tracesSampler),\n };\n\n // As long as tracing is opt in with either one of these options, then this is how we determine tracing is enabled.\n const tracingEnabled =\n typeof options.tracesSampler !== 'undefined' ||\n typeof options.tracesSampleRate !== 'undefined';\n\n const defaultIntegrations: Integration[] = passedOptions.defaultIntegrations || [];\n if (passedOptions.defaultIntegrations === undefined) {\n defaultIntegrations.push(new ModulesLoader());\n defaultIntegrations.push(new ReactNativeErrorHandlers({\n patchGlobalPromise: options.patchGlobalPromise,\n }));\n defaultIntegrations.push(new Release());\n defaultIntegrations.push(...[\n ...reactDefaultIntegrations.filter(\n (i) => !IGNORED_DEFAULT_INTEGRATIONS.includes(i.name)\n ),\n ]);\n\n defaultIntegrations.push(new EventOrigin());\n defaultIntegrations.push(new SdkInfo());\n defaultIntegrations.push(new ReactNativeInfo());\n\n if (__DEV__) {\n defaultIntegrations.push(new DebugSymbolicator());\n }\n\n defaultIntegrations.push(new RewriteFrames({\n iteratee: (frame: StackFrame) => {\n if (frame.filename) {\n frame.filename = frame.filename\n .replace(/^file:\\/\\//, '')\n .replace(/^address at /, '')\n .replace(/^.*\\/[^.]+(\\.app|CodePush|.*(?=\\/))/, '');\n\n if (\n frame.filename !== '[native code]' &&\n frame.filename !== 'native'\n ) {\n const appPrefix = 'app://';\n // We always want to have a triple slash\n frame.filename =\n frame.filename.indexOf('/') === 0\n ? `${appPrefix}${frame.filename}`\n : `${appPrefix}/${frame.filename}`;\n }\n }\n return frame;\n },\n }));\n if (options.enableNative) {\n defaultIntegrations.push(new DeviceContext());\n }\n if (tracingEnabled) {\n if (options.enableAutoPerformanceTracing) {\n defaultIntegrations.push(new ReactNativeTracing());\n }\n }\n if (options.attachScreenshot) {\n defaultIntegrations.push(new Screenshot());\n }\n if (options.attachViewHierarchy) {\n defaultIntegrations.push(new ViewHierarchy());\n }\n }\n\n options.integrations = getIntegrationsToSetup({\n integrations: safeFactory(passedOptions.integrations, { loggerMessage: 'The integrations threw an error' }),\n defaultIntegrations,\n });\n initAndBind(ReactNativeClient, options);\n}\n\n/**\n * Inits the Sentry React Native SDK with automatic instrumentation and wrapped features.\n */\nexport function wrap<P>(\n RootComponent: React.ComponentType<P>,\n options?: ReactNativeWrapperOptions\n): React.ComponentType<P> {\n const tracingIntegration = getCurrentHub().getIntegration(ReactNativeTracing);\n if (tracingIntegration) {\n tracingIntegration.useAppStartWithProfiler = true;\n }\n\n const profilerProps = {\n ...(options?.profilerProps ?? {}),\n name: RootComponent.displayName ?? 'Root',\n };\n\n const RootApp: React.FC<P> = (appProps) => {\n return (\n <TouchEventBoundary {...(options?.touchEventBoundaryProps ?? {})}>\n <ReactNativeProfiler {...profilerProps}>\n <RootComponent {...appProps} />\n </ReactNativeProfiler>\n </TouchEventBoundary>\n );\n };\n\n return RootApp;\n}\n\n/**\n * Deprecated. Sets the release on the event.\n * NOTE: Does not set the release on sessions.\n * @deprecated\n */\nexport function setRelease(release: string): void {\n setExtra('__sentry_release', release);\n}\n\n/**\n * Deprecated. Sets the dist on the event.\n * NOTE: Does not set the dist on sessions.\n * @deprecated\n */\nexport function setDist(dist: string): void {\n setExtra('__sentry_dist', dist);\n}\n\n/**\n * If native client is available it will trigger a native crash.\n * Use this only for testing purposes.\n */\nexport function nativeCrash(): void {\n const client = getCurrentHub().getClient<ReactNativeClient>();\n if (client) {\n client.nativeCrash();\n }\n}\n\n/**\n * Flushes all pending events in the queue to disk.\n * Use this before applying any realtime updates such as code-push or expo updates.\n */\nexport async function flush(): Promise<boolean> {\n try {\n const client = getCurrentHub().getClient<ReactNativeClient>();\n\n if (client) {\n const result = await client.flush();\n\n return result;\n }\n // eslint-disable-next-line no-empty\n } catch (_) { }\n\n logger.error('Failed to flush the event queue.');\n\n return false;\n}\n\n/**\n * Closes the SDK, stops sending events.\n */\nexport async function close(): Promise<void> {\n try {\n const client = getCurrentHub().getClient<ReactNativeClient>();\n\n if (client) {\n await client.close();\n }\n } catch (e) {\n logger.error('Failed to close the SDK');\n }\n}\n\n/**\n * Captures user feedback and sends it to Sentry.\n */\nexport function captureUserFeedback(feedback: UserFeedback): void {\n getCurrentHub().getClient<ReactNativeClient>()?.captureUserFeedback(feedback);\n}\n\n/**\n * Creates a new scope with and executes the given operation within.\n * The scope is automatically removed once the operation\n * finishes or throws.\n *\n * This is essentially a convenience function for:\n *\n * pushScope();\n * callback();\n * popScope();\n *\n * @param callback that will be enclosed into push/popScope.\n */\nexport function withScope(callback: (scope: Scope) => void): ReturnType<Hub['withScope']> {\n const safeCallback = (scope: Scope): void => {\n try {\n callback(scope);\n } catch (e) {\n logger.error('Error while running withScope callback', e);\n }\n };\n getCurrentHub().withScope(safeCallback);\n}\n\n/**\n * Callback to set context information onto the scope.\n * @param callback Callback function that receives Scope.\n */\nexport function configureScope(callback: (scope: Scope) => void): ReturnType<Hub['configureScope']> {\n const safeCallback = (scope: Scope): void => {\n try {\n callback(scope);\n } catch (e) {\n logger.error('Error while running configureScope callback', e);\n }\n };\n getCurrentHub().configureScope(safeCallback);\n}\n"]}
1
+ {"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/js/sdk.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,sBAAsB,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC5F,OAAO,EACL,mBAAmB,IAAI,wBAAwB,EA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aAAa,EAAE,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;AAC1C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,QAAgC;IAC7D,MAAM,YAAY,GAAG,CAAC,KAAY,EAAQ,EAAE;QAC1C,IAAI;YACF,QAAQ,CAAC,KAAK,CAAC,CAAC;SACjB;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,KAAK,CAAC,6CAA6C,EAAE,CAAC,CAAC,CAAC;SAChE;IACH,CAAC,CAAC;IACF,aAAa,EAAE,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["import type { Scope } from '@sentry/core';\nimport { getIntegrationsToSetup, Hub, initAndBind, makeMain, setExtra } from '@sentry/core';\nimport {\n defaultIntegrations as reactDefaultIntegrations,\n defaultStackParser,\n getCurrentHub,\n makeFetchTransport,\n} from '@sentry/react';\nimport type { Integration, UserFeedback } from '@sentry/types';\nimport { logger, stackParserFromStackParserOptions } from '@sentry/utils';\nimport * as React from 'react';\n\nimport { ReactNativeClient } from './client';\nimport {\n DebugSymbolicator,\n DeviceContext,\n EventOrigin,\n ModulesLoader,\n ReactNativeErrorHandlers,\n ReactNativeInfo,\n Release,\n SdkInfo,\n} from './integrations';\nimport { createReactNativeRewriteFrames } from './integrations/rewriteframes';\nimport { Screenshot } from './integrations/screenshot';\nimport { ViewHierarchy } from './integrations/viewhierarchy';\nimport type { ReactNativeClientOptions, ReactNativeOptions, ReactNativeWrapperOptions } from './options';\nimport { ReactNativeScope } from './scope';\nimport { TouchEventBoundary } from './touchevents';\nimport { ReactNativeProfiler, ReactNativeTracing } from './tracing';\nimport { DEFAULT_BUFFER_SIZE, makeNativeTransportFactory } from './transports/native';\nimport { makeUtf8TextEncoder } from './transports/TextEncoder';\nimport { safeFactory, safeTracesSampler } from './utils/safe';\n\nconst IGNORED_DEFAULT_INTEGRATIONS = [\n 'GlobalHandlers', // We will use the react-native internal handlers\n 'TryCatch', // We don't need this\n];\nconst DEFAULT_OPTIONS: ReactNativeOptions = {\n enableNative: true,\n enableNativeCrashHandling: true,\n enableNativeNagger: true,\n autoInitializeNativeSdk: true,\n enableAutoPerformanceTracing: true,\n enableWatchdogTerminationTracking: true,\n patchGlobalPromise: true,\n transportOptions: {\n textEncoder: makeUtf8TextEncoder(),\n },\n sendClientReports: true,\n maxQueueSize: DEFAULT_BUFFER_SIZE,\n attachStacktrace: true,\n};\n\n/**\n * Inits the SDK and returns the final options.\n */\nexport function init(passedOptions: ReactNativeOptions): void {\n const reactNativeHub = new Hub(undefined, new ReactNativeScope());\n makeMain(reactNativeHub);\n\n const maxQueueSize = passedOptions.maxQueueSize\n // eslint-disable-next-line deprecation/deprecation\n ?? passedOptions.transportOptions?.bufferSize\n ?? DEFAULT_OPTIONS.maxQueueSize;\n const options: ReactNativeClientOptions = {\n ...DEFAULT_OPTIONS,\n ...passedOptions,\n // If custom transport factory fails the SDK won't initialize\n transport: passedOptions.transport || makeNativeTransportFactory() || makeFetchTransport,\n transportOptions: {\n ...DEFAULT_OPTIONS.transportOptions,\n ...(passedOptions.transportOptions ?? {}),\n bufferSize: maxQueueSize,\n },\n maxQueueSize,\n integrations: [],\n stackParser: stackParserFromStackParserOptions(passedOptions.stackParser || defaultStackParser),\n beforeBreadcrumb: safeFactory(passedOptions.beforeBreadcrumb, { loggerMessage: 'The beforeBreadcrumb threw an error' }),\n initialScope: safeFactory(passedOptions.initialScope, { loggerMessage: 'The initialScope threw an error' }),\n tracesSampler: safeTracesSampler(passedOptions.tracesSampler),\n };\n\n // As long as tracing is opt in with either one of these options, then this is how we determine tracing is enabled.\n const tracingEnabled =\n typeof options.tracesSampler !== 'undefined' ||\n typeof options.tracesSampleRate !== 'undefined';\n\n const defaultIntegrations: Integration[] = passedOptions.defaultIntegrations || [];\n if (passedOptions.defaultIntegrations === undefined) {\n defaultIntegrations.push(new ModulesLoader());\n defaultIntegrations.push(new ReactNativeErrorHandlers({\n patchGlobalPromise: options.patchGlobalPromise,\n }));\n defaultIntegrations.push(new Release());\n defaultIntegrations.push(...[\n ...reactDefaultIntegrations.filter(\n (i) => !IGNORED_DEFAULT_INTEGRATIONS.includes(i.name)\n ),\n ]);\n\n defaultIntegrations.push(new EventOrigin());\n defaultIntegrations.push(new SdkInfo());\n defaultIntegrations.push(new ReactNativeInfo());\n\n if (__DEV__) {\n defaultIntegrations.push(new DebugSymbolicator());\n }\n\n defaultIntegrations.push(createReactNativeRewriteFrames());\n if (options.enableNative) {\n defaultIntegrations.push(new DeviceContext());\n }\n if (tracingEnabled) {\n if (options.enableAutoPerformanceTracing) {\n defaultIntegrations.push(new ReactNativeTracing());\n }\n }\n if (options.attachScreenshot) {\n defaultIntegrations.push(new Screenshot());\n }\n if (options.attachViewHierarchy) {\n defaultIntegrations.push(new ViewHierarchy());\n }\n }\n\n options.integrations = getIntegrationsToSetup({\n integrations: safeFactory(passedOptions.integrations, { loggerMessage: 'The integrations threw an error' }),\n defaultIntegrations,\n });\n initAndBind(ReactNativeClient, options);\n}\n\n/**\n * Inits the Sentry React Native SDK with automatic instrumentation and wrapped features.\n */\nexport function wrap<P>(\n RootComponent: React.ComponentType<P>,\n options?: ReactNativeWrapperOptions\n): React.ComponentType<P> {\n const tracingIntegration = getCurrentHub().getIntegration(ReactNativeTracing);\n if (tracingIntegration) {\n tracingIntegration.useAppStartWithProfiler = true;\n }\n\n const profilerProps = {\n ...(options?.profilerProps ?? {}),\n name: RootComponent.displayName ?? 'Root',\n };\n\n const RootApp: React.FC<P> = (appProps) => {\n return (\n <TouchEventBoundary {...(options?.touchEventBoundaryProps ?? {})}>\n <ReactNativeProfiler {...profilerProps}>\n <RootComponent {...appProps} />\n </ReactNativeProfiler>\n </TouchEventBoundary>\n );\n };\n\n return RootApp;\n}\n\n/**\n * Deprecated. Sets the release on the event.\n * NOTE: Does not set the release on sessions.\n * @deprecated\n */\nexport function setRelease(release: string): void {\n setExtra('__sentry_release', release);\n}\n\n/**\n * Deprecated. Sets the dist on the event.\n * NOTE: Does not set the dist on sessions.\n * @deprecated\n */\nexport function setDist(dist: string): void {\n setExtra('__sentry_dist', dist);\n}\n\n/**\n * If native client is available it will trigger a native crash.\n * Use this only for testing purposes.\n */\nexport function nativeCrash(): void {\n const client = getCurrentHub().getClient<ReactNativeClient>();\n if (client) {\n client.nativeCrash();\n }\n}\n\n/**\n * Flushes all pending events in the queue to disk.\n * Use this before applying any realtime updates such as code-push or expo updates.\n */\nexport async function flush(): Promise<boolean> {\n try {\n const client = getCurrentHub().getClient<ReactNativeClient>();\n\n if (client) {\n const result = await client.flush();\n\n return result;\n }\n // eslint-disable-next-line no-empty\n } catch (_) { }\n\n logger.error('Failed to flush the event queue.');\n\n return false;\n}\n\n/**\n * Closes the SDK, stops sending events.\n */\nexport async function close(): Promise<void> {\n try {\n const client = getCurrentHub().getClient<ReactNativeClient>();\n\n if (client) {\n await client.close();\n }\n } catch (e) {\n logger.error('Failed to close the SDK');\n }\n}\n\n/**\n * Captures user feedback and sends it to Sentry.\n */\nexport function captureUserFeedback(feedback: UserFeedback): void {\n getCurrentHub().getClient<ReactNativeClient>()?.captureUserFeedback(feedback);\n}\n\n/**\n * Creates a new scope with and executes the given operation within.\n * The scope is automatically removed once the operation\n * finishes or throws.\n *\n * This is essentially a convenience function for:\n *\n * pushScope();\n * callback();\n * popScope();\n *\n * @param callback that will be enclosed into push/popScope.\n */\nexport function withScope(callback: (scope: Scope) => void): ReturnType<Hub['withScope']> {\n const safeCallback = (scope: Scope): void => {\n try {\n callback(scope);\n } catch (e) {\n logger.error('Error while running withScope callback', e);\n }\n };\n getCurrentHub().withScope(safeCallback);\n}\n\n/**\n * Callback to set context information onto the scope.\n * @param callback Callback function that receives Scope.\n */\nexport function configureScope(callback: (scope: Scope) => void): ReturnType<Hub['configureScope']> {\n const safeCallback = (scope: Scope): void => {\n try {\n callback(scope);\n } catch (e) {\n logger.error('Error while running configureScope callback', e);\n }\n };\n getCurrentHub().configureScope(safeCallback);\n}\n"]}
@@ -5,4 +5,5 @@ export { ReactNavigationV4Instrumentation } from './reactnavigationv4';
5
5
  export { ReactNativeNavigationInstrumentation } from './reactnativenavigation';
6
6
  export { ReactNavigationCurrentRoute, ReactNavigationRoute, ReactNavigationTransactionContext, } from './types';
7
7
  export { ReactNativeProfiler } from './reactnativeprofiler';
8
+ export * from './ops';
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EACL,sBAAsB,EACtB,8BAA8B,GAC/B,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,8BAA8B,EAE9B,gCAAgC,GACjC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,oCAAoC,EAAE,MAAM,yBAAyB,CAAC;AAE/E,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,EACpB,iCAAiC,GAClC,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EACL,sBAAsB,EACtB,8BAA8B,GAC/B,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,8BAA8B,EAE9B,gCAAgC,GACjC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,oCAAoC,EAAE,MAAM,yBAAyB,CAAC;AAE/E,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,EACpB,iCAAiC,GAClC,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,cAAc,OAAO,CAAC"}
@@ -6,4 +6,5 @@ ReactNavigationV5Instrumentation, } from './reactnavigation';
6
6
  export { ReactNavigationV4Instrumentation } from './reactnavigationv4';
7
7
  export { ReactNativeNavigationInstrumentation } from './reactnativenavigation';
8
8
  export { ReactNativeProfiler } from './reactnativeprofiler';
9
+ export * from './ops';
9
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/js/tracing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EACL,sBAAsB,GAEvB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,8BAA8B;AAC9B,mDAAmD;AACnD,gCAAgC,GACjC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,oCAAoC,EAAE,MAAM,yBAAyB,CAAC;AAQ/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC","sourcesContent":["export { ReactNativeTracing } from './reactnativetracing';\n\nexport {\n RoutingInstrumentation,\n RoutingInstrumentationInstance,\n} from './routingInstrumentation';\n\nexport {\n ReactNavigationInstrumentation,\n // eslint-disable-next-line deprecation/deprecation\n ReactNavigationV5Instrumentation,\n} from './reactnavigation';\nexport { ReactNavigationV4Instrumentation } from './reactnavigationv4';\nexport { ReactNativeNavigationInstrumentation } from './reactnativenavigation';\n\nexport {\n ReactNavigationCurrentRoute,\n ReactNavigationRoute,\n ReactNavigationTransactionContext,\n} from './types';\n\nexport { ReactNativeProfiler } from './reactnativeprofiler';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/js/tracing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EACL,sBAAsB,GAEvB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,8BAA8B;AAC9B,mDAAmD;AACnD,gCAAgC,GACjC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,oCAAoC,EAAE,MAAM,yBAAyB,CAAC;AAQ/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,cAAc,OAAO,CAAC","sourcesContent":["export { ReactNativeTracing } from './reactnativetracing';\n\nexport {\n RoutingInstrumentation,\n RoutingInstrumentationInstance,\n} from './routingInstrumentation';\n\nexport {\n ReactNavigationInstrumentation,\n // eslint-disable-next-line deprecation/deprecation\n ReactNavigationV5Instrumentation,\n} from './reactnavigation';\nexport { ReactNavigationV4Instrumentation } from './reactnavigationv4';\nexport { ReactNativeNavigationInstrumentation } from './reactnativenavigation';\n\nexport {\n ReactNavigationCurrentRoute,\n ReactNavigationRoute,\n ReactNavigationTransactionContext,\n} from './types';\n\nexport { ReactNativeProfiler } from './reactnativeprofiler';\n\nexport * from './ops';\n"]}
@@ -0,0 +1,6 @@
1
+ export declare const DEFAULT = "default";
2
+ export declare const UI_LOAD = "ui.load";
3
+ export declare const NAVIGATION = "navigation";
4
+ export declare const APP_START_COLD = "app.start.cold";
5
+ export declare const APP_START_WARM = "app.start.warm";
6
+ //# sourceMappingURL=ops.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ops.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/ops.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,YAAY,CAAC;AACjC,eAAO,MAAM,OAAO,YAAY,CAAC;AACjC,eAAO,MAAM,UAAU,eAAe,CAAC;AAEvC,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAC/C,eAAO,MAAM,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export const DEFAULT = 'default';
2
+ export const UI_LOAD = 'ui.load';
3
+ export const NAVIGATION = 'navigation';
4
+ export const APP_START_COLD = 'app.start.cold';
5
+ export const APP_START_WARM = 'app.start.warm';
6
+ //# sourceMappingURL=ops.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ops.js","sourceRoot":"","sources":["../../../src/js/tracing/ops.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC;AACjC,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC;AACjC,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAC;AAEvC,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAC/C,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAC","sourcesContent":["\nexport const DEFAULT = 'default';\nexport const UI_LOAD = 'ui.load';\nexport const NAVIGATION = 'navigation';\n\nexport const APP_START_COLD = 'app.start.cold';\nexport const APP_START_WARM = 'app.start.warm';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"reactnativetracing.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/reactnativetracing.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,EAEV,6BAA6B,EAC7B,WAAW,EACZ,MAAM,iBAAiB,CAAC;AAMzB,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EAGZ,MAAM,eAAe,CAAC;AAIvB,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;AAExF,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAA0B,MAAM,SAAS,CAAC;AAOtE,MAAM,WAAW,yBACf,SAAQ,6BAA6B;IACrC;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,sBAAsB,EAAE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ransaction } from '@sentry/tracing';
3
3
  import { logger } from '@sentry/utils';
4
+ import { APP_START_COLD, APP_START_WARM } from '../measurements';
4
5
  import { NATIVE } from '../wrapper';
5
6
  import { NativeFramesInstrumentation } from './nativeframes';
7
+ import { APP_START_COLD as APP_START_COLD_OP, APP_START_WARM as APP_START_WARM_OP, UI_LOAD, } from './ops';
6
8
  import { StallTrackingInstrumentation } from './stalltracking';
7
9
  import { adjustTransactionDuration, getTimeOriginMilliseconds, isNearToNow, } from './utils';
8
10
  const defaultReactNativeTracingOptions = Object.assign(Object.assign({}, defaultRequestInstrumentationOptions), { idleTimeout: 1000, maxTransactionDuration: 600, idleTimeoutMs: 1000, finalTimeoutMs: 600000, ignoreEmptyBackNavigationTransactions: true, beforeNavigate: (context) => context, enableAppStartTracking: true, enableNativeFramesTracking: true, enableStallTracking: true });
@@ -116,7 +118,7 @@ export class ReactNativeTracing {
116
118
  const appStartTimeSeconds = appStart.appStartTime / 1000;
117
119
  const idleTransaction = this._createRouteTransaction({
118
120
  name: 'App Start',
119
- op: 'ui.load',
121
+ op: UI_LOAD,
120
122
  startTimestamp: appStartTimeSeconds,
121
123
  });
122
124
  if (idleTransaction) {
@@ -134,10 +136,10 @@ export class ReactNativeTracing {
134
136
  return;
135
137
  }
136
138
  const appStartTimeSeconds = appStart.appStartTime / 1000;
137
- const appStartMode = appStart.isColdStart ? 'app.start.cold' : 'app.start.warm';
139
+ const op = appStart.isColdStart ? APP_START_COLD_OP : APP_START_WARM_OP;
138
140
  transaction.startChild({
139
141
  description: appStart.isColdStart ? 'Cold App Start' : 'Warm App Start',
140
- op: appStartMode,
142
+ op,
141
143
  startTimestamp: appStartTimeSeconds,
142
144
  endTimestamp: this._appStartFinishTimestamp,
143
145
  });
@@ -148,7 +150,8 @@ export class ReactNativeTracing {
148
150
  if (appStartDurationMilliseconds >= ReactNativeTracing._maxAppStart) {
149
151
  return;
150
152
  }
151
- transaction.setMeasurement(appStartMode, appStartDurationMilliseconds, 'millisecond');
153
+ const measurement = appStart.isColdStart ? APP_START_COLD : APP_START_WARM;
154
+ transaction.setMeasurement(measurement, appStartDurationMilliseconds, 'millisecond');
152
155
  }
153
156
  /** To be called when the route changes, but BEFORE the components of the new route mount. */
154
157
  _onRouteWillChange(context) {
@@ -1 +1 @@
1
- {"version":3,"file":"reactnativetracing.js","sourceRoot":"","sources":["../../../src/js/tracing/reactnativetracing.ts"],"names":[],"mappings":";AAOA,OAAO,EACL,oCAAoC,EACpC,0BAA0B,EAC1B,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AAOzB,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAIvC,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAE/D,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,WAAW,GACZ,MAAM,SAAS,CAAC;AA4EjB,MAAM,gCAAgC,mCACjC,oCAAoC,KACvC,WAAW,EAAE,IAAI,EACjB,sBAAsB,EAAE,GAAG,EAC3B,aAAa,EAAE,IAAI,EACnB,cAAc,EAAE,MAAM,EACtB,qCAAqC,EAAE,IAAI,EAC3C,cAAc,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,EACpC,sBAAsB,EAAE,IAAI,EAC5B,0BAA0B,EAAE,IAAI,EAChC,mBAAmB,EAAE,IAAI,GAC1B,CAAC;AAEF;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAuB7B,YAAmB,UAA8C,EAAE;;QAhBnE;;WAEG;QACI,SAAI,GAAW,kBAAkB,CAAC,EAAE,CAAC;QAOrC,4BAAuB,GAAY,KAAK,CAAC;QAO9C,IAAI,CAAC,OAAO,iDACP,gCAAgC,GAChC,OAAO,KACV,cAAc,cAAE,OAAO,CAAC,cAAc,mCAEjC,CAAC,OAAO,OAAO,CAAC,sBAAsB,K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,CAAC,MAAM,CACnC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,WAAW,CAAC,MAAM,CAC7C,CAAC,MAAM,KAAK,CAAC,CAAC,EACjB;oBACA,MAAM,CAAC,GAAG,CACR,0JAA0J,CAC3J,CAAC;oBACF,qDAAqD;oBACrD,WAAW,CAAC,OAAO,GAAG,KAAK,CAAC;iBAC7B;YACH,CAAC,CAAC,CAAC;SACJ;QAED,OAAO,eAAe,CAAC;IACzB,CAAC;;AAxUD;;GAEG;AACW,qBAAE,GAAW,oBAAoB,CAAC;AAChD,6CAA6C;AAC9B,+BAAY,GAAW,KAAK,CAAC","sourcesContent":["/* eslint-disable max-lines */\nimport type { Hub } from '@sentry/core';\nimport type {\n IdleTransaction,\n RequestInstrumentationOptions,\n Transaction\n} from '@sentry/tracing';\nimport {\n defaultRequestInstrumentationOptions,\n instrumentOutgoingRequests,\n startIdleTransaction\n} from '@sentry/tracing';\nimport type {\n EventProcessor,\n Integration,\n Transaction as TransactionType,\n TransactionContext,\n} from '@sentry/types';\nimport { logger } from '@sentry/utils';\n\nimport type { NativeAppStartResponse } from '../NativeRNSentry';\nimport type { RoutingInstrumentationInstance } from '../tracing/routingInstrumentation';\nimport { NATIVE } from '../wrapper';\nimport { NativeFramesInstrumentation } from './nativeframes';\nimport { StallTrackingInstrumentation } from './stalltracking';\nimport type { BeforeNavigate, RouteChangeContextData } from './types';\nimport {\n adjustTransactionDuration,\n getTimeOriginMilliseconds,\n isNearToNow,\n} from './utils';\n\nexport interface ReactNativeTracingOptions\n extends RequestInstrumentationOptions {\n /**\n * @deprecated Replaced by idleTimeoutMs\n */\n idleTimeout: number;\n\n /**\n * @deprecated Replaced by maxTransactionDurationMs\n */\n maxTransactionDuration: number;\n\n /**\n * The time to wait in ms until the transaction will be finished. The transaction will use the end timestamp of\n * the last finished span as the endtime for the transaction.\n * Time is in ms.\n *\n * Default: 1000\n */\n idleTimeoutMs: number;\n\n /**\n * The maximum duration (transaction duration + idle timeout) of a transaction\n * before it will be marked as \"deadline_exceeded\".\n * If you never want to mark a transaction set it to 0.\n * Time is in ms.\n *\n * Default: 600000\n */\n finalTimeoutMs: number;\n\n /**\n * The routing instrumentation to be used with the tracing integration.\n * There is no routing instrumentation if nothing is passed.\n */\n routingInstrumentation?: RoutingInstrumentationInstance;\n\n /**\n * Does not sample transactions that are from routes that have been seen any more and don't have any spans.\n * This removes a lot of the clutter as most back navigation transactions are now ignored.\n *\n * Default: true\n */\n ignoreEmptyBackNavigationTransactions: boolean;\n\n /**\n * beforeNavigate is called before a navigation transaction is created and allows users to modify transaction\n * context data, or drop the transaction entirely (by setting `sampled = false` in the context).\n *\n * @param context: The context data which will be passed to `startTransaction` by default\n *\n * @returns A (potentially) modified context object, with `sampled = false` if the transaction should be dropped.\n */\n beforeNavigate: BeforeNavigate;\n\n /**\n * Track the app start time by adding measurements to the first route transaction. If there is no routing instrumentation\n * an app start transaction will be started.\n *\n * Default: true\n */\n enableAppStartTracking: boolean;\n\n /**\n * Track slow/frozen frames from the native layer and adds them as measurements to all transactions.\n */\n enableNativeFramesTracking: boolean;\n\n /**\n * Track when and how long the JS event loop stalls for. Adds stalls as measurements to all transactions.\n */\n enableStallTracking: boolean;\n}\n\nconst defaultReactNativeTracingOptions: ReactNativeTracingOptions = {\n ...defaultRequestInstrumentationOptions,\n idleTimeout: 1000,\n maxTransactionDuration: 600,\n idleTimeoutMs: 1000,\n finalTimeoutMs: 600000,\n ignoreEmptyBackNavigationTransactions: true,\n beforeNavigate: (context) => context,\n enableAppStartTracking: true,\n enableNativeFramesTracking: true,\n enableStallTracking: true,\n};\n\n/**\n * Tracing integration for React Native.\n */\nexport class ReactNativeTracing implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'ReactNativeTracing';\n /** We filter out App starts more than 60s */\n private static _maxAppStart: number = 60000;\n /**\n * @inheritDoc\n */\n public name: string = ReactNativeTracing.id;\n\n /** ReactNativeTracing options */\n public options: ReactNativeTracingOptions;\n\n public nativeFramesInstrumentation?: NativeFramesInstrumentation;\n public stallTrackingInstrumentation?: StallTrackingInstrumentation;\n public useAppStartWithProfiler: boolean = false;\n\n private _getCurrentHub?: () => Hub;\n private _awaitingAppStartData?: NativeAppStartResponse;\n private _appStartFinishTimestamp?: number;\n\n public constructor(options: Partial<ReactNativeTracingOptions> = {}) {\n this.options = {\n ...defaultReactNativeTracingOptions,\n ...options,\n finalTimeoutMs: options.finalTimeoutMs\n // eslint-disable-next-line deprecation/deprecation\n ?? (typeof options.maxTransactionDuration === 'number'\n // eslint-disable-next-line deprecation/deprecation\n ? options.maxTransactionDuration * 1000\n : undefined)\n ?? defaultReactNativeTracingOptions.finalTimeoutMs,\n idleTimeoutMs: options.idleTimeoutMs\n // eslint-disable-next-line deprecation/deprecation\n ?? options.idleTimeout\n ?? defaultReactNativeTracingOptions.idleTimeoutMs,\n };\n }\n\n /**\n * Registers routing and request instrumentation.\n */\n public setupOnce(\n // @ts-ignore TODO\n addGlobalEventProcessor: (callback: EventProcessor) => void,\n getCurrentHub: () => Hub\n ): void {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const {\n traceFetch,\n traceXHR,\n // eslint-disable-next-line deprecation/deprecation\n tracingOrigins,\n // @ts-ignore TODO\n shouldCreateSpanForRequest,\n tracePropagationTargets,\n routingInstrumentation,\n enableAppStartTracking,\n enableNativeFramesTracking,\n enableStallTracking,\n } = this.options;\n\n this._getCurrentHub = getCurrentHub;\n\n if (enableAppStartTracking) {\n void this._instrumentAppStart();\n }\n\n if (enableNativeFramesTracking) {\n NATIVE.enableNativeFramesTracking();\n this.nativeFramesInstrumentation = new NativeFramesInstrumentation(\n addGlobalEventProcessor,\n () => {\n const self = getCurrentHub().getIntegration(ReactNativeTracing);\n\n if (self) {\n return !!self.nativeFramesInstrumentation;\n }\n\n return false;\n }\n );\n } else {\n NATIVE.disableNativeFramesTracking();\n }\n\n if (enableStallTracking) {\n this.stallTrackingInstrumentation = new StallTrackingInstrumentation();\n }\n\n if (routingInstrumentation) {\n routingInstrumentation.registerRoutingInstrumentation(\n this._onRouteWillChange.bind(this),\n this.options.beforeNavigate,\n this._onConfirmRoute.bind(this)\n );\n } else {\n logger.log(\n '[ReactNativeTracing] Not instrumenting route changes as routingInstrumentation has not been set.'\n );\n }\n\n instrumentOutgoingRequests({\n traceFetch,\n traceXHR,\n tracingOrigins,\n shouldCreateSpanForRequest,\n tracePropagationTargets,\n });\n }\n\n /**\n * To be called on a transaction start. Can have async methods\n */\n public onTransactionStart(transaction: Transaction): void {\n if (isNearToNow(transaction.startTimestamp)) {\n // Only if this method is called at or within margin of error to the start timestamp.\n this.nativeFramesInstrumentation?.onTransactionStart(transaction);\n this.stallTrackingInstrumentation?.onTransactionStart(transaction);\n }\n }\n\n /**\n * To be called on a transaction finish. Cannot have async methods.\n */\n public onTransactionFinish(\n transaction: Transaction,\n endTimestamp?: number\n ): void {\n this.nativeFramesInstrumentation?.onTransactionFinish(transaction);\n this.stallTrackingInstrumentation?.onTransactionFinish(\n transaction,\n endTimestamp\n );\n }\n\n /**\n * Called by the ReactNativeProfiler component on first component mount.\n */\n public onAppStartFinish(endTimestamp: number): void {\n this._appStartFinishTimestamp = endTimestamp;\n }\n\n /**\n * Instruments the app start measurements on the first route transaction.\n * Starts a route transaction if there isn't routing instrumentation.\n */\n private async _instrumentAppStart(): Promise<void> {\n if (!this.options.enableAppStartTracking || !NATIVE.enableNative) {\n return;\n }\n\n const appStart = await NATIVE.fetchNativeAppStart();\n\n if (!appStart || appStart.didFetchAppStart) {\n return;\n }\n\n if (!this.useAppStartWithProfiler) {\n this._appStartFinishTimestamp = getTimeOriginMilliseconds() / 1000;\n }\n\n if (this.options.routingInstrumentation) {\n this._awaitingAppStartData = appStart;\n } else {\n const appStartTimeSeconds = appStart.appStartTime / 1000;\n\n const idleTransaction = this._createRouteTransaction({\n name: 'App Start',\n op: 'ui.load',\n startTimestamp: appStartTimeSeconds,\n });\n\n if (idleTransaction) {\n this._addAppStartData(idleTransaction, appStart);\n }\n }\n }\n\n /**\n * Adds app start measurements and starts a child span on a transaction.\n */\n private _addAppStartData(\n transaction: IdleTransaction,\n appStart: NativeAppStartResponse\n ): void {\n if (!this._appStartFinishTimestamp) {\n logger.warn('App start was never finished.');\n return;\n }\n\n const appStartTimeSeconds = appStart.appStartTime / 1000;\n\n const appStartMode = appStart.isColdStart ? 'app.start.cold' : 'app.start.warm';\n transaction.startChild({\n description: appStart.isColdStart ? 'Cold App Start' : 'Warm App Start',\n op: appStartMode,\n startTimestamp: appStartTimeSeconds,\n endTimestamp: this._appStartFinishTimestamp,\n });\n\n const appStartDurationMilliseconds =\n this._appStartFinishTimestamp * 1000 - appStart.appStartTime;\n\n // we filter out app start more than 60s.\n // this could be due to many different reasons.\n // we've seen app starts with hours, days and even months.\n if (appStartDurationMilliseconds >= ReactNativeTracing._maxAppStart) {\n return;\n }\n\n transaction.setMeasurement(appStartMode, appStartDurationMilliseconds, 'millisecond');\n }\n\n /** To be called when the route changes, but BEFORE the components of the new route mount. */\n private _onRouteWillChange(\n context: TransactionContext\n ): TransactionType | undefined {\n return this._createRouteTransaction(context);\n }\n\n /**\n * Creates a breadcrumb and sets the current route as a tag.\n */\n private _onConfirmRoute(context: TransactionContext): void {\n this._getCurrentHub?.().configureScope((scope) => {\n if (context.data) {\n const contextData = context.data as RouteChangeContextData;\n\n scope.addBreadcrumb({\n category: 'navigation',\n type: 'navigation',\n // We assume that context.name is the name of the route.\n message: `Navigation to ${context.name}`,\n data: {\n from: contextData.previousRoute?.name,\n to: contextData.route.name,\n },\n });\n }\n\n scope.setTag('routing.route.name', context.name);\n });\n }\n\n /** Create routing idle transaction. */\n private _createRouteTransaction(\n context: TransactionContext\n ): IdleTransaction | undefined {\n if (!this._getCurrentHub) {\n logger.warn(\n `[ReactNativeTracing] Did not create ${context.op} transaction because _getCurrentHub is invalid.`\n );\n return undefined;\n }\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const { idleTimeoutMs, finalTimeoutMs } = this.options;\n\n const expandedContext = {\n ...context,\n trimEnd: true,\n };\n\n const hub = this._getCurrentHub();\n const idleTransaction = startIdleTransaction(\n hub as Hub,\n expandedContext,\n idleTimeoutMs,\n finalTimeoutMs,\n true\n );\n\n this.onTransactionStart(idleTransaction);\n\n logger.log(\n `[ReactNativeTracing] Starting ${context.op} transaction \"${context.name}\" on scope`\n );\n\n idleTransaction.registerBeforeFinishCallback(\n (transaction, endTimestamp) => {\n this.onTransactionFinish(transaction, endTimestamp);\n }\n );\n\n idleTransaction.registerBeforeFinishCallback((transaction) => {\n if (this.options.enableAppStartTracking && this._awaitingAppStartData) {\n transaction.startTimestamp =\n this._awaitingAppStartData.appStartTime / 1000;\n transaction.op = 'ui.load';\n\n this._addAppStartData(transaction, this._awaitingAppStartData);\n\n this._awaitingAppStartData = undefined;\n }\n });\n\n idleTransaction.registerBeforeFinishCallback(\n (transaction, endTimestamp) => {\n adjustTransactionDuration(\n finalTimeoutMs,\n transaction,\n endTimestamp\n );\n }\n );\n\n if (this.options.ignoreEmptyBackNavigationTransactions) {\n idleTransaction.registerBeforeFinishCallback((transaction) => {\n if (\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n transaction.data?.route?.hasBeenSeen &&\n (!transaction.spanRecorder ||\n transaction.spanRecorder.spans.filter(\n (span) => span.spanId !== transaction.spanId\n ).length === 0)\n ) {\n logger.log(\n '[ReactNativeTracing] Not sampling transaction as route has been seen before. Pass ignoreEmptyBackNavigationTransactions = false to disable this feature.'\n );\n // Route has been seen before and has no child spans.\n transaction.sampled = false;\n }\n });\n }\n\n return idleTransaction;\n }\n}\n"]}
1
+ {"version":3,"file":"reactnativetracing.js","sourceRoot":"","sources":["../../../src/js/tracing/reactnativetracing.ts"],"names":[],"mappings":";AAOA,OAAO,EACL,oCAAoC,EACpC,0BAA0B,EAC1B,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AAOzB,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OA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,CACR,0JAA0J,CAC3J,CAAC;oBACF,qDAAqD;oBACrD,WAAW,CAAC,OAAO,GAAG,KAAK,CAAC;iBAC7B;YACH,CAAC,CAAC,CAAC;SACJ;QAED,OAAO,eAAe,CAAC;IACzB,CAAC;;AAzUD;;GAEG;AACW,qBAAE,GAAW,oBAAoB,CAAC;AAChD,6CAA6C;AAC9B,+BAAY,GAAW,KAAK,CAAC","sourcesContent":["/* eslint-disable max-lines */\nimport type { Hub } from '@sentry/core';\nimport type {\n IdleTransaction,\n RequestInstrumentationOptions,\n Transaction\n} from '@sentry/tracing';\nimport {\n defaultRequestInstrumentationOptions,\n instrumentOutgoingRequests,\n startIdleTransaction\n} from '@sentry/tracing';\nimport type {\n EventProcessor,\n Integration,\n Transaction as TransactionType,\n TransactionContext,\n} from '@sentry/types';\nimport { logger } from '@sentry/utils';\n\nimport { APP_START_COLD, APP_START_WARM } from '../measurements';\nimport type { NativeAppStartResponse } from '../NativeRNSentry';\nimport type { RoutingInstrumentationInstance } from '../tracing/routingInstrumentation';\nimport { NATIVE } from '../wrapper';\nimport { NativeFramesInstrumentation } from './nativeframes';\nimport {\n APP_START_COLD as APP_START_COLD_OP,\n APP_START_WARM as APP_START_WARM_OP,\n UI_LOAD,\n} from './ops';\nimport { StallTrackingInstrumentation } from './stalltracking';\nimport type { BeforeNavigate, RouteChangeContextData } from './types';\nimport {\n adjustTransactionDuration,\n getTimeOriginMilliseconds,\n isNearToNow,\n} from './utils';\n\nexport interface ReactNativeTracingOptions\n extends RequestInstrumentationOptions {\n /**\n * @deprecated Replaced by idleTimeoutMs\n */\n idleTimeout: number;\n\n /**\n * @deprecated Replaced by maxTransactionDurationMs\n */\n maxTransactionDuration: number;\n\n /**\n * The time to wait in ms until the transaction will be finished. The transaction will use the end timestamp of\n * the last finished span as the endtime for the transaction.\n * Time is in ms.\n *\n * Default: 1000\n */\n idleTimeoutMs: number;\n\n /**\n * The maximum duration (transaction duration + idle timeout) of a transaction\n * before it will be marked as \"deadline_exceeded\".\n * If you never want to mark a transaction set it to 0.\n * Time is in ms.\n *\n * Default: 600000\n */\n finalTimeoutMs: number;\n\n /**\n * The routing instrumentation to be used with the tracing integration.\n * There is no routing instrumentation if nothing is passed.\n */\n routingInstrumentation?: RoutingInstrumentationInstance;\n\n /**\n * Does not sample transactions that are from routes that have been seen any more and don't have any spans.\n * This removes a lot of the clutter as most back navigation transactions are now ignored.\n *\n * Default: true\n */\n ignoreEmptyBackNavigationTransactions: boolean;\n\n /**\n * beforeNavigate is called before a navigation transaction is created and allows users to modify transaction\n * context data, or drop the transaction entirely (by setting `sampled = false` in the context).\n *\n * @param context: The context data which will be passed to `startTransaction` by default\n *\n * @returns A (potentially) modified context object, with `sampled = false` if the transaction should be dropped.\n */\n beforeNavigate: BeforeNavigate;\n\n /**\n * Track the app start time by adding measurements to the first route transaction. If there is no routing instrumentation\n * an app start transaction will be started.\n *\n * Default: true\n */\n enableAppStartTracking: boolean;\n\n /**\n * Track slow/frozen frames from the native layer and adds them as measurements to all transactions.\n */\n enableNativeFramesTracking: boolean;\n\n /**\n * Track when and how long the JS event loop stalls for. Adds stalls as measurements to all transactions.\n */\n enableStallTracking: boolean;\n}\n\nconst defaultReactNativeTracingOptions: ReactNativeTracingOptions = {\n ...defaultRequestInstrumentationOptions,\n idleTimeout: 1000,\n maxTransactionDuration: 600,\n idleTimeoutMs: 1000,\n finalTimeoutMs: 600000,\n ignoreEmptyBackNavigationTransactions: true,\n beforeNavigate: (context) => context,\n enableAppStartTracking: true,\n enableNativeFramesTracking: true,\n enableStallTracking: true,\n};\n\n/**\n * Tracing integration for React Native.\n */\nexport class ReactNativeTracing implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'ReactNativeTracing';\n /** We filter out App starts more than 60s */\n private static _maxAppStart: number = 60000;\n /**\n * @inheritDoc\n */\n public name: string = ReactNativeTracing.id;\n\n /** ReactNativeTracing options */\n public options: ReactNativeTracingOptions;\n\n public nativeFramesInstrumentation?: NativeFramesInstrumentation;\n public stallTrackingInstrumentation?: StallTrackingInstrumentation;\n public useAppStartWithProfiler: boolean = false;\n\n private _getCurrentHub?: () => Hub;\n private _awaitingAppStartData?: NativeAppStartResponse;\n private _appStartFinishTimestamp?: number;\n\n public constructor(options: Partial<ReactNativeTracingOptions> = {}) {\n this.options = {\n ...defaultReactNativeTracingOptions,\n ...options,\n finalTimeoutMs: options.finalTimeoutMs\n // eslint-disable-next-line deprecation/deprecation\n ?? (typeof options.maxTransactionDuration === 'number'\n // eslint-disable-next-line deprecation/deprecation\n ? options.maxTransactionDuration * 1000\n : undefined)\n ?? defaultReactNativeTracingOptions.finalTimeoutMs,\n idleTimeoutMs: options.idleTimeoutMs\n // eslint-disable-next-line deprecation/deprecation\n ?? options.idleTimeout\n ?? defaultReactNativeTracingOptions.idleTimeoutMs,\n };\n }\n\n /**\n * Registers routing and request instrumentation.\n */\n public setupOnce(\n // @ts-ignore TODO\n addGlobalEventProcessor: (callback: EventProcessor) => void,\n getCurrentHub: () => Hub\n ): void {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const {\n traceFetch,\n traceXHR,\n // eslint-disable-next-line deprecation/deprecation\n tracingOrigins,\n // @ts-ignore TODO\n shouldCreateSpanForRequest,\n tracePropagationTargets,\n routingInstrumentation,\n enableAppStartTracking,\n enableNativeFramesTracking,\n enableStallTracking,\n } = this.options;\n\n this._getCurrentHub = getCurrentHub;\n\n if (enableAppStartTracking) {\n void this._instrumentAppStart();\n }\n\n if (enableNativeFramesTracking) {\n NATIVE.enableNativeFramesTracking();\n this.nativeFramesInstrumentation = new NativeFramesInstrumentation(\n addGlobalEventProcessor,\n () => {\n const self = getCurrentHub().getIntegration(ReactNativeTracing);\n\n if (self) {\n return !!self.nativeFramesInstrumentation;\n }\n\n return false;\n }\n );\n } else {\n NATIVE.disableNativeFramesTracking();\n }\n\n if (enableStallTracking) {\n this.stallTrackingInstrumentation = new StallTrackingInstrumentation();\n }\n\n if (routingInstrumentation) {\n routingInstrumentation.registerRoutingInstrumentation(\n this._onRouteWillChange.bind(this),\n this.options.beforeNavigate,\n this._onConfirmRoute.bind(this)\n );\n } else {\n logger.log(\n '[ReactNativeTracing] Not instrumenting route changes as routingInstrumentation has not been set.'\n );\n }\n\n instrumentOutgoingRequests({\n traceFetch,\n traceXHR,\n tracingOrigins,\n shouldCreateSpanForRequest,\n tracePropagationTargets,\n });\n }\n\n /**\n * To be called on a transaction start. Can have async methods\n */\n public onTransactionStart(transaction: Transaction): void {\n if (isNearToNow(transaction.startTimestamp)) {\n // Only if this method is called at or within margin of error to the start timestamp.\n this.nativeFramesInstrumentation?.onTransactionStart(transaction);\n this.stallTrackingInstrumentation?.onTransactionStart(transaction);\n }\n }\n\n /**\n * To be called on a transaction finish. Cannot have async methods.\n */\n public onTransactionFinish(\n transaction: Transaction,\n endTimestamp?: number\n ): void {\n this.nativeFramesInstrumentation?.onTransactionFinish(transaction);\n this.stallTrackingInstrumentation?.onTransactionFinish(\n transaction,\n endTimestamp\n );\n }\n\n /**\n * Called by the ReactNativeProfiler component on first component mount.\n */\n public onAppStartFinish(endTimestamp: number): void {\n this._appStartFinishTimestamp = endTimestamp;\n }\n\n /**\n * Instruments the app start measurements on the first route transaction.\n * Starts a route transaction if there isn't routing instrumentation.\n */\n private async _instrumentAppStart(): Promise<void> {\n if (!this.options.enableAppStartTracking || !NATIVE.enableNative) {\n return;\n }\n\n const appStart = await NATIVE.fetchNativeAppStart();\n\n if (!appStart || appStart.didFetchAppStart) {\n return;\n }\n\n if (!this.useAppStartWithProfiler) {\n this._appStartFinishTimestamp = getTimeOriginMilliseconds() / 1000;\n }\n\n if (this.options.routingInstrumentation) {\n this._awaitingAppStartData = appStart;\n } else {\n const appStartTimeSeconds = appStart.appStartTime / 1000;\n\n const idleTransaction = this._createRouteTransaction({\n name: 'App Start',\n op: UI_LOAD,\n startTimestamp: appStartTimeSeconds,\n });\n\n if (idleTransaction) {\n this._addAppStartData(idleTransaction, appStart);\n }\n }\n }\n\n /**\n * Adds app start measurements and starts a child span on a transaction.\n */\n private _addAppStartData(\n transaction: IdleTransaction,\n appStart: NativeAppStartResponse\n ): void {\n if (!this._appStartFinishTimestamp) {\n logger.warn('App start was never finished.');\n return;\n }\n\n const appStartTimeSeconds = appStart.appStartTime / 1000;\n\n const op = appStart.isColdStart ? APP_START_COLD_OP : APP_START_WARM_OP;\n transaction.startChild({\n description: appStart.isColdStart ? 'Cold App Start' : 'Warm App Start',\n op,\n startTimestamp: appStartTimeSeconds,\n endTimestamp: this._appStartFinishTimestamp,\n });\n\n const appStartDurationMilliseconds =\n this._appStartFinishTimestamp * 1000 - appStart.appStartTime;\n\n // we filter out app start more than 60s.\n // this could be due to many different reasons.\n // we've seen app starts with hours, days and even months.\n if (appStartDurationMilliseconds >= ReactNativeTracing._maxAppStart) {\n return;\n }\n\n const measurement = appStart.isColdStart ? APP_START_COLD : APP_START_WARM;\n transaction.setMeasurement(measurement, appStartDurationMilliseconds, 'millisecond');\n }\n\n /** To be called when the route changes, but BEFORE the components of the new route mount. */\n private _onRouteWillChange(\n context: TransactionContext\n ): TransactionType | undefined {\n return this._createRouteTransaction(context);\n }\n\n /**\n * Creates a breadcrumb and sets the current route as a tag.\n */\n private _onConfirmRoute(context: TransactionContext): void {\n this._getCurrentHub?.().configureScope((scope) => {\n if (context.data) {\n const contextData = context.data as RouteChangeContextData;\n\n scope.addBreadcrumb({\n category: 'navigation',\n type: 'navigation',\n // We assume that context.name is the name of the route.\n message: `Navigation to ${context.name}`,\n data: {\n from: contextData.previousRoute?.name,\n to: contextData.route.name,\n },\n });\n }\n\n scope.setTag('routing.route.name', context.name);\n });\n }\n\n /** Create routing idle transaction. */\n private _createRouteTransaction(\n context: TransactionContext\n ): IdleTransaction | undefined {\n if (!this._getCurrentHub) {\n logger.warn(\n `[ReactNativeTracing] Did not create ${context.op} transaction because _getCurrentHub is invalid.`\n );\n return undefined;\n }\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const { idleTimeoutMs, finalTimeoutMs } = this.options;\n\n const expandedContext = {\n ...context,\n trimEnd: true,\n };\n\n const hub = this._getCurrentHub();\n const idleTransaction = startIdleTransaction(\n hub as Hub,\n expandedContext,\n idleTimeoutMs,\n finalTimeoutMs,\n true\n );\n\n this.onTransactionStart(idleTransaction);\n\n logger.log(\n `[ReactNativeTracing] Starting ${context.op} transaction \"${context.name}\" on scope`\n );\n\n idleTransaction.registerBeforeFinishCallback(\n (transaction, endTimestamp) => {\n this.onTransactionFinish(transaction, endTimestamp);\n }\n );\n\n idleTransaction.registerBeforeFinishCallback((transaction) => {\n if (this.options.enableAppStartTracking && this._awaitingAppStartData) {\n transaction.startTimestamp =\n this._awaitingAppStartData.appStartTime / 1000;\n transaction.op = 'ui.load';\n\n this._addAppStartData(transaction, this._awaitingAppStartData);\n\n this._awaitingAppStartData = undefined;\n }\n });\n\n idleTransaction.registerBeforeFinishCallback(\n (transaction, endTimestamp) => {\n adjustTransactionDuration(\n finalTimeoutMs,\n transaction,\n endTimestamp\n );\n }\n );\n\n if (this.options.ignoreEmptyBackNavigationTransactions) {\n idleTransaction.registerBeforeFinishCallback((transaction) => {\n if (\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n transaction.data?.route?.hasBeenSeen &&\n (!transaction.spanRecorder ||\n transaction.spanRecorder.spans.filter(\n (span) => span.spanId !== transaction.spanId\n ).length === 0)\n ) {\n logger.log(\n '[ReactNativeTracing] Not sampling transaction as route has been seen before. Pass ignoreEmptyBackNavigationTransactions = false to disable this feature.'\n );\n // Route has been seen before and has no child spans.\n transaction.sampled = false;\n }\n });\n }\n\n return idleTransaction;\n }\n}\n"]}
@@ -1,15 +1,16 @@
1
1
  import type { IdleTransaction, Transaction } from '@sentry/tracing';
2
2
  import type { Measurements, MeasurementUnit } from '@sentry/types';
3
+ import { STALL_COUNT, STALL_LONGEST_TIME, STALL_TOTAL_TIME } from '../measurements';
3
4
  export interface StallMeasurements extends Measurements {
4
- 'stall_count': {
5
+ [STALL_COUNT]: {
5
6
  value: number;
6
7
  unit: MeasurementUnit;
7
8
  };
8
- 'stall_total_time': {
9
+ [STALL_TOTAL_TIME]: {
9
10
  value: number;
10
11
  unit: MeasurementUnit;
11
12
  };
12
- 'stall_longest_time': {
13
+ [STALL_LONGEST_TIME]: {
13
14
  value: number;
14
15
  unit: MeasurementUnit;
15
16
  };
@@ -1 +1 @@
1
- {"version":3,"file":"stalltracking.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/stalltracking.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAQ,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGnE,MAAM,WAAW,iBAAkB,SAAQ,YAAY;IACrD,aAAa,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC;IACxD,kBAAkB,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC;IAC7D,oBAAoB,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC;CAChE;AAED,oBAAY,oBAAoB,GAAG;IACjC;;;OAGG;IACH,qBAAqB,EAAE,MAAM,CAAC;CAC/B,CAAC;AASF;;;;;;GAMG;AACH,qBAAa,4BAA4B;IAChC,UAAU,EAAE,OAAO,CAAS;IAEnC,OAAO,CAAC,sBAAsB,CAAS;IAEvC,2FAA2F;IAC3F,OAAO,CAAC,eAAe,CAAa;IACpC,+EAA+E;IAC/E,OAAO,CAAC,WAAW,CAAa;IAEhC,2DAA2D;IAC3D,OAAO,CAAC,eAAe,CAAa;IACpC,OAAO,CAAC,QAAQ,CAA8C;IAE9D,OAAO,CAAC,mBAAmB,CAUb;gBAGZ,OAAO,GAAE,oBAAoD;IAK/D;;;OAGG;IACI,SAAS,IAAI,IAAI;IAIxB;;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AASF;;;;;;GAMG;AACH,qBAAa,4BAA4B;IAChC,UAAU,EAAE,OAAO,CAAS;IAEnC,OAAO,CAAC,sBAAsB,CAAS;IAEvC,2FAA2F;IAC3F,OAAO,CAAC,eAAe,CAAa;IACpC,+EAA+E;IAC/E,OAAO,CAAC,WAAW,CAAa;IAEhC,2DAA2D;IAC3D,OAAO,CAAC,eAAe,CAAa;IACpC,OAAO,CAAC,QAAQ,CAA8C;IAE9D,OAAO,CAAC,mBAAmB,CAUb;gBAGZ,OAAO,GAAE,oBAAoD;IAK/D;;;OAGG;IACI,SAAS,IAAI,IAAI;IAIxB;;;OAGG;IACI,kBAAkB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAwCzD;;;;OAIG;IACI,mBAAmB,CACxB,WAAW,EAAE,WAAW,GAAG,eAAe,EAC1C,kBAAkB,CAAC,EAAE,MAAM,GAC1B,IAAI;IAuGP;;OAEG;IACH,OAAO,CAAC,eAAe;IAoCvB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAUxB;;OAEG;IACH,OAAO,CAAC,cAAc;IAStB;;OAEG;IACH,OAAO,CAAC,aAAa;IAWrB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAM3B;;OAEG;IACH,OAAO,CAAC,MAAM;IAOd;;;OAGG;IACH,OAAO,CAAC,UAAU;IAmClB;;OAEG;IACH,OAAO,CAAC,wBAAwB;CAYjC"}
@@ -1,4 +1,5 @@
1
1
  import { logger, timestampInSeconds } from '@sentry/utils';
2
+ import { STALL_COUNT, STALL_LONGEST_TIME, STALL_TOTAL_TIME } from '../measurements';
2
3
  /** Margin of error of 20ms */
3
4
  const MARGIN_OF_ERROR_SECONDS = 0.02;
4
5
  /** How long between each iteration in the event loop tracker timeout */
@@ -136,11 +137,11 @@ export class StallTrackingInstrumentation {
136
137
  }
137
138
  return;
138
139
  }
139
- transaction.setMeasurement('stall_count', statsOnFinish.stall_count.value -
140
+ transaction.setMeasurement(STALL_COUNT, statsOnFinish.stall_count.value -
140
141
  transactionStats.atStart.stall_count.value, transactionStats.atStart.stall_count.unit);
141
- transaction.setMeasurement('stall_total_time', statsOnFinish.stall_total_time.value -
142
+ transaction.setMeasurement(STALL_TOTAL_TIME, statsOnFinish.stall_total_time.value -
142
143
  transactionStats.atStart.stall_total_time.value, transactionStats.atStart.stall_total_time.unit);
143
- transaction.setMeasurement('stall_longest_time', statsOnFinish.stall_longest_time.value, statsOnFinish.stall_longest_time.unit);
144
+ transaction.setMeasurement(STALL_LONGEST_TIME, statsOnFinish.stall_longest_time.value, statsOnFinish.stall_longest_time.unit);
144
145
  }
145
146
  /**
146
147
  * Logs the finish time of the span for use in `trimEnd: true` transactions.
@@ -1 +1 @@
1
- {"version":3,"file":"stalltracking.js","sourceRoot":"","sources":["../../../src/js/tracing/stalltracking.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAgB3D,8BAA8B;AAC9B,MAAM,uBAAuB,GAAG,IAAI,CAAC;AACrC,wEAAwE;AACxE,MAAM,wBAAwB,GAAG,EAAE,CAAC;AACpC,qIAAqI;AACrI,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,OAAO,4BAA4B;IA0BvC,YACE,UAAgC,EAAE,qBAAqB,EAAE,EAAE,EAAE;QA1BxD,eAAU,GAAY,KAAK,CAAC;QAInC,2FAA2F;QACnF,oBAAe,GAAW,CAAC,CAAC;QACpC,+EAA+E;QACvE,gBAAW,GAAW,CAAC,CAAC;QAEhC,2DAA2D;QACnD,oBAAe,GAAW,CAAC,CAAC;QAC5B,aAAQ,GAAyC,IAAI,CAAC;QAEtD,wBAAmB,GAUvB,IAAI,GAAG,EAAE,CAAC;QAKZ,IAAI,CAAC,sBAAsB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAC9D,CAAC;IAED;;;OAGG;IACI,SAAS;QACd,cAAc;IAChB,CAAC;IAED;;;OAGG;IACI,kBAAk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gBACrE,MAAM,gBAAgB,GAAG,IAAI,CAAC,GAAG,OAC/B,KAAK,CAAC,gBAAgB,mCAAI,CAAC,EAC3B,SAAS,CACV,CAAC;gBAEF,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,WAAW,kCACnC,KAAK,KACR,gBAAgB,IAChB,CAAC;aACJ;SACF;QAED,IAAI,CAAC,eAAe,GAAG,GAAG,CAAC;QAE3B,IAAI,IAAI,CAAC,UAAU,EAAE;YACnB,IAAI,CAAC,QAAQ,GAAG,UAAU,CACxB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAC1B,wBAAwB,CACzB,CAAC;SACH;IACH,CAAC;IAED;;OAEG;IACK,wBAAwB;QAC9B,IAAI,IAAI,CAAC,mBAAmB,CAAC,IAAI,GAAG,wBAAwB,EAAE;YAC5D,IAAI,OAAO,GAAG,CAAC,CAAC;YAChB,MAAM,GAAG,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,GAAG,wBAAwB,CAAC;YACrE,MAAM,YAAY,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,EAAE,CAAC;YACrD,KAAK,MAAM,CAAC,IAAI,YAAY,EAAE;gBAC5B,IAAI,OAAO,IAAI,GAAG;oBAAE,MAAM;gBAC1B,OAAO,IAAI,CAAC,CAAC;gBACb,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;aACpC;SACF;IACH,CAAC;CACF","sourcesContent":["/* eslint-disable max-lines */\nimport type { IdleTransaction, Span, Transaction } from '@sentry/tracing';\nimport type { Measurements, MeasurementUnit } from '@sentry/types';\nimport { logger, timestampInSeconds } from '@sentry/utils';\n\nexport interface StallMeasurements extends Measurements {\n 'stall_count': { value: number, unit: MeasurementUnit };\n 'stall_total_time': { value: number, unit: MeasurementUnit };\n 'stall_longest_time': { value: number, unit: MeasurementUnit };\n}\n\nexport type StallTrackingOptions = {\n /**\n * How long in milliseconds an event loop iteration can be delayed for before being considered a \"stall.\"\n * @default 100\n */\n minimumStallThreshold: number;\n};\n\n/** Margin of error of 20ms */\nconst MARGIN_OF_ERROR_SECONDS = 0.02;\n/** How long between each iteration in the event loop tracker timeout */\nconst LOOP_TIMEOUT_INTERVAL_MS = 50;\n/** Limit for how many transactions the stall tracker will track at a time to prevent leaks due to transactions not being finished */\nconst MAX_RUNNING_TRANSACTIONS = 10;\n\n/**\n * Stall measurement tracker inspired by the `JSEventLoopWatchdog` used internally in React Native:\n * https://github.com/facebook/react-native/blob/006f5afe120c290a37cf6ff896748fbc062bf7ed/Libraries/Interaction/JSEventLoopWatchdog.js\n *\n * However, we modified the interval implementation to instead have a fixed loop timeout interval of `LOOP_TIMEOUT_INTERVAL_MS`.\n * We then would consider that iteration a stall when the total time for that interval to run is greater than `LOOP_TIMEOUT_INTERVAL_MS + minimumStallThreshold`\n */\nexport class StallTrackingInstrumentation {\n public isTracking: boolean = false;\n\n private _minimumStallThreshold: number;\n\n /** Total amount of time of all stalls that occurred during the current tracking session */\n private _totalStallTime: number = 0;\n /** Total number of stalls that occurred during the current tracking session */\n private _stallCount: number = 0;\n\n /** The last timestamp the iteration ran in milliseconds */\n private _lastIntervalMs: number = 0;\n private _timeout: ReturnType<typeof setTimeout> | null = null;\n\n private _statsByTransaction: Map<\n Transaction,\n {\n longestStallTime: number;\n atStart: StallMeasurements;\n atTimestamp: {\n timestamp: number;\n stats: StallMeasurements;\n } | null;\n }\n > = new Map();\n\n public constructor(\n options: StallTrackingOptions = { minimumStallThreshold: 50 }\n ) {\n this._minimumStallThreshold = options.minimumStallThreshold;\n }\n\n /**\n * @inheritDoc\n * Not used for this integration. Instead call `registerTransactionStart` to start tracking.\n */\n public setupOnce(): void {\n // Do nothing.\n }\n\n /**\n * Register a transaction as started. Starts stall tracking if not already running.\n * @returns A finish method that returns the stall measurements.\n */\n public onTransactionStart(transaction: Transaction): void {\n if (this._statsByTransaction.has(transaction)) {\n logger.error(\n '[StallTracking] Tried to start stall tracking on a transaction already being tracked. Measurements might be lost.'\n );\n\n return;\n }\n\n this._startTracking();\n this._statsByTransaction.set(transaction, {\n longestStallTime: 0,\n atTimestamp: null,\n atStart: this._getCurrentStats(transaction),\n });\n this._flushLeakedTransactions();\n\n if (transaction.spanRecorder) {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const originalAdd = transaction.spanRecorder.add;\n\n transaction.spanRecorder.add = (span: Span): void => {\n originalAdd.apply(transaction.spanRecorder, [span]);\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const originalSpanFinish = span.finish;\n\n span.finish = (endTimestamp?: number) => {\n // We let the span determine its own end timestamp as well in case anything gets changed upstream\n originalSpanFinish.apply(span, [endTimestamp]);\n\n // The span should set a timestamp, so this would be defined.\n if (span.endTimestamp) {\n this._markSpanFinish(transaction, span.endTimestamp);\n }\n };\n };\n }\n }\n\n /**\n * Logs a transaction as finished.\n * Stops stall tracking if no more transactions are running.\n * @returns The stall measurements\n */\n public onTransactionFinish(\n transaction: Transaction | IdleTransaction,\n passedEndTimestamp?: number\n ): void {\n const transactionStats = this._statsByTransaction.get(transaction);\n\n if (!transactionStats) {\n // Transaction has been flushed out somehow, we return null.\n logger.log(\n '[StallTracking] Stall measurements were not added to transaction due to exceeding the max count.'\n );\n\n this._statsByTransaction.delete(transaction);\n this._shouldStopTracking();\n\n return;\n }\n\n const endTimestamp = passedEndTimestamp ?? transaction.endTimestamp;\n\n const spans = transaction.spanRecorder\n ? transaction.spanRecorder.spans\n : [];\n const finishedSpanCount = spans.reduce(\n (count, s) => (s !== transaction && s.endTimestamp ? count + 1 : count),\n 0\n );\n\n const trimEnd = transaction.toContext().trimEnd;\n const endWillBeTrimmed = trimEnd && finishedSpanCount > 0;\n\n /*\n This is not safe in the case that something changes upstream, but if we're planning to move this over to @sentry/javascript anyways,\n we can have this temporarily for now.\n */\n const isIdleTransaction = 'activities' in transaction;\n\n let statsOnFinish: StallMeasurements | undefined;\n if (endTimestamp && isIdleTransaction) {\n /*\n There is different behavior regarding child spans in a normal transaction and an idle transaction. In normal transactions,\n the child spans that aren't finished will be dumped, while in an idle transaction they're cancelled and finished.\n\n Note: `endTimestamp` will always be defined if this is called on an idle transaction finish. This is because we only instrument\n idle transactions inside `ReactNativeTracing`, which will pass an `endTimestamp`.\n */\n\n // There will be cancelled spans, which means that the end won't be trimmed\n const spansWillBeCancelled = spans.some(\n (s) =>\n s !== transaction &&\n s.startTimestamp < endTimestamp &&\n !s.endTimestamp\n );\n\n if (endWillBeTrimmed && !spansWillBeCancelled) {\n // the last span's timestamp will be used.\n\n if (transactionStats.atTimestamp) {\n statsOnFinish = transactionStats.atTimestamp.stats;\n }\n } else {\n // this endTimestamp will be used.\n statsOnFinish = this._getCurrentStats(transaction);\n }\n } else if (endWillBeTrimmed) {\n // If `trimEnd` is used, and there is a span to trim to. If there isn't, then the transaction should use `endTimestamp` or generate one.\n if (transactionStats.atTimestamp) {\n statsOnFinish = transactionStats.atTimestamp.stats;\n }\n } else if (!endTimestamp) {\n statsOnFinish = this._getCurrentStats(transaction);\n }\n\n this._statsByTransaction.delete(transaction);\n this._shouldStopTracking();\n\n if (!statsOnFinish) {\n if (typeof endTimestamp !== 'undefined') {\n logger.log(\n '[StallTracking] Stall measurements not added due to `endTimestamp` being set.'\n );\n } else if (trimEnd) {\n logger.log(\n '[StallTracking] Stall measurements not added due to `trimEnd` being set but we could not determine the stall measurements at that time.'\n );\n }\n\n return;\n }\n\n transaction.setMeasurement('stall_count',\n statsOnFinish.stall_count.value -\n transactionStats.atStart.stall_count.value,\n transactionStats.atStart.stall_count.unit);\n\n transaction.setMeasurement('stall_total_time',\n statsOnFinish.stall_total_time.value -\n transactionStats.atStart.stall_total_time.value,\n transactionStats.atStart.stall_total_time.unit);\n\n transaction.setMeasurement('stall_longest_time',\n statsOnFinish.stall_longest_time.value,\n statsOnFinish.stall_longest_time.unit);\n }\n\n /**\n * Logs the finish time of the span for use in `trimEnd: true` transactions.\n */\n private _markSpanFinish(\n transaction: Transaction,\n spanEndTimestamp: number\n ): void {\n const previousStats = this._statsByTransaction.get(transaction);\n if (previousStats) {\n if (\n Math.abs(timestampInSeconds() - spanEndTimestamp) >\n MARGIN_OF_ERROR_SECONDS\n ) {\n logger.log(\n '[StallTracking] Span end not logged due to end timestamp being outside the margin of error from now.'\n );\n\n if (\n previousStats.atTimestamp &&\n previousStats.atTimestamp.timestamp < spanEndTimestamp\n ) {\n // We also need to delete the stat for the last span, as the transaction would be trimmed to this span not the last one.\n this._statsByTransaction.set(transaction, {\n ...previousStats,\n atTimestamp: null,\n });\n }\n } else {\n this._statsByTransaction.set(transaction, {\n ...previousStats,\n atTimestamp: {\n timestamp: spanEndTimestamp,\n stats: this._getCurrentStats(transaction),\n },\n });\n }\n }\n }\n\n /**\n * Get the current stats for a transaction at a given time.\n */\n private _getCurrentStats(transaction: Transaction): StallMeasurements {\n return {\n stall_count: { value: this._stallCount, unit: 'none' },\n stall_total_time: { value: this._totalStallTime, unit: 'millisecond' },\n stall_longest_time: {\n value: this._statsByTransaction.get(transaction)?.longestStallTime ?? 0, unit: 'millisecond'\n },\n };\n }\n\n /**\n * Start tracking stalls\n */\n private _startTracking(): void {\n if (!this.isTracking) {\n this.isTracking = true;\n this._lastIntervalMs = Math.floor(timestampInSeconds() * 1000);\n\n this._iteration();\n }\n }\n\n /**\n * Stops the stall tracking interval and calls reset().\n */\n private _stopTracking(): void {\n this.isTracking = false;\n\n if (this._timeout !== null) {\n clearTimeout(this._timeout);\n this._timeout = null;\n }\n\n this._reset();\n }\n\n /**\n * Will stop tracking if there are no more transactions.\n */\n private _shouldStopTracking(): void {\n if (this._statsByTransaction.size === 0) {\n this._stopTracking();\n }\n }\n\n /**\n * Clears all the collected stats\n */\n private _reset(): void {\n this._stallCount = 0;\n this._totalStallTime = 0;\n this._lastIntervalMs = 0;\n this._statsByTransaction.clear();\n }\n\n /**\n * Iteration of the stall tracking interval. Measures how long the timer strayed from its expected time of running, and how\n * long the stall is for.\n */\n private _iteration(): void {\n const now = timestampInSeconds() * 1000;\n const totalTimeTaken = now - this._lastIntervalMs;\n\n if (\n totalTimeTaken >=\n LOOP_TIMEOUT_INTERVAL_MS + this._minimumStallThreshold\n ) {\n const stallTime = totalTimeTaken - LOOP_TIMEOUT_INTERVAL_MS;\n this._stallCount += 1;\n this._totalStallTime += stallTime;\n\n for (const [transaction, value] of this._statsByTransaction.entries()) {\n const longestStallTime = Math.max(\n value.longestStallTime ?? 0,\n stallTime\n );\n\n this._statsByTransaction.set(transaction, {\n ...value,\n longestStallTime,\n });\n }\n }\n\n this._lastIntervalMs = now;\n\n if (this.isTracking) {\n this._timeout = setTimeout(\n this._iteration.bind(this),\n LOOP_TIMEOUT_INTERVAL_MS\n );\n }\n }\n\n /**\n * Deletes leaked transactions (Earliest transactions when we have more than MAX_RUNNING_TRANSACTIONS transactions.)\n */\n private _flushLeakedTransactions(): void {\n if (this._statsByTransaction.size > MAX_RUNNING_TRANSACTIONS) {\n let counter = 0;\n const len = this._statsByTransaction.size - MAX_RUNNING_TRANSACTIONS;\n const transactions = this._statsByTransaction.keys();\n for (const t of transactions) {\n if (counter >= len) break;\n counter += 1;\n this._statsByTransaction.delete(t);\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"stalltracking.js","sourceRoot":"","sources":["../../../src/js/tracing/stalltracking.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAgBpF,8BAA8B;AAC9B,MAAM,uBAAuB,GAAG,IAAI,CAAC;AACrC,wEAAwE;AACxE,MAAM,wBAAwB,GAAG,EAAE,CAAC;AACpC,qIAAqI;AACrI,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,OAAO,4BAA4B;IA0BvC,YACE,UAAgC,EAAE,qBAAqB,EAAE,EAAE,EAAE;QA1BxD,e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AAC,MAAM,CAAC,CAAC,CAAC,CAAC;aACpC;SACF;IACH,CAAC;CACF","sourcesContent":["/* eslint-disable max-lines */\nimport type { IdleTransaction, Span, Transaction } from '@sentry/tracing';\nimport type { Measurements, MeasurementUnit } from '@sentry/types';\nimport { logger, timestampInSeconds } from '@sentry/utils';\n\nimport { STALL_COUNT, STALL_LONGEST_TIME, STALL_TOTAL_TIME } from '../measurements';\n\nexport interface StallMeasurements extends Measurements {\n [STALL_COUNT]: { value: number, unit: MeasurementUnit };\n [STALL_TOTAL_TIME]: { value: number, unit: MeasurementUnit };\n [STALL_LONGEST_TIME]: { value: number, unit: MeasurementUnit };\n}\n\nexport type StallTrackingOptions = {\n /**\n * How long in milliseconds an event loop iteration can be delayed for before being considered a \"stall.\"\n * @default 100\n */\n minimumStallThreshold: number;\n};\n\n/** Margin of error of 20ms */\nconst MARGIN_OF_ERROR_SECONDS = 0.02;\n/** How long between each iteration in the event loop tracker timeout */\nconst LOOP_TIMEOUT_INTERVAL_MS = 50;\n/** Limit for how many transactions the stall tracker will track at a time to prevent leaks due to transactions not being finished */\nconst MAX_RUNNING_TRANSACTIONS = 10;\n\n/**\n * Stall measurement tracker inspired by the `JSEventLoopWatchdog` used internally in React Native:\n * https://github.com/facebook/react-native/blob/006f5afe120c290a37cf6ff896748fbc062bf7ed/Libraries/Interaction/JSEventLoopWatchdog.js\n *\n * However, we modified the interval implementation to instead have a fixed loop timeout interval of `LOOP_TIMEOUT_INTERVAL_MS`.\n * We then would consider that iteration a stall when the total time for that interval to run is greater than `LOOP_TIMEOUT_INTERVAL_MS + minimumStallThreshold`\n */\nexport class StallTrackingInstrumentation {\n public isTracking: boolean = false;\n\n private _minimumStallThreshold: number;\n\n /** Total amount of time of all stalls that occurred during the current tracking session */\n private _totalStallTime: number = 0;\n /** Total number of stalls that occurred during the current tracking session */\n private _stallCount: number = 0;\n\n /** The last timestamp the iteration ran in milliseconds */\n private _lastIntervalMs: number = 0;\n private _timeout: ReturnType<typeof setTimeout> | null = null;\n\n private _statsByTransaction: Map<\n Transaction,\n {\n longestStallTime: number;\n atStart: StallMeasurements;\n atTimestamp: {\n timestamp: number;\n stats: StallMeasurements;\n } | null;\n }\n > = new Map();\n\n public constructor(\n options: StallTrackingOptions = { minimumStallThreshold: 50 }\n ) {\n this._minimumStallThreshold = options.minimumStallThreshold;\n }\n\n /**\n * @inheritDoc\n * Not used for this integration. Instead call `registerTransactionStart` to start tracking.\n */\n public setupOnce(): void {\n // Do nothing.\n }\n\n /**\n * Register a transaction as started. Starts stall tracking if not already running.\n * @returns A finish method that returns the stall measurements.\n */\n public onTransactionStart(transaction: Transaction): void {\n if (this._statsByTransaction.has(transaction)) {\n logger.error(\n '[StallTracking] Tried to start stall tracking on a transaction already being tracked. Measurements might be lost.'\n );\n\n return;\n }\n\n this._startTracking();\n this._statsByTransaction.set(transaction, {\n longestStallTime: 0,\n atTimestamp: null,\n atStart: this._getCurrentStats(transaction),\n });\n this._flushLeakedTransactions();\n\n if (transaction.spanRecorder) {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const originalAdd = transaction.spanRecorder.add;\n\n transaction.spanRecorder.add = (span: Span): void => {\n originalAdd.apply(transaction.spanRecorder, [span]);\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const originalSpanFinish = span.finish;\n\n span.finish = (endTimestamp?: number) => {\n // We let the span determine its own end timestamp as well in case anything gets changed upstream\n originalSpanFinish.apply(span, [endTimestamp]);\n\n // The span should set a timestamp, so this would be defined.\n if (span.endTimestamp) {\n this._markSpanFinish(transaction, span.endTimestamp);\n }\n };\n };\n }\n }\n\n /**\n * Logs a transaction as finished.\n * Stops stall tracking if no more transactions are running.\n * @returns The stall measurements\n */\n public onTransactionFinish(\n transaction: Transaction | IdleTransaction,\n passedEndTimestamp?: number\n ): void {\n const transactionStats = this._statsByTransaction.get(transaction);\n\n if (!transactionStats) {\n // Transaction has been flushed out somehow, we return null.\n logger.log(\n '[StallTracking] Stall measurements were not added to transaction due to exceeding the max count.'\n );\n\n this._statsByTransaction.delete(transaction);\n this._shouldStopTracking();\n\n return;\n }\n\n const endTimestamp = passedEndTimestamp ?? transaction.endTimestamp;\n\n const spans = transaction.spanRecorder\n ? transaction.spanRecorder.spans\n : [];\n const finishedSpanCount = spans.reduce(\n (count, s) => (s !== transaction && s.endTimestamp ? count + 1 : count),\n 0\n );\n\n const trimEnd = transaction.toContext().trimEnd;\n const endWillBeTrimmed = trimEnd && finishedSpanCount > 0;\n\n /*\n This is not safe in the case that something changes upstream, but if we're planning to move this over to @sentry/javascript anyways,\n we can have this temporarily for now.\n */\n const isIdleTransaction = 'activities' in transaction;\n\n let statsOnFinish: StallMeasurements | undefined;\n if (endTimestamp && isIdleTransaction) {\n /*\n There is different behavior regarding child spans in a normal transaction and an idle transaction. In normal transactions,\n the child spans that aren't finished will be dumped, while in an idle transaction they're cancelled and finished.\n\n Note: `endTimestamp` will always be defined if this is called on an idle transaction finish. This is because we only instrument\n idle transactions inside `ReactNativeTracing`, which will pass an `endTimestamp`.\n */\n\n // There will be cancelled spans, which means that the end won't be trimmed\n const spansWillBeCancelled = spans.some(\n (s) =>\n s !== transaction &&\n s.startTimestamp < endTimestamp &&\n !s.endTimestamp\n );\n\n if (endWillBeTrimmed && !spansWillBeCancelled) {\n // the last span's timestamp will be used.\n\n if (transactionStats.atTimestamp) {\n statsOnFinish = transactionStats.atTimestamp.stats;\n }\n } else {\n // this endTimestamp will be used.\n statsOnFinish = this._getCurrentStats(transaction);\n }\n } else if (endWillBeTrimmed) {\n // If `trimEnd` is used, and there is a span to trim to. If there isn't, then the transaction should use `endTimestamp` or generate one.\n if (transactionStats.atTimestamp) {\n statsOnFinish = transactionStats.atTimestamp.stats;\n }\n } else if (!endTimestamp) {\n statsOnFinish = this._getCurrentStats(transaction);\n }\n\n this._statsByTransaction.delete(transaction);\n this._shouldStopTracking();\n\n if (!statsOnFinish) {\n if (typeof endTimestamp !== 'undefined') {\n logger.log(\n '[StallTracking] Stall measurements not added due to `endTimestamp` being set.'\n );\n } else if (trimEnd) {\n logger.log(\n '[StallTracking] Stall measurements not added due to `trimEnd` being set but we could not determine the stall measurements at that time.'\n );\n }\n\n return;\n }\n\n transaction.setMeasurement(STALL_COUNT,\n statsOnFinish.stall_count.value -\n transactionStats.atStart.stall_count.value,\n transactionStats.atStart.stall_count.unit);\n\n transaction.setMeasurement(STALL_TOTAL_TIME,\n statsOnFinish.stall_total_time.value -\n transactionStats.atStart.stall_total_time.value,\n transactionStats.atStart.stall_total_time.unit);\n\n transaction.setMeasurement(STALL_LONGEST_TIME,\n statsOnFinish.stall_longest_time.value,\n statsOnFinish.stall_longest_time.unit);\n }\n\n /**\n * Logs the finish time of the span for use in `trimEnd: true` transactions.\n */\n private _markSpanFinish(\n transaction: Transaction,\n spanEndTimestamp: number\n ): void {\n const previousStats = this._statsByTransaction.get(transaction);\n if (previousStats) {\n if (\n Math.abs(timestampInSeconds() - spanEndTimestamp) >\n MARGIN_OF_ERROR_SECONDS\n ) {\n logger.log(\n '[StallTracking] Span end not logged due to end timestamp being outside the margin of error from now.'\n );\n\n if (\n previousStats.atTimestamp &&\n previousStats.atTimestamp.timestamp < spanEndTimestamp\n ) {\n // We also need to delete the stat for the last span, as the transaction would be trimmed to this span not the last one.\n this._statsByTransaction.set(transaction, {\n ...previousStats,\n atTimestamp: null,\n });\n }\n } else {\n this._statsByTransaction.set(transaction, {\n ...previousStats,\n atTimestamp: {\n timestamp: spanEndTimestamp,\n stats: this._getCurrentStats(transaction),\n },\n });\n }\n }\n }\n\n /**\n * Get the current stats for a transaction at a given time.\n */\n private _getCurrentStats(transaction: Transaction): StallMeasurements {\n return {\n stall_count: { value: this._stallCount, unit: 'none' },\n stall_total_time: { value: this._totalStallTime, unit: 'millisecond' },\n stall_longest_time: {\n value: this._statsByTransaction.get(transaction)?.longestStallTime ?? 0, unit: 'millisecond'\n },\n };\n }\n\n /**\n * Start tracking stalls\n */\n private _startTracking(): void {\n if (!this.isTracking) {\n this.isTracking = true;\n this._lastIntervalMs = Math.floor(timestampInSeconds() * 1000);\n\n this._iteration();\n }\n }\n\n /**\n * Stops the stall tracking interval and calls reset().\n */\n private _stopTracking(): void {\n this.isTracking = false;\n\n if (this._timeout !== null) {\n clearTimeout(this._timeout);\n this._timeout = null;\n }\n\n this._reset();\n }\n\n /**\n * Will stop tracking if there are no more transactions.\n */\n private _shouldStopTracking(): void {\n if (this._statsByTransaction.size === 0) {\n this._stopTracking();\n }\n }\n\n /**\n * Clears all the collected stats\n */\n private _reset(): void {\n this._stallCount = 0;\n this._totalStallTime = 0;\n this._lastIntervalMs = 0;\n this._statsByTransaction.clear();\n }\n\n /**\n * Iteration of the stall tracking interval. Measures how long the timer strayed from its expected time of running, and how\n * long the stall is for.\n */\n private _iteration(): void {\n const now = timestampInSeconds() * 1000;\n const totalTimeTaken = now - this._lastIntervalMs;\n\n if (\n totalTimeTaken >=\n LOOP_TIMEOUT_INTERVAL_MS + this._minimumStallThreshold\n ) {\n const stallTime = totalTimeTaken - LOOP_TIMEOUT_INTERVAL_MS;\n this._stallCount += 1;\n this._totalStallTime += stallTime;\n\n for (const [transaction, value] of this._statsByTransaction.entries()) {\n const longestStallTime = Math.max(\n value.longestStallTime ?? 0,\n stallTime\n );\n\n this._statsByTransaction.set(transaction, {\n ...value,\n longestStallTime,\n });\n }\n }\n\n this._lastIntervalMs = now;\n\n if (this.isTracking) {\n this._timeout = setTimeout(\n this._iteration.bind(this),\n LOOP_TIMEOUT_INTERVAL_MS\n );\n }\n }\n\n /**\n * Deletes leaked transactions (Earliest transactions when we have more than MAX_RUNNING_TRANSACTIONS transactions.)\n */\n private _flushLeakedTransactions(): void {\n if (this._statsByTransaction.size > MAX_RUNNING_TRANSACTIONS) {\n let counter = 0;\n const len = this._statsByTransaction.size - MAX_RUNNING_TRANSACTIONS;\n const transactions = this._statsByTransaction.keys();\n for (const t of transactions) {\n if (counter >= len) break;\n counter += 1;\n this._statsByTransaction.delete(t);\n }\n }\n }\n}\n"]}
@@ -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.0.0";
3
+ export declare const SDK_VERSION = "5.1.1";
4
4
  //# sourceMappingURL=version.d.ts.map
@@ -1,4 +1,4 @@
1
1
  export const SDK_PACKAGE_NAME = 'npm:@sentry/react-native';
2
2
  export const SDK_NAME = 'sentry.javascript.react-native';
3
- export const SDK_VERSION = '5.0.0';
3
+ export const SDK_VERSION = '5.1.1';
4
4
  //# sourceMappingURL=version.js.map
@@ -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,OAAO,CAAC","sourcesContent":["export const SDK_PACKAGE_NAME = 'npm:@sentry/react-native';\nexport const SDK_NAME = 'sentry.javascript.react-native';\nexport const SDK_VERSION = '5.0.0';\n"]}
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,OAAO,CAAC","sourcesContent":["export const SDK_PACKAGE_NAME = 'npm:@sentry/react-native';\nexport const SDK_NAME = 'sentry.javascript.react-native';\nexport const SDK_VERSION = '5.1.1';\n"]}
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.0.0",
5
+ "version": "5.1.1",
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",
@@ -42,21 +42,21 @@
42
42
  "react-native": ">=0.65.0"
43
43
  },
44
44
  "dependencies": {
45
- "@sentry/browser": "7.37.2",
46
- "@sentry/cli": "2.10.0",
47
- "@sentry/core": "7.37.2",
48
- "@sentry/hub": "7.37.2",
49
- "@sentry/integrations": "7.37.2",
50
- "@sentry/react": "7.37.2",
51
- "@sentry/tracing": "7.37.2",
52
- "@sentry/types": "7.37.2",
53
- "@sentry/utils": "7.37.2"
45
+ "@sentry/browser": "7.40.0",
46
+ "@sentry/cli": "2.14.4",
47
+ "@sentry/core": "7.40.0",
48
+ "@sentry/hub": "7.40.0",
49
+ "@sentry/integrations": "7.40.0",
50
+ "@sentry/react": "7.40.0",
51
+ "@sentry/tracing": "7.40.0",
52
+ "@sentry/types": "7.40.0",
53
+ "@sentry/utils": "7.40.0"
54
54
  },
55
55
  "devDependencies": {
56
- "@sentry-internal/eslint-config-sdk": "7.37.2",
57
- "@sentry-internal/eslint-plugin-sdk": "7.37.2",
56
+ "@sentry-internal/eslint-config-sdk": "7.40.0",
57
+ "@sentry-internal/eslint-plugin-sdk": "7.40.0",
58
58
  "@sentry/typescript": "^5.20.1",
59
- "@sentry/wizard": "2.2.0",
59
+ "@sentry/wizard": "2.6.0",
60
60
  "@types/jest": "^29.2.5",
61
61
  "@types/react": "^18.0.25",
62
62
  "babel-jest": "^29.3.1",