@sentry/browser 6.17.0-beta.0 → 6.17.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 (49) hide show
  1. package/build/bundle.es6.js +76 -116
  2. package/build/bundle.es6.js.map +1 -1
  3. package/build/bundle.es6.min.js +2 -2
  4. package/build/bundle.es6.min.js.map +1 -1
  5. package/build/bundle.js +77 -102
  6. package/build/bundle.js.map +1 -1
  7. package/build/bundle.min.js +2 -2
  8. package/build/bundle.min.js.map +1 -1
  9. package/dist/backend.d.ts +2 -2
  10. package/dist/backend.d.ts.map +1 -1
  11. package/dist/backend.js +2 -1
  12. package/dist/backend.js.map +1 -1
  13. package/dist/eventbuilder.d.ts +4 -4
  14. package/dist/eventbuilder.d.ts.map +1 -1
  15. package/dist/eventbuilder.js +8 -7
  16. package/dist/eventbuilder.js.map +1 -1
  17. package/dist/exports.d.ts +1 -1
  18. package/dist/exports.d.ts.map +1 -1
  19. package/dist/exports.js +2 -0
  20. package/dist/exports.js.map +1 -1
  21. package/dist/integrations/breadcrumbs.d.ts.map +1 -1
  22. package/dist/integrations/breadcrumbs.js +2 -1
  23. package/dist/integrations/breadcrumbs.js.map +1 -1
  24. package/dist/integrations/globalhandlers.d.ts.map +1 -1
  25. package/dist/integrations/globalhandlers.js +4 -3
  26. package/dist/integrations/globalhandlers.js.map +1 -1
  27. package/dist/transports/fetch.js +3 -3
  28. package/dist/transports/fetch.js.map +1 -1
  29. package/esm/backend.d.ts +2 -2
  30. package/esm/backend.d.ts.map +1 -1
  31. package/esm/backend.js +2 -1
  32. package/esm/backend.js.map +1 -1
  33. package/esm/eventbuilder.d.ts +4 -4
  34. package/esm/eventbuilder.d.ts.map +1 -1
  35. package/esm/eventbuilder.js +8 -7
  36. package/esm/eventbuilder.js.map +1 -1
  37. package/esm/exports.d.ts +1 -1
  38. package/esm/exports.d.ts.map +1 -1
  39. package/esm/exports.js +1 -0
  40. package/esm/exports.js.map +1 -1
  41. package/esm/integrations/breadcrumbs.d.ts.map +1 -1
  42. package/esm/integrations/breadcrumbs.js +2 -1
  43. package/esm/integrations/breadcrumbs.js.map +1 -1
  44. package/esm/integrations/globalhandlers.d.ts.map +1 -1
  45. package/esm/integrations/globalhandlers.js +4 -3
  46. package/esm/integrations/globalhandlers.js.map +1 -1
  47. package/esm/transports/fetch.js +3 -3
  48. package/esm/transports/fetch.js.map +1 -1
  49. package/package.json +4 -4
