@nativescript-community/sentry 3.1.5 → 4.6.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 (105) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +2 -6
  3. package/client.d.ts +38 -3
  4. package/client.js +143 -5
  5. package/client.js.map +1 -1
  6. package/index.d.ts +7 -11
  7. package/index.js +28 -12
  8. package/index.js.map +1 -1
  9. package/integrations/debugsymbolicator.d.ts +4 -4
  10. package/integrations/debugsymbolicator.js +11 -22
  11. package/integrations/debugsymbolicator.js.map +1 -1
  12. package/integrations/devicecontext.js +22 -5
  13. package/integrations/devicecontext.js.map +1 -1
  14. package/integrations/eventorigin.d.ts +7 -7
  15. package/integrations/eventorigin.js +9 -9
  16. package/integrations/eventorigin.js.map +1 -1
  17. package/integrations/nativescripterrorhandlers.d.ts +15 -5
  18. package/integrations/nativescripterrorhandlers.js +55 -44
  19. package/integrations/nativescripterrorhandlers.js.map +1 -1
  20. package/integrations/release.js +10 -8
  21. package/integrations/release.js.map +1 -1
  22. package/integrations/sdkinfo.d.ts +4 -1
  23. package/integrations/sdkinfo.js +17 -10
  24. package/integrations/sdkinfo.js.map +1 -1
  25. package/measurement.d.ts +4 -0
  26. package/measurement.js +50 -0
  27. package/measurement.js.map +1 -0
  28. package/measurements.d.ts +4 -0
  29. package/measurements.js +50 -0
  30. package/measurements.js.map +1 -0
  31. package/misc.d.ts +8 -0
  32. package/misc.js +17 -0
  33. package/misc.js.map +1 -0
  34. package/options.d.ts +125 -0
  35. package/options.js +2 -0
  36. package/options.js.map +1 -0
  37. package/package.json +9 -12
  38. package/platforms/android/buildscript.gradle +6 -2
  39. package/platforms/android/include.gradle +1 -1
  40. package/platforms/android/sentry.aar +0 -0
  41. package/platforms/ios/Podfile +1 -1
  42. package/platforms/ios/src/NSSentry.h +8 -3
  43. package/platforms/ios/src/NSSentry.m +41 -0
  44. package/scope.d.ts +1 -45
  45. package/scope.js +90 -68
  46. package/scope.js.map +1 -1
  47. package/sdk.d.ts +27 -3
  48. package/sdk.js +105 -30
  49. package/sdk.js.map +1 -1
  50. package/tracing/index.d.ts +2 -1
  51. package/tracing/index.js +14 -6
  52. package/tracing/index.js.map +1 -1
  53. package/tracing/nativeframes.d.ts +68 -0
  54. package/tracing/nativeframes.js +175 -0
  55. package/tracing/nativeframes.js.map +1 -0
  56. package/tracing/nstracing.d.ts +98 -47
  57. package/tracing/nstracing.js +164 -44
  58. package/tracing/nstracing.js.map +1 -1
  59. package/tracing/routingInstrumentation.d.ts +46 -0
  60. package/tracing/routingInstrumentation.js +33 -0
  61. package/tracing/routingInstrumentation.js.map +1 -0
  62. package/tracing/stalltracking.d.ts +92 -0
  63. package/tracing/stalltracking.js +258 -0
  64. package/tracing/stalltracking.js.map +1 -0
  65. package/tracing/types.d.ts +13 -0
  66. package/tracing/types.js +2 -0
  67. package/tracing/types.js.map +1 -0
  68. package/tracing/utils.d.ts +22 -1
  69. package/tracing/utils.js +51 -2
  70. package/tracing/utils.js.map +1 -1
  71. package/transports/TextEncoder.d.ts +2 -0
  72. package/transports/TextEncoder.js +12 -0
  73. package/transports/TextEncoder.js.map +1 -0
  74. package/transports/native.d.ts +20 -8
  75. package/transports/native.js +21 -13
  76. package/transports/native.js.map +1 -1
  77. package/utils/envelope.d.ts +11 -0
  78. package/utils/envelope.js +21 -0
  79. package/utils/envelope.js.map +1 -0
  80. package/utils/outcome.d.ts +5 -0
  81. package/utils/outcome.js +19 -0
  82. package/utils/outcome.js.map +1 -0
  83. package/utils/safe.d.ts +17 -0
  84. package/utils/safe.js +46 -0
  85. package/utils/safe.js.map +1 -0
  86. package/vendor/buffer/index.d.ts +1 -0
  87. package/vendor/buffer/index.js +2 -0
  88. package/vendor/buffer/index.js.map +1 -0
  89. package/vendor/buffer/utf8ToBytes.d.ts +9 -0
  90. package/vendor/buffer/utf8ToBytes.js +81 -0
  91. package/vendor/buffer/utf8ToBytes.js.map +1 -0
  92. package/vendor/index.d.ts +1 -0
  93. package/vendor/index.js +2 -0
  94. package/vendor/index.js.map +1 -0
  95. package/version.d.ts +2 -1
  96. package/version.js +2 -1
  97. package/version.js.map +1 -1
  98. package/wrapper.android.d.ts +30 -0
  99. package/wrapper.android.js +952 -0
  100. package/wrapper.android.js.map +1 -0
  101. package/wrapper.d.ts +88 -0
  102. package/wrapper.ios.d.ts +34 -0
  103. package/wrapper.ios.js +497 -0
  104. package/wrapper.ios.js.map +1 -0
  105. package/pnpm-lock.yaml +0 -914
