@sentry/react-native 5.1.1 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/RNSentry.podspec +1 -1
  3. package/android/build.gradle +1 -1
  4. package/dist/js/index.d.ts +1 -1
  5. package/dist/js/index.d.ts.map +1 -1
  6. package/dist/js/index.js +1 -1
  7. package/dist/js/index.js.map +1 -1
  8. package/dist/js/options.d.ts +8 -0
  9. package/dist/js/options.d.ts.map +1 -1
  10. package/dist/js/options.js.map +1 -1
  11. package/dist/js/sdk.d.ts.map +1 -1
  12. package/dist/js/sdk.js +15 -9
  13. package/dist/js/sdk.js.map +1 -1
  14. package/dist/js/touchevents.d.ts +1 -0
  15. package/dist/js/touchevents.d.ts.map +1 -1
  16. package/dist/js/touchevents.js +66 -54
  17. package/dist/js/touchevents.js.map +1 -1
  18. package/dist/js/tracing/gesturetracing.d.ts +20 -0
  19. package/dist/js/tracing/gesturetracing.d.ts.map +1 -0
  20. package/dist/js/tracing/gesturetracing.js +98 -0
  21. package/dist/js/tracing/gesturetracing.js.map +1 -0
  22. package/dist/js/tracing/index.d.ts +1 -0
  23. package/dist/js/tracing/index.d.ts.map +1 -1
  24. package/dist/js/tracing/index.js +1 -0
  25. package/dist/js/tracing/index.js.map +1 -1
  26. package/dist/js/tracing/nativeframes.d.ts.map +1 -1
  27. package/dist/js/tracing/nativeframes.js +4 -0
  28. package/dist/js/tracing/nativeframes.js.map +1 -1
  29. package/dist/js/tracing/ops.d.ts +3 -1
  30. package/dist/js/tracing/ops.d.ts.map +1 -1
  31. package/dist/js/tracing/ops.js +3 -1
  32. package/dist/js/tracing/ops.js.map +1 -1
  33. package/dist/js/tracing/reactnativenavigation.d.ts +13 -2
  34. package/dist/js/tracing/reactnativenavigation.d.ts.map +1 -1
  35. package/dist/js/tracing/reactnativenavigation.js +31 -24
  36. package/dist/js/tracing/reactnativenavigation.js.map +1 -1
  37. package/dist/js/tracing/reactnativetracing.d.ts +15 -1
  38. package/dist/js/tracing/reactnativetracing.d.ts.map +1 -1
  39. package/dist/js/tracing/reactnativetracing.js +64 -4
  40. package/dist/js/tracing/reactnativetracing.js.map +1 -1
  41. package/dist/js/tracing/transaction.d.ts +7 -0
  42. package/dist/js/tracing/transaction.d.ts.map +1 -0
  43. package/dist/js/tracing/transaction.js +13 -0
  44. package/dist/js/tracing/transaction.js.map +1 -0
  45. package/dist/js/transports/native.d.ts +3 -1
  46. package/dist/js/transports/native.d.ts.map +1 -1
  47. package/dist/js/transports/native.js +2 -2
  48. package/dist/js/transports/native.js.map +1 -1
  49. package/dist/js/version.d.ts +1 -1
  50. package/dist/js/version.js +1 -1
  51. package/dist/js/version.js.map +1 -1
  52. package/dist/js/wrapper.d.ts +3 -3
  53. package/dist/js/wrapper.d.ts.map +1 -1
  54. package/dist/js/wrapper.js +10 -6
  55. package/dist/js/wrapper.js.map +1 -1
  56. package/package.json +13 -13
