@nativescript-community/sentry 3.1.4 → 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.
- package/CHANGELOG.md +28 -0
- package/README.md +2 -6
- package/client.d.ts +38 -3
- package/client.js +143 -5
- package/client.js.map +1 -1
- package/index.d.ts +7 -11
- package/index.js +28 -12
- package/index.js.map +1 -1
- package/integrations/debugsymbolicator.d.ts +4 -4
- package/integrations/debugsymbolicator.js +11 -22
- package/integrations/debugsymbolicator.js.map +1 -1
- package/integrations/devicecontext.js +22 -5
- package/integrations/devicecontext.js.map +1 -1
- package/integrations/eventorigin.d.ts +7 -7
- package/integrations/eventorigin.js +9 -9
- package/integrations/eventorigin.js.map +1 -1
- package/integrations/nativescripterrorhandlers.d.ts +15 -5
- package/integrations/nativescripterrorhandlers.js +55 -44
- package/integrations/nativescripterrorhandlers.js.map +1 -1
- package/integrations/release.js +10 -8
- package/integrations/release.js.map +1 -1
- package/integrations/sdkinfo.d.ts +4 -1
- package/integrations/sdkinfo.js +17 -10
- package/integrations/sdkinfo.js.map +1 -1
- package/measurement.d.ts +4 -0
- package/measurement.js +50 -0
- package/measurement.js.map +1 -0
- package/measurements.d.ts +4 -0
- package/measurements.js +50 -0
- package/measurements.js.map +1 -0
- package/misc.d.ts +8 -0
- package/misc.js +17 -0
- package/misc.js.map +1 -0
- package/options.d.ts +125 -0
- package/options.js +2 -0
- package/options.js.map +1 -0
- package/package.json +9 -12
- package/platforms/android/buildscript.gradle +6 -2
- package/platforms/android/include.gradle +1 -1
- package/platforms/android/native-api-usage.json +4 -0
- package/platforms/android/sentry.aar +0 -0
- package/platforms/ios/Podfile +1 -1
- package/platforms/ios/src/NSSentry.h +8 -3
- package/platforms/ios/src/NSSentry.m +41 -0
- package/scope.d.ts +1 -45
- package/scope.js +90 -68
- package/scope.js.map +1 -1
- package/sdk.d.ts +27 -3
- package/sdk.js +105 -30
- package/sdk.js.map +1 -1
- package/tracing/index.d.ts +2 -1
- package/tracing/index.js +14 -6
- package/tracing/index.js.map +1 -1
- package/tracing/nativeframes.d.ts +68 -0
- package/tracing/nativeframes.js +175 -0
- package/tracing/nativeframes.js.map +1 -0
- package/tracing/nstracing.d.ts +98 -47
- package/tracing/nstracing.js +164 -44
- package/tracing/nstracing.js.map +1 -1
- package/tracing/routingInstrumentation.d.ts +46 -0
- package/tracing/routingInstrumentation.js +33 -0
- package/tracing/routingInstrumentation.js.map +1 -0
- package/tracing/stalltracking.d.ts +92 -0
- package/tracing/stalltracking.js +258 -0
- package/tracing/stalltracking.js.map +1 -0
- package/tracing/types.d.ts +13 -0
- package/tracing/types.js +2 -0
- package/tracing/types.js.map +1 -0
- package/tracing/utils.d.ts +22 -1
- package/tracing/utils.js +51 -2
- package/tracing/utils.js.map +1 -1
- package/transports/TextEncoder.d.ts +2 -0
- package/transports/TextEncoder.js +12 -0
- package/transports/TextEncoder.js.map +1 -0
- package/transports/native.d.ts +20 -8
- package/transports/native.js +21 -13
- package/transports/native.js.map +1 -1
- package/utils/envelope.d.ts +11 -0
- package/utils/envelope.js +21 -0
- package/utils/envelope.js.map +1 -0
- package/utils/outcome.d.ts +5 -0
- package/utils/outcome.js +19 -0
- package/utils/outcome.js.map +1 -0
- package/utils/safe.d.ts +17 -0
- package/utils/safe.js +46 -0
- package/utils/safe.js.map +1 -0
- package/vendor/buffer/index.d.ts +1 -0
- package/vendor/buffer/index.js +2 -0
- package/vendor/buffer/index.js.map +1 -0
- package/vendor/buffer/utf8ToBytes.d.ts +9 -0
- package/vendor/buffer/utf8ToBytes.js +81 -0
- package/vendor/buffer/utf8ToBytes.js.map +1 -0
- package/vendor/index.d.ts +1 -0
- package/vendor/index.js +2 -0
- package/vendor/index.js.map +1 -0
- package/version.d.ts +2 -1
- package/version.js +2 -1
- package/version.js.map +1 -1
- package/wrapper.android.d.ts +30 -0
- package/wrapper.android.js +952 -0
- package/wrapper.android.js.map +1 -0
- package/wrapper.d.ts +88 -0
- package/wrapper.ios.d.ts +34 -0
- package/wrapper.ios.js +497 -0
- package/wrapper.ios.js.map +1 -0
- package/pnpm-lock.yaml +0 -914
@@ -0,0 +1,258 @@
|
|
1
|
+
import { logger, timestampInSeconds } from '@sentry/utils';
|
2
|
+
/** Margin of error of 20ms */
|
3
|
+
const MARGIN_OF_ERROR_SECONDS = 0.02;
|
4
|
+
/** How long between each iteration in the event loop tracker timeout */
|
5
|
+
const LOOP_TIMEOUT_INTERVAL_MS = 50;
|
6
|
+
/** Limit for how many transactions the stall tracker will track at a time to prevent leaks due to transactions not being finished */
|
7
|
+
const MAX_RUNNING_TRANSACTIONS = 10;
|
8
|
+
/**
|
9
|
+
* Stall measurement tracker inspired by the `JSEventLoopWatchdog` used internally in React Native:
|
10
|
+
* https://github.com/facebook/react-native/blob/006f5afe120c290a37cf6ff896748fbc062bf7ed/Libraries/Interaction/JSEventLoopWatchdog.js
|
11
|
+
*
|
12
|
+
* However, we modified the interval implementation to instead have a fixed loop timeout interval of `LOOP_TIMEOUT_INTERVAL_MS`.
|
13
|
+
* 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`
|
14
|
+
*/
|
15
|
+
export class StallTrackingInstrumentation {
|
16
|
+
constructor(options = { minimumStallThreshold: 50 }) {
|
17
|
+
this.isTracking = false;
|
18
|
+
/** Total amount of time of all stalls that occurred during the current tracking session */
|
19
|
+
this._totalStallTime = 0;
|
20
|
+
/** Total number of stalls that occurred during the current tracking session */
|
21
|
+
this._stallCount = 0;
|
22
|
+
/** The last timestamp the iteration ran in milliseconds */
|
23
|
+
this._lastIntervalMs = 0;
|
24
|
+
this._timeout = null;
|
25
|
+
this._statsByTransaction = new Map();
|
26
|
+
this._minimumStallThreshold = options.minimumStallThreshold;
|
27
|
+
}
|
28
|
+
/**
|
29
|
+
* @inheritDoc
|
30
|
+
* Not used for this integration. Instead call `registerTransactionStart` to start tracking.
|
31
|
+
*/
|
32
|
+
setupOnce() {
|
33
|
+
// Do nothing.
|
34
|
+
}
|
35
|
+
/**
|
36
|
+
* Register a transaction as started. Starts stall tracking if not already running.
|
37
|
+
* @returns A finish method that returns the stall measurements.
|
38
|
+
*/
|
39
|
+
onTransactionStart(transaction) {
|
40
|
+
if (this._statsByTransaction.has(transaction)) {
|
41
|
+
logger.error('[StallTracking] Tried to start stall tracking on a transaction already being tracked. Measurements might be lost.');
|
42
|
+
return;
|
43
|
+
}
|
44
|
+
this._startTracking();
|
45
|
+
this._statsByTransaction.set(transaction, {
|
46
|
+
longestStallTime: 0,
|
47
|
+
atTimestamp: null,
|
48
|
+
atStart: this._getCurrentStats(transaction),
|
49
|
+
});
|
50
|
+
this._flushLeakedTransactions();
|
51
|
+
if (transaction.spanRecorder) {
|
52
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
53
|
+
const originalAdd = transaction.spanRecorder.add;
|
54
|
+
transaction.spanRecorder.add = (span) => {
|
55
|
+
originalAdd.apply(transaction.spanRecorder, [span]);
|
56
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
57
|
+
const originalSpanFinish = span.finish;
|
58
|
+
span.finish = (endTimestamp) => {
|
59
|
+
// We let the span determine its own end timestamp as well in case anything gets changed upstream
|
60
|
+
originalSpanFinish.apply(span, [endTimestamp]);
|
61
|
+
// The span should set a timestamp, so this would be defined.
|
62
|
+
if (span.endTimestamp) {
|
63
|
+
this._markSpanFinish(transaction, span.endTimestamp);
|
64
|
+
}
|
65
|
+
};
|
66
|
+
};
|
67
|
+
}
|
68
|
+
}
|
69
|
+
/**
|
70
|
+
* Logs a transaction as finished.
|
71
|
+
* Stops stall tracking if no more transactions are running.
|
72
|
+
* @returns The stall measurements
|
73
|
+
*/
|
74
|
+
onTransactionFinish(transaction, passedEndTimestamp) {
|
75
|
+
const transactionStats = this._statsByTransaction.get(transaction);
|
76
|
+
if (!transactionStats) {
|
77
|
+
// Transaction has been flushed out somehow, we return null.
|
78
|
+
logger.log('[StallTracking] Stall measurements were not added to transaction due to exceeding the max count.');
|
79
|
+
this._statsByTransaction.delete(transaction);
|
80
|
+
this._shouldStopTracking();
|
81
|
+
return;
|
82
|
+
}
|
83
|
+
const endTimestamp = passedEndTimestamp !== null && passedEndTimestamp !== void 0 ? passedEndTimestamp : transaction.endTimestamp;
|
84
|
+
const spans = transaction.spanRecorder
|
85
|
+
? transaction.spanRecorder.spans
|
86
|
+
: [];
|
87
|
+
const finishedSpanCount = spans.reduce((count, s) => (s !== transaction && s.endTimestamp ? count + 1 : count), 0);
|
88
|
+
const trimEnd = transaction.toContext().trimEnd;
|
89
|
+
const endWillBeTrimmed = trimEnd && finishedSpanCount > 0;
|
90
|
+
/*
|
91
|
+
This is not safe in the case that something changes upstream, but if we're planning to move this over to @sentry/javascript anyways,
|
92
|
+
we can have this temporarily for now.
|
93
|
+
*/
|
94
|
+
const isIdleTransaction = 'activities' in transaction;
|
95
|
+
let statsOnFinish;
|
96
|
+
if (endTimestamp && isIdleTransaction) {
|
97
|
+
/*
|
98
|
+
There is different behavior regarding child spans in a normal transaction and an idle transaction. In normal transactions,
|
99
|
+
the child spans that aren't finished will be dumped, while in an idle transaction they're cancelled and finished.
|
100
|
+
Note: `endTimestamp` will always be defined if this is called on an idle transaction finish. This is because we only instrument
|
101
|
+
idle transactions inside `ReactNativeTracing`, which will pass an `endTimestamp`.
|
102
|
+
*/
|
103
|
+
// There will be cancelled spans, which means that the end won't be trimmed
|
104
|
+
const spansWillBeCancelled = spans.some((s) => s !== transaction &&
|
105
|
+
s.startTimestamp < endTimestamp &&
|
106
|
+
!s.endTimestamp);
|
107
|
+
if (endWillBeTrimmed && !spansWillBeCancelled) {
|
108
|
+
// the last span's timestamp will be used.
|
109
|
+
if (transactionStats.atTimestamp) {
|
110
|
+
statsOnFinish = transactionStats.atTimestamp.stats;
|
111
|
+
}
|
112
|
+
}
|
113
|
+
else {
|
114
|
+
// this endTimestamp will be used.
|
115
|
+
statsOnFinish = this._getCurrentStats(transaction);
|
116
|
+
}
|
117
|
+
}
|
118
|
+
else if (endWillBeTrimmed) {
|
119
|
+
// If `trimEnd` is used, and there is a span to trim to. If there isn't, then the transaction should use `endTimestamp` or generate one.
|
120
|
+
if (transactionStats.atTimestamp) {
|
121
|
+
statsOnFinish = transactionStats.atTimestamp.stats;
|
122
|
+
}
|
123
|
+
}
|
124
|
+
else if (!endTimestamp) {
|
125
|
+
statsOnFinish = this._getCurrentStats(transaction);
|
126
|
+
}
|
127
|
+
this._statsByTransaction.delete(transaction);
|
128
|
+
this._shouldStopTracking();
|
129
|
+
if (!statsOnFinish) {
|
130
|
+
if (typeof endTimestamp !== 'undefined') {
|
131
|
+
logger.log('[StallTracking] Stall measurements not added due to `endTimestamp` being set.');
|
132
|
+
}
|
133
|
+
else if (trimEnd) {
|
134
|
+
logger.log('[StallTracking] Stall measurements not added due to `trimEnd` being set but we could not determine the stall measurements at that time.');
|
135
|
+
}
|
136
|
+
return;
|
137
|
+
}
|
138
|
+
transaction.setMeasurement('stall_count', statsOnFinish.stall_count.value -
|
139
|
+
transactionStats.atStart.stall_count.value, transactionStats.atStart.stall_count.unit);
|
140
|
+
transaction.setMeasurement('stall_total_time', statsOnFinish.stall_total_time.value -
|
141
|
+
transactionStats.atStart.stall_total_time.value, transactionStats.atStart.stall_total_time.unit);
|
142
|
+
transaction.setMeasurement('stall_longest_time', statsOnFinish.stall_longest_time.value, statsOnFinish.stall_longest_time.unit);
|
143
|
+
}
|
144
|
+
/**
|
145
|
+
* Logs the finish time of the span for use in `trimEnd: true` transactions.
|
146
|
+
*/
|
147
|
+
_markSpanFinish(transaction, spanEndTimestamp) {
|
148
|
+
const previousStats = this._statsByTransaction.get(transaction);
|
149
|
+
if (previousStats) {
|
150
|
+
if (Math.abs(timestampInSeconds() - spanEndTimestamp) >
|
151
|
+
MARGIN_OF_ERROR_SECONDS) {
|
152
|
+
logger.log('[StallTracking] Span end not logged due to end timestamp being outside the margin of error from now.');
|
153
|
+
if (previousStats.atTimestamp &&
|
154
|
+
previousStats.atTimestamp.timestamp < spanEndTimestamp) {
|
155
|
+
// We also need to delete the stat for the last span, as the transaction would be trimmed to this span not the last one.
|
156
|
+
this._statsByTransaction.set(transaction, Object.assign(Object.assign({}, previousStats), { atTimestamp: null }));
|
157
|
+
}
|
158
|
+
}
|
159
|
+
else {
|
160
|
+
this._statsByTransaction.set(transaction, Object.assign(Object.assign({}, previousStats), { atTimestamp: {
|
161
|
+
timestamp: spanEndTimestamp,
|
162
|
+
stats: this._getCurrentStats(transaction),
|
163
|
+
} }));
|
164
|
+
}
|
165
|
+
}
|
166
|
+
}
|
167
|
+
/**
|
168
|
+
* Get the current stats for a transaction at a given time.
|
169
|
+
*/
|
170
|
+
_getCurrentStats(transaction) {
|
171
|
+
var _a, _b;
|
172
|
+
return {
|
173
|
+
stall_count: { value: this._stallCount, unit: 'none' },
|
174
|
+
stall_total_time: { value: this._totalStallTime, unit: 'millisecond' },
|
175
|
+
stall_longest_time: {
|
176
|
+
value: (_b = (_a = this._statsByTransaction.get(transaction)) === null || _a === void 0 ? void 0 : _a.longestStallTime) !== null && _b !== void 0 ? _b : 0, unit: 'millisecond'
|
177
|
+
},
|
178
|
+
};
|
179
|
+
}
|
180
|
+
/**
|
181
|
+
* Start tracking stalls
|
182
|
+
*/
|
183
|
+
_startTracking() {
|
184
|
+
if (!this.isTracking) {
|
185
|
+
this.isTracking = true;
|
186
|
+
this._lastIntervalMs = Math.floor(timestampInSeconds() * 1000);
|
187
|
+
this._iteration();
|
188
|
+
}
|
189
|
+
}
|
190
|
+
/**
|
191
|
+
* Stops the stall tracking interval and calls reset().
|
192
|
+
*/
|
193
|
+
_stopTracking() {
|
194
|
+
this.isTracking = false;
|
195
|
+
if (this._timeout !== null) {
|
196
|
+
clearTimeout(this._timeout);
|
197
|
+
this._timeout = null;
|
198
|
+
}
|
199
|
+
this._reset();
|
200
|
+
}
|
201
|
+
/**
|
202
|
+
* Will stop tracking if there are no more transactions.
|
203
|
+
*/
|
204
|
+
_shouldStopTracking() {
|
205
|
+
if (this._statsByTransaction.size === 0) {
|
206
|
+
this._stopTracking();
|
207
|
+
}
|
208
|
+
}
|
209
|
+
/**
|
210
|
+
* Clears all the collected stats
|
211
|
+
*/
|
212
|
+
_reset() {
|
213
|
+
this._stallCount = 0;
|
214
|
+
this._totalStallTime = 0;
|
215
|
+
this._lastIntervalMs = 0;
|
216
|
+
this._statsByTransaction.clear();
|
217
|
+
}
|
218
|
+
/**
|
219
|
+
* Iteration of the stall tracking interval. Measures how long the timer strayed from its expected time of running, and how
|
220
|
+
* long the stall is for.
|
221
|
+
*/
|
222
|
+
_iteration() {
|
223
|
+
var _a;
|
224
|
+
const now = timestampInSeconds() * 1000;
|
225
|
+
const totalTimeTaken = now - this._lastIntervalMs;
|
226
|
+
if (totalTimeTaken >=
|
227
|
+
LOOP_TIMEOUT_INTERVAL_MS + this._minimumStallThreshold) {
|
228
|
+
const stallTime = totalTimeTaken - LOOP_TIMEOUT_INTERVAL_MS;
|
229
|
+
this._stallCount += 1;
|
230
|
+
this._totalStallTime += stallTime;
|
231
|
+
for (const [transaction, value] of this._statsByTransaction.entries()) {
|
232
|
+
const longestStallTime = Math.max((_a = value.longestStallTime) !== null && _a !== void 0 ? _a : 0, stallTime);
|
233
|
+
this._statsByTransaction.set(transaction, Object.assign(Object.assign({}, value), { longestStallTime }));
|
234
|
+
}
|
235
|
+
}
|
236
|
+
this._lastIntervalMs = now;
|
237
|
+
if (this.isTracking) {
|
238
|
+
this._timeout = setTimeout(this._iteration.bind(this), LOOP_TIMEOUT_INTERVAL_MS);
|
239
|
+
}
|
240
|
+
}
|
241
|
+
/**
|
242
|
+
* Deletes leaked transactions (Earliest transactions when we have more than MAX_RUNNING_TRANSACTIONS transactions.)
|
243
|
+
*/
|
244
|
+
_flushLeakedTransactions() {
|
245
|
+
if (this._statsByTransaction.size > MAX_RUNNING_TRANSACTIONS) {
|
246
|
+
let counter = 0;
|
247
|
+
const len = this._statsByTransaction.size - MAX_RUNNING_TRANSACTIONS;
|
248
|
+
const transactions = this._statsByTransaction.keys();
|
249
|
+
for (const t of transactions) {
|
250
|
+
if (counter >= len)
|
251
|
+
break;
|
252
|
+
counter += 1;
|
253
|
+
this._statsByTransaction.delete(t);
|
254
|
+
}
|
255
|
+
}
|
256
|
+
}
|
257
|
+
}
|
258
|
+
//# sourceMappingURL=stalltracking.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"stalltracking.js","sourceRoot":"","sources":["../../src/tracing/stalltracking.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAgB3D,8BAA8B;AAC9B,MAAM,uBAAuB,GAAG,IAAI,CAAC;AACrC,wEAAwE;AACxE,MAAM,wBAAwB,GAAG,EAAE,CAAC;AACpC,qIAAqI;AACrI,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,OAAO,4BAA4B;IA0BrC,YACI,UAAgC,EAAE,qBAAqB,EAAE,EAAE,EAAE;QA1B1D,eAAU,GAAY,KAAK,CAAC;QAInC,2FAA2F;QACnF,oBAAe,GAAW,CAAC,CAAC;QACpC,+EAA+E;QACvE,gBAAW,GAAW,CAAC,CAAC;QAEhC,2DAA2D;QACnD,oBAAe,GAAW,CAAC,CAAC;QAC5B,aAAQ,GAAyC,IAAI,CAAC;QAEtD,wBAAmB,GAUvB,IAAI,GAAG,EAAE,CAAC;QAKV,IAAI,CAAC,sBAAsB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAChE,CAAC;IAED;;;KAGC;IACM,SAAS;QAChB,cAAc;IACd,CAAC;IAED;;;KAGC;IACM,kBAAkB,CAAC,WAAwB;QAC9C,IAAI,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;YAC3C,MAAM,CAAC,KAAK,CACR,mHAAmH,CACtH,CAAC;YAEF,OAAO;SACV;QAED,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,IA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,KACR,gBAAgB,IAClB,CAAC;aACN;SACJ;QAED,IAAI,CAAC,eAAe,GAAG,GAAG,CAAC;QAE3B,IAAI,IAAI,CAAC,UAAU,EAAE;YACjB,IAAI,CAAC,QAAQ,GAAG,UAAU,CACtB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAC1B,wBAAwB,CAC3B,CAAC;SACL;IACL,CAAC;IAED;;KAEC;IACO,wBAAwB;QAC5B,IAAI,IAAI,CAAC,mBAAmB,CAAC,IAAI,GAAG,wBAAwB,EAAE;YAC1D,IAAI,OAAO,GAAG,CAAC,CAAC;YAChB,MAAM,GAAG,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,GAAG,wBAAwB,CAAC;YACrE,MAAM,YAAY,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,EAAE,CAAC;YACrD,KAAK,MAAM,CAAC,IAAI,YAAY,EAAE;gBAC1B,IAAI,OAAO,IAAI,GAAG;oBAAE,MAAM;gBAC1B,OAAO,IAAI,CAAC,CAAC;gBACb,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;aACtC;SACJ;IACL,CAAC;CACJ"}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { TransactionContext } from '@sentry/types';
|
2
|
+
export interface RouteChangeContextData {
|
3
|
+
previousRoute?: {
|
4
|
+
[key: string]: unknown;
|
5
|
+
name: string;
|
6
|
+
} | null;
|
7
|
+
route: {
|
8
|
+
[key: string]: unknown;
|
9
|
+
name: string;
|
10
|
+
hasBeenSeen: boolean;
|
11
|
+
};
|
12
|
+
}
|
13
|
+
export declare type BeforeNavigate = (context: TransactionContext) => TransactionContext;
|
package/tracing/types.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/tracing/types.ts"],"names":[],"mappings":""}
|
package/tracing/utils.d.ts
CHANGED
@@ -1,6 +1,27 @@
|
|
1
|
-
import { IdleTransaction } from '@sentry/tracing';
|
1
|
+
import { IdleTransaction, Span, Transaction } from '@sentry/tracing';
|
2
|
+
import { TransactionContext, TransactionSource } from '@sentry/types';
|
3
|
+
export declare const defaultTransactionSource: TransactionSource;
|
4
|
+
export declare const customTransactionSource: TransactionSource;
|
5
|
+
export declare const getBlankTransactionContext: (name: string) => TransactionContext;
|
6
|
+
/**
|
7
|
+
* A margin of error of 50ms is allowed for the async native bridge call.
|
8
|
+
* Anything larger would reduce the accuracy of our frames measurements.
|
9
|
+
*/
|
10
|
+
export declare const MARGIN_OF_ERROR_SECONDS = 0.05;
|
2
11
|
/**
|
3
12
|
*
|
4
13
|
*/
|
5
14
|
export declare function adjustTransactionDuration(maxDuration: number, // in seconds
|
6
15
|
transaction: IdleTransaction, endTimestamp: number): void;
|
16
|
+
/**
|
17
|
+
* Returns the timestamp where the JS global scope was initialized.
|
18
|
+
*/
|
19
|
+
export declare function getTimeOriginMilliseconds(): number;
|
20
|
+
/**
|
21
|
+
* Calls the callback every time a child span of the transaction is finished.
|
22
|
+
*/
|
23
|
+
export declare function instrumentChildSpanFinish(transaction: Transaction, callback: (span: Span, endTimestamp?: number) => void): void;
|
24
|
+
/**
|
25
|
+
* Determines if the timestamp is now or within the specified margin of error from now.
|
26
|
+
*/
|
27
|
+
export declare function isNearToNow(timestamp: number): boolean;
|
package/tracing/utils.js
CHANGED
@@ -1,4 +1,23 @@
|
|
1
|
-
import {
|
1
|
+
import { timestampInSeconds } from '@sentry/utils';
|
2
|
+
export const defaultTransactionSource = 'component';
|
3
|
+
export const customTransactionSource = 'custom';
|
4
|
+
export const getBlankTransactionContext = (name) => ({
|
5
|
+
name: 'Route Change',
|
6
|
+
op: 'navigation',
|
7
|
+
tags: {
|
8
|
+
'routing.instrumentation': name,
|
9
|
+
},
|
10
|
+
data: {},
|
11
|
+
metadata: {
|
12
|
+
source: defaultTransactionSource,
|
13
|
+
},
|
14
|
+
});
|
15
|
+
/**
|
16
|
+
* A margin of error of 50ms is allowed for the async native bridge call.
|
17
|
+
* Anything larger would reduce the accuracy of our frames measurements.
|
18
|
+
*/
|
19
|
+
export const MARGIN_OF_ERROR_SECONDS = 0.05;
|
20
|
+
const timeOriginMilliseconds = Date.now();
|
2
21
|
/**
|
3
22
|
* Converts from seconds to milliseconds
|
4
23
|
* @param time time in seconds
|
@@ -14,8 +33,38 @@ transaction, endTimestamp) {
|
|
14
33
|
const diff = endTimestamp - transaction.startTimestamp;
|
15
34
|
const isOutdatedTransaction = endTimestamp && (diff > secToMs(maxDuration) || diff < 0);
|
16
35
|
if (isOutdatedTransaction) {
|
17
|
-
transaction.setStatus(
|
36
|
+
transaction.setStatus('deadline_exceeded');
|
18
37
|
transaction.setTag('maxTransactionDurationExceeded', 'true');
|
19
38
|
}
|
20
39
|
}
|
40
|
+
/**
|
41
|
+
* Returns the timestamp where the JS global scope was initialized.
|
42
|
+
*/
|
43
|
+
export function getTimeOriginMilliseconds() {
|
44
|
+
return timeOriginMilliseconds;
|
45
|
+
}
|
46
|
+
/**
|
47
|
+
* Calls the callback every time a child span of the transaction is finished.
|
48
|
+
*/
|
49
|
+
export function instrumentChildSpanFinish(transaction, callback) {
|
50
|
+
if (transaction.spanRecorder) {
|
51
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
52
|
+
const originalAdd = transaction.spanRecorder.add;
|
53
|
+
transaction.spanRecorder.add = (span) => {
|
54
|
+
originalAdd.apply(transaction.spanRecorder, [span]);
|
55
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
56
|
+
const originalSpanFinish = span.finish;
|
57
|
+
span.finish = (endTimestamp) => {
|
58
|
+
originalSpanFinish.apply(span, [endTimestamp]);
|
59
|
+
callback(span, endTimestamp);
|
60
|
+
};
|
61
|
+
};
|
62
|
+
}
|
63
|
+
}
|
64
|
+
/**
|
65
|
+
* Determines if the timestamp is now or within the specified margin of error from now.
|
66
|
+
*/
|
67
|
+
export function isNearToNow(timestamp) {
|
68
|
+
return Math.abs(timestampInSeconds() - timestamp) <= MARGIN_OF_ERROR_SECONDS;
|
69
|
+
}
|
21
70
|
//# sourceMappingURL=utils.js.map
|
package/tracing/utils.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/tracing/utils.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/tracing/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,CAAC,MAAM,wBAAwB,GAAsB,WAAW,CAAC;AACvE,MAAM,CAAC,MAAM,uBAAuB,GAAsB,QAAQ,CAAC;AAEnE,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACtC,IAAY,EACM,EAAE,CAAC,CAAC;IACtB,IAAI,EAAE,cAAc;IACpB,EAAE,EAAE,YAAY;IAChB,IAAI,EAAE;QACF,yBAAyB,EAAE,IAAI;KAClC;IACD,IAAI,EAAE,EAAE;IACR,QAAQ,EAAE;QACN,MAAM,EAAE,wBAAwB;KACnC;CACJ,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAE5C,MAAM,sBAAsB,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;AAE1C;;;GAGG;AACH,SAAS,OAAO,CAAC,IAAY;IACzB,OAAO,IAAI,GAAG,IAAI,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,yBAAyB,CACrC,WAAmB,EAAE,aAAa;AAClC,WAA4B,EAC5B,YAAoB;IAEpB,MAAM,IAAI,GAAG,YAAY,GAAG,WAAW,CAAC,cAAc,CAAC;IACvD,MAAM,qBAAqB,GAC3B,YAAY,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC;IAC1D,IAAI,qBAAqB,EAAE;QACvB,WAAW,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;QAC3C,WAAW,CAAC,MAAM,CAAC,gCAAgC,EAAE,MAAM,CAAC,CAAC;KAChE;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,yBAAyB;IACrC,OAAO,sBAAsB,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,yBAAyB,CACrC,WAAwB,EACxB,QAAqD;IAErD,IAAI,WAAW,CAAC,YAAY,EAAE;QAC9B,6DAA6D;QACzD,MAAM,WAAW,GAAG,WAAW,CAAC,YAAY,CAAC,GAAG,CAAC;QAEjD,WAAW,CAAC,YAAY,CAAC,GAAG,GAAG,CAAC,IAAU,EAAQ,EAAE;YAChD,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;YAEpD,6DAA6D;YAC7D,MAAM,kBAAkB,GAAG,IAAI,CAAC,MAAM,CAAC;YAEvC,IAAI,CAAC,MAAM,GAAG,CAAC,YAAqB,EAAE,EAAE;gBACpC,kBAAkB,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;gBAE/C,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;YACjC,CAAC,CAAC;QACN,CAAC,CAAC;KACL;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,SAAiB;IACzC,OAAO,IAAI,CAAC,GAAG,CAAC,kBAAkB,EAAE,GAAG,SAAS,CAAC,IAAI,uBAAuB,CAAC;AACjF,CAAC"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { utf8ToBytes } from '../vendor';
|
2
|
+
export const makeUtf8TextEncoder = () => {
|
3
|
+
const textEncoder = {
|
4
|
+
encode: (text) =>
|
5
|
+
// const bytes = new Uint8Array(NATIVE.utf8ToBytes(text));
|
6
|
+
// NATIVE.utf8ToBytes(text)
|
7
|
+
new Uint8Array(utf8ToBytes(text)),
|
8
|
+
encoding: 'utf-8',
|
9
|
+
};
|
10
|
+
return textEncoder;
|
11
|
+
};
|
12
|
+
//# sourceMappingURL=TextEncoder.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"TextEncoder.js","sourceRoot":"","sources":["../../src/transports/TextEncoder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAIxC,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAwB,EAAE;IACzD,MAAM,WAAW,GAAG;QAChB,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;QACrB,0DAA0D;QAC1D,2BAA2B;QAC3B,IAAI,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAErC,QAAQ,EAAE,OAAO;KACpB,CAAC;IACF,OAAO,WAAW,CAAC;AACvB,CAAC,CAAC"}
|
package/transports/native.d.ts
CHANGED
@@ -1,15 +1,27 @@
|
|
1
|
-
import {
|
1
|
+
import { BaseTransportOptions, Envelope, Transport } from '@sentry/types';
|
2
2
|
import { PromiseBuffer } from '@sentry/utils';
|
3
|
+
export declare type BaseNativeTransport = BaseTransportOptions;
|
3
4
|
/** Native Transport class implementation */
|
4
5
|
export declare class NativeTransport implements Transport {
|
5
6
|
/** A simple buffer holding all requests. */
|
6
|
-
protected readonly _buffer: PromiseBuffer<
|
7
|
+
protected readonly _buffer: PromiseBuffer<void>;
|
7
8
|
/**
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
* Sends the envelope to the Store endpoint in Sentry.
|
10
|
+
*
|
11
|
+
* @param envelope Envelope that should be sent to Sentry.
|
12
|
+
*/
|
13
|
+
send(envelope: Envelope): PromiseLike<void>;
|
11
14
|
/**
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
+
* Wait for all envelopes to be sent or the timeout to expire, whichever comes first.
|
16
|
+
*
|
17
|
+
* @param timeout Maximum time in ms the transport should wait for envelopes to be flushed. Omitting this parameter will
|
18
|
+
* cause the transport to wait until all events are sent before resolving the promise.
|
19
|
+
* @returns A promise that will resolve with `true` if all events are sent before the timeout, or `false` if there are
|
20
|
+
* still events in the queue when the timeout is reached.
|
21
|
+
*/
|
22
|
+
flush(timeout?: number): PromiseLike<boolean>;
|
15
23
|
}
|
24
|
+
/**
|
25
|
+
* Creates a Native Transport.
|
26
|
+
*/
|
27
|
+
export declare function makeNativescriptTransport(): NativeTransport;
|
package/transports/native.js
CHANGED
@@ -1,25 +1,33 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
1
|
+
import { makePromiseBuffer } from '@sentry/utils';
|
2
|
+
import { NATIVE } from '../wrapper';
|
3
3
|
/** Native Transport class implementation */
|
4
4
|
export class NativeTransport {
|
5
5
|
constructor() {
|
6
6
|
/** A simple buffer holding all requests. */
|
7
|
-
this._buffer =
|
7
|
+
this._buffer = makePromiseBuffer(30);
|
8
8
|
}
|
9
9
|
/**
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
return this._buffer.add(() => NSSentry.sendEvent(event));
|
10
|
+
* Sends the envelope to the Store endpoint in Sentry.
|
11
|
+
*
|
12
|
+
* @param envelope Envelope that should be sent to Sentry.
|
13
|
+
*/
|
14
|
+
send(envelope) {
|
15
|
+
return this._buffer.add(() => NATIVE.sendEnvelope(envelope));
|
17
16
|
}
|
18
17
|
/**
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
* Wait for all envelopes to be sent or the timeout to expire, whichever comes first.
|
19
|
+
*
|
20
|
+
* @param timeout Maximum time in ms the transport should wait for envelopes to be flushed. Omitting this parameter will
|
21
|
+
* cause the transport to wait until all events are sent before resolving the promise.
|
22
|
+
* @returns A promise that will resolve with `true` if all events are sent before the timeout, or `false` if there are
|
23
|
+
* still events in the queue when the timeout is reached.
|
24
|
+
*/
|
25
|
+
flush(timeout) {
|
22
26
|
return this._buffer.drain(timeout);
|
23
27
|
}
|
24
28
|
}
|
29
|
+
/**
|
30
|
+
* Creates a Native Transport.
|
31
|
+
*/
|
32
|
+
export function makeNativescriptTransport() { return new NativeTransport(); }
|
25
33
|
//# sourceMappingURL=native.js.map
|
package/transports/native.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"native.js","sourceRoot":"","sources":["../../src/transports/native.ts"],"names":[],"mappings":"AACA,OAAO,
|
1
|
+
{"version":3,"file":"native.js","sourceRoot":"","sources":["../../src/transports/native.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEjE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAIpC,4CAA4C;AAC5C,MAAM,OAAO,eAAe;IAA5B;QACI,4CAA4C;QACzB,YAAO,GAAwB,iBAAiB,CAAC,EAAE,CAAC,CAAC;IAsB5E,CAAC;IApBG;;;;KAIC;IACM,IAAI,CAAC,QAAkB;QAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;IACjE,CAAC;IAED;;;;;;;KAOC;IACM,KAAK,CAAC,OAAgB;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,UAAU,yBAAyB,KAAsB,OAAO,IAAI,eAAe,EAAE,CAAC,CAAC,CAAC"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { DsnComponents, EventEnvelope, SdkMetadata, UserFeedback } from '@sentry/types';
|
2
|
+
export declare const header = 0;
|
3
|
+
export declare const items = 1;
|
4
|
+
/**
|
5
|
+
* Creates an envelope from a user feedback.
|
6
|
+
*/
|
7
|
+
export declare function createUserFeedbackEnvelope(feedback: UserFeedback, { metadata, tunnel, dsn, }: {
|
8
|
+
metadata: SdkMetadata | undefined;
|
9
|
+
tunnel: string | undefined;
|
10
|
+
dsn: DsnComponents | undefined;
|
11
|
+
}): EventEnvelope;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { createEnvelope, dsnToString } from '@sentry/utils';
|
2
|
+
export const header = 0;
|
3
|
+
export const items = 1;
|
4
|
+
/**
|
5
|
+
* Creates an envelope from a user feedback.
|
6
|
+
*/
|
7
|
+
export function createUserFeedbackEnvelope(feedback, { metadata, tunnel, dsn, }) {
|
8
|
+
const headers = Object.assign(Object.assign({ event_id: feedback.event_id, sent_at: new Date().toISOString() }, (metadata && metadata.sdk && { sdk: {
|
9
|
+
name: metadata.sdk.name,
|
10
|
+
version: metadata.sdk.version,
|
11
|
+
} })), (!!tunnel && !!dsn && { dsn: dsnToString(dsn) }));
|
12
|
+
const item = createUserFeedbackEnvelopeItem(feedback);
|
13
|
+
return createEnvelope(headers, [item]);
|
14
|
+
}
|
15
|
+
function createUserFeedbackEnvelopeItem(feedback) {
|
16
|
+
const feedbackHeaders = {
|
17
|
+
type: 'user_report',
|
18
|
+
};
|
19
|
+
return [feedbackHeaders, feedback];
|
20
|
+
}
|
21
|
+
//# sourceMappingURL=envelope.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"envelope.js","sourceRoot":"","sources":["../../src/utils/envelope.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5D,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAC;AACxB,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC;AAEvB;;KAEK;AACL,MAAM,UAAU,0BAA0B,CACtC,QAAsB,EACtB,EACI,QAAQ,EACR,MAAM,EACN,GAAG,GAKN;IAED,MAAM,OAAO,iCACT,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAC3B,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,IAC9B,CAAC,QAAQ,IAAI,QAAQ,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;YACnC,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,IAAI;YACvB,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO;SAChC,EAAC,CAAC,GACA,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CACtD,CAAC;IACF,MAAM,IAAI,GAAG,8BAA8B,CAAC,QAAQ,CAAC,CAAC;IAEtD,OAAO,cAAc,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,8BAA8B,CACnC,QAAsB;IAEtB,MAAM,eAAe,GAAwB;QACzC,IAAI,EAAE,aAAa;KACtB,CAAC;IACF,OAAO,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;AACvC,CAAC"}
|
package/utils/outcome.js
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
/**
|
2
|
+
* Merges buffer with new outcomes.
|
3
|
+
*/
|
4
|
+
export function mergeOutcomes(...merge) {
|
5
|
+
const map = new Map();
|
6
|
+
const process = (outcome) => {
|
7
|
+
const key = `${outcome.reason}:${outcome.category}`;
|
8
|
+
const existing = map.get(key);
|
9
|
+
if (existing) {
|
10
|
+
existing.quantity += outcome.quantity;
|
11
|
+
}
|
12
|
+
else {
|
13
|
+
map.set(key, outcome);
|
14
|
+
}
|
15
|
+
};
|
16
|
+
merge.forEach((outcomes) => outcomes.forEach(process));
|
17
|
+
return [...map.values()];
|
18
|
+
}
|
19
|
+
//# sourceMappingURL=outcome.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"outcome.js","sourceRoot":"","sources":["../../src/utils/outcome.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,GAAG,KAAkB;IAC/C,MAAM,GAAG,GAAG,IAAI,GAAG,EAAmB,CAAC;IAEvC,MAAM,OAAO,GAAG,CAAC,OAAgB,EAAQ,EAAE;QACvC,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACpD,MAAM,QAAQ,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC9B,IAAI,QAAQ,EAAE;YACV,QAAQ,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC;SACzC;aAAM;YACH,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;SACzB;IACL,CAAC,CAAC;IAEF,KAAK,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAEvD,OAAO,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;AAC7B,CAAC"}
|
package/utils/safe.d.ts
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
import { NativescriptOptions } from '../options';
|
2
|
+
declare type DangerTypesWithoutCallSignature = Object | null | undefined;
|
3
|
+
/**
|
4
|
+
* Returns callback factory wrapped with try/catch
|
5
|
+
* or the original passed value is it's not a function.
|
6
|
+
*
|
7
|
+
* If the factory fails original data are returned as it.
|
8
|
+
* They might be partially modified by the failed function.
|
9
|
+
*/
|
10
|
+
export declare function safeFactory<A extends [R, ...unknown[]], R, T extends DangerTypesWithoutCallSignature>(danger: ((...args: A) => R) | T, options?: {
|
11
|
+
loggerMessage?: string;
|
12
|
+
}): ((...args: A) => R) | T;
|
13
|
+
/**
|
14
|
+
* Returns sage tracesSampler that returns 0 if the original failed.
|
15
|
+
*/
|
16
|
+
export declare function safeTracesSampler(tracesSampler: NativescriptOptions['tracesSampler']): NativescriptOptions['tracesSampler'];
|
17
|
+
export {};
|
package/utils/safe.js
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
import { logger } from '@sentry/utils';
|
2
|
+
/**
|
3
|
+
* Returns callback factory wrapped with try/catch
|
4
|
+
* or the original passed value is it's not a function.
|
5
|
+
*
|
6
|
+
* If the factory fails original data are returned as it.
|
7
|
+
* They might be partially modified by the failed function.
|
8
|
+
*/
|
9
|
+
export function safeFactory(danger, options = {}) {
|
10
|
+
if (typeof danger === 'function') {
|
11
|
+
return (...args) => {
|
12
|
+
try {
|
13
|
+
return danger(...args);
|
14
|
+
}
|
15
|
+
catch (error) {
|
16
|
+
logger.error(options.loggerMessage
|
17
|
+
? options.loggerMessage
|
18
|
+
: `The ${danger.name} callback threw an error`, error);
|
19
|
+
return args[0];
|
20
|
+
}
|
21
|
+
};
|
22
|
+
}
|
23
|
+
else {
|
24
|
+
return danger;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
/**
|
28
|
+
* Returns sage tracesSampler that returns 0 if the original failed.
|
29
|
+
*/
|
30
|
+
export function safeTracesSampler(tracesSampler) {
|
31
|
+
if (tracesSampler) {
|
32
|
+
return (...args) => {
|
33
|
+
try {
|
34
|
+
return tracesSampler(...args);
|
35
|
+
}
|
36
|
+
catch (error) {
|
37
|
+
logger.error('The tracesSampler callback threw an error', error);
|
38
|
+
return 0;
|
39
|
+
}
|
40
|
+
};
|
41
|
+
}
|
42
|
+
else {
|
43
|
+
return tracesSampler;
|
44
|
+
}
|
45
|
+
}
|
46
|
+
//# sourceMappingURL=safe.js.map
|