@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
@@ -1,5 +1,26 @@
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
+ /**
4
+ * TODO(v7): Remove this enum and replace with SeverityLevel
5
+ */
6
+ (function (Severity) {
7
+ /** JSDoc */
8
+ Severity["Fatal"] = "fatal";
9
+ /** JSDoc */
10
+ Severity["Error"] = "error";
11
+ /** JSDoc */
12
+ Severity["Warning"] = "warning";
13
+ /** JSDoc */
14
+ Severity["Log"] = "log";
15
+ /** JSDoc */
16
+ Severity["Info"] = "info";
17
+ /** JSDoc */
18
+ Severity["Debug"] = "debug";
19
+ /** JSDoc */
20
+ Severity["Critical"] = "critical";
21
+ })(exports.Severity || (exports.Severity = {}));
22
+ const SeverityLevels = ['fatal', 'error', 'warning', 'log', 'info', 'debug', 'critical'];
23
+
3
24
  /**
4
25
  * Consumes the promise and logs the error when it rejects.
5
26
  * @param promise A promise to forget.
@@ -151,7 +172,7 @@ var Sentry = (function (exports) {
151
172
  return isBuiltin(wat, 'String');
152
173
  }
153
174
  /**
154
- * Checks whether given value's is a primitive (undefined, null, number, boolean, string, bigint, symbol)
175
+ * Checks whether given value is a primitive (undefined, null, number, boolean, string, bigint, symbol)
155
176
  * {@link isPrimitive}.
156
177
  *
157
178
  * @param wat A value to be checked.
@@ -394,7 +415,7 @@ var Sentry = (function (exports) {
394
415
  function dsnFromString(str) {
395
416
  const match = DSN_REGEX.exec(str);
396
417
  if (!match) {
397
- throw new SentryError('Invalid Dsn');
418
+ throw new SentryError(`Invalid Sentry Dsn: ${str}`);
398
419
  }
399
420
  const [protocol, publicKey, pass = '', host, port = '', lastPath] = match.slice(1);
400
421
  let path = '';
@@ -436,17 +457,17 @@ var Sentry = (function (exports) {
436
457
  const requiredComponents = ['protocol', 'publicKey', 'host', 'projectId'];
437
458
  requiredComponents.forEach(component => {
438
459
  if (!dsn[component]) {
439
- throw new SentryError(`Invalid Dsn: ${component} missing`);
460
+ throw new SentryError(`Invalid Sentry Dsn: ${component} missing`);
440
461
  }
441
462
  });
442
463
  if (!projectId.match(/^\d+$/)) {
443
- throw new SentryError(`Invalid Dsn: Invalid projectId ${projectId}`);
464
+ throw new SentryError(`Invalid Sentry Dsn: Invalid projectId ${projectId}`);
444
465
  }
445
466
  if (!isValidProtocol(protocol)) {
446
- throw new SentryError(`Invalid Dsn: Invalid protocol ${protocol}`);
467
+ throw new SentryError(`Invalid Sentry Dsn: Invalid protocol ${protocol}`);
447
468
  }
448
469
  if (port && isNaN(parseInt(port, 10))) {
449
- throw new SentryError(`Invalid Dsn: Invalid port ${port}`);
470
+ throw new SentryError(`Invalid Sentry Dsn: Invalid port ${port}`);
450
471
  }
451
472
  return true;
452
473
  }
@@ -892,7 +913,7 @@ var Sentry = (function (exports) {
892
913
  */
