@sentry/react-native 5.1.0 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/RNSentry.podspec +1 -1
- package/android/build.gradle +1 -1
- package/dist/js/index.d.ts +1 -1
- package/dist/js/index.d.ts.map +1 -1
- package/dist/js/index.js +1 -1
- package/dist/js/index.js.map +1 -1
- package/dist/js/integrations/rewriteframes.d.ts +8 -0
- package/dist/js/integrations/rewriteframes.d.ts.map +1 -0
- package/dist/js/integrations/rewriteframes.js +30 -0
- package/dist/js/integrations/rewriteframes.js.map +1 -0
- package/dist/js/sdk.d.ts.map +1 -1
- package/dist/js/sdk.js +9 -22
- package/dist/js/sdk.js.map +1 -1
- package/dist/js/touchevents.d.ts +1 -0
- package/dist/js/touchevents.d.ts.map +1 -1
- package/dist/js/touchevents.js +66 -54
- package/dist/js/touchevents.js.map +1 -1
- package/dist/js/tracing/gesturetracing.d.ts +20 -0
- package/dist/js/tracing/gesturetracing.d.ts.map +1 -0
- package/dist/js/tracing/gesturetracing.js +98 -0
- package/dist/js/tracing/gesturetracing.js.map +1 -0
- package/dist/js/tracing/index.d.ts +1 -0
- package/dist/js/tracing/index.d.ts.map +1 -1
- package/dist/js/tracing/index.js +1 -0
- package/dist/js/tracing/index.js.map +1 -1
- package/dist/js/tracing/nativeframes.d.ts.map +1 -1
- package/dist/js/tracing/nativeframes.js +4 -0
- package/dist/js/tracing/nativeframes.js.map +1 -1
- package/dist/js/tracing/ops.d.ts +3 -1
- package/dist/js/tracing/ops.d.ts.map +1 -1
- package/dist/js/tracing/ops.js +3 -1
- package/dist/js/tracing/ops.js.map +1 -1
- package/dist/js/tracing/reactnativetracing.d.ts +15 -1
- package/dist/js/tracing/reactnativetracing.d.ts.map +1 -1
- package/dist/js/tracing/reactnativetracing.js +64 -4
- package/dist/js/tracing/reactnativetracing.js.map +1 -1
- package/dist/js/tracing/transaction.d.ts +7 -0
- package/dist/js/tracing/transaction.d.ts.map +1 -0
- package/dist/js/tracing/transaction.js +13 -0
- package/dist/js/tracing/transaction.js.map +1 -0
- package/dist/js/transports/native.d.ts +3 -1
- package/dist/js/transports/native.d.ts.map +1 -1
- package/dist/js/transports/native.js +2 -2
- package/dist/js/transports/native.js.map +1 -1
- package/dist/js/version.d.ts +1 -1
- package/dist/js/version.js +1 -1
- package/dist/js/version.js.map +1 -1
- package/dist/js/wrapper.d.ts +1 -1
- package/dist/js/wrapper.d.ts.map +1 -1
- package/dist/js/wrapper.js +9 -5
- package/dist/js/wrapper.js.map +1 -1
- package/package.json +12 -12
|
@@ -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;AA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AAI,KAAK,EAAE;gBACrB,IAAI,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;aAClC;SACF;QACD,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;KACnB;IAED,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAEzB,MAAM,CAAC,GAAG,CAAC,oBAAoB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;AAClD,CAAC;AAED;;;;GAIG;AACH,MAAM,gBAAgB,GAAG;IACvB,kBAAkB,EAAE,kBAAkB;IACtC,iBAAiB,EAAE,iBAAiB;IACpC,KAAK,EAAE,OAAO;IACd,YAAY,EAAE,aAAa;IAC3B,QAAQ,EAAE,UAAU;IACpB,eAAe,EAAE,gBAAgB;IACjC,KAAK,EAAE,OAAO;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"}
|
package/dist/js/tracing/index.js
CHANGED
|
@@ -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,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AAM,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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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,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,OAA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EACZ,SAAwB;;;YAExB,IAAI,CAAC,SAAS,EAAE,EAAE;gBAChB,OAAO,KAAK,CAAC;aACd;YAED,IACE,KAAK,CAAC,IAAI,KAAK,aAAa;gBAC5B,KAAK,CAAC,WAAW;gBACjB,KAAK,CAAC,QAAQ;gBACd,KAAK,CAAC,QAAQ,CAAC,KAAK,EACpB;gBACA,MAAM,YAAY,GAAG,KAAK,CAAC,QAAQ,CAAC,KAKnC,CAAC;gBAEF,MAAM,OAAO,GAAG,YAAY,CAAC,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 }).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"]}
|
package/dist/js/tracing/ops.d.ts
CHANGED
|
@@ -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,
|
|
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"}
|
package/dist/js/tracing/ops.js
CHANGED
|
@@ -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,
|
|
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"]}
|
|
@@ -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;
|
|
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;AAExC,OAAO,KAAK,EAEV,6BAA6B,EAC7B,WAAW,EACZ,MAAM,iBAAiB,CAAC;AAQzB,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EACX,WAAW,IAAI,eAAe,EAE/B,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;AAI/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,s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I,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;IAInD;;;OAGG;IACI,+BAA+B,CAAC,iBAAiB,EAAE;QACxD,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;QAC9B,EAAE,EAAE,MAAM,CAAC;KACZ,GAAG,eAAe,GAAG,SAAS;IA0D/B;;;OAGG;YACW,mBAAmB;IAgCjC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAiCxB,6FAA6F;IAC7F,OAAO,CAAC,kBAAkB;IAM1B;;OAEG;IACH,OAAO,CAAC,eAAe;IAwBvB,uCAAuC;IACvC,OAAO,CAAC,uBAAuB;CA0FhC"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
-
import {
|
|
2
|
+
import { getCurrentHub } from '@sentry/core';
|
|
3
|
+
import { defaultRequestInstrumentationOptions, getActiveTransaction, instrumentOutgoingRequests, startIdleTransaction } from '@sentry/tracing';
|
|
3
4
|
import { logger } from '@sentry/utils';
|
|
4
5
|
import { APP_START_COLD, APP_START_WARM } from '../measurements';
|
|
5
6
|
import { NATIVE } from '../wrapper';
|
|
6
7
|
import { NativeFramesInstrumentation } from './nativeframes';
|
|
7
8
|
import { APP_START_COLD as APP_START_COLD_OP, APP_START_WARM as APP_START_WARM_OP, UI_LOAD, } from './ops';
|
|
8
9
|
import { StallTrackingInstrumentation } from './stalltracking';
|
|
10
|
+
import { onlySampleIfChildSpans, } from './transaction';
|
|
9
11
|
import { adjustTransactionDuration, getTimeOriginMilliseconds, isNearToNow, } from './utils';
|
|
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 });
|
|
12
|
+
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, enableUserInteractionTracing: false });
|
|
11
13
|
/**
|
|
12
14
|
* Tracing integration for React Native.
|
|
13
15
|
*/
|
|
@@ -95,6 +97,57 @@ export class ReactNativeTracing {
|
|
|
95
97
|
onAppStartFinish(endTimestamp) {
|
|
96
98
|
this._appStartFinishTimestamp = endTimestamp;
|
|
97
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Starts a new transaction for a user interaction.
|
|
102
|
+
* @param userInteractionId Consists of `op` representation UI Event and `elementId` unique element identifier on current screen.
|
|
103
|
+
*/
|
|
104
|
+
startUserInteractionTransaction(userInteractionId) {
|
|
105
|
+
var _a, _b;
|
|
106
|
+
const { elementId, op } = userInteractionId;
|
|
107
|
+
if (!this.options.enableUserInteractionTracing) {
|
|
108
|
+
logger.log('[ReactNativeTracing] User Interaction Tracing is disabled.');
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (!this.options.routingInstrumentation) {
|
|
112
|
+
logger.error('[ReactNativeTracing] User Interaction Tracing is not working because no routing instrumentation is set.');
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (!elementId) {
|
|
116
|
+
logger.log('[ReactNativeTracing] User Interaction Tracing can not create transaction with undefined elementId.');
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (!this._currentRoute) {
|
|
120
|
+
logger.log('[ReactNativeTracing] User Interaction Tracing can not create transaction without a current route.');
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const hub = ((_a = this._getCurrentHub) === null || _a === void 0 ? void 0 : _a.call(this)) || getCurrentHub();
|
|
124
|
+
const activeTransaction = getActiveTransaction(hub);
|
|
125
|
+
const activeTransactionIsNotInteraction = (activeTransaction === null || activeTransaction === void 0 ? void 0 : activeTransaction.spanId) !== ((_b = this._inflightInteractionTransaction) === null || _b === void 0 ? void 0 : _b.spanId);
|
|
126
|
+
if (activeTransaction && activeTransactionIsNotInteraction) {
|
|
127
|
+
logger.warn(`[ReactNativeTracing] Did not create ${op} transaction because active transaction ${activeTransaction.name} exists on the scope.`);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const { idleTimeoutMs, finalTimeoutMs } = this.options;
|
|
131
|
+
if (this._inflightInteractionTransaction) {
|
|
132
|
+
this._inflightInteractionTransaction.cancelIdleTimeout(undefined, { restartOnChildSpanChange: false });
|
|
133
|
+
this._inflightInteractionTransaction = undefined;
|
|
134
|
+
}
|
|
135
|
+
const name = `${this._currentRoute}.${elementId}`;
|
|
136
|
+
const context = {
|
|
137
|
+
name,
|
|
138
|
+
op,
|
|
139
|
+
trimEnd: true,
|
|
140
|
+
};
|
|
141
|
+
this._inflightInteractionTransaction = startIdleTransaction(hub, context, idleTimeoutMs, finalTimeoutMs, true);
|
|
142
|
+
this._inflightInteractionTransaction.registerBeforeFinishCallback((transaction) => {
|
|
143
|
+
this._inflightInteractionTransaction = undefined;
|
|
144
|
+
this.onTransactionFinish(transaction);
|
|
145
|
+
});
|
|
146
|
+
this._inflightInteractionTransaction.registerBeforeFinishCallback(onlySampleIfChildSpans);
|
|
147
|
+
this.onTransactionStart(this._inflightInteractionTransaction);
|
|
148
|
+
logger.log(`[ReactNativeTracing] User Interaction Tracing Created ${op} transaction ${name}.`);
|
|
149
|
+
return this._inflightInteractionTransaction;
|
|
150
|
+
}
|
|
98
151
|
/**
|
|
99
152
|
* Instruments the app start measurements on the first route transaction.
|
|
100
153
|
* Starts a route transaction if there isn't routing instrumentation.
|
|
@@ -161,8 +214,10 @@ export class ReactNativeTracing {
|
|
|
161
214
|
* Creates a breadcrumb and sets the current route as a tag.
|
|
162
215
|
*/
|
|
163
216
|
_onConfirmRoute(context) {
|
|
164
|
-
var _a;
|
|
165
|
-
|
|
217
|
+
var _a, _b, _c;
|
|
218
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
219
|
+
this._currentRoute = (_b = (_a = context.data) === null || _a === void 0 ? void 0 : _a.route) === null || _b === void 0 ? void 0 : _b.name;
|
|
220
|
+
(_c = this._getCurrentHub) === null || _c === void 0 ? void 0 : _c.call(this).configureScope((scope) => {
|
|
166
221
|
var _a;
|
|
167
222
|
if (context.data) {
|
|
168
223
|
const contextData = context.data;
|
|
@@ -186,6 +241,11 @@ export class ReactNativeTracing {
|
|
|
186
241
|
logger.warn(`[ReactNativeTracing] Did not create ${context.op} transaction because _getCurrentHub is invalid.`);
|
|
187
242
|
return undefined;
|
|
188
243
|
}
|
|
244
|
+
if (this._inflightInteractionTransaction) {
|
|
245
|
+
logger.log(`[ReactNativeTracing] Canceling ${this._inflightInteractionTransaction.op} transaction because navigation ${context.op}.`);
|
|
246
|
+
this._inflightInteractionTransaction.setStatus('cancelled');
|
|
247
|
+
this._inflightInteractionTransaction.finish();
|
|
248
|
+
}
|
|
189
249
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
190
250
|
const { idleTimeoutMs, finalTimeoutMs } = this.options;
|
|
191
251
|
const expandedContext = Object.assign(Object.assign({}, context), { trimEnd: true });
|
|
@@ -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;AAEvC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EACL,cAAc,IAAI,iBAAi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BAAoB,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
|
+
{"version":3,"file":"reactnativetracing.js","sourceRoot":"","sources":["../../../src/js/tracing/reactnativetracing.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAM7C,OAAO,EACL,oCAAoC,EACpC,oBAAoB,EAEpB,0BAA0B,EAC1B,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AAOzB,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,2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EG;AACW,qBAAE,GAAW,oBAAoB,CAAC;AAChD,6CAA6C;AAC9B,+BAAY,GAAW,KAAK,CAAC","sourcesContent":["/* eslint-disable max-lines */\nimport type { Hub } from '@sentry/core';\nimport { getCurrentHub } from '@sentry/core';\nimport type {\n IdleTransaction,\n RequestInstrumentationOptions,\n Transaction\n} from '@sentry/tracing';\nimport {\n defaultRequestInstrumentationOptions,\n getActiveTransaction\n ,\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 {\n onlySampleIfChildSpans,\n} from './transaction';\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 /**\n * Trace User Interaction events like touch and gestures.\n */\n enableUserInteractionTracing: 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 enableUserInteractionTracing: false,\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 _inflightInteractionTransaction?: IdleTransaction;\n private _getCurrentHub?: () => Hub;\n private _awaitingAppStartData?: NativeAppStartResponse;\n private _appStartFinishTimestamp?: number;\n private _currentRoute?: string;\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 * Starts a new transaction for a user interaction.\n * @param userInteractionId Consists of `op` representation UI Event and `elementId` unique element identifier on current screen.\n */\n public startUserInteractionTransaction(userInteractionId: {\n elementId: string | undefined;\n op: string;\n }): TransactionType | undefined {\n const { elementId, op } = userInteractionId;\n if (!this.options.enableUserInteractionTracing) {\n logger.log('[ReactNativeTracing] User Interaction Tracing is disabled.');\n return;\n }\n if (!this.options.routingInstrumentation) {\n logger.error('[ReactNativeTracing] User Interaction Tracing is not working because no routing instrumentation is set.');\n return;\n }\n if (!elementId) {\n logger.log('[ReactNativeTracing] User Interaction Tracing can not create transaction with undefined elementId.');\n return;\n }\n if (!this._currentRoute) {\n logger.log('[ReactNativeTracing] User Interaction Tracing can not create transaction without a current route.');\n return;\n }\n\n const hub = this._getCurrentHub?.() || getCurrentHub();\n const activeTransaction = getActiveTransaction(hub);\n const activeTransactionIsNotInteraction =\n activeTransaction?.spanId !== this._inflightInteractionTransaction?.spanId;\n if (activeTransaction && activeTransactionIsNotInteraction) {\n logger.warn(`[ReactNativeTracing] Did not create ${op} transaction because active transaction ${activeTransaction.name} exists on the scope.`);\n return;\n }\n\n const { idleTimeoutMs, finalTimeoutMs } = this.options;\n\n if (this._inflightInteractionTransaction) {\n this._inflightInteractionTransaction.cancelIdleTimeout(undefined, { restartOnChildSpanChange: false });\n this._inflightInteractionTransaction = undefined;\n }\n\n const name = `${this._currentRoute}.${elementId}`;\n const context: TransactionContext = {\n name,\n op,\n trimEnd: true,\n };\n this._inflightInteractionTransaction = startIdleTransaction(\n hub,\n context,\n idleTimeoutMs,\n finalTimeoutMs,\n true,\n );\n this._inflightInteractionTransaction.registerBeforeFinishCallback((transaction: IdleTransaction) => {\n this._inflightInteractionTransaction = undefined;\n this.onTransactionFinish(transaction);\n });\n this._inflightInteractionTransaction.registerBeforeFinishCallback(onlySampleIfChildSpans);\n this.onTransactionStart(this._inflightInteractionTransaction);\n logger.log(`[ReactNativeTracing] User Interaction Tracing Created ${op} transaction ${name}.`);\n return this._inflightInteractionTransaction;\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 // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n this._currentRoute = context.data?.route?.name;\n\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 if (this._inflightInteractionTransaction) {\n logger.log(\n `[ReactNativeTracing] Canceling ${this._inflightInteractionTransaction.op} transaction because navigation ${context.op}.`\n );\n this._inflightInteractionTransaction.setStatus('cancelled');\n this._inflightInteractionTransaction.finish();\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"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BeforeFinishCallback } from '@sentry/core/types/tracing/idletransaction';
|
|
2
|
+
/**
|
|
3
|
+
* Idle Transaction callback to only sample transactions with child spans.
|
|
4
|
+
* To avoid side effects of other callbacks this should be hooked as the last callback.
|
|
5
|
+
*/
|
|
6
|
+
export declare const onlySampleIfChildSpans: BeforeFinishCallback;
|
|
7
|
+
//# sourceMappingURL=transaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAIvF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,oBAWpC,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { logger } from '@sentry/utils';
|
|
2
|
+
/**
|
|
3
|
+
* Idle Transaction callback to only sample transactions with child spans.
|
|
4
|
+
* To avoid side effects of other callbacks this should be hooked as the last callback.
|
|
5
|
+
*/
|
|
6
|
+
export const onlySampleIfChildSpans = (transaction) => {
|
|
7
|
+
const spansCount = transaction.spanRecorder && transaction.spanRecorder.spans.filter((span) => span.spanId !== transaction.spanId).length;
|
|
8
|
+
if (!spansCount || spansCount <= 0) {
|
|
9
|
+
logger.log(`Not sampling as ${transaction.op} transaction has no child spans.`);
|
|
10
|
+
transaction.sampled = false;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=transaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../../src/js/tracing/transaction.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAyB,CAC1D,WAA4B,EACtB,EAAE;IACR,MAAM,UAAU,GAAG,WAAW,CAAC,YAAY,IAAI,WAAW,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,CAClF,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,WAAW,CAAC,MAAM,CAC7C,CAAC,MAAM,CAAC;IAET,IAAI,CAAC,UAAU,IAAI,UAAU,IAAI,CAAC,EAAE;QAClC,MAAM,CAAC,GAAG,CAAC,mBAAmB,WAAW,CAAC,EAAE,kCAAkC,CAAC,CAAC;QAChF,WAAW,CAAC,OAAO,GAAG,KAAK,CAAC;KAC7B;AACH,CAAC,CAAA","sourcesContent":["import type { BeforeFinishCallback } from '@sentry/core/types/tracing/idletransaction';\nimport type { IdleTransaction } from '@sentry/tracing';\nimport { logger } from '@sentry/utils';\n\n/**\n * Idle Transaction callback to only sample transactions with child spans.\n * To avoid side effects of other callbacks this should be hooked as the last callback.\n */\nexport const onlySampleIfChildSpans: BeforeFinishCallback = (\n transaction: IdleTransaction,\n): void => {\n const spansCount = transaction.spanRecorder && transaction.spanRecorder.spans.filter(\n (span) => span.spanId !== transaction.spanId\n ).length;\n\n if (!spansCount || spansCount <= 0) {\n logger.log(`Not sampling as ${transaction.op} transaction has no child spans.`);\n transaction.sampled = false;\n }\n}\n"]}
|
|
@@ -33,5 +33,7 @@ export declare function makeNativeTransport(options?: BaseNativeTransportOptions
|
|
|
33
33
|
/**
|
|
34
34
|
* Creates a Native Transport factory if the native transport is available.
|
|
35
35
|
*/
|
|
36
|
-
export declare function makeNativeTransportFactory(
|
|
36
|
+
export declare function makeNativeTransportFactory({ enableNative }: {
|
|
37
|
+
enableNative?: boolean;
|
|
38
|
+
}): typeof makeNativeTransport | null;
|
|
37
39
|
//# sourceMappingURL=native.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../../src/js/transports/native.ts"],"names":[],"mappings":"AAA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