@@ -1,84 +1,204 @@
1
- import { defaultRequestInstrumentationOptions, registerRequestInstrumentation, startIdleTransaction, } from '@sentry/tracing';
1
+ import { defaultRequestInstrumentationOptions, instrumentOutgoingRequests, startIdleTransaction } from '@sentry/tracing';
2
2
  import { logger } from '@sentry/utils';
3
- // import { RoutingInstrumentationInstance } from '../tracing/routingInstrumentation';
4
- import { adjustTransactionDuration } from './utils';
5
- const defaultNSTracingOptions = Object.assign(Object.assign({}, defaultRequestInstrumentationOptions), { idleTimeout: 1000, maxTransactionDuration: 600, ignoreEmptyBackNavigationTransactions: true });
3
+ import { NATIVE } from '../wrapper';
4
+ import { NativeFramesInstrumentation } from './nativeframes';
5
+ import { StallTrackingInstrumentation } from './stalltracking';
6
+ import { adjustTransactionDuration, getTimeOriginMilliseconds, isNearToNow } from './utils';
7
+ const defaultNativescriptTracingOptions = Object.assign(Object.assign({}, defaultRequestInstrumentationOptions), { idleTimeout: 1000, maxTransactionDuration: 600, ignoreEmptyBackNavigationTransactions: true, beforeNavigate: (context) => context, enableAppStartTracking: true, enableNativeFramesTracking: true, enableStallTracking: true });
6
8
  /**
7
- * Tracing integration for React Native.
8
- */
9
- export class NSTracing {
9
+ * Tracing integration for React Native.
10
+ */
11
+ export class NativescriptTracing {
10
12
  constructor(options = {}) {
11
13
  /**
12
- * @inheritDoc
13
- */
14
- this.name = NSTracing.id;
15
- this.options = Object.assign(Object.assign({}, defaultNSTracingOptions), options);
14
+ * @inheritDoc
15
+ */
16
+ this.name = NativescriptTracing.id;
17
+ this.useAppStartWithProfiler = false;
18
+ this.options = Object.assign(Object.assign({}, defaultNativescriptTracingOptions), options);
16
19
  }
17
20
  /**
18
- * Registers routing and request instrumentation.
19
- */
21
+ * Registers routing and request instrumentation.
22
+ */
20
23
  setupOnce(
21
24
  // @ts-ignore TODO
22
25
  addGlobalEventProcessor, getCurrentHub) {
23
26
  // eslint-disable-next-line @typescript-eslint/unbound-method
24
27
  const { traceFetch, traceXHR, tracingOrigins,
25
28
  // @ts-ignore TODO
26
- shouldCreateSpanForRequest,
27
- // routingInstrumentation,
28
- } = this.options;
29
+ shouldCreateSpanForRequest, routingInstrumentation, enableAppStartTracking, enableNativeFramesTracking, enableStallTracking, } = this.options;
29
30
  this._getCurrentHub = getCurrentHub;
30
- // routingInstrumentation?.registerRoutingInstrumentation(
31
- // this._onRouteWillChange.bind(this)
32
- // );
33
- // if (!routingInstrumentation) {
34
- // logger.log(
35
- // '[NSTracing] Not instrumenting route changes as routingInstrumentation has not been set.'
36
- // );
37
- // }
38
- registerRequestInstrumentation({
31
+ console.log('NativescriptTracing', this.options);
32
+ if (enableAppStartTracking) {
33
+ void this._instrumentAppStart();
34
+ }
35
+ if (enableNativeFramesTracking) {
36
+ this.nativeFramesInstrumentation = new NativeFramesInstrumentation(addGlobalEventProcessor, () => {
37
+ const self = getCurrentHub().getIntegration(NativescriptTracing);
38
+ if (self) {
39
+ return !!self.nativeFramesInstrumentation;
40
+ }
41
+ return false;
42
+ });
43
+ }
44
+ else {
45
+ NATIVE.disableNativeFramesTracking();
46
+ }
47
+ if (enableStallTracking) {
48
+ this.stallTrackingInstrumentation = new StallTrackingInstrumentation();
49
+ }
50
+ if (routingInstrumentation) {
51
+ routingInstrumentation.registerRoutingInstrumentation(this._onRouteWillChange.bind(this), this.options.beforeNavigate, this._onConfirmRoute.bind(this));
52
+ }
53
+ else {
54
+ logger.log('[NativescriptTracing] Not instrumenting route changes as routingInstrumentation has not been set.');
55
+ }
56
+ instrumentOutgoingRequests({
39
57
  traceFetch,
40
58
  traceXHR,
41
59
  tracingOrigins,
42
60
  shouldCreateSpanForRequest,
43
61
  });
44
- addGlobalEventProcessor((event) => {
45
- // eslint-disable-next-line no-empty
46
- if (event.type === 'transaction') {
62
+ }
63
+ /**
64
+ * To be called on a transaction start. Can have async methods
65
+ */
66
+ onTransactionStart(transaction) {
67
+ var _a, _b;
68
+ if (isNearToNow(transaction.startTimestamp)) {
69
+ // Only if this method is called at or within margin of error to the start timestamp.
70
+ (_a = this.nativeFramesInstrumentation) === null || _a === void 0 ? void 0 : _a.onTransactionStart(transaction);
71
+ (_b = this.stallTrackingInstrumentation) === null || _b === void 0 ? void 0 : _b.onTransactionStart(transaction);
72
+ }
73
+ }
74
+ /**
75
+ * To be called on a transaction finish. Cannot have async methods.
76
+ */
77
+ onTransactionFinish(transaction, endTimestamp) {
78
+ var _a, _b;
79
+ (_a = this.nativeFramesInstrumentation) === null || _a === void 0 ? void 0 : _a.onTransactionFinish(transaction);
80
+ (_b = this.stallTrackingInstrumentation) === null || _b === void 0 ? void 0 : _b.onTransactionFinish(transaction, endTimestamp);
81
+ }
82
+ /**
83
+ * Called by the NativescriptProfiler component on first component mount.
84
+ */
85
+ onAppStartFinish(endTimestamp) {
86
+ this._appStartFinishTimestamp = endTimestamp;
87
+ }
88
+ /**
89
+ * Instruments the app start measurements on the first route transaction.
90
+ * Starts a route transaction if there isn't routing instrumentation.
91
+ */
92
+ async _instrumentAppStart() {
93
+ if (!this.options.enableAppStartTracking || !NATIVE.enableNative) {
94
+ return;
95
+ }
96
+ const appStart = await NATIVE.fetchNativeAppStart();
97
+ if (!appStart || appStart.didFetchAppStart) {
98
+ return;
99
+ }
100
+ if (!this.useAppStartWithProfiler) {
101
+ this._appStartFinishTimestamp = getTimeOriginMilliseconds() / 1000;
102
+ }
103
+ if (this.options.routingInstrumentation) {
104
+ this._awaitingAppStartData = appStart;
105
+ }
106
+ else {
107
+ const appStartTimeSeconds = appStart.appStartTime / 1000;
108
+ const idleTransaction = this._createRouteTransaction({
109
+ name: 'App Start',
110
+ op: 'ui.load',
111
+ startTimestamp: appStartTimeSeconds,
112
+ });
113
+ if (idleTransaction) {
114
+ this._addAppStartData(idleTransaction, appStart);
47
115
  }
48
- return event;
116
+ }
117
+ }
118
+ /**
119
+ * Adds app start measurements and starts a child span on a transaction.
120
+ */
121
+ _addAppStartData(transaction, appStart) {
122
+ if (!this._appStartFinishTimestamp) {
123
+ logger.warn('App start was never finished.');
124
+ return;
125
+ }
126
+ const appStartTimeSeconds = appStart.appStartTime / 1000;
127
+ const appStartMode = appStart.isColdStart ? 'app_start_cold' : 'app_start_warm';
128
+ transaction.startChild({
129
+ description: appStart.isColdStart ? 'Cold App Start' : 'Warm App Start',
130
+ op: appStartMode,
131
+ startTimestamp: appStartTimeSeconds,
132
+ endTimestamp: this._appStartFinishTimestamp,
49
133
  });
134
+ const appStartDurationMilliseconds = this._appStartFinishTimestamp * 1000 - appStart.appStartTime;
135
+ transaction.setMeasurement(appStartMode, appStartDurationMilliseconds);
50
136
  }
51
137
  /** To be called when the route changes, but BEFORE the components of the new route mount. */
52
138
  _onRouteWillChange(context) {
53
- // TODO: Consider more features on route change, one example is setting a tag of what route the user is on
54
139
  return this._createRouteTransaction(context);
55
140
  }
141
+ /**
142
+ * Creates a breadcrumb and sets the current route as a tag.
143
+ */
144
+ _onConfirmRoute(context) {
145
+ var _a;
146
+ (_a = this._getCurrentHub) === null || _a === void 0 ? void 0 : _a.call(this).configureScope((scope) => {
147
+ var _a;
148
+ if (context.data) {
149
+ const contextData = context.data;
150
+ scope.addBreadcrumb({
151
+ category: 'navigation',
152
+ type: 'navigation',
153
+ // We assume that context.name is the name of the route.
154
+ message: `Navigation to ${context.name}`,
155
+ data: {
156
+ from: (_a = contextData.previousRoute) === null || _a === void 0 ? void 0 : _a.name,
157
+ to: contextData.route.name,
158
+ },
159
+ });
160
+ }
161
+ scope.setTag('routing.route.name', context.name);
162
+ });
163
+ }
56
164
  /** Create routing idle transaction. */
57
165
  _createRouteTransaction(context) {
58
166
  if (!this._getCurrentHub) {
59
- logger.warn(`[NSTracing] Did not create ${context.op} transaction because _getCurrentHub is invalid.`);
167
+ logger.warn(`[NativescriptTracing] Did not create ${context.op} transaction because _getCurrentHub is invalid.`);
60
168
  return undefined;
61
169
  }
62
170
  // eslint-disable-next-line @typescript-eslint/unbound-method
63
- const { beforeNavigate, idleTimeout, maxTransactionDuration, } = this.options;
171
+ const { idleTimeout, maxTransactionDuration } = this.options;
64
172
  const expandedContext = Object.assign(Object.assign({}, context), { trimEnd: true });
65
- const modifiedContext = typeof beforeNavigate === 'function'
66
- ? beforeNavigate(expandedContext)
67
- : expandedContext;
68
- if (modifiedContext.sampled === false) {
69
- logger.log(`[NSTracing] Will not send ${context.op} transaction.`);
70
- }
71
173
  const hub = this._getCurrentHub();
72
- const idleTransaction = startIdleTransaction(hub, context, idleTimeout, true);
73
- logger.log(`[NSTracing] Starting ${context.op} transaction on scope`);
174
+ const idleTransaction = startIdleTransaction(hub, expandedContext, idleTimeout, idleTimeout, // BREAKCHANGE: check the correct parameter here
175
+ true);
176
+ this.onTransactionStart(idleTransaction);
177
+ logger.log(`[NativescriptTracing] Starting ${context.op} transaction "${context.name}" on scope`);
178
+ idleTransaction.registerBeforeFinishCallback((transaction, endTimestamp) => {
179
+ this.onTransactionFinish(transaction, endTimestamp);
180
+ });
181
+ idleTransaction.registerBeforeFinishCallback((transaction) => {
182
+ if (this.options.enableAppStartTracking && this._awaitingAppStartData) {
183
+ transaction.startTimestamp =
184
+ this._awaitingAppStartData.appStartTime / 1000;
185
+ transaction.op = 'ui.load';
186
+ this._addAppStartData(transaction, this._awaitingAppStartData);
187
+ this._awaitingAppStartData = undefined;
188
+ }
189
+ });
74
190
  idleTransaction.registerBeforeFinishCallback((transaction, endTimestamp) => {
75
191
  adjustTransactionDuration(maxTransactionDuration, transaction, endTimestamp);
76
192
  });
77
193
  if (this.options.ignoreEmptyBackNavigationTransactions) {
78
194
  idleTransaction.registerBeforeFinishCallback((transaction) => {
79
- if (transaction.data['routing.route.hasBeenSeen'] &&
195
+ var _a, _b;
196
+ if (
197
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
198
+ ((_b = (_a = transaction.data) === null || _a === void 0 ? void 0 : _a.route) === null || _b === void 0 ? void 0 : _b.hasBeenSeen) &&
80
199
  (!transaction.spanRecorder ||
81
200
  transaction.spanRecorder.spans.filter((span) => span.spanId !== transaction.spanId).length === 0)) {
201
+ logger.log('[NativescriptTracing] Not sampling transaction as route has been seen before. Pass ignoreEmptyBackNavigationTransactions = false to disable this feature.');
82
202
  // Route has been seen before and has no child spans.
83
203
  transaction.sampled = false;
84
204
  }
@@ -88,7 +208,7 @@ export class NSTracing {
88
208
  }
89
209
  }
90
210
  /**
91
- * @inheritDoc
92
- */
93
- NSTracing.id = 'NSTracing';
211
+ * @inheritDoc
212
+ */
213
+ NativescriptTracing.id = 'NativescriptTracing';
94
214
  //# sourceMappingURL=nstracing.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nstracing.js","sourceRoot":"","sources":["../../src/tracing/nstracing.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,oCAAoC,EACpC,8BAA8B,EAC9B,oBAAoB,GACvB,MAAM,iBAAiB,CAAC;AAQzB,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,sFAAsF;AACtF,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AA+CpD,MAAM,uBAAuB,mCACtB,oCAAoC,KACvC,WAAW,EAAE,IAAI,EACjB,sBAAsB,EAAE,GAAG,EAC3B,qCAAqC,EAAE,IAAI,GAC9C,CAAC;AAEF;;KAEK;AACL,MAAM,OAAO,SAAS;IAelB,YAAY,UAAqC,EAAE;QAVnD;;WAEG;QACI,SAAI,GAAW,SAAS,CAAC,EAAE,CAAC;QAQ/B,IAAI,CAAC,OAAO,mCACL,uBAAuB,GACvB,OAAO,CACb,CAAC;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,4BAA4B,CACxC,CAAC,WAAW,EAAE,YAAY,EAAE,EAAE;YAC1B,yBAAyB,CACrB,sBAAsB,EACtB,WAAW,EACX,YAAY,CACf,CAAC;QACN,CAAC,CACJ,CAAC;QAEF,IAAI,IAAI,CAAC,OAAO,CAAC,qCAAqC,EAAE;YACpD,eAAe,CAAC,4BAA4B,CAAC,CAAC,WAAW,EAAE,EAAE;;gBACzD;gBACA,sEAAsE;gBAClE,CAAA,MAAA,MAAA,WAAW,CAAC,IAAI,0CAAE,KAAK,0CAAE,WAAW;oBAC9C,CAAC,CAAC,WAAW,CAAC,YAAY;wBACxB,WAAW,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,CACjC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,WAAW,CAAC,MAAM,CAC/C,CAAC,MAAM,KAAK,CAAC,CAAC,EACT;oBACE,MAAM,CAAC,GAAG,CACN,2JAA2J,CAC9J,CAAC;oBACF,qDAAqD;oBACrD,WAAW,CAAC,OAAO,GAAG,KAAK,CAAC;iBAC/B;YACL,CAAC,CAAC,CAAC;SACN;QAED,OAAO,eAAe,CAAC;IAC3B,CAAC;;AAhTD;;EAEC;AACa,sBAAE,GAAW,qBAAqB,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { Hub } from '@sentry/hub';
2
+ import { Transaction, TransactionContext } from '@sentry/types';
3
+ import { BeforeNavigate } from './types';
4
+ export declare type TransactionCreator = (context: TransactionContext) => Transaction | undefined;
5
+ export declare type OnConfirmRoute = (context: TransactionContext) => void;
6
+ export interface RoutingInstrumentationInstance {
7
+ /**
8
+ * Registers a listener that's called on every route change with a `TransactionContext`.
9
+ *
10
+ * Do not overwrite this unless you know what you are doing.
11
+ *
12
+ * @param listener A `RouteListener`
13
+ * @param beforeNavigate BeforeNavigate
14
+ * @param inConfirmRoute OnConfirmRoute
15
+ */
16
+ registerRoutingInstrumentation(listener: TransactionCreator, beforeNavigate: BeforeNavigate, onConfirmRoute: OnConfirmRoute): void;
17
+ /**
18
+ * To be called when the route changes, BEFORE the new route mounts.
19
+ * If this is called after a route mounts the child spans will not be correctly attached.
20
+ *
21
+ * @param context A `TransactionContext` used to initialize the transaction.
22
+ */
23
+ onRouteWillChange(context: TransactionContext): Transaction | undefined;
24
+ }
25
+ /**
26
+ * Base Routing Instrumentation. Can be used by users to manually instrument custom routers.
27
+ * Pass this to the tracing integration, and call `onRouteWillChange` every time before a route changes.
28
+ */
29
+ export declare class RoutingInstrumentation implements RoutingInstrumentationInstance {
30
+ static instrumentationName: string;
31
+ protected _getCurrentHub?: () => Hub;
32
+ protected _beforeNavigate?: BeforeNavigate;
33
+ protected _onConfirmRoute?: OnConfirmRoute;
34
+ protected _tracingListener?: TransactionCreator;
35
+ /** @inheritdoc */
36
+ registerRoutingInstrumentation(listener: TransactionCreator, beforeNavigate: BeforeNavigate, onConfirmRoute: OnConfirmRoute): void;
37
+ /** @inheritdoc */
38
+ onRouteWillChange(context: TransactionContext): Transaction | undefined;
39
+ }
40
+ /**
41
+ * Internal base routing instrumentation where `_onConfirmRoute` is not called in onRouteWillChange
42
+ */
43
+ export declare class InternalRoutingInstrumentation extends RoutingInstrumentation {
44
+ /** @inheritdoc */
45
+ onRouteWillChange(context: TransactionContext): Transaction | undefined;
46
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Base Routing Instrumentation. Can be used by users to manually instrument custom routers.
3
+ * Pass this to the tracing integration, and call `onRouteWillChange` every time before a route changes.
4
+ */
5
+ export class RoutingInstrumentation {
6
+ /** @inheritdoc */
7
+ registerRoutingInstrumentation(listener, beforeNavigate, onConfirmRoute) {
8
+ this._tracingListener = listener;
9
+ this._beforeNavigate = beforeNavigate;
10
+ this._onConfirmRoute = onConfirmRoute;
11
+ }
12
+ /** @inheritdoc */
13
+ onRouteWillChange(context) {
14
+ var _a, _b;
15
+ const transaction = (_a = this._tracingListener) === null || _a === void 0 ? void 0 : _a.call(this, context);
16
+ if (transaction) {
17
+ (_b = this._onConfirmRoute) === null || _b === void 0 ? void 0 : _b.call(this, context);
18
+ }
19
+ return transaction;
20
+ }
21
+ }
22
+ RoutingInstrumentation.instrumentationName = 'base-routing-instrumentation';
23
+ /**
24
+ * Internal base routing instrumentation where `_onConfirmRoute` is not called in onRouteWillChange
25
+ */
26
+ export class InternalRoutingInstrumentation extends RoutingInstrumentation {
27
+ /** @inheritdoc */
28
+ onRouteWillChange(context) {
29
+ var _a;
30
+ return (_a = this._tracingListener) === null || _a === void 0 ? void 0 : _a.call(this, context);
31
+ }
32
+ }
33
+ //# sourceMappingURL=routingInstrumentation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routingInstrumentation.js","sourceRoot":"","sources":["../../src/tracing/routingInstrumentation.ts"],"names":[],"mappings":"AAmCA;;;GAGG;AACH,MAAM,OAAO,sBAAsB;IAQ/B,kBAAkB;IACX,8BAA8B,CACjC,QAA4B,EAC5B,cAA8B,EAC9B,cAA8B;QAE9B,IAAI,CAAC,gBAAgB,GAAG,QAAQ,CAAC;QACjC,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;QACtC,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;IAC1C,CAAC;IAED,kBAAkB;IACX,iBAAiB,CACpB,OAA2B;;QAE3B,MAAM,WAAW,GAAG,MAAA,IAAI,CAAC,gBAAgB,qDAAG,OAAO,CAAC,CAAC;QAErD,IAAI,WAAW,EAAE;YACb,MAAA,IAAI,CAAC,eAAe,qDAAG,OAAO,CAAC,CAAC;SACnC;QAED,OAAO,WAAW,CAAC;IACvB,CAAC;;AA7Ba,0CAAmB,GAAW,8BAA8B,CAAC;AAgC/E;;GAEG;AACH,MAAM,OAAO,8BAA+B,SAAQ,sBAAsB;IACtE,kBAAkB;IACX,iBAAiB,CACpB,OAA2B;;QAE3B,OAAO,MAAA,IAAI,CAAC,gBAAgB,qDAAG,OAAO,CAAC,CAAC;IAC5C,CAAC;CACJ"}
@@ -0,0 +1,92 @@
1
+ import { IdleTransaction, Transaction } from '@sentry/tracing';
2
+ import { MeasurementUnit, Measurements } from '@sentry/types';
3
+ export interface StallMeasurements extends Measurements {
4
+ 'stall_count': {
5
+ value: number;
6
+ unit: MeasurementUnit;
7
+ };
8
+ 'stall_total_time': {
9
+ value: number;
10
+ unit: MeasurementUnit;
11
+ };
12
+ 'stall_longest_time': {
13
+ value: number;
14
+ unit: MeasurementUnit;
15
+ };
16
+ }
17
+ export interface StallTrackingOptions {
18
+ /**
19
+ * How long in milliseconds an event loop iteration can be delayed for before being considered a "stall."
20
+ * @default 100
21
+ */
22
+ minimumStallThreshold: number;
23
+ }
24
+ /**
25
+ * Stall measurement tracker inspired by the `JSEventLoopWatchdog` used internally in React Native:
26
+ * https://github.com/facebook/react-native/blob/006f5afe120c290a37cf6ff896748fbc062bf7ed/Libraries/Interaction/JSEventLoopWatchdog.js
27
+ *
28
+ * However, we modified the interval implementation to instead have a fixed loop timeout interval of `LOOP_TIMEOUT_INTERVAL_MS`.
29
+ * We then would consider that iteration a stall when the total time for that interval to run is greater than `LOOP_TIMEOUT_INTERVAL_MS + minimumStallThreshold`
30
+ */
31
+ export declare class StallTrackingInstrumentation {
32
+ isTracking: boolean;
33
+ private _minimumStallThreshold;
34
+ /** Total amount of time of all stalls that occurred during the current tracking session */
35
+ private _totalStallTime;
36
+ /** Total number of stalls that occurred during the current tracking session */
37
+ private _stallCount;
38
+ /** The last timestamp the iteration ran in milliseconds */
39
+ private _lastIntervalMs;
40
+ private _timeout;
41
+ private _statsByTransaction;
42
+ constructor(options?: StallTrackingOptions);
43
+ /**
44
+ * @inheritDoc
45
+ * Not used for this integration. Instead call `registerTransactionStart` to start tracking.
46
+ */
47
+ setupOnce(): void;
48
+ /**
49
+ * Register a transaction as started. Starts stall tracking if not already running.
50
+ * @returns A finish method that returns the stall measurements.
51
+ */
52
+ onTransactionStart(transaction: Transaction): void;
53
+ /**
54
+ * Logs a transaction as finished.
55
+ * Stops stall tracking if no more transactions are running.
56
+ * @returns The stall measurements
57
+ */
58
+ onTransactionFinish(transaction: Transaction | IdleTransaction, passedEndTimestamp?: number): void;
59
+ /**
60
+ * Logs the finish time of the span for use in `trimEnd: true` transactions.
61
+ */
62
+ private _markSpanFinish;
63
+ /**
64
+ * Get the current stats for a transaction at a given time.
65
+ */
66
+ private _getCurrentStats;
67
+ /**
68
+ * Start tracking stalls
69
+ */
70
+ private _startTracking;
71
+ /**
72
+ * Stops the stall tracking interval and calls reset().
73
+ */
74
+ private _stopTracking;
75
+ /**
76
+ * Will stop tracking if there are no more transactions.
77
+ */
78
+ private _shouldStopTracking;
79
+ /**
80
+ * Clears all the collected stats
81
+ */
82
+ private _reset;
83
+ /**
84
+ * Iteration of the stall tracking interval. Measures how long the timer strayed from its expected time of running, and how
85
+ * long the stall is for.
86
+ */
87
+ private _iteration;
88
+ /**
89
+ * Deletes leaked transactions (Earliest transactions when we have more than MAX_RUNNING_TRANSACTIONS transactions.)
90
+ */
91
+ private _flushLeakedTransactions;
92
+ }