893
914
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
894
915
  function walk(key, value, depth = +Infinity, memo = memoBuilder()) {
895
- // If we reach the maximum depth, serialize whatever has left
916
+ // If we reach the maximum depth, serialize whatever is left
896
917
  if (depth === 0) {
897
918
  return serializeValue(value);
898
919
  }
@@ -902,12 +923,13 @@ var Sentry = (function (exports) {
902
923
  return value.toJSON();
903
924
  }
904
925
  /* eslint-enable @typescript-eslint/no-unsafe-member-access */
905
- // 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
926
+ // If normalized value is a primitive, there are no branches left to walk, so bail out
906
927
  const normalized = normalizeValue(value, key);
907
928
  if (isPrimitive(normalized)) {
908
929
  return normalized;
909
930
  }
910
- // Create source that we will use for next itterations, either objectified error object (Error type with extracted keys:value pairs) or the input itself
931
+ // Create source that we will use for the next iteration. It will either be an objectified error object (`Error` type
932
+ // with extracted key:value pairs) or the input itself.
911
933
  const source = getWalkSource(value);
912
934
  // Create an accumulator that will act as a parent for all future itterations of that branch
913
935
  const acc = Array.isArray(value) ? [] : {};
@@ -1072,9 +1094,9 @@ var Sentry = (function (exports) {
1072
1094
  * @returns Answer to the given question.
1073
1095
  */
1074
1096
  function supportsReferrerPolicy() {
1075
- // Despite all stars in the sky saying that Edge supports old draft syntax, aka 'never', 'always', 'origin' and 'default
1076
- // https://caniuse.com/#feat=referrer-policy
1077
- // It doesn't. And it throw exception instead of ignoring this parameter...
1097
+ // Despite all stars in the sky saying that Edge supports old draft syntax, aka 'never', 'always', 'origin' and 'default'
1098
+ // (see https://caniuse.com/#feat=referrer-policy),
1099
+ // it doesn't. And it throws an exception instead of ignoring this parameter...
1078
1100
  // REF: https://github.com/getsentry/raven-js/issues/1233
1079
1101
  if (!supportsFetch()) {
1080
1102
  return false;
@@ -1257,9 +1279,6 @@ var Sentry = (function (exports) {
1257
1279
  if (!('XMLHttpRequest' in global$2)) {
1258
1280
  return;
1259
1281
  }
1260
- // Poor man's implementation of ES6 `Map`, tracking and keeping in sync key and value separately.
1261
- const requestKeys = [];
1262
- const requestValues = [];
1263
1282
  const xhrproto = XMLHttpRequest.prototype;
1264
1283
  fill(xhrproto, 'open', function (originalOpen) {
1265
1284
  return function (...args) {
@@ -1286,20 +1305,6 @@ var Sentry = (function (exports) {
1286
1305
  catch (e) {
1287
1306
  /* do nothing */
1288
1307
  }
1289
- try {
1290
- const requestPos = requestKeys.indexOf(xhr);
1291
- if (requestPos !== -1) {
1292
- // Make sure to pop both key and value to keep it in sync.
1293
- requestKeys.splice(requestPos);
1294
- const args = requestValues.splice(requestPos)[0];
1295
- if (args[0] !== undefined) {
1296
- xhrInfo.body = args[0];
1297
- }
1298
- }
1299
- }
1300
- catch (e) {
1301
- /* do nothing */
1302
- }
1303
1308
  triggerHandlers('xhr', {
1304
1309
  args,
1305
1310
  endTimestamp: Date.now(),
@@ -1324,8 +1329,9 @@ var Sentry = (function (exports) {
1324
1329
  });
1325
1330
  fill(xhrproto, 'send', function (originalSend) {
1326
1331
  return function (...args) {
1327
- requestKeys.push(this);
1328
- requestValues.push(args);
1332
+ if (this.__sentry_xhr__ && args[0] !== undefined) {
1333
+ this.__sentry_xhr__.body = args[0];
1334
+ }
1329
1335
  triggerHandlers('xhr', {
1330
1336
  args,
1331
1337
  startTimestamp: Date.now(),
@@ -2012,28 +2018,6 @@ var Sentry = (function (exports) {
2012
2018
  };
2013
2019
  }
2014
2020
 
2015
- /** JSDoc
2016
- * @deprecated Use string literals - if you require type casting, cast to SeverityLevel type
2017
- */
2018
- var Severity;
2019
- (function (Severity) {
2020
- /** JSDoc */
2021
- Severity["Fatal"] = "fatal";
2022
- /** JSDoc */
2023
- Severity["Error"] = "error";
2024
- /** JSDoc */
2025
- Severity["Warning"] = "warning";
2026
- /** JSDoc */
2027
- Severity["Log"] = "log";
2028
- /** JSDoc */
2029
- Severity["Info"] = "info";
2030
- /** JSDoc */
2031
- Severity["Debug"] = "debug";
2032
- /** JSDoc */
2033
- Severity["Critical"] = "critical";
2034
- })(Severity || (Severity = {}));
2035
- const SeverityLevels = ['fatal', 'error', 'warning', 'log', 'info', 'debug', 'critical'];
2036
-
2037
2021
  function isSupportedSeverity(level) {
2038
2022
  return SeverityLevels.indexOf(level) !== -1;
2039
2023
  }
@@ -2045,11 +2029,11 @@ var Sentry = (function (exports) {
2045
2029
  */
2046
2030
  function severityFromString(level) {
2047
2031
  if (level === 'warn')
2048
- return 'warning';
2032
+ return exports.Severity.Warning;
2049
2033
  if (isSupportedSeverity(level)) {
2050
2034
  return level;
2051
2035
  }
2052
- return 'log';
2036
+ return exports.Severity.Log;
2053
2037
  }
2054
2038
 
2055
2039
  /**
@@ -2230,6 +2214,11 @@ var Sentry = (function (exports) {
2230
2214
  this._extra = {};
2231
2215
  /** Contexts */
2232
2216
  this._contexts = {};
2217
+ /**
2218
+ * A place to stash data which is needed at some point in the SDK's event processing pipeline but which shouldn't get
2219
+ * sent to Sentry
2220
+ */
2221
+ this._sdkProcessingMetadata = {};
2233
2222
  }
2234
2223
  /**
2235
2224
  * Inherit values from the parent scope.
@@ -2392,18 +2381,10 @@ var Sentry = (function (exports) {
2392
2381
  * @inheritDoc
2393
2382
  */
2394
2383
  getTransaction() {
2395
- // often, this span will be a transaction, but it's not guaranteed to be
2384
+ // Often, this span (if it exists at all) will be a transaction, but it's not guaranteed to be. Regardless, it will
2385
+ // have a pointer to the currently-active transaction.
2396
2386
  const span = this.getSpan();
2397
- // try it the new way first
2398
- if (span && span.transaction) {
2399
- return span.transaction;
2400
- }
2401
- // fallback to the old way (known bug: this only finds transactions with sampled = true)
2402
- if (span && span.spanRecorder && span.spanRecorder.spans[0]) {
2403
- return span.spanRecorder.spans[0];
2404
- }
2405
- // neither way found a transaction
2406
- return undefined;
2387
+ return span && span.transaction;
2407
2388
  }
2408
2389
  /**
2409
2390
  * @inheritDoc
@@ -2553,8 +2534,16 @@ var Sentry = (function (exports) {
2553
2534
  this._applyFingerprint(event);
2554
2535
  event.breadcrumbs = [...(event.breadcrumbs || []), ...this._breadcrumbs];
2555
2536
  event.breadcrumbs = event.breadcrumbs.length > 0 ? event.breadcrumbs : undefined;
2537
+ event.sdkProcessingMetadata = this._sdkProcessingMetadata;
2556
2538
  return this._notifyEventProcessors([...getGlobalEventProcessors(), ...this._eventProcessors], event, hint);
2557
2539
  }
2540
+ /**
2541
+ * Add data which will be accessible during event processing but won't get sent to Sentry
2542
+ */
2543
+ setSDKProcessingMetadata(newData) {
2544
+ this._sdkProcessingMetadata = Object.assign(Object.assign({}, this._sdkProcessingMetadata), newData);
2545
+ return this;
2546
+ }
2558
2547
  /**
2559
2548
  * This will be called after {@link applyToEvent} is finished.
2560
2549
  */
@@ -3275,7 +3264,7 @@ var Sentry = (function (exports) {
3275
3264
  * Captures a message event and sends it to Sentry.
3276
3265
  *
3277
3266
  * @param message The message to send to Sentry.
3278
- * @param SeverityLevel Define the level of the message.
3267
+ * @param Severity Define the level of the message.
3279
3268
  * @returns The generated eventId.
3280
3269
  */
3281
3270
  function captureMessage(message, captureContext) {
@@ -4131,31 +4120,6 @@ var Sentry = (function (exports) {
4131
4120
  }
4132
4121
  }
4133
4122
 
4134
- /*! *****************************************************************************
4135
- Copyright (c) Microsoft Corporation. All rights reserved.
4136
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4137
- this file except in compliance with the License. You may obtain a copy of the
4138
- License at http://www.apache.org/licenses/LICENSE-2.0
4139
-
4140
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4141
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
4142
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
4143
- MERCHANTABLITY OR NON-INFRINGEMENT.
4144
-
4145
- See the Apache Version 2.0 License for specific language governing permissions
4146
- and limitations under the License.
4147
- ***************************************************************************** */
4148
-
4149
- function __rest(s, e) {
4150
- var t = {};
4151
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4152
- t[p] = s[p];
4153
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
4154
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
4155
- t[p[i]] = s[p[i]];
4156
- return t;
4157
- }
4158
-
4159
4123
  /** Extract sdk info from from the API metadata */
4160
4124
  function getSdkMetadataForEnvelopeHeader(api) {
4161
4125
  if (!api.metadata || !api.metadata.sdk) {
@@ -4199,14 +4163,10 @@ var Sentry = (function (exports) {
4199
4163
  const sdkInfo = getSdkMetadataForEnvelopeHeader(api);
4200
4164
  const eventType = event.type || 'event';
4201
4165
  const useEnvelope = eventType === 'transaction' || !!api.tunnel;
4202
- const _a = event.debug_meta || {}, { transactionSampling } = _a, metadata = __rest(_a, ["transactionSampling"]);
4166
+ const { transactionSampling } = event.sdkProcessingMetadata || {};
4203
4167
  const { method: samplingMethod, rate: sampleRate } = transactionSampling || {};
4204
- if (Object.keys(metadata).length === 0) {
4205
- delete event.debug_meta;
4206
- }
4207
- else {
4208
- event.debug_meta = metadata;
4209
- }
4168
+ // prevent this data from being sent to sentry
4169
+ delete event.sdkProcessingMetadata;
4210
4170
  const req = {
4211
4171
  body: JSON.stringify(sdkInfo ? enhanceEventWithSdkInfo(event, api.metadata.sdk) : event),
4212
4172
  type: eventType,
@@ -4257,7 +4217,7 @@ var Sentry = (function (exports) {
4257
4217
  hub.bindClient(client);
4258
4218
  }
4259
4219
 
4260
- const SDK_VERSION = '6.17.0-beta.0';
4220
+ const SDK_VERSION = '6.17.0';
4261
4221
 
4262
4222
  let originalFunctionToString;
4263
4223
  /** Patch toString calls to return proper name for wrapped functions */
@@ -4832,7 +4792,7 @@ var Sentry = (function (exports) {
4832
4792
  }
4833
4793
 
4834
4794
  /**
4835
- * Builds and Event from a Exception
4795
+ * Creates an {@link Event} from all inputs to `captureException` and non-primitive inputs to `captureMessage`.
4836
4796
  * @hidden
4837
4797
  */
4838
4798
  function eventFromException(options, exception, hint) {
@@ -4841,7 +4801,7 @@ var Sentry = (function (exports) {
4841
4801
  attachStacktrace: options.attachStacktrace,
4842
4802
  });
4843
4803
  addExceptionMechanism(event); // defaults to { type: 'generic', handled: true }
4844
- event.level = 'error';
4804
+ event.level = exports.Severity.Error;
4845
4805
  if (hint && hint.event_id) {
4846
4806
  event.event_id = hint.event_id;
4847
4807
  }
@@ -4851,7 +4811,7 @@ var Sentry = (function (exports) {
4851
4811
  * Builds and Event from a Message
4852
4812
  * @hidden
4853
4813
  */
4854
- function eventFromMessage(options, message, level = 'info', hint) {
4814
+ function eventFromMessage(options, message, level = exports.Severity.Info, hint) {
4855
4815
  const syntheticException = (hint && hint.syntheticException) || undefined;
4856
4816
  const event = eventFromString(message, syntheticException, {
4857
4817
  attachStacktrace: options.attachStacktrace,
@@ -4904,11 +4864,11 @@ var Sentry = (function (exports) {
4904
4864
  return event;
4905
4865
  }
4906
4866
  if (isPlainObject(exception) || isEvent(exception)) {
4907
- // If it is plain Object or Event, serialize it manually and extract options
4908
- // This will allow us to group events based on top-level keys
4909
- // which is much better than creating new group when any key/value change
4867
+ // If it's a plain object or an instance of `Event` (the built-in JS kind, not this SDK's `Event` type), serialize
4868
+ // it manually. This will allow us to group events based on top-level keys which is much better than creating a new
4869
+ // group on any key/value change.
4910
4870
  const objectException = exception;
4911
- event = eventFromPlainObject(objectException, syntheticException, options.rejection);
4871
+ event = eventFromPlainObject(objectException, syntheticException, options.isRejection);
4912
4872
  addExceptionMechanism(event, {
4913
4873
  synthetic: true,
4914
4874
  });
@@ -5235,9 +5195,9 @@ var Sentry = (function (exports) {
5235
5195
  const options = {
5236
5196
  body: sentryRequest.body,
5237
5197
  method: 'POST',
5238
- // Despite all stars in the sky saying that Edge supports old draft syntax, aka 'never', 'always', 'origin' and 'default
5239
- // https://caniuse.com/#feat=referrer-policy
5240
- // It doesn't. And it throw exception instead of ignoring this parameter...
5198
+ // Despite all stars in the sky saying that Edge supports old draft syntax, aka 'never', 'always', 'origin' and 'default'
5199
+ // (see https://caniuse.com/#feat=referrer-policy),
5200
+ // it doesn't. And it throws an exception instead of ignoring this parameter...
5241
5201
  // REF: https://github.com/getsentry/raven-js/issues/1233
5242
5202
  referrerPolicy: (supportsReferrerPolicy() ? 'origin' : ''),
5243
5203
  };
@@ -5350,7 +5310,7 @@ var Sentry = (function (exports) {
5350
5310
  /**
5351
5311
  * @inheritDoc
5352
5312
  */
5353
- eventFromMessage(message, level = 'info', hint) {
5313
+ eventFromMessage(message, level = exports.Severity.Info, hint) {
5354
5314
  return eventFromMessage(this._options, message, level, hint);
5355
5315
  }
5356
5316
  /**
@@ -5580,7 +5540,7 @@ var Sentry = (function (exports) {
5580
5540
  ? _eventFromIncompleteOnError(msg, url, line, column)
5581
5541
  : _enhanceEventWithInitialFrame(eventFromUnknownInput(error || msg, undefined, {
5582
5542
  attachStacktrace,
5583
- rejection: false,
5543
+ isRejection: false,
5584
5544
  }), url, line, column);
5585
5545
  addMechanismAndCapture(hub, error, event, 'onerror');
5586
5546
  });
@@ -5621,9 +5581,9 @@ var Sentry = (function (exports) {
5621
5581
  ? _eventFromRejectionWithPrimitive(error)
5622
5582
  : eventFromUnknownInput(error, undefined, {
5623
5583
  attachStacktrace,
5624
- rejection: true,
5584
+ isRejection: true,
5625
5585
  });
5626
- event.level = 'error';
5586
+ event.level = exports.Severity.Error;
5627
5587
  addMechanismAndCapture(hub, error, event, 'onunhandledrejection');
5628
5588
  return;
5629
5589
  });
@@ -6110,7 +6070,7 @@ var Sentry = (function (exports) {
6110
6070
  getCurrentHub().addBreadcrumb({
6111
6071
  category: 'fetch',
6112
6072
  data: handlerData.fetchData,
6113
- level: 'error',
6073
+ level: exports.Severity.Error,
6114
6074
  type: 'http',
6115
6075
  }, {
6116
6076
  data: handlerData.error,