@@ -0,0 +1,98 @@
1
+ import { getCurrentHub } from '@sentry/core';
2
+ import { logger } from '@sentry/utils';
3
+ import { UI_ACTION } from './ops';
4
+ import { ReactNativeTracing } from './reactnativetracing';
5
+ export const DEFAULT_BREADCRUMB_CATEGORY = 'gesture';
6
+ export const DEFAULT_BREADCRUMB_TYPE = 'user';
7
+ export const GESTURE_POSTFIX_LENGTH = 'GestureHandler'.length;
8
+ export const ACTION_GESTURE_FALLBACK = 'gesture';
9
+ /**
10
+ * Patches React Native Gesture Handler v2 Gesture to start a transaction on gesture begin with the appropriate label.
11
+ * Example: ShoppingCartScreen.dismissGesture
12
+ */
13
+ export function sentryTraceGesture(
14
+ /**
15
+ * Label of the gesture to be used in transaction name.
16
+ * Example: dismissGesture
17
+ */
18
+ label, gesture, options = {}) {
19
+ var _a;
20
+ const gestureCandidate = gesture;
21
+ if (!gestureCandidate) {
22
+ logger.warn('[GestureTracing] Gesture can not be undefined');
23
+ return gesture;
24
+ }
25
+ if (!gestureCandidate.handlers) {
26
+ logger.warn('[GestureTracing] Can not wrap gesture without handlers. If you want to wrap a gesture composition wrap individual gestures.');
27
+ return gesture;
28
+ }
29
+ if (!label) {
30
+ logger.warn('[GestureTracing] Can not wrap gesture without name.');
31
+ return gesture;
32
+ }
33
+ const hub = ((_a = options.getCurrentHub) === null || _a === void 0 ? void 0 : _a.call(options)) || getCurrentHub();
34
+ const name = gestureCandidate.handlerName.length > GESTURE_POSTFIX_LENGTH
35
+ ? gestureCandidate.handlerName
36
+ .substring(0, gestureCandidate.handlerName.length - GESTURE_POSTFIX_LENGTH).toLowerCase()
37
+ : ACTION_GESTURE_FALLBACK;
38
+ const originalOnBegin = gestureCandidate.handlers.onBegin;
39
+ gesture.handlers.onBegin = (event) => {
40
+ var _a, _b;
41
+ (_b = (_a = hub.getClient()) === null || _a === void 0 ? void 0 : _a.getIntegration(ReactNativeTracing)) === null || _b === void 0 ? void 0 : _b.startUserInteractionTransaction({ elementId: label, op: `${UI_ACTION}.${name}` });
42
+ addGestureBreadcrumb(`Gesture ${label} begin.`, { event, hub, name });
43
+ if (originalOnBegin) {
44
+ originalOnBegin(event);
45
+ }
46
+ };
47
+ const originalOnEnd = gestureCandidate.handlers.onEnd;
48
+ gesture.handlers.onEnd = (event) => {
49
+ addGestureBreadcrumb(`Gesture ${label} end.`, { event, hub, name });
50
+ if (originalOnEnd) {
51
+ originalOnEnd(event);
52
+ }
53
+ };
54
+ return gesture;
55
+ }
56
+ function addGestureBreadcrumb(message, options) {
57
+ const { event, hub, name } = options;
58
+ const crumb = {
59
+ message,
60
+ level: 'info',
61
+ type: DEFAULT_BREADCRUMB_TYPE,
62
+ category: DEFAULT_BREADCRUMB_CATEGORY,
63
+ };
64
+ if (event) {
65
+ const data = {
66
+ gesture: name,
67
+ };
68
+ for (const key of Object.keys(GestureEventKeys)) {
69
+ const eventKey = GestureEventKeys[key];
70
+ if (eventKey in event) {
71
+ data[eventKey] = event[eventKey];
72
+ }
73
+ }
74
+ crumb.data = data;
75
+ }
76
+ hub.addBreadcrumb(crumb);
77
+ logger.log(`[GestureTracing] ${crumb.message}`);
78
+ }
79
+ /**
80
+ * Selected keys from RNGH 2 Gesture Event API.
81
+ * We only want to send relevant data to save on payload size.
82
+ * @hidden
83
+ */
84
+ const GestureEventKeys = {
85
+ NUMBER_OF_POINTERS: 'numberOfPointers',
86
+ NUMBER_OF_TOUCHES: 'numberOfTouches',
87
+ FORCE: 'force',
88
+ FORCE_CHANGE: 'forceChange',
89
+ ROTATION: 'rotation',
90
+ ROTATION_CHANGE: 'rotationChange',
91
+ SCALE: 'scale',
92
+ SCALE_CHANGE: 'scaleChange',
93
+ DURATION: 'duration',
94
+ VELOCITY: 'velocity',
95
+ VELOCITY_X: 'velocityX',
96
+ VELOCITY_Y: 'velocityY',
97
+ };
98
+ //# sourceMappingURL=gesturetracing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gesturetracing.js","sourceRoot":"","sources":["../../../src/js/tracing/gesturetracing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,CAAC,MAAM,2BAA2B,GAAG,SAAS,CAAC;AACrD,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAE9C,MAAM,CAAC,MAAM,sBAAsB,GAAG,gBAAgB,CAAC,MAAM,CAAC;AAC9D,MAAM,CAAC,MAAM,uBAAuB,GAAG,SAAS,CAAC;AA4BjD;;;GAGG;AACH,MAAM,UAAU,kBAAkB;AAChC;;;GAGG;AACH,KAAa,EACb,OAAiB,EACjB,UAA0C,EAAE;;IAE5C,MAAM,gBAAgB,GAAG,OAAoD,CAAC;IAC9E,IAAI,CAAC,gBAAgB,EAAE;QACr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O;IACd,YAAY,EAAE,aAAa;IAC3B,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;IACpB,UAAU,EAAE,WAAW;IACvB,UAAU,EAAE,WAAW;CACf,CAAC","sourcesContent":["import { getCurrentHub } from '@sentry/core';\nimport type { Breadcrumb, Hub } from '@sentry/types';\nimport { logger } from '@sentry/utils';\n\nimport { UI_ACTION } from './ops';\nimport { ReactNativeTracing } from './reactnativetracing';\n\nexport const DEFAULT_BREADCRUMB_CATEGORY = 'gesture';\nexport const DEFAULT_BREADCRUMB_TYPE = 'user';\n\nexport const GESTURE_POSTFIX_LENGTH = 'GestureHandler'.length;\nexport const ACTION_GESTURE_FALLBACK = 'gesture';\n\n/**\n * Internal interface following RNGH 2 Gesture Event API.\n * We need to use this to avoid importing RNGH 2 types and depending on it.\n * https://github.com/software-mansion/react-native-gesture-handler/blob/f0868f7ccf678c947ef65519ebf97ae149a10289/src/handlers/gestures/gesture.ts#L55\n * @hidden\n */\ntype GestureEvent = Record<string, unknown>;\n\n/**\n * Internal interface for RNGH 2 Gesture API.\n * We need to use this to avoid importing RNGH 2 types and depending on it.\n * https://github.com/software-mansion/react-native-gesture-handler/blob/2.9.0/src/handlers/gestures/gesture.ts#L120\n * @hidden\n */\ninterface BaseGesture {\n handlers?: {\n onBegin?: (event: GestureEvent) => void;\n onEnd?: (event: GestureEvent) => void;\n };\n handlerName: string;\n}\n\ninterface GestureTracingOptions {\n getCurrentHub: () => Hub;\n}\n\n/**\n * Patches React Native Gesture Handler v2 Gesture to start a transaction on gesture begin with the appropriate label.\n * Example: ShoppingCartScreen.dismissGesture\n */\nexport function sentryTraceGesture<GestureT>(\n /**\n * Label of the gesture to be used in transaction name.\n * Example: dismissGesture\n */\n label: string,\n gesture: GestureT,\n options: Partial<GestureTracingOptions> = {},\n): GestureT {\n const gestureCandidate = gesture as unknown as BaseGesture | undefined | null;\n if (!gestureCandidate) {\n logger.warn('[GestureTracing] Gesture can not be undefined');\n return gesture;\n }\n if (!gestureCandidate.handlers) {\n logger.warn('[GestureTracing] Can not wrap gesture without handlers. If you want to wrap a gesture composition wrap individual gestures.');\n return gesture;\n }\n if (!label) {\n logger.warn('[GestureTracing] Can not wrap gesture without name.');\n return gesture;\n }\n const hub = options.getCurrentHub?.() || getCurrentHub();\n\n const name = gestureCandidate.handlerName.length > GESTURE_POSTFIX_LENGTH\n ? gestureCandidate.handlerName\n .substring(0, gestureCandidate.handlerName.length - GESTURE_POSTFIX_LENGTH).toLowerCase()\n : ACTION_GESTURE_FALLBACK;\n\n const originalOnBegin = gestureCandidate.handlers.onBegin;\n (gesture as unknown as Required<BaseGesture>).handlers.onBegin = (event: GestureEvent) => {\n hub.getClient()?.getIntegration(ReactNativeTracing)\n ?.startUserInteractionTransaction({ elementId: label, op: `${UI_ACTION}.${name}` });\n\n addGestureBreadcrumb(`Gesture ${label} begin.`, { event, hub, name });\n\n if (originalOnBegin) {\n originalOnBegin(event);\n }\n };\n\n const originalOnEnd = gestureCandidate.handlers.onEnd;\n (gesture as unknown as Required<BaseGesture>).handlers.onEnd = (event: GestureEvent) => {\n addGestureBreadcrumb(`Gesture ${label} end.`, { event, hub, name });\n\n if (originalOnEnd) {\n originalOnEnd(event);\n }\n };\n\n return gesture;\n}\n\nfunction addGestureBreadcrumb(\n message: string,\n options: {\n event: Record<string, unknown> | undefined | null;\n hub: Hub;\n name: string;\n },\n): void {\n const { event, hub, name } = options;\n const crumb: Breadcrumb = {\n message,\n level: 'info',\n type: DEFAULT_BREADCRUMB_TYPE,\n category: DEFAULT_BREADCRUMB_CATEGORY,\n };\n\n if (event) {\n const data: Record<string, unknown> = {\n gesture: name,\n };\n for (const key of Object.keys(GestureEventKeys)) {\n const eventKey = GestureEventKeys[key as keyof typeof GestureEventKeys];\n if (eventKey in event) {\n data[eventKey] = event[eventKey];\n }\n }\n crumb.data = data;\n }\n\n hub.addBreadcrumb(crumb);\n\n logger.log(`[GestureTracing] ${crumb.message}`);\n}\n\n/**\n * Selected keys from RNGH 2 Gesture Event API.\n * We only want to send relevant data to save on payload size.\n * @hidden\n */\nconst GestureEventKeys = {\n NUMBER_OF_POINTERS: 'numberOfPointers',\n NUMBER_OF_TOUCHES: 'numberOfTouches',\n FORCE: 'force',\n FORCE_CHANGE: 'forceChange',\n ROTATION: 'rotation',\n ROTATION_CHANGE: 'rotationChange',\n SCALE: 'scale',\n SCALE_CHANGE: 'scaleChange',\n DURATION: 'duration',\n VELOCITY: 'velocity',\n VELOCITY_X: 'velocityX',\n VELOCITY_Y: 'velocityY',\n} as const;\n"]}
@@ -5,5 +5,6 @@ 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 { sentryTraceGesture, } from './gesturetracing';
8
9
  export * from './ops';
9
10
  //# 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;AAE5D,cAAc,OAAO,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,OAAO,EACL,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAE1B,cAAc,OAAO,CAAC"}
@@ -6,5 +6,6 @@ ReactNavigationV5Instrumentation, } from './reactnavigation';
6
6
  export { ReactNavigationV4Instrumentation } from './reactnavigationv4';
7
7
  export { ReactNativeNavigationInstrumentation } from './reactnativenavigation';
8
8
  export { ReactNativeProfiler } from './reactnativeprofiler';
9
+ export { sentryTraceGesture, } from './gesturetracing';
9
10
  export * from './ops';
10
11
  //# 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;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"]}
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,OAAO,EACL,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAE1B,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 {\n sentryTraceGesture,\n} from './gesturetracing';\n\nexport * from './ops';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"nativeframes.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/nativeframes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAS,cAAc,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAO1F,MAAM,WAAW,kBAAmB,SAAQ,YAAY;IACtD,cAAc,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC;IACzD,aAAa,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC;IACxD,eAAe,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC;CAC3D;AAQD;;GAEG;AACH,qBAAa,2BAA2B;IACtC,0EAA0E;IAC1E,OAAO,CAAC,aAAa,CAGP;IACd,sEAAsE;IACtE,OAAO,CAAC,gBAAgB,CAAsC;IAC9D,oEAAoE;IACpE,OAAO,CAAC,qBAAqB,CAAC,CAG5B;gBAGA,uBAAuB,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,IAAI,EACpD,SAAS,EAAE,MAAM,OAAO;IAS1B;;;OAGG;IACI,kBAAkB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAczD;;OAEG;IACI,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAI1D;;;OAGG;IACH,OAAO,CAAC,aAAa;IAarB;;OAEG;YACW,sBAAsB;IA2BpC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IA8C5B;;OAEG;YACW,0BAA0B;IAwBxC;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAU3B;;;OAGG;YACW,aAAa;CA0D5B"}
1
+ {"version":3,"file":"nativeframes.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/nativeframes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAS,cAAc,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAO1F,MAAM,WAAW,kBAAmB,SAAQ,YAAY;IACtD,cAAc,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC;IACzD,aAAa,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC;IACxD,eAAe,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC;CAC3D;AAQD;;GAEG;AACH,qBAAa,2BAA2B;IACtC,0EAA0E;IAC1E,OAAO,CAAC,aAAa,CAGP;IACd,sEAAsE;IACtE,OAAO,CAAC,gBAAgB,CAAsC;IAC9D,oEAAoE;IACpE,OAAO,CAAC,qBAAqB,CAAC,CAG5B;gBAGA,uBAAuB,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,IAAI,EACpD,SAAS,EAAE,MAAM,OAAO;IAS1B;;;OAGG;IACI,kBAAkB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAgBzD;;OAEG;IACI,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAI1D;;;OAGG;IACH,OAAO,CAAC,aAAa;IAerB;;OAEG;YACW,sBAAsB;IA2BpC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IA8C5B;;OAEG;YACW,0BAA0B;IAwBxC;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAU3B;;;OAGG;YACW,aAAa;CA0D5B"}
@@ -28,6 +28,8 @@ export class NativeFramesInstrumentation {
28
28
  if (framesMetrics) {
29
29
  transaction.setData('__startFrames', framesMetrics);
30
30
  }
31
+ }).then(undefined, (error) => {
32
+ logger.error(`[ReactNativeTracing] Error while fetching native frames: ${error}`);
31
33
  });