package/build/bundle.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @sentry/browser 6.17.0-beta.0 (2a9a3d4) | https://github.com/getsentry/sentry-javascript */
1
+ /*! @sentry/browser 6.17.0 (ad2f4ad) | https://github.com/getsentry/sentry-javascript */
2
2
  var Sentry = (function (exports) {
3
3
  /*! *****************************************************************************
4
4
  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -40,16 +40,6 @@ var Sentry = (function (exports) {
40
40
  return __assign.apply(this, arguments);
41
41
  };
42
42
 
43
- function __rest(s, e) {
44
- var t = {};
45
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
46
- t[p] = s[p];
47
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
48
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
49
- t[p[i]] = s[p[i]];
50
- return t;
51
- }
52
-
53
43
  function __values(o) {
54
44
  var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
55
45
  if (m) return m.call(o);
@@ -84,6 +74,27 @@ var Sentry = (function (exports) {
84
74
  return ar;
85
75
  }
86
76
 
77
+ /**
78
+ * TODO(v7): Remove this enum and replace with SeverityLevel
79
+ */
80
+ (function (Severity) {
81
+ /** JSDoc */
82
+ Severity["Fatal"] = "fatal";
83
+ /** JSDoc */
84
+ Severity["Error"] = "error";
85
+ /** JSDoc */
86
+ Severity["Warning"] = "warning";
87
+ /** JSDoc */
88
+ Severity["Log"] = "log";
89
+ /** JSDoc */
90
+ Severity["Info"] = "info";
91
+ /** JSDoc */
92
+ Severity["Debug"] = "debug";
93
+ /** JSDoc */
94
+ Severity["Critical"] = "critical";
95
+ })(exports.Severity || (exports.Severity = {}));
96
+ var SeverityLevels = ['fatal', 'error', 'warning', 'log', 'info', 'debug', 'critical'];
97
+
87
98
  /**
88
99
  * Consumes the promise and logs the error when it rejects.
89
100
  * @param promise A promise to forget.
@@ -235,7 +246,7 @@ var Sentry = (function (exports) {
235
246
  return isBuiltin(wat, 'String');
236
247
  }
237
248
  /**
238
- * Checks whether given value's is a primitive (undefined, null, number, boolean, string, bigint, symbol)
249
+ * Checks whether given value is a primitive (undefined, null, number, boolean, string, bigint, symbol)
239
250
  * {@link isPrimitive}.
240
251
  *
241
252
  * @param wat A value to be checked.
@@ -483,7 +494,7 @@ var Sentry = (function (exports) {
483
494
  function dsnFromString(str) {
484
495
  var match = DSN_REGEX.exec(str);
485
496
  if (!match) {
486
- throw new SentryError('Invalid Dsn');
497
+ throw new SentryError("Invalid Sentry Dsn: " + str);
487
498
  }
488
499
  var _a = __read(match.slice(1), 6), protocol = _a[0], publicKey = _a[1], _b = _a[2], pass = _b === void 0 ? '' : _b, host = _a[3], _c = _a[4], port = _c === void 0 ? '' : _c, lastPath = _a[5];
489
500
  var path = '';
@@ -525,17 +536,17 @@ var Sentry = (function (exports) {
525
536
  var requiredComponents = ['protocol', 'publicKey', 'host', 'projectId'];
526
537
  requiredComponents.forEach(function (component) {
527
538
  if (!dsn[component]) {
528
- throw new SentryError("Invalid Dsn: " + component + " missing");
539
+ throw new SentryError("Invalid Sentry Dsn: " + component + " missing");
529
540
  }
530
541
  });
531
542
  if (!projectId.match(/^\d+$/)) {
532
- throw new SentryError("Invalid Dsn: Invalid projectId " + projectId);
543
+ throw new SentryError("Invalid Sentry Dsn: Invalid projectId " + projectId);
533
544
  }
534
545
  if (!isValidProtocol(protocol)) {
535
- throw new SentryError("Invalid Dsn: Invalid protocol " + protocol);
546
+ throw new SentryError("Invalid Sentry Dsn: Invalid protocol " + protocol);
536
547
  }
537
548
  if (port && isNaN(parseInt(port, 10))) {
538
- throw new SentryError("Invalid Dsn: Invalid port " + port);
549
+ throw new SentryError("Invalid Sentry Dsn: Invalid port " + port);
539
550
  }
540
551
  return true;
541
552
  }
@@ -999,7 +1010,7 @@ var Sentry = (function (exports) {
999
1010
  function walk(key, value, depth, memo) {
1000
1011
  if (depth === void 0) { depth = +Infinity; }
1001
1012
  if (memo === void 0) { memo = memoBuilder(); }
1002
- // If we reach the maximum depth, serialize whatever has left
1013
+ // If we reach the maximum depth, serialize whatever is left
1003
1014
  if (depth === 0) {
1004
1015
  return serializeValue(value);
1005
1016
  }
@@ -1009,12 +1020,13 @@ var Sentry = (function (exports) {
1009
1020
  return value.toJSON();
1010
1021
  }
1011
1022
  /* eslint-enable @typescript-eslint/no-unsafe-member-access */
1012
- // If normalized value is a primitive, there are no branches left to walk, so we can just bail out, as theres no point in going down that branch any further
1023
+ // If normalized value is a primitive, there are no branches left to walk, so bail out
1013
1024
  var normalized = normalizeValue(value, key);
1014
1025
  if (isPrimitive(normalized)) {
1015
1026
  return normalized;
1016
1027
  }
1017
- // Create source that we will use for next itterations, either objectified error object (Error type with extracted keys:value pairs) or the input itself
1028
+ // Create source that we will use for the next iteration. It will either be an objectified error object (`Error` type
1029
+ // with extracted key:value pairs) or the input itself.
1018
1030
  var source = getWalkSource(value);
1019
1031
  // Create an accumulator that will act as a parent for all future itterations of that branch
1020
1032
  var acc = Array.isArray(value) ? [] : {};
@@ -1191,9 +1203,9 @@ var Sentry = (function (exports) {
1191
1203
  * @returns Answer to the given question.
1192
1204
  */
1193
1205
  function supportsReferrerPolicy() {
1194
- // Despite all stars in the sky saying that Edge supports old draft syntax, aka 'never', 'always', 'origin' and 'default
1195
- // https://caniuse.com/#feat=referrer-policy
1196
- // It doesn't. And it throw exception instead of ignoring this parameter...
1206
+ // Despite all stars in the sky saying that Edge supports old draft syntax, aka 'never', 'always', 'origin' and 'default'
1207
+ // (see https://caniuse.com/#feat=referrer-policy),
1208
+ // it doesn't. And it throws an exception instead of ignoring this parameter...
1197
1209
  // REF: https://github.com/getsentry/raven-js/issues/1233
1198
1210
  if (!supportsFetch()) {
1199
1211
  return false;
@@ -1397,9 +1409,6 @@ var Sentry = (function (exports) {
1397
1409
  if (!('XMLHttpRequest' in global$2)) {
1398
1410
  return;
1399
1411
  }
1400
- // Poor man's implementation of ES6 `Map`, tracking and keeping in sync key and value separately.
1401
- var requestKeys = [];
1402
- var requestValues = [];
1403
1412
  var xhrproto = XMLHttpRequest.prototype;
1404
1413
  fill(xhrproto, 'open', function (originalOpen) {
1405
1414
  return function () {
@@ -1430,20 +1439,6 @@ var Sentry = (function (exports) {
1430
1439
  catch (e) {
1431
1440
  /* do nothing */
1432
1441
  }
1433
- try {
1434
- var requestPos = requestKeys.indexOf(xhr);
1435
- if (requestPos !== -1) {
1436
- // Make sure to pop both key and value to keep it in sync.
1437
- requestKeys.splice(requestPos);
1438
- var args_1 = requestValues.splice(requestPos)[0];
1439
- if (args_1[0] !== undefined) {
1440
- xhrInfo.body = args_1[0];
1441
- }
1442
- }
1443
- }
1444
- catch (e) {
1445
- /* do nothing */
1446
- }
1447
1442
  triggerHandlers('xhr', {
1448
1443
  args: args,
1449
1444
  endTimestamp: Date.now(),
@@ -1476,8 +1471,9 @@ var Sentry = (function (exports) {
1476
1471
  for (var _i = 0; _i < arguments.length; _i++) {
1477
1472
  args[_i] = arguments[_i];
1478
1473
  }
1479
- requestKeys.push(this);
1480
- requestValues.push(args);
1474
+ if (this.__sentry_xhr__ && args[0] !== undefined) {
1475
+ this.__sentry_xhr__.body = args[0];
1476
+ }
1481
1477
  triggerHandlers('xhr', {
1482
1478
  args: args,
1483
1479
  startTimestamp: Date.now(),
@@ -2179,28 +2175,6 @@ var Sentry = (function (exports) {
2179
2175
  };
2180
2176
  }
2181
2177
 
2182
- /** JSDoc
2183
- * @deprecated Use string literals - if you require type casting, cast to SeverityLevel type
2184
- */
2185
- var Severity;
2186
- (function (Severity) {
2187
- /** JSDoc */
2188
- Severity["Fatal"] = "fatal";
2189
- /** JSDoc */
2190
- Severity["Error"] = "error";
2191
- /** JSDoc */
2192
- Severity["Warning"] = "warning";
2193
- /** JSDoc */
2194
- Severity["Log"] = "log";
2195
- /** JSDoc */
2196
- Severity["Info"] = "info";
2197
- /** JSDoc */
2198
- Severity["Debug"] = "debug";
2199
- /** JSDoc */
2200
- Severity["Critical"] = "critical";
2201
- })(Severity || (Severity = {}));
2202
- var SeverityLevels = ['fatal', 'error', 'warning', 'log', 'info', 'debug', 'critical'];
2203
-
2204
2178
  function isSupportedSeverity(level) {
2205
2179
  return SeverityLevels.indexOf(level) !== -1;
2206
2180
  }
@@ -2212,11 +2186,11 @@ var Sentry = (function (exports) {
2212
2186
  */
2213
2187
  function severityFromString(level) {
2214
2188
  if (level === 'warn')
2215
- return 'warning';
2189
+ return exports.Severity.Warning;
2216
2190
  if (isSupportedSeverity(level)) {
2217
2191
  return level;
2218
2192
  }
2219
- return 'log';
2193
+ return exports.Severity.Log;
2220
2194
  }
2221
2195
 
2222
2196
  /**
@@ -2397,6 +2371,11 @@ var Sentry = (function (exports) {
2397
2371
  this._extra = {};
2398
2372
  /** Contexts */
2399
2373
  this._contexts = {};
2374
+ /**
2375
+ * A place to stash data which is needed at some point in the SDK's event processing pipeline but which shouldn't get
2376
+ * sent to Sentry
2377
+ */
2378
+ this._sdkProcessingMetadata = {};
2400
2379
  }
2401
2380
  /**
2402
2381
  * Inherit values from the parent scope.
@@ -2562,18 +2541,10 @@ var Sentry = (function (exports) {
2562
2541
  * @inheritDoc
2563
2542
  */
2564
2543
  Scope.prototype.getTransaction = function () {
2565
- // often, this span will be a transaction, but it's not guaranteed to be
2544
+ // Often, this span (if it exists at all) will be a transaction, but it's not guaranteed to be. Regardless, it will
2545
+ // have a pointer to the currently-active transaction.
2566
2546
  var span = this.getSpan();
2567
- // try it the new way first
2568
- if (span && span.transaction) {
2569
- return span.transaction;
2570
- }
2571
- // fallback to the old way (known bug: this only finds transactions with sampled = true)
2572
- if (span && span.spanRecorder && span.spanRecorder.spans[0]) {
2573
- return span.spanRecorder.spans[0];
2574
- }
2575
- // neither way found a transaction
2576
- return undefined;
2547
+ return span && span.transaction;
2577
2548
  };
2578
2549
  /**
2579
2550
  * @inheritDoc
@@ -2723,8 +2694,16 @@ var Sentry = (function (exports) {
2723
2694
  this._applyFingerprint(event);
2724
2695
  event.breadcrumbs = __spread((event.breadcrumbs || []), this._breadcrumbs);
2725
2696
  event.breadcrumbs = event.breadcrumbs.length > 0 ? event.breadcrumbs : undefined;
2697
+ event.sdkProcessingMetadata = this._sdkProcessingMetadata;
2726
2698
  return this._notifyEventProcessors(__spread(getGlobalEventProcessors(), this._eventProcessors), event, hint);
2727
2699
  };
2700
+ /**
2701
+ * Add data which will be accessible during event processing but won't get sent to Sentry
2702
+ */
2703
+ Scope.prototype.setSDKProcessingMetadata = function (newData) {
2704
+ this._sdkProcessingMetadata = __assign(__assign({}, this._sdkProcessingMetadata), newData);
2705
+ return this;
2706
+ };
2728
2707
  /**
2729
2708
  * This will be called after {@link applyToEvent} is finished.
2730
2709
  */
@@ -3468,7 +3447,7 @@ var Sentry = (function (exports) {
3468
3447
  * Captures a message event and sends it to Sentry.
3469
3448
  *
3470
3449
  * @param message The message to send to Sentry.
3471
- * @param SeverityLevel Define the level of the message.
3450
+ * @param Severity Define the level of the message.
3472
3451
  * @returns The generated eventId.
3473
3452
  */
3474
3453
  function captureMessage(message, captureContext) {
@@ -4388,14 +4367,10 @@ var Sentry = (function (exports) {
4388
4367
  var sdkInfo = getSdkMetadataForEnvelopeHeader(api);
4389
4368
  var eventType = event.type || 'event';
4390
4369
  var useEnvelope = eventType === 'transaction' || !!api.tunnel;
4391
- var _a = event.debug_meta || {}, transactionSampling = _a.transactionSampling, metadata = __rest(_a, ["transactionSampling"]);
4392
- var _b = transactionSampling || {}, samplingMethod = _b.method, sampleRate = _b.rate;
4393
- if (Object.keys(metadata).length === 0) {
4394
- delete event.debug_meta;
4395
- }
4396
- else {
4397
- event.debug_meta = metadata;
4398
- }
4370
+ var transactionSampling = (event.sdkProcessingMetadata || {}).transactionSampling;
4371
+ var _a = transactionSampling || {}, samplingMethod = _a.method, sampleRate = _a.rate;
4372
+ // prevent this data from being sent to sentry
4373
+ delete event.sdkProcessingMetadata;
4399
4374
  var req = {
4400
4375
  body: JSON.stringify(sdkInfo ? enhanceEventWithSdkInfo(event, api.metadata.sdk) : event),
4401
4376
  type: eventType,
@@ -4446,7 +4421,7 @@ var Sentry = (function (exports) {
4446
4421
  hub.bindClient(client);
4447
4422
  }
4448
4423
 
4449
- var SDK_VERSION = '6.17.0-beta.0';
4424
+ var SDK_VERSION = '6.17.0';
4450
4425
 
4451
4426
  var originalFunctionToString;
4452
4427
  /** Patch toString calls to return proper name for wrapped functions */
@@ -5014,7 +4989,7 @@ var Sentry = (function (exports) {
5014
4989
  }
5015
4990
 
5016
4991
  /**
5017
- * Builds and Event from a Exception
4992
+ * Creates an {@link Event} from all inputs to `captureException` and non-primitive inputs to `captureMessage`.
5018
4993
  * @hidden
5019
4994
  */
5020
4995
  function eventFromException(options, exception, hint) {
@@ -5023,7 +4998,7 @@ var Sentry = (function (exports) {
5023
4998
  attachStacktrace: options.attachStacktrace,
5024
4999
  });
5025
5000
  addExceptionMechanism(event); // defaults to { type: 'generic', handled: true }
5026
- event.level = 'error';
5001
+ event.level = exports.Severity.Error;
5027
5002
  if (hint && hint.event_id) {
5028
5003
  event.event_id = hint.event_id;
5029
5004
  }
@@ -5034,7 +5009,7 @@ var Sentry = (function (exports) {
5034
5009
  * @hidden
5035
5010
  */
5036
5011
  function eventFromMessage(options, message, level, hint) {
5037
- if (level === void 0) { level = 'info'; }
5012
+ if (level === void 0) { level = exports.Severity.Info; }
5038
5013
  var syntheticException = (hint && hint.syntheticException) || undefined;
5039
5014
  var event = eventFromString(message, syntheticException, {
5040
5015
  attachStacktrace: options.attachStacktrace,
@@ -5088,11 +5063,11 @@ var Sentry = (function (exports) {
5088
5063
  return event;
5089
5064
  }
5090
5065
  if (isPlainObject(exception) || isEvent(exception)) {
5091
- // If it is plain Object or Event, serialize it manually and extract options
5092
- // This will allow us to group events based on top-level keys
5093
- // which is much better than creating new group when any key/value change
5066
+ // If it's a plain object or an instance of `Event` (the built-in JS kind, not this SDK's `Event` type), serialize
5067
+ // it manually. This will allow us to group events based on top-level keys which is much better than creating a new
5068
+ // group on any key/value change.
5094
5069
  var objectException = exception;
5095
- event = eventFromPlainObject(objectException, syntheticException, options.rejection);
5070
+ event = eventFromPlainObject(objectException, syntheticException, options.isRejection);
5096
5071
  addExceptionMechanism(event, {
5097
5072
  synthetic: true,
5098
5073
  });
@@ -5448,9 +5423,9 @@ var Sentry = (function (exports) {
5448
5423
  var options = {
5449
5424
  body: sentryRequest.body,
5450
5425
  method: 'POST',
5451
- // Despite all stars in the sky saying that Edge supports old draft syntax, aka 'never', 'always', 'origin' and 'default
5452
- // https://caniuse.com/#feat=referrer-policy
5453
- // It doesn't. And it throw exception instead of ignoring this parameter...
5426
+ // Despite all stars in the sky saying that Edge supports old draft syntax, aka 'never', 'always', 'origin' and 'default'
5427
+ // (see https://caniuse.com/#feat=referrer-policy),
5428
+ // it doesn't. And it throws an exception instead of ignoring this parameter...
5454
5429
  // REF: https://github.com/getsentry/raven-js/issues/1233
5455
5430
  referrerPolicy: (supportsReferrerPolicy() ? 'origin' : ''),
5456
5431
  };
@@ -5579,7 +5554,7 @@ var Sentry = (function (exports) {
5579
5554
  * @inheritDoc
5580
5555
  */
5581
5556
  BrowserBackend.prototype.eventFromMessage = function (message, level, hint) {
5582
- if (level === void 0) { level = 'info'; }
5557
+ if (level === void 0) { level = exports.Severity.Info; }
5583
5558
  return eventFromMessage(this._options, message, level, hint);
5584
5559
  };
5585
5560
  /**
@@ -5812,7 +5787,7 @@ var Sentry = (function (exports) {
5812
5787
  ? _eventFromIncompleteOnError(msg, url, line, column)
5813
5788
  : _enhanceEventWithInitialFrame(eventFromUnknownInput(error || msg, undefined, {
5814
5789
  attachStacktrace: attachStacktrace,
5815
- rejection: false,
5790
+ isRejection: false,
5816
5791
  }), url, line, column);
5817
5792
  addMechanismAndCapture(hub, error, event, 'onerror');
5818
5793
  });
@@ -5853,9 +5828,9 @@ var Sentry = (function (exports) {
5853
5828
  ? _eventFromRejectionWithPrimitive(error)
5854
5829
  : eventFromUnknownInput(error, undefined, {
5855
5830
  attachStacktrace: attachStacktrace,
5856
- rejection: true,
5831
+ isRejection: true,
5857
5832
  });
5858
- event.level = 'error';
5833
+ event.level = exports.Severity.Error;
5859
5834
  addMechanismAndCapture(hub, error, event, 'onunhandledrejection');
5860
5835
  return;
5861
5836
  });
@@ -6351,7 +6326,7 @@ var Sentry = (function (exports) {
6351
6326
  getCurrentHub().addBreadcrumb({
6352
6327
  category: 'fetch',
6353
6328
  data: handlerData.fetchData,
6354
- level: 'error',
6329
+ level: exports.Severity.Error,
6355
6330
  type: 'http',
6356
6331
  }, {
6357
6332
  data: handlerData.error,