32
34
  instrumentChildSpanFinish(transaction, (_, endTimestamp) => {
33
35
  if (!endTimestamp) {
@@ -54,6 +56,8 @@ export class NativeFramesInstrumentation {
54
56
  nativeFrames,
55
57
  };
56
58
  }
59
+ }).then(undefined, (error) => {
60
+ logger.error(`[ReactNativeTracing] Error while fetching native frames: ${error}`);
57
61
  });
58
62
  }
59
63
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"nativeframes.js","sourceRoot":"","sources":["../../../src/js/tracing/nativeframes.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAG3D,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAQpD;;;GAGG;AACH,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAErC;;GAEG;AACH,MAAM,OAAO,2BAA2B;IActC,YACE,uBAAoD,EACpD,SAAwB;QAf1B,0EAA0E;QAClE,kBAAa,GAGjB,IAAI,GAAG,EAAE,CAAC;QACd,sEAAsE;QAC9D,qBAAgB,GAA4B,IAAI,GAAG,EAAE,CAAC;QAW5D,MAAM,CAAC,GAAG,CACR,iEAAiE,CAClE,CAAC;QAEF,uBAAuB,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED;;;OAGG;IACI,kBAAkB,CAAC,WAAwB;QAChD,KAAK,MAAM,CAAC,iBAAiB,EAAE,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,EAAE;YACrD,IAAI,aAAa,EAAE;gBACjB,WAAW,CAAC,OAAO,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;aACrD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C,QAAQ,CAAC;gBAEtC,IAAI,OAAO,WAAI,YAAY,CAAC,IAAI,0CAAE,aAAa,CAAA,IAAI,KAAK,CAAC,SAAS,EAAE;oBAClE,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,sBAAsB,CACpD,OAAO,EACP,KAAK,CAAC,SAAS,EACf,YAAY,CAAC,IAAI,CAAC,aAAqC,CACxD,CAAC;oBAEF,IAAI,CAAC,YAAY,EAAE;wBACjB,MAAM,CAAC,GAAG,CACR,oDAAoD,YAAY,CAAC,EAAE,gBAAgB,KAAK,CAAC,WAAW,0CAA0C,CAC/I,CAAC;qBACH;yBAAM;wBACL,MAAM,CAAC,GAAG,CACR,yCAAyC,YAAY,CAAC,EACtD,gBAAgB,KAAK,CAAC,WAAW,KAAK,IAAI,CAAC,SAAS,CAClD,YAAY,EACZ,SAAS,EACT,CAAC,CACF,EAAE,CACJ,CAAC;wBAEF,KAAK,CAAC,YAAY,mCACb,OAAC,KAAK,CAAC,YAAY,mCAAI,EAAE,CAAC,GAC1B,YAAY,CAChB,CAAC;wBAEF,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;qBACpC;oBAED,OAAO,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC;iBACxC;aACF;YAED,OAAO,KAAK,CAAC;;KACd;CACF","sourcesContent":["import type { Span, Transaction } from '@sentry/tracing';\nimport type { Event, EventProcessor, Measurements, MeasurementUnit } from '@sentry/types';\nimport { logger, timestampInSeconds } from '@sentry/utils';\n\nimport type { NativeFramesResponse } from '../NativeRNSentry';\nimport { NATIVE } from '../wrapper';\nimport { instrumentChildSpanFinish } from './utils';\n\nexport interface FramesMeasurements extends Measurements {\n 'frames_total': { value: number, unit: MeasurementUnit };\n 'frames_slow': { value: number, unit: MeasurementUnit };\n 'frames_frozen': { value: number, unit: MeasurementUnit };\n}\n\n/**\n * A margin of error of 50ms is allowed for the async native bridge call.\n * Anything larger would reduce the accuracy of our frames measurements.\n */\nconst MARGIN_OF_ERROR_SECONDS = 0.05;\n\n/**\n * Instrumentation to add native slow/frozen frames measurements onto transactions.\n */\nexport class NativeFramesInstrumentation {\n /** The native frames at the transaction finish time, keyed by traceId. */\n private _finishFrames: Map<\n string,\n { timestamp: number; nativeFrames: NativeFramesResponse | null }\n > = new Map();\n /** The listeners for each native frames response, keyed by traceId */\n private _framesListeners: Map<string, () => void> = new Map();\n /** The native frames at the finish time of the most recent span. */\n private _lastSpanFinishFrames?: {\n timestamp: number;\n nativeFrames: NativeFramesResponse;\n };\n\n public constructor(\n addGlobalEventProcessor: (e: EventProcessor) => void,\n doesExist: () => boolean\n ) {\n logger.log(\n '[ReactNativeTracing] Native frames instrumentation initialized.'\n );\n\n addGlobalEventProcessor((event) => this._processEvent(event, doesExist));\n }\n\n /**\n * To be called when a transaction is started.\n * Logs the native frames at this start point and instruments child span finishes.\n */\n public onTransactionStart(transaction: Transaction): void {\n void NATIVE.fetchNativeFrames().then((framesMetrics) => {\n if (framesMetrics) {\n transaction.setData('__startFrames', framesMetrics);\n }\n });\n\n instrumentChildSpanFinish(transaction, (_: Span, endTimestamp?: number) => {\n if (!endTimestamp) {\n this._onSpanFinish();\n }\n });\n }\n\n /**\n * To be called when a transaction is finished\n */\n public onTransactionFinish(transaction: Transaction): void {\n void this._fetchFramesForTransaction(transaction);\n }\n\n /**\n * Called on a span finish to fetch native frames to support transactions with trimEnd.\n * Only to be called when a span does not have an end timestamp.\n */\n private _onSpanFinish(): void {\n const timestamp = timestampInSeconds();\n\n void NATIVE.fetchNativeFrames().then((nativeFrames) => {\n if (nativeFrames) {\n this._lastSpanFinishFrames = {\n timestamp,\n nativeFrames,\n };\n }\n });\n }\n\n /**\n * Returns the computed frames measurements and awaits for them if they are not ready yet.\n */\n private async _getFramesMeasurements(\n traceId: string,\n finalEndTimestamp: number,\n startFrames: NativeFramesResponse\n ): Promise<FramesMeasurements | null> {\n if (this._finishFrames.has(traceId)) {\n return this._prepareMeasurements(traceId, finalEndTimestamp, startFrames);\n }\n\n return new Promise((resolve) => {\n const timeout = setTimeout(() => {\n this._framesListeners.delete(traceId);\n\n resolve(null);\n }, 2000);\n\n this._framesListeners.set(traceId, () => {\n resolve(\n this._prepareMeasurements(traceId, finalEndTimestamp, startFrames)\n );\n\n clearTimeout(timeout);\n this._framesListeners.delete(traceId);\n });\n });\n }\n\n /**\n * Returns the computed frames measurements given ready data\n */\n private _prepareMeasurements(\n traceId: string,\n finalEndTimestamp: number, // The actual transaction finish time.\n startFrames: NativeFramesResponse\n ): FramesMeasurements | null {\n let finalFinishFrames: NativeFramesResponse | undefined;\n\n const finish = this._finishFrames.get(traceId);\n if (\n finish &&\n finish.nativeFrames &&\n // Must be in the margin of error of the actual transaction finish time (finalEndTimestamp)\n Math.abs(finish.timestamp - finalEndTimestamp) < MARGIN_OF_ERROR_SECONDS\n ) {\n finalFinishFrames = finish.nativeFrames;\n } else if (\n this._lastSpanFinishFrames &&\n Math.abs(this._lastSpanFinishFrames.timestamp - finalEndTimestamp) <\n MARGIN_OF_ERROR_SECONDS\n ) {\n // Fallback to the last span finish if it is within the margin of error of the actual finish timestamp.\n // This should be the case for trimEnd.\n finalFinishFrames = this._lastSpanFinishFrames.nativeFrames;\n } else {\n return null;\n }\n\n const measurements = {\n frames_total: {\n value: finalFinishFrames.totalFrames - startFrames.totalFrames,\n unit: 'none'\n },\n frames_frozen: {\n value: finalFinishFrames.frozenFrames - startFrames.frozenFrames,\n unit: 'none'\n },\n frames_slow: {\n value: finalFinishFrames.slowFrames - startFrames.slowFrames,\n unit: 'none'\n },\n };\n\n\n return measurements;\n }\n\n /**\n * Fetch finish frames for a transaction at the current time. Calls any awaiting listeners.\n */\n private async _fetchFramesForTransaction(\n transaction: Transaction\n ): Promise<void> {\n const startFrames = transaction.data.__startFrames as\n | NativeFramesResponse\n | undefined;\n\n // This timestamp marks when the finish frames were retrieved. It should be pretty close to the transaction finish.\n const timestamp = timestampInSeconds();\n let finishFrames: NativeFramesResponse | null = null;\n if (startFrames) {\n finishFrames = await NATIVE.fetchNativeFrames();\n }\n\n this._finishFrames.set(transaction.traceId, {\n nativeFrames: finishFrames,\n timestamp,\n });\n\n this._framesListeners.get(transaction.traceId)?.();\n\n setTimeout(() => this._cancelFinishFrames(transaction), 2000);\n }\n\n /**\n * On a finish frames failure, we cancel the await.\n */\n private _cancelFinishFrames(transaction: Transaction): void {\n if (this._finishFrames.has(transaction.traceId)) {\n this._finishFrames.delete(transaction.traceId);\n\n logger.log(\n `[NativeFrames] Native frames timed out for ${transaction.op} transaction ${transaction.name}. Not adding native frames measurements.`\n );\n }\n }\n\n /**\n * Adds frames measurements to an event. Called from a valid event processor.\n * Awaits for finish frames if needed.\n */\n private async _processEvent(\n event: Event,\n doesExist: () => boolean\n ): Promise<Event> {\n if (!doesExist()) {\n return event;\n }\n\n if (\n event.type === 'transaction' &&\n event.transaction &&\n event.contexts &&\n event.contexts.trace\n ) {\n const traceContext = event.contexts.trace as {\n data?: { [key: string]: unknown };\n trace_id: string;\n name?: string;\n op?: string;\n };\n\n const traceId = traceContext.trace_id;\n\n if (traceId && traceContext.data?.__startFrames && event.timestamp) {\n const measurements = await this._getFramesMeasurements(\n traceId,\n event.timestamp,\n traceContext.data.__startFrames as NativeFramesResponse\n );\n\n if (!measurements) {\n logger.log(\n `[NativeFrames] Could not fetch native frames for ${traceContext.op} transaction ${event.transaction}. Not adding native frames measurements.`\n );\n } else {\n logger.log(\n `[Measurements] Adding measurements to ${traceContext.op\n } transaction ${event.transaction}: ${JSON.stringify(\n measurements,\n undefined,\n 2\n )}`\n );\n\n event.measurements = {\n ...(event.measurements ?? {}),\n ...measurements,\n };\n\n this._finishFrames.delete(traceId);\n }\n\n delete traceContext.data.__startFrames;\n }\n }\n\n return event;\n }\n}\n"]}
1
+ {"version":3,"file":"nativeframes.js","sourceRoot":"","sources":["../../../src/js/tracing/nativeframes.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAA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C,CACxD,CAAC;oBAEF,IAAI,CAAC,YAAY,EAAE;wBACjB,MAAM,CAAC,GAAG,CACR,oDAAoD,YAAY,CAAC,EAAE,gBAAgB,KAAK,CAAC,WAAW,0CAA0C,CAC/I,CAAC;qBACH;yBAAM;wBACL,MAAM,CAAC,GAAG,CACR,yCAAyC,YAAY,CAAC,EACtD,gBAAgB,KAAK,CAAC,WAAW,KAAK,IAAI,CAAC,SAAS,CAClD,YAAY,EACZ,SAAS,EACT,CAAC,CACF,EAAE,CACJ,CAAC;wBAEF,KAAK,CAAC,YAAY,mCACb,OAAC,KAAK,CAAC,YAAY,mCAAI,EAAE,CAAC,GAC1B,YAAY,CAChB,CAAC;wBAEF,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;qBACpC;oBAED,OAAO,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC;iBACxC;aACF;YAED,OAAO,KAAK,CAAC;;KACd;CACF","sourcesContent":["import type { Span, Transaction } from '@sentry/tracing';\nimport type { Event, EventProcessor, Measurements, MeasurementUnit } from '@sentry/types';\nimport { logger, timestampInSeconds } from '@sentry/utils';\n\nimport type { NativeFramesResponse } from '../NativeRNSentry';\nimport { NATIVE } from '../wrapper';\nimport { instrumentChildSpanFinish } from './utils';\n\nexport interface FramesMeasurements extends Measurements {\n 'frames_total': { value: number, unit: MeasurementUnit };\n 'frames_slow': { value: number, unit: MeasurementUnit };\n 'frames_frozen': { value: number, unit: MeasurementUnit };\n}\n\n/**\n * A margin of error of 50ms is allowed for the async native bridge call.\n * Anything larger would reduce the accuracy of our frames measurements.\n */\nconst MARGIN_OF_ERROR_SECONDS = 0.05;\n\n/**\n * Instrumentation to add native slow/frozen frames measurements onto transactions.\n */\nexport class NativeFramesInstrumentation {\n /** The native frames at the transaction finish time, keyed by traceId. */\n private _finishFrames: Map<\n string,\n { timestamp: number; nativeFrames: NativeFramesResponse | null }\n > = new Map();\n /** The listeners for each native frames response, keyed by traceId */\n private _framesListeners: Map<string, () => void> = new Map();\n /** The native frames at the finish time of the most recent span. */\n private _lastSpanFinishFrames?: {\n timestamp: number;\n nativeFrames: NativeFramesResponse;\n };\n\n public constructor(\n addGlobalEventProcessor: (e: EventProcessor) => void,\n doesExist: () => boolean\n ) {\n logger.log(\n '[ReactNativeTracing] Native frames instrumentation initialized.'\n );\n\n addGlobalEventProcessor((event) => this._processEvent(event, doesExist));\n }\n\n /**\n * To be called when a transaction is started.\n * Logs the native frames at this start point and instruments child span finishes.\n */\n public onTransactionStart(transaction: Transaction): void {\n void NATIVE.fetchNativeFrames().then((framesMetrics) => {\n if (framesMetrics) {\n transaction.setData('__startFrames', framesMetrics);\n }\n }).then(undefined, (error) => {\n logger.error(`[ReactNativeTracing] Error while fetching native frames: ${error}`);\n });\n\n instrumentChildSpanFinish(transaction, (_: Span, endTimestamp?: number) => {\n if (!endTimestamp) {\n this._onSpanFinish();\n }\n });\n }\n\n /**\n * To be called when a transaction is finished\n */\n public onTransactionFinish(transaction: Transaction): void {\n void this._fetchFramesForTransaction(transaction);\n }\n\n /**\n * Called on a span finish to fetch native frames to support transactions with trimEnd.\n * Only to be called when a span does not have an end timestamp.\n */\n private _onSpanFinish(): void {\n const timestamp = timestampInSeconds();\n\n void NATIVE.fetchNativeFrames().then((nativeFrames) => {\n if (nativeFrames) {\n this._lastSpanFinishFrames = {\n timestamp,\n nativeFrames,\n };\n }\n }).then(undefined, (error) => {\n logger.error(`[ReactNativeTracing] Error while fetching native frames: ${error}`);\n });\n }\n\n /**\n * Returns the computed frames measurements and awaits for them if they are not ready yet.\n */\n private async _getFramesMeasurements(\n traceId: string,\n finalEndTimestamp: number,\n startFrames: NativeFramesResponse\n ): Promise<FramesMeasurements | null> {\n if (this._finishFrames.has(traceId)) {\n return this._prepareMeasurements(traceId, finalEndTimestamp, startFrames);\n }\n\n return new Promise((resolve) => {\n const timeout = setTimeout(() => {\n this._framesListeners.delete(traceId);\n\n resolve(null);\n }, 2000);\n\n this._framesListeners.set(traceId, () => {\n resolve(\n this._prepareMeasurements(traceId, finalEndTimestamp, startFrames)\n );\n\n clearTimeout(timeout);\n this._framesListeners.delete(traceId);\n });\n });\n }\n\n /**\n * Returns the computed frames measurements given ready data\n */\n private _prepareMeasurements(\n traceId: string,\n finalEndTimestamp: number, // The actual transaction finish time.\n startFrames: NativeFramesResponse\n ): FramesMeasurements | null {\n let finalFinishFrames: NativeFramesResponse | undefined;\n\n const finish = this._finishFrames.get(traceId);\n if (\n finish &&\n finish.nativeFrames &&\n // Must be in the margin of error of the actual transaction finish time (finalEndTimestamp)\n Math.abs(finish.timestamp - finalEndTimestamp) < MARGIN_OF_ERROR_SECONDS\n ) {\n finalFinishFrames = finish.nativeFrames;\n } else if (\n this._lastSpanFinishFrames &&\n Math.abs(this._lastSpanFinishFrames.timestamp - finalEndTimestamp) <\n MARGIN_OF_ERROR_SECONDS\n ) {\n // Fallback to the last span finish if it is within the margin of error of the actual finish timestamp.\n // This should be the case for trimEnd.\n finalFinishFrames = this._lastSpanFinishFrames.nativeFrames;\n } else {\n return null;\n }\n\n const measurements = {\n frames_total: {\n value: finalFinishFrames.totalFrames - startFrames.totalFrames,\n unit: 'none'\n },\n frames_frozen: {\n value: finalFinishFrames.frozenFrames - startFrames.frozenFrames,\n unit: 'none'\n },\n frames_slow: {\n value: finalFinishFrames.slowFrames - startFrames.slowFrames,\n unit: 'none'\n },\n };\n\n\n return measurements;\n }\n\n /**\n * Fetch finish frames for a transaction at the current time. Calls any awaiting listeners.\n */\n private async _fetchFramesForTransaction(\n transaction: Transaction\n ): Promise<void> {\n const startFrames = transaction.data.__startFrames as\n | NativeFramesResponse\n | undefined;\n\n // This timestamp marks when the finish frames were retrieved. It should be pretty close to the transaction finish.\n const timestamp = timestampInSeconds();\n let finishFrames: NativeFramesResponse | null = null;\n if (startFrames) {\n finishFrames = await NATIVE.fetchNativeFrames();\n }\n\n this._finishFrames.set(transaction.traceId, {\n nativeFrames: finishFrames,\n timestamp,\n });\n\n this._framesListeners.get(transaction.traceId)?.();\n\n setTimeout(() => this._cancelFinishFrames(transaction), 2000);\n }\n\n /**\n * On a finish frames failure, we cancel the await.\n */\n private _cancelFinishFrames(transaction: Transaction): void {\n if (this._finishFrames.has(transaction.traceId)) {\n this._finishFrames.delete(transaction.traceId);\n\n logger.log(\n `[NativeFrames] Native frames timed out for ${transaction.op} transaction ${transaction.name}. Not adding native frames measurements.`\n );\n }\n }\n\n /**\n * Adds frames measurements to an event. Called from a valid event processor.\n * Awaits for finish frames if needed.\n */\n private async _processEvent(\n event: Event,\n doesExist: () => boolean\n ): Promise<Event> {\n if (!doesExist()) {\n return event;\n }\n\n if (\n event.type === 'transaction' &&\n event.transaction &&\n event.contexts &&\n event.contexts.trace\n ) {\n const traceContext = event.contexts.trace as {\n data?: { [key: string]: unknown };\n trace_id: string;\n name?: string;\n op?: string;\n };\n\n const traceId = traceContext.trace_id;\n\n if (traceId && traceContext.data?.__startFrames && event.timestamp) {\n const measurements = await this._getFramesMeasurements(\n traceId,\n event.timestamp,\n traceContext.data.__startFrames as NativeFramesResponse\n );\n\n if (!measurements) {\n logger.log(\n `[NativeFrames] Could not fetch native frames for ${traceContext.op} transaction ${event.transaction}. Not adding native frames measurements.`\n );\n } else {\n logger.log(\n `[Measurements] Adding measurements to ${traceContext.op\n } transaction ${event.transaction}: ${JSON.stringify(\n measurements,\n undefined,\n 2\n )}`\n );\n\n event.measurements = {\n ...(event.measurements ?? {}),\n ...measurements,\n };\n\n this._finishFrames.delete(traceId);\n }\n\n delete traceContext.data.__startFrames;\n }\n }\n\n return event;\n }\n}\n"]}
@@ -1,6 +1,8 @@
1
1
  export declare const DEFAULT = "default";
2
- export declare const UI_LOAD = "ui.load";
3
2
  export declare const NAVIGATION = "navigation";
3
+ export declare const UI_LOAD = "ui.load";
4
+ export declare const UI_ACTION = "ui.action";
5
+ export declare const UI_ACTION_TOUCH = "ui.action.touch";
4
6
  export declare const APP_START_COLD = "app.start.cold";
5
7
  export declare const APP_START_WARM = "app.start.warm";
6
8
  //# sourceMappingURL=ops.d.ts.map
@@ -1 +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"}
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,UAAU,eAAe,CAAC;AAEvC,eAAO,MAAM,OAAO,YAAY,CAAC;AACjC,eAAO,MAAM,SAAS,cAAc,CAAC;AACrC,eAAO,MAAM,eAAe,oBAAoB,CAAC;AAEjD,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAC/C,eAAO,MAAM,cAAc,mBAAmB,CAAC"}
@@ -1,6 +1,8 @@
1
1
  export const DEFAULT = 'default';
2
- export const UI_LOAD = 'ui.load';
3
2
  export const NAVIGATION = 'navigation';
3
+ export const UI_LOAD = 'ui.load';
4
+ export const UI_ACTION = 'ui.action';
5
+ export const UI_ACTION_TOUCH = 'ui.action.touch';
4
6
  export const APP_START_COLD = 'app.start.cold';
5
7
  export const APP_START_WARM = 'app.start.warm';
6
8
  //# sourceMappingURL=ops.js.map
@@ -1 +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
+ {"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,UAAU,GAAG,YAAY,CAAC;AAEvC,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC;AACjC,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAC;AACrC,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAEjD,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAC/C,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAC","sourcesContent":["\nexport const DEFAULT = 'default';\nexport const NAVIGATION = 'navigation';\n\nexport const UI_LOAD = 'ui.load';\nexport const UI_ACTION = 'ui.action';\nexport const UI_ACTION_TOUCH = 'ui.action.touch';\n\nexport const APP_START_COLD = 'app.start.cold';\nexport const APP_START_WARM = 'app.start.warm';\n"]}
@@ -11,6 +11,13 @@ interface ReactNativeNavigationOptions {
11
11
  * Default: 1000
12
12
  */
13
13
  routeChangeTimeoutMs: number;
14
+ /**
15
+ * Instrumentation will create a transaction on tab change.
16
+ * By default only navigation commands create transactions.
17
+ *
18
+ * Default: true
19
+ */
20
+ enableTabsInstrumentation: boolean;
14
21
  }
15
22
  interface ComponentEvent {
16
23
  componentId: string;
@@ -24,9 +31,13 @@ export interface ComponentWillAppearEvent extends ComponentEvent {
24
31
  export interface EventSubscription {
25
32
  remove(): void;
26
33
  }
34
+ export interface BottomTabPressedEvent {
35
+ tabIndex: number;
36
+ }
27
37
  export interface EventsRegistry {
28
38
  registerComponentWillAppearListener(callback: (event: ComponentWillAppearEvent) => void): EmitterSubscription;
29
39
  registerCommandListener(callback: (name: string, params: unknown) => void): EventSubscription;
40
+ registerBottomTabPressedListener(callback: (event: BottomTabPressedEvent) => void): EmitterSubscription;
30
41
  }
31
42
  export interface NavigationDelegate {
32
43
  events: () => EventsRegistry;
@@ -56,9 +67,9 @@ export declare class ReactNativeNavigationInstrumentation extends InternalRoutin
56
67
  */
57
68
  registerRoutingInstrumentation(listener: TransactionCreator, beforeNavigate: BeforeNavigate, onConfirmRoute: OnConfirmRoute): void;
58
69
  /**
59
- * To be called when a navigation command is dispatched
70
+ * To be called when a navigation is initiated. (Command, BottomTabSelected, etc.)
60
71
  */
61
- private _onCommand;
72
+ private _onNavigation;
62
73
  /**
63
74
  * To be called AFTER the state has been changed to populate the transaction with the current route.
64
75
  */
@@ -1 +1 @@
1
- {"version":3,"file":"reactnativenavigation.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/reactnativenavigation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAAC,MAAM,0BAA0B,CAAC;AACtD,OAAO,EACL,8BAA8B,EAC/B,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,cAAc,EAA0B,MAAM,SAAS,CAAC;AAGtE,UAAU,4BAA4B;IACpC;;;;;;OAMG;IACH,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAMD,UAAU,cAAc;IACtB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,aAAK,aAAa,GACd,WAAW,GACX,aAAa,GACb,kBAAkB,GAClB,cAAc,CAAC;AAEnB,MAAM,WAAW,wBAAyB,SAAQ,cAAc;IAC9D,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,CAAC;IACtD,aAAa,EAAE,aAAa,CAAC;CA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BAAa,oCAAqC,SAAQ,8BAA8B;IACtF,OAAc,mBAAmB,EAAE,MAAM,CAA6B;IAEtE,SAAgB,IAAI,EAAE,MAAM,CAA4D;IAExF,OAAO,CAAC,WAAW,CAAqB;IACxC,OAAO,CAAC,QAAQ,CAA+B;IAE/C,OAAO,CAAC,mBAAmB,CAAyC;IAEpE,OAAO,CAAC,kBAAkB,CAAC,CAAkB;IAC7C,OAAO,CAAC,mBAAmB,CAAgB;IAC3C,OAAO,CAAC,mBAAmB,CAAC,CAAqB;;IAG/C,uGAAuG;IACvG,UAAU,EAAE,OAAO,EACnB,OAAO,GAAE,OAAO,CAAC,4BAA4B,CAAM;IAYrD;;OAEG;IACI,8BAA8B,CACnC,QAAQ,EAAE,kBAAkB,EAC5B,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,cAAc,GAC7B,IAAI;IAwBP;;OAEG;IACH,OAAO,CAAC,aAAa;IAerB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IA4D9B,4DAA4D;IAC5D,OAAO,CAAC,oBAAoB;IAwB5B,wEAAwE;IACxE,OAAO,CAAC,yBAAyB;IAUjC,wEAAwE;IACxE,OAAO,CAAC,wBAAwB;CAMjC"}
@@ -3,6 +3,7 @@ import { InternalRoutingInstrumentation } from './routingInstrumentation';
3
3
  import { customTransactionSource, defaultTransactionSource, getBlankTransactionContext } from './utils';
4
4
  const defaultOptions = {
5
5
  routeChangeTimeoutMs: 1000,
6
+ enableTabsInstrumentation: true,
6
7
  };
7
8
  /**
8
9
  * Instrumentation for React Native Navigation. See docs or sample app for usage.
@@ -30,15 +31,20 @@ export class ReactNativeNavigationInstrumentation extends InternalRoutingInstrum
30
31
  super.registerRoutingInstrumentation(listener, beforeNavigate, onConfirmRoute);
31
32
  this._navigation
32
33
  .events()
33
- .registerCommandListener(this._onCommand.bind(this));
34
+ .registerCommandListener(this._onNavigation.bind(this));
35
+ if (this._options.enableTabsInstrumentation) {
36
+ this._navigation
37
+ .events()
38
+ .registerBottomTabPressedListener(this._onNavigation.bind(this));
39
+ }
34
40
  this._navigation
35
41
  .events()
36
42
  .registerComponentWillAppearListener(this._onComponentWillAppear.bind(this));
37
43
  }
38
44
  /**
39
- * To be called when a navigation command is dispatched
45
+ * To be called when a navigation is initiated. (Command, BottomTabSelected, etc.)
40
46
  */
41
- _onCommand() {
47
+ _onNavigation() {
42
48
  if (this._latestTransaction) {
43
49
  this._discardLatestTransaction();
44
50
  }
@@ -50,28 +56,29 @@ export class ReactNativeNavigationInstrumentation extends InternalRoutingInstrum
50
56
  */
51
57
  _onComponentWillAppear(event) {
52
58
  var _a, _b;
53
- // If the route is a different key, this is so we ignore actions that pertain to the same screen.
54
- if (this._latestTransaction) {
55
- if (!this._prevComponentEvent ||
56
- event.componentId != this._prevComponentEvent.componentId) {
57
- this._clearStateChangeTimeout();
58
- const originalContext = this._latestTransaction.toContext();
59
- const routeHasBeenSeen = this._recentComponentIds.includes(event.componentId);
60
- const data = Object.assign(Object.assign({}, originalContext.data), { route: Object.assign(Object.assign({}, event), { name: event.componentName, hasBeenSeen: routeHasBeenSeen }), previousRoute: this._prevComponentEvent
61
- ? Object.assign(Object.assign({}, this._prevComponentEvent), { name: (_a = this._prevComponentEvent) === null || _a === void 0 ? void 0 : _a.componentName }) : null });
62
- const updatedContext = Object.assign(Object.assign({}, originalContext), { name: event.componentName, tags: Object.assign(Object.assign({}, originalContext.tags), { 'routing.route.name': event.componentName }), data });
63
- const finalContext = this._prepareFinalContext(updatedContext);
64
- this._latestTransaction.updateWithContext(finalContext);
65
- const isCustomName = updatedContext.name !== finalContext.name;
66
- this._latestTransaction.setName(finalContext.name, isCustomName ? customTransactionSource : defaultTransactionSource);
67
- (_b = this._onConfirmRoute) === null || _b === void 0 ? void 0 : _b.call(this, finalContext);
68
- this._prevComponentEvent = event;
69
- }
70
- else {
71
- this._discardLatestTransaction();
72
- }
73
- this._latestTransaction = undefined;
59
+ if (!this._latestTransaction) {
60
+ return;
74
61
  }
62
+ // We ignore actions that pertain to the same screen.
63
+ const isSameComponent = this._prevComponentEvent
64
+ && event.componentId === this._prevComponentEvent.componentId;
65
+ if (isSameComponent) {
66
+ this._discardLatestTransaction();
67
+ return;
68
+ }
69
+ this._clearStateChangeTimeout();
70
+ const originalContext = this._latestTransaction.toContext();
71
+ const routeHasBeenSeen = this._recentComponentIds.includes(event.componentId);
72
+ const data = Object.assign(Object.assign({}, originalContext.data), { route: Object.assign(Object.assign({}, event), { name: event.componentName, hasBeenSeen: routeHasBeenSeen }), previousRoute: this._prevComponentEvent
73
+ ? Object.assign(Object.assign({}, this._prevComponentEvent), { name: (_a = this._prevComponentEvent) === null || _a === void 0 ? void 0 : _a.componentName }) : null });
74
+ const updatedContext = Object.assign(Object.assign({}, originalContext), { name: event.componentName, tags: Object.assign(Object.assign({}, originalContext.tags), { 'routing.route.name': event.componentName }), data });
75
+ const finalContext = this._prepareFinalContext(updatedContext);
76
+ this._latestTransaction.updateWithContext(finalContext);
77
+ const isCustomName = updatedContext.name !== finalContext.name;
78
+ this._latestTransaction.setName(finalContext.name, isCustomName ? customTransactionSource : defaultTransactionSource);
79
+ (_b = this._onConfirmRoute) === null || _b === void 0 ? void 0 : _b.call(this, finalContext);
80
+ this._prevComponentEvent = event;
81
+ this._latestTransaction = undefined;
75
82
  }
76
83
  /** Creates final transaction context before confirmation */
77
84
  _prepareFinalContext(updatedContext) {
@@ -1 +1 @@
1
- {"version":3,"file":"reactnativenavigation.js","sourceRoot":"","sources":["../../../src/js/tracing/reactnativenavigation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAMvC,OAAO,EACL,8BAA8B,EAC/B,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAaxG,MAAM,cAAc,GAAiC;IACnD,oBAAoB,EAAE,IAAI;CAC3B,CAAC;AAmCF;;;;;;;GAOG;AACH,MAAM,OA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L,IAAI,CAAC,yBAAyB,EAAE,CAAC;aAClC;YAED,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;SACrC;IACH,CAAC;IAED,4DAA4D;IACpD,oBAAoB,CAAC,cAAkC;;QAC7D,IAAI,YAAY,SAAG,IAAI,CAAC,eAAe,+CAApB,IAAI,oBAAwB,cAAc,EAAG,CAAC;QAEjE,mEAAmE;QACnE,IAAI,CAAC,YAAY,EAAE;YACjB,MAAM,CAAC,KAAK,CACV,IAAI,oCAAoC,CAAC,IAAI,6BAA6B,YAAY,2DAA2D,CAClJ,CAAC;YAEF,YAAY,mCACP,cAAc,KACjB,OAAO,EAAE,KAAK,GACf,CAAC;SACH;QAED,IAAI,YAAY,CAAC,OAAO,KAAK,KAAK,EAAE;YAClC,MAAM,CAAC,GAAG,CACR,IAAI,oCAAoC,CAAC,IAAI,gCAAgC,YAAY,CAAC,IAAI,0BAA0B,CACzH,CAAC;SACH;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,wEAAwE;IAChE,yBAAyB;QAC/B,IAAI,IAAI,CAAC,kBAAkB,EAAE;YAC3B,IAAI,CAAC,kBAAkB,CAAC,OAAO,GAAG,KAAK,CAAC;YACxC,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,CAAC;YACjC,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;SACrC;QAED,IAAI,CAAC,wBAAwB,EAAE,CAAC;IAClC,CAAC;IAED,wEAAwE;IAChE,wBAAwB;QAC9B,IAAI,OAAO,IAAI,CAAC,mBAAmB,KAAK,WAAW,EAAE;YACnD,YAAY,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;YACvC,IAAI,CAAC,mBAAmB,GAAG,SAAS,CAAC;SACtC;IACH,CAAC;;AA9Ka,wDAAmB,GAAW,yBAAyB,CAAC","sourcesContent":["import type { Transaction as TransactionType, TransactionContext } from '@sentry/types';\nimport { logger } from '@sentry/utils';\nimport type { EmitterSubscription } from 'react-native';\n\nimport type {\n OnConfirmRoute,\n TransactionCreator} from './routingInstrumentation';\nimport {\n InternalRoutingInstrumentation\n} from './routingInstrumentation';\nimport type { BeforeNavigate, RouteChangeContextData } from './types';\nimport { customTransactionSource, defaultTransactionSource, getBlankTransactionContext } from './utils';\n\ninterface ReactNativeNavigationOptions {\n /**\n * How long the instrumentation will wait for the route to mount after a change has been initiated,\n * before the transaction is discarded.\n * Time is in ms.\n *\n * Default: 1000\n */\n routeChangeTimeoutMs: number;\n}\n\nconst defaultOptions: ReactNativeNavigationOptions = {\n routeChangeTimeoutMs: 1000,\n};\n\ninterface ComponentEvent {\n componentId: string;\n}\n\ntype ComponentType =\n | 'Component'\n | 'TopBarTitle'\n | 'TopBarBackground'\n | 'TopBarButton';\n\nexport interface ComponentWillAppearEvent extends ComponentEvent {\n componentName: string;\n passProps?: Record<string | number | symbol, unknown>;\n componentType: ComponentType;\n}\n\nexport interface EventSubscription {\n remove(): void;\n}\n\nexport interface EventsRegistry {\n registerComponentWillAppearListener(\n callback: (event: ComponentWillAppearEvent) => void\n ): EmitterSubscription;\n registerCommandListener(\n callback: (name: string, params: unknown) => void\n ): EventSubscription;\n}\n\nexport interface NavigationDelegate {\n events: () => EventsRegistry;\n}\n\n/**\n * Instrumentation for React Native Navigation. See docs or sample app for usage.\n *\n * How this works:\n * - `_onCommand` is called every time a commands happens and sets an IdleTransaction on the scope without any route context.\n * - `_onComponentWillAppear` is then called AFTER the state change happens due to a dispatch and sets the route context onto the active transaction.\n * - If `_onComponentWillAppear` isn't called within `options.routeChangeTimeoutMs` of the dispatch, then the transaction is not sampled and finished.\n */\nexport class ReactNativeNavigationInstrumentation extends InternalRoutingInstrumentation {\n public static instrumentationName: string = 'react-native-navigation';\n\n public readonly name: string = ReactNativeNavigationInstrumentation.instrumentationName;\n\n private _navigation: NavigationDelegate;\n private _options: ReactNativeNavigationOptions;\n\n private _prevComponentEvent: ComponentWillAppearEvent | null = null;\n\n private _latestTransaction?: TransactionType;\n private _recentComponentIds: string[] = [];\n private _stateChangeTimeout?: number | undefined;\n\n public constructor(\n /** The react native navigation `NavigationDelegate`. This is usually the import named `Navigation`. */\n navigation: unknown,\n options: Partial<ReactNativeNavigationOptions> = {}\n ) {\n super();\n\n this._navigation = navigation as NavigationDelegate;\n\n this._options = {\n ...defaultOptions,\n ...options,\n };\n }\n\n /**\n * Registers the event listeners for React Native Navigation\n */\n public registerRoutingInstrumentation(\n listener: TransactionCreator,\n beforeNavigate: BeforeNavigate,\n onConfirmRoute: OnConfirmRoute\n ): void {\n super.registerRoutingInstrumentation(\n listener,\n beforeNavigate,\n onConfirmRoute\n );\n\n this._navigation\n .events()\n .registerCommandListener(this._onCommand.bind(this));\n\n this._navigation\n .events()\n .registerComponentWillAppearListener(\n this._onComponentWillAppear.bind(this)\n );\n }\n\n /**\n * To be called when a navigation command is dispatched\n */\n private _onCommand(): void {\n if (this._latestTransaction) {\n this._discardLatestTransaction();\n }\n\n this._latestTransaction = this.onRouteWillChange(\n getBlankTransactionContext(ReactNativeNavigationInstrumentation.name)\n );\n\n this._stateChangeTimeout = setTimeout(\n this._discardLatestTransaction.bind(this),\n this._options.routeChangeTimeoutMs\n );\n }\n\n /**\n * To be called AFTER the state has been changed to populate the transaction with the current route.\n */\n private _onComponentWillAppear(event: ComponentWillAppearEvent): void {\n // If the route is a different key, this is so we ignore actions that pertain to the same screen.\n if (this._latestTransaction) {\n if (\n !this._prevComponentEvent ||\n event.componentId != this._prevComponentEvent.componentId\n ) {\n this._clearStateChangeTimeout();\n\n const originalContext = this._latestTransaction.toContext();\n const routeHasBeenSeen = this._recentComponentIds.includes(\n event.componentId\n );\n\n const data: RouteChangeContextData = {\n ...originalContext.data,\n route: {\n ...event,\n name: event.componentName,\n hasBeenSeen: routeHasBeenSeen,\n },\n previousRoute: this._prevComponentEvent\n ? {\n ...this._prevComponentEvent,\n name: this._prevComponentEvent?.componentName,\n }\n : null,\n };\n\n const updatedContext = {\n ...originalContext,\n name: event.componentName,\n tags: {\n ...originalContext.tags,\n 'routing.route.name': event.componentName,\n },\n data,\n };\n\n const finalContext = this._prepareFinalContext(updatedContext);\n this._latestTransaction.updateWithContext(finalContext);\n\n const isCustomName = updatedContext.name !== finalContext.name;\n this._latestTransaction.setName(\n finalContext.name,\n isCustomName ? customTransactionSource : defaultTransactionSource,\n );\n\n this._onConfirmRoute?.(finalContext);\n this._prevComponentEvent = event;\n } else {\n this._discardLatestTransaction();\n }\n\n this._latestTransaction = undefined;\n }\n }\n\n /** Creates final transaction context before confirmation */\n private _prepareFinalContext(updatedContext: TransactionContext): TransactionContext {\n let finalContext = this._beforeNavigate?.({ ...updatedContext });\n\n // This block is to catch users not returning a transaction context\n if (!finalContext) {\n logger.error(\n `[${ReactNativeNavigationInstrumentation.name}] beforeNavigate returned ${finalContext}, return context.sampled = false to not send transaction.`\n );\n\n finalContext = {\n ...updatedContext,\n sampled: false,\n };\n }\n\n if (finalContext.sampled === false) {\n logger.log(\n `[${ReactNativeNavigationInstrumentation.name}] Will not send transaction \"${finalContext.name}\" due to beforeNavigate.`\n );\n }\n\n return finalContext;\n }\n\n /** Cancels the latest transaction so it does not get sent to Sentry. */\n private _discardLatestTransaction(): void {\n if (this._latestTransaction) {\n this._latestTransaction.sampled = false;\n this._latestTransaction.finish();\n this._latestTransaction = undefined;\n }\n\n this._clearStateChangeTimeout();\n }\n\n /** Cancels the latest transaction so it does not get sent to Sentry. */\n private _clearStateChangeTimeout(): void {\n if (typeof this._stateChangeTimeout !== 'undefined') {\n clearTimeout(this._stateChangeTimeout);\n this._stateChangeTimeout = undefined;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"reactnativenavigation.js","sourceRoot":"","sources":["../../../src/js/tracing/reactnativenavigation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAMvC,OAAO,EACL,8BAA8B,EAC/B,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,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E,CAAC;IAClC,CAAC;IAED,wEAAwE;IAChE,wBAAwB;QAC9B,IAAI,OAAO,IAAI,CAAC,mBAAmB,KAAK,WAAW,EAAE;YACnD,YAAY,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;YACvC,IAAI,CAAC,mBAAmB,GAAG,SAAS,CAAC;SACtC;IACH,CAAC;;AAtLa,wDAAmB,GAAW,yBAAyB,CAAC","sourcesContent":["import type { Transaction as TransactionType, TransactionContext } from '@sentry/types';\nimport { logger } from '@sentry/utils';\nimport type { EmitterSubscription } from 'react-native';\n\nimport type {\n OnConfirmRoute,\n TransactionCreator} from './routingInstrumentation';\nimport {\n InternalRoutingInstrumentation\n} from './routingInstrumentation';\nimport type { BeforeNavigate, RouteChangeContextData } from './types';\nimport { customTransactionSource, defaultTransactionSource, getBlankTransactionContext } from './utils';\n\ninterface ReactNativeNavigationOptions {\n /**\n * How long the instrumentation will wait for the route to mount after a change has been initiated,\n * before the transaction is discarded.\n * Time is in ms.\n *\n * Default: 1000\n */\n routeChangeTimeoutMs: number;\n /**\n * Instrumentation will create a transaction on tab change.\n * By default only navigation commands create transactions.\n *\n * Default: true\n */\n enableTabsInstrumentation: boolean;\n}\n\nconst defaultOptions: ReactNativeNavigationOptions = {\n routeChangeTimeoutMs: 1000,\n enableTabsInstrumentation: true,\n};\n\ninterface ComponentEvent {\n componentId: string;\n}\n\ntype ComponentType =\n | 'Component'\n | 'TopBarTitle'\n | 'TopBarBackground'\n | 'TopBarButton';\n\nexport interface ComponentWillAppearEvent extends ComponentEvent {\n componentName: string;\n passProps?: Record<string | number | symbol, unknown>;\n componentType: ComponentType;\n}\n\nexport interface EventSubscription {\n remove(): void;\n}\n\nexport interface BottomTabPressedEvent {\n tabIndex: number;\n}\n\nexport interface EventsRegistry {\n registerComponentWillAppearListener(\n callback: (event: ComponentWillAppearEvent) => void\n ): EmitterSubscription;\n registerCommandListener(\n callback: (name: string, params: unknown) => void\n ): EventSubscription;\n registerBottomTabPressedListener(\n callback: (event: BottomTabPressedEvent) => void\n ): EmitterSubscription;\n}\n\nexport interface NavigationDelegate {\n events: () => EventsRegistry;\n}\n\n/**\n * Instrumentation for React Native Navigation. See docs or sample app for usage.\n *\n * How this works:\n * - `_onCommand` is called every time a commands happens and sets an IdleTransaction on the scope without any route context.\n * - `_onComponentWillAppear` is then called AFTER the state change happens due to a dispatch and sets the route context onto the active transaction.\n * - If `_onComponentWillAppear` isn't called within `options.routeChangeTimeoutMs` of the dispatch, then the transaction is not sampled and finished.\n */\nexport class ReactNativeNavigationInstrumentation extends InternalRoutingInstrumentation {\n public static instrumentationName: string = 'react-native-navigation';\n\n public readonly name: string = ReactNativeNavigationInstrumentation.instrumentationName;\n\n private _navigation: NavigationDelegate;\n private _options: ReactNativeNavigationOptions;\n\n private _prevComponentEvent: ComponentWillAppearEvent | null = null;\n\n private _latestTransaction?: TransactionType;\n private _recentComponentIds: string[] = [];\n private _stateChangeTimeout?: number | undefined;\n\n public constructor(\n /** The react native navigation `NavigationDelegate`. This is usually the import named `Navigation`. */\n navigation: unknown,\n options: Partial<ReactNativeNavigationOptions> = {}\n ) {\n super();\n\n this._navigation = navigation as NavigationDelegate;\n\n this._options = {\n ...defaultOptions,\n ...options,\n };\n }\n\n /**\n * Registers the event listeners for React Native Navigation\n */\n public registerRoutingInstrumentation(\n listener: TransactionCreator,\n beforeNavigate: BeforeNavigate,\n onConfirmRoute: OnConfirmRoute\n ): void {\n super.registerRoutingInstrumentation(\n listener,\n beforeNavigate,\n onConfirmRoute\n );\n\n this._navigation\n .events()\n .registerCommandListener(this._onNavigation.bind(this));\n\n if (this._options.enableTabsInstrumentation) {\n this._navigation\n .events()\n .registerBottomTabPressedListener(this._onNavigation.bind(this));\n }\n\n this._navigation\n .events()\n .registerComponentWillAppearListener(\n this._onComponentWillAppear.bind(this)\n );\n }\n\n /**\n * To be called when a navigation is initiated. (Command, BottomTabSelected, etc.)\n */\n private _onNavigation(): void {\n if (this._latestTransaction) {\n this._discardLatestTransaction();\n }\n\n this._latestTransaction = this.onRouteWillChange(\n getBlankTransactionContext(ReactNativeNavigationInstrumentation.name)\n );\n\n this._stateChangeTimeout = setTimeout(\n this._discardLatestTransaction.bind(this),\n this._options.routeChangeTimeoutMs\n );\n }\n\n /**\n * To be called AFTER the state has been changed to populate the transaction with the current route.\n */\n private _onComponentWillAppear(event: ComponentWillAppearEvent): void {\n if (!this._latestTransaction) {\n return;\n }\n\n // We ignore actions that pertain to the same screen.\n const isSameComponent = this._prevComponentEvent\n && event.componentId === this._prevComponentEvent.componentId;\n if (isSameComponent) {\n this._discardLatestTransaction();\n return;\n }\n\n this._clearStateChangeTimeout();\n\n const originalContext = this._latestTransaction.toContext();\n const routeHasBeenSeen = this._recentComponentIds.includes(\n event.componentId\n );\n\n const data: RouteChangeContextData = {\n ...originalContext.data,\n route: {\n ...event,\n name: event.componentName,\n hasBeenSeen: routeHasBeenSeen,\n },\n previousRoute: this._prevComponentEvent\n ? {\n ...this._prevComponentEvent,\n name: this._prevComponentEvent?.componentName,\n }\n : null,\n };\n\n const updatedContext = {\n ...originalContext,\n name: event.componentName,\n tags: {\n ...originalContext.tags,\n 'routing.route.name': event.componentName,\n },\n data,\n };\n\n const finalContext = this._prepareFinalContext(updatedContext);\n this._latestTransaction.updateWithContext(finalContext);\n\n const isCustomName = updatedContext.name !== finalContext.name;\n this._latestTransaction.setName(\n finalContext.name,\n isCustomName ? customTransactionSource : defaultTransactionSource,\n );\n\n this._onConfirmRoute?.(finalContext);\n this._prevComponentEvent = event;\n\n this._latestTransaction = undefined;\n }\n\n /** Creates final transaction context before confirmation */\n private _prepareFinalContext(updatedContext: TransactionContext): TransactionContext {\n let finalContext = this._beforeNavigate?.({ ...updatedContext });\n\n // This block is to catch users not returning a transaction context\n if (!finalContext) {\n logger.error(\n `[${ReactNativeNavigationInstrumentation.name}] beforeNavigate returned ${finalContext}, return context.sampled = false to not send transaction.`\n );\n\n finalContext = {\n ...updatedContext,\n sampled: false,\n };\n }\n\n if (finalContext.sampled === false) {\n logger.log(\n `[${ReactNativeNavigationInstrumentation.name}] Will not send transaction \"${finalContext.name}\" due to beforeNavigate.`\n );\n }\n\n return finalContext;\n }\n\n /** Cancels the latest transaction so it does not get sent to Sentry. */\n private _discardLatestTransaction(): void {\n if (this._latestTransaction) {\n this._latestTransaction.sampled = false;\n this._latestTransaction.finish();\n this._latestTransaction = undefined;\n }\n\n this._clearStateChangeTimeout();\n }\n\n /** Cancels the latest transaction so it does not get sent to Sentry. */\n private _clearStateChangeTimeout(): void {\n if (typeof this._stateChangeTimeout !== 'undefined') {\n clearTimeout(this._stateChangeTimeout);\n this._stateChangeTimeout = undefined;\n }\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { Hub } from '@sentry/core';
2
2
  import type { RequestInstrumentationOptions, Transaction } from '@sentry/tracing';
3
- import type { EventProcessor, Integration } from '@sentry/types';
3
+ import type { EventProcessor, Integration, Transaction as TransactionType } from '@sentry/types';
4
4
  import type { RoutingInstrumentationInstance } from '../tracing/routingInstrumentation';
5
5
  import { NativeFramesInstrumentation } from './nativeframes';
6
6
  import { StallTrackingInstrumentation } from './stalltracking';
@@ -67,6 +67,10 @@ export interface ReactNativeTracingOptions extends RequestInstrumentationOptions
67
67
  * Track when and how long the JS event loop stalls for. Adds stalls as measurements to all transactions.
68
68
  */
69
69
  enableStallTracking: boolean;
70
+ /**
71
+ * Trace User Interaction events like touch and gestures.
72
+ */
73
+ enableUserInteractionTracing: boolean;
70
74
  }
71
75
  /**
72
76
  * Tracing integration for React Native.
@@ -87,9 +91,11 @@ export declare class ReactNativeTracing implements Integration {
87
91
  nativeFramesInstrumentation?: NativeFramesInstrumentation;
88
92
  stallTrackingInstrumentation?: StallTrackingInstrumentation;
89
93
  useAppStartWithProfiler: boolean;
94
+ private _inflightInteractionTransaction?;
90
95
  private _getCurrentHub?;
91
96
  private _awaitingAppStartData?;
92
97
  private _appStartFinishTimestamp?;
98
+ private _currentRoute?;
93
99
  constructor(options?: Partial<ReactNativeTracingOptions>);
94
100
  /**
95
101
  * Registers routing and request instrumentation.
@@ -107,6 +113,14 @@ export declare class ReactNativeTracing implements Integration {
107
113
  * Called by the ReactNativeProfiler component on first component mount.
108
114
  */
109
115
  onAppStartFinish(endTimestamp: number): void;
116
+ /**
117
+ * Starts a new transaction for a user interaction.
118
+ * @param userInteractionId Consists of `op` representation UI Event and `elementId` unique element identifier on current screen.
119
+ */
120
+ startUserInteractionTransaction(userInteractionId: {
121
+ elementId: string | undefined;
122
+ op: string;
123
+ }): TransactionType | undefined;
110
124
  /**
111
125
  * Instruments the app start measurements on the first route transaction.
112
126
  * Starts a route transaction if there isn't routing instrumentation.
@@ -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;AAKvB,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;AAExF,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAM7D,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,MAAM,CAAC;IAE/B;;;;;;OAMG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;;;;;;OAOG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,sBAAsB,CAAC,EAAE,8BAA8B,CAAC;IAExD;;;;;OAKG;I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