@sentry/browser 6.17.8 → 6.18.1-beta.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/build/bundle.js CHANGED
@@ -1,5 +1,6 @@
1
- /*! @sentry/browser 6.17.8 (db493a0) | https://github.com/getsentry/sentry-javascript */
1
+ /*! @sentry/browser 6.18.1-beta.0 (8443996) | https://github.com/getsentry/sentry-javascript */
2
2
  var Sentry = (function (exports) {
3
+
3
4
  /*! *****************************************************************************
4
5
  Copyright (c) Microsoft Corporation.
5
6
 
@@ -81,6 +82,7 @@ var Sentry = (function (exports) {
81
82
  /**
82
83
  * TODO(v7): Remove this enum and replace with SeverityLevel
83
84
  */
85
+ exports.Severity = void 0;
84
86
  (function (Severity) {
85
87
  /** JSDoc */
86
88
  Severity["Fatal"] = "fatal";
@@ -141,7 +143,7 @@ var Sentry = (function (exports) {
141
143
  * @returns Global scope object
142
144
  */
143
145
  function getGlobalObject() {
144
- return ( typeof window !== 'undefined' // eslint-disable-line no-restricted-globals
146
+ return (typeof window !== 'undefined' // eslint-disable-line no-restricted-globals
145
147
  ? window // eslint-disable-line no-restricted-globals
146
148
  : typeof self !== 'undefined'
147
149
  ? self
@@ -527,7 +529,7 @@ var Sentry = (function (exports) {
527
529
  var SeverityLevels = ['fatal', 'error', 'warning', 'log', 'info', 'debug', 'critical'];
528
530
 
529
531
  // TODO: Implement different loggers for different environments
530
- var global$1 = getGlobalObject();
532
+ var global$6 = getGlobalObject();
531
533
  /** Prefix for logging strings */
532
534
  var PREFIX = 'Sentry Logger ';
533
535
  /**
@@ -586,7 +588,7 @@ var Sentry = (function (exports) {
586
588
  return;
587
589
  }
588
590
  consoleSandbox(function () {
589
- global$1.console.log(PREFIX + "[Log]: " + args.join(' '));
591
+ global$6.console.log(PREFIX + "[Log]: " + args.join(' '));
590
592
  });
591
593
  };
592
594
  /** JSDoc */
@@ -599,7 +601,7 @@ var Sentry = (function (exports) {
599
601
  return;
600
602
  }
601
603
  consoleSandbox(function () {
602
- global$1.console.warn(PREFIX + "[Warn]: " + args.join(' '));
604
+ global$6.console.warn(PREFIX + "[Warn]: " + args.join(' '));
603
605
  });
604
606
  };
605
607
  /** JSDoc */
@@ -612,14 +614,14 @@ var Sentry = (function (exports) {
612
614
  return;
613
615
  }
614
616
  consoleSandbox(function () {
615
- global$1.console.error(PREFIX + "[Error]: " + args.join(' '));
617
+ global$6.console.error(PREFIX + "[Error]: " + args.join(' '));
616
618
  });
617
619
  };
618
620
  return Logger;
619
621
  }());
620
622
  // Ensure we only have a single logger instance, even if multiple versions of @sentry/utils are being used
621
- global$1.__SENTRY__ = global$1.__SENTRY__ || {};
622
- var logger = global$1.__SENTRY__.logger || (global$1.__SENTRY__.logger = new Logger());
623
+ global$6.__SENTRY__ = global$6.__SENTRY__ || {};
624
+ var logger = global$6.__SENTRY__.logger || (global$6.__SENTRY__.logger = new Logger());
623
625
 
624
626
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
625
627
  /* eslint-disable @typescript-eslint/no-explicit-any */
@@ -1284,7 +1286,7 @@ var Sentry = (function (exports) {
1284
1286
  return !isChromePackagedApp && hasHistoryApi;
1285
1287
  }
1286
1288
 
1287
- var global$2 = getGlobalObject();
1289
+ var global$5 = getGlobalObject();
1288
1290
  /**
1289
1291
  * Instrument native APIs to call handlers that can be used to create breadcrumbs, APM spans etc.
1290
1292
  * - Console API
@@ -1368,14 +1370,14 @@ var Sentry = (function (exports) {
1368
1370
  }
1369
1371
  /** JSDoc */
1370
1372
  function instrumentConsole() {
1371
- if (!('console' in global$2)) {
1373
+ if (!('console' in global$5)) {
1372
1374
  return;
1373
1375
  }
1374
1376
  ['debug', 'info', 'warn', 'error', 'log', 'assert'].forEach(function (level) {
1375
- if (!(level in global$2.console)) {
1377
+ if (!(level in global$5.console)) {
1376
1378
  return;
1377
1379
  }
1378
- fill(global$2.console, level, function (originalConsoleMethod) {
1380
+ fill(global$5.console, level, function (originalConsoleMethod) {
1379
1381
  return function () {
1380
1382
  var args = [];
1381
1383
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -1384,7 +1386,7 @@ var Sentry = (function (exports) {
1384
1386
  triggerHandlers('console', { args: args, level: level });
1385
1387
  // this fails for some browsers. :(
1386
1388
  if (originalConsoleMethod) {
1387
- originalConsoleMethod.apply(global$2.console, args);
1389
+ originalConsoleMethod.apply(global$5.console, args);
1388
1390
  }
1389
1391
  };
1390
1392
  });
@@ -1395,7 +1397,7 @@ var Sentry = (function (exports) {
1395
1397
  if (!supportsNativeFetch()) {
1396
1398
  return;
1397
1399
  }
1398
- fill(global$2, 'fetch', function (originalFetch) {
1400
+ fill(global$5, 'fetch', function (originalFetch) {
1399
1401
  return function () {
1400
1402
  var args = [];
1401
1403
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -1411,7 +1413,7 @@ var Sentry = (function (exports) {
1411
1413
  };
1412
1414
  triggerHandlers('fetch', __assign({}, handlerData));
1413
1415
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1414
- return originalFetch.apply(global$2, args).then(function (response) {
1416
+ return originalFetch.apply(global$5, args).then(function (response) {
1415
1417
  triggerHandlers('fetch', __assign(__assign({}, handlerData), { endTimestamp: Date.now(), response: response }));
1416
1418
  return response;
1417
1419
  }, function (error) {
@@ -1428,7 +1430,7 @@ var Sentry = (function (exports) {
1428
1430
  /** Extract `method` from fetch call arguments */
1429
1431
  function getFetchMethod(fetchArgs) {
1430
1432
  if (fetchArgs === void 0) { fetchArgs = []; }
1431
- if ('Request' in global$2 && isInstanceOf(fetchArgs[0], Request) && fetchArgs[0].method) {
1433
+ if ('Request' in global$5 && isInstanceOf(fetchArgs[0], Request) && fetchArgs[0].method) {
1432
1434
  return String(fetchArgs[0].method).toUpperCase();
1433
1435
  }
1434
1436
  if (fetchArgs[1] && fetchArgs[1].method) {
@@ -1442,7 +1444,7 @@ var Sentry = (function (exports) {
1442
1444
  if (typeof fetchArgs[0] === 'string') {
1443
1445
  return fetchArgs[0];
1444
1446
  }
1445
- if ('Request' in global$2 && isInstanceOf(fetchArgs[0], Request)) {
1447
+ if ('Request' in global$5 && isInstanceOf(fetchArgs[0], Request)) {
1446
1448
  return fetchArgs[0].url;
1447
1449
  }
1448
1450
  return String(fetchArgs[0]);
@@ -1450,7 +1452,7 @@ var Sentry = (function (exports) {
1450
1452
  /* eslint-enable @typescript-eslint/no-unsafe-member-access */
1451
1453
  /** JSDoc */
1452
1454
  function instrumentXHR() {
1453
- if (!('XMLHttpRequest' in global$2)) {
1455
+ if (!('XMLHttpRequest' in global$5)) {
1454
1456
  return;
1455
1457
  }
1456
1458
  var xhrproto = XMLHttpRequest.prototype;
@@ -1533,13 +1535,13 @@ var Sentry = (function (exports) {
1533
1535
  if (!supportsHistory()) {
1534
1536
  return;
1535
1537
  }
1536
- var oldOnPopState = global$2.onpopstate;
1537
- global$2.onpopstate = function () {
1538
+ var oldOnPopState = global$5.onpopstate;
1539
+ global$5.onpopstate = function () {
1538
1540
  var args = [];
1539
1541
  for (var _i = 0; _i < arguments.length; _i++) {
1540
1542
  args[_i] = arguments[_i];
1541
1543
  }
1542
- var to = global$2.location.href;
1544
+ var to = global$5.location.href;
1543
1545
  // keep track of the current URL state, as we always receive only the updated state
1544
1546
  var from = lastHref;
1545
1547
  lastHref = to;
@@ -1581,8 +1583,8 @@ var Sentry = (function (exports) {
1581
1583
  return originalHistoryFunction.apply(this, args);
1582
1584
  };
1583
1585
  }
1584
- fill(global$2.history, 'pushState', historyReplacementFunction);
1585
- fill(global$2.history, 'replaceState', historyReplacementFunction);
1586
+ fill(global$5.history, 'pushState', historyReplacementFunction);
1587
+ fill(global$5.history, 'replaceState', historyReplacementFunction);
1586
1588
  }
1587
1589
  var debounceDuration = 1000;
1588
1590
  var debounceTimerID;
@@ -1685,14 +1687,14 @@ var Sentry = (function (exports) {
1685
1687
  }
1686
1688
  // Start a new debounce timer that will prevent us from capturing multiple events that should be grouped together.
1687
1689
  clearTimeout(debounceTimerID);
1688
- debounceTimerID = global$2.setTimeout(function () {
1690
+ debounceTimerID = global$5.setTimeout(function () {
1689
1691
  debounceTimerID = undefined;
1690
1692
  }, debounceDuration);
1691
1693
  };
1692
1694
  }
1693
1695
  /** JSDoc */
1694
1696
  function instrumentDOM() {
1695
- if (!('document' in global$2)) {
1697
+ if (!('document' in global$5)) {
1696
1698
  return;
1697
1699
  }
1698
1700
  // Make it so that any click or keypress that is unhandled / bubbled up all the way to the document triggers our dom
@@ -1700,8 +1702,8 @@ var Sentry = (function (exports) {
1700
1702
  // we instrument `addEventListener` so that we don't end up attaching this handler twice.
1701
1703
  var triggerDOMHandler = triggerHandlers.bind(null, 'dom');
1702
1704
  var globalDOMEventHandler = makeDOMEventHandler(triggerDOMHandler, true);
1703
- global$2.document.addEventListener('click', globalDOMEventHandler, false);
1704
- global$2.document.addEventListener('keypress', globalDOMEventHandler, false);
1705
+ global$5.document.addEventListener('click', globalDOMEventHandler, false);
1706
+ global$5.document.addEventListener('keypress', globalDOMEventHandler, false);
1705
1707
  // After hooking into click and keypress events bubbled up to `document`, we also hook into user-handled
1706
1708
  // clicks & keypresses, by adding an event listener of our own to any element to which they add a listener. That
1707
1709
  // way, whenever one of their handlers is triggered, ours will be, too. (This is needed because their handler
@@ -1709,7 +1711,7 @@ var Sentry = (function (exports) {
1709
1711
  // guaranteed to fire at least once.)
1710
1712
  ['EventTarget', 'Node'].forEach(function (target) {
1711
1713
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1712
- var proto = global$2[target] && global$2[target].prototype;
1714
+ var proto = global$5[target] && global$5[target].prototype;
1713
1715
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, no-prototype-builtins
1714
1716
  if (!proto || !proto.hasOwnProperty || !proto.hasOwnProperty('addEventListener')) {
1715
1717
  return;
@@ -1770,8 +1772,8 @@ var Sentry = (function (exports) {
1770
1772
  var _oldOnErrorHandler = null;
1771
1773
  /** JSDoc */
1772
1774
  function instrumentError() {
1773
- _oldOnErrorHandler = global$2.onerror;
1774
- global$2.onerror = function (msg, url, line, column, error) {
1775
+ _oldOnErrorHandler = global$5.onerror;
1776
+ global$5.onerror = function (msg, url, line, column, error) {
1775
1777
  triggerHandlers('error', {
1776
1778
  column: column,
1777
1779
  error: error,
@@ -1789,8 +1791,8 @@ var Sentry = (function (exports) {
1789
1791
  var _oldOnUnhandledRejectionHandler = null;
1790
1792
  /** JSDoc */
1791
1793
  function instrumentUnhandledRejection() {
1792
- _oldOnUnhandledRejectionHandler = global$2.onunhandledrejection;
1793
- global$2.onunhandledrejection = function (e) {
1794
+ _oldOnUnhandledRejectionHandler = global$5.onunhandledrejection;
1795
+ global$5.onunhandledrejection = function (e) {
1794
1796
  triggerHandlers('unhandledrejection', e);
1795
1797
  if (_oldOnUnhandledRejectionHandler) {
1796
1798
  // eslint-disable-next-line prefer-rest-params
@@ -2310,7 +2312,7 @@ var Sentry = (function (exports) {
2310
2312
  /**
2311
2313
  * The Performance API implementation for the current platform, if available.
2312
2314
  */
2313
- var platformPerformance = getBrowserPerformance();
2315
+ var platformPerformance = getBrowserPerformance();
2314
2316
  var timestampSource = platformPerformance === undefined
2315
2317
  ? dateTimestampSource
2316
2318
  : {
@@ -2336,7 +2338,7 @@ var Sentry = (function (exports) {
2336
2338
  * The number of milliseconds since the UNIX epoch. This value is only usable in a browser, and only when the
2337
2339
  * performance API is available.
2338
2340
  */
2339
- var browserPerformanceTimeOrigin = (function () {
2341
+ ((function () {
2340
2342
  // Unfortunately browsers may report an inaccurate time origin data, through either performance.timeOrigin or
2341
2343
  // performance.timing.navigationStart, which results in poor results in performance data. We only treat time origin
2342
2344
  // data as reliable if they are within a reasonable threshold of the current time.
@@ -2373,7 +2375,49 @@ var Sentry = (function (exports) {
2373
2375
  }
2374
2376
  }
2375
2377
  return dateNow;
2376
- })();
2378
+ }))();
2379
+
2380
+ /**
2381
+ * Creates an envelope.
2382
+ * Make sure to always explicitly provide the generic to this function
2383
+ * so that the envelope types resolve correctly.
2384
+ */
2385
+ function createEnvelope(headers, items) {
2386
+ if (items === void 0) { items = []; }
2387
+ return [headers, items];
2388
+ }
2389
+ /**
2390
+ * Serializes an envelope into a string.
2391
+ */
2392
+ function serializeEnvelope(envelope) {
2393
+ var _a = __read(envelope, 2), headers = _a[0], items = _a[1];
2394
+ var serializedHeaders = JSON.stringify(headers);
2395
+ // Have to cast items to any here since Envelope is a union type
2396
+ // Fixed in Typescript 4.2
2397
+ // TODO: Remove any[] cast when we upgrade to TS 4.2
2398
+ // https://github.com/microsoft/TypeScript/issues/36390
2399
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2400
+ return items.reduce(function (acc, item) {
2401
+ var _a = __read(item, 2), itemHeaders = _a[0], payload = _a[1];
2402
+ return acc + "\n" + JSON.stringify(itemHeaders) + "\n" + JSON.stringify(payload);
2403
+ }, serializedHeaders);
2404
+ }
2405
+
2406
+ /**
2407
+ * Creates client report envelope
2408
+ * @param discarded_events An array of discard events
2409
+ * @param dsn A DSN that can be set on the header. Optional.
2410
+ */
2411
+ function createClientReportEnvelope(discarded_events, dsn, timestamp) {
2412
+ var clientReportItem = [
2413
+ { type: 'client_report' },
2414
+ {
2415
+ timestamp: timestamp || dateTimestampInSeconds(),
2416
+ discarded_events: discarded_events,
2417
+ },
2418
+ ];
2419
+ return createEnvelope(dsn ? { dsn: dsn } : {}, [clientReportItem]);
2420
+ }
2377
2421
 
2378
2422
  /**
2379
2423
  * Absolute maximum number of breadcrumbs added to an event.
@@ -3038,7 +3082,7 @@ var Sentry = (function (exports) {
3038
3082
  */
3039
3083
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
3040
3084
  Hub.prototype.captureException = function (exception, hint) {
3041
- var eventId = (this._lastEventId = uuid4());
3085
+ var eventId = (this._lastEventId = hint && hint.event_id ? hint.event_id : uuid4());
3042
3086
  var finalHint = hint;
3043
3087
  // If there's no explicit hint provided, mimic the same thing that would happen
3044
3088
  // in the minimal itself to create a consistent behavior.
@@ -3064,7 +3108,7 @@ var Sentry = (function (exports) {
3064
3108
  * @inheritDoc
3065
3109
  */
3066
3110
  Hub.prototype.captureMessage = function (message, level, hint) {
3067
- var eventId = (this._lastEventId = uuid4());
3111
+ var eventId = (this._lastEventId = hint && hint.event_id ? hint.event_id : uuid4());
3068
3112
  var finalHint = hint;
3069
3113
  // If there's no explicit hint provided, mimic the same thing that would happen
3070
3114
  // in the minimal itself to create a consistent behavior.
@@ -3090,7 +3134,7 @@ var Sentry = (function (exports) {
3090
3134
  * @inheritDoc
3091
3135
  */
3092
3136
  Hub.prototype.captureEvent = function (event, hint) {
3093
- var eventId = uuid4();
3137
+ var eventId = hint && hint.event_id ? hint.event_id : uuid4();
3094
3138
  if (event.type !== 'transaction') {
3095
3139
  this._lastEventId = eventId;
3096
3140
  }
@@ -4476,7 +4520,7 @@ var Sentry = (function (exports) {
4476
4520
  hub.bindClient(client);
4477
4521
  }
4478
4522
 
4479
- var SDK_VERSION = '6.17.8';
4523
+ var SDK_VERSION = '6.18.1-beta.0';
4480
4524
 
4481
4525
  var originalFunctionToString;
4482
4526
  /** Patch toString calls to return proper name for wrapped functions */
@@ -4691,8 +4735,6 @@ var Sentry = (function (exports) {
4691
4735
  return InboundFilters;
4692
4736
  }());
4693
4737
 
4694
-
4695
-
4696
4738
  var CoreIntegrations = /*#__PURE__*/Object.freeze({
4697
4739
  __proto__: null,
4698
4740
  FunctionToString: FunctionToString,
@@ -4852,9 +4894,10 @@ var Sentry = (function (exports) {
4852
4894
  },
4853
4895
  };
4854
4896
  if (syntheticException) {
4855
- event.stacktrace = {
4856
- frames: parseStackFrames(syntheticException),
4857
- };
4897
+ var frames_1 = parseStackFrames(syntheticException);
4898
+ if (frames_1.length) {
4899
+ event.stacktrace = { frames: frames_1 };
4900
+ }
4858
4901
  }
4859
4902
  return event;
4860
4903
  }
@@ -5020,14 +5063,15 @@ var Sentry = (function (exports) {
5020
5063
  message: input,
5021
5064
  };
5022
5065
  if (options.attachStacktrace && syntheticException) {
5023
- event.stacktrace = {
5024
- frames: parseStackFrames(syntheticException),
5025
- };
5066
+ var frames_1 = parseStackFrames(syntheticException);
5067
+ if (frames_1.length) {
5068
+ event.stacktrace = { frames: frames_1 };
5069
+ }
5026
5070
  }
5027
5071
  return event;
5028
5072
  }
5029
5073
 
5030
- var global$3 = getGlobalObject();
5074
+ var global$4 = getGlobalObject();
5031
5075
  var cachedFetchImpl;
5032
5076
  /**
5033
5077
  * A special usecase for incorrectly wrapped Fetch APIs in conjunction with ad-blockers.
@@ -5073,11 +5117,11 @@ var Sentry = (function (exports) {
5073
5117
  }
5074
5118
  /* eslint-disable @typescript-eslint/unbound-method */
5075
5119
  // Fast path to avoid DOM I/O
5076
- if (isNativeFetch(global$3.fetch)) {
5077
- return (cachedFetchImpl = global$3.fetch.bind(global$3));
5120
+ if (isNativeFetch(global$4.fetch)) {
5121
+ return (cachedFetchImpl = global$4.fetch.bind(global$4));
5078
5122
  }
5079
- var document = global$3.document;
5080
- var fetchImpl = global$3.fetch;
5123
+ var document = global$4.document;
5124
+ var fetchImpl = global$4.fetch;
5081
5125
  // eslint-disable-next-line deprecation/deprecation
5082
5126
  if (document && typeof document.createElement === "function") {
5083
5127
  try {
@@ -5096,7 +5140,7 @@ var Sentry = (function (exports) {
5096
5140
  }
5097
5141
  }
5098
5142
  }
5099
- return (cachedFetchImpl = fetchImpl.bind(global$3));
5143
+ return (cachedFetchImpl = fetchImpl.bind(global$4));
5100
5144
  /* eslint-enable @typescript-eslint/unbound-method */
5101
5145
  }
5102
5146
  /**
@@ -5106,11 +5150,11 @@ var Sentry = (function (exports) {
5106
5150
  * @param body report payload
5107
5151
  */
5108
5152
  function sendReport(url, body) {
5109
- var isRealNavigator = Object.prototype.toString.call(global$3 && global$3.navigator) === '[object Navigator]';
5110
- var hasSendBeacon = isRealNavigator && typeof global$3.navigator.sendBeacon === 'function';
5153
+ var isRealNavigator = Object.prototype.toString.call(global$4 && global$4.navigator) === '[object Navigator]';
5154
+ var hasSendBeacon = isRealNavigator && typeof global$4.navigator.sendBeacon === 'function';
5111
5155
  if (hasSendBeacon) {
5112
5156
  // Prevent illegal invocations - https://xgwang.me/posts/you-may-not-know-beacon/#it-may-throw-error%2C-be-sure-to-catch
5113
- var sendBeacon = global$3.navigator.sendBeacon.bind(global$3.navigator);
5157
+ var sendBeacon = global$4.navigator.sendBeacon.bind(global$4.navigator);
5114
5158
  return sendBeacon(url, body);
5115
5159
  }
5116
5160
  if (supportsFetch()) {
@@ -5128,7 +5172,7 @@ var Sentry = (function (exports) {
5128
5172
  var tyStr = ty;
5129
5173
  return tyStr === 'event' ? 'error' : tyStr;
5130
5174
  }
5131
- var global$4 = getGlobalObject();
5175
+ var global$3 = getGlobalObject();
5132
5176
  /** Base Transport class implementation */
5133
5177
  var BaseTransport = /** @class */ (function () {
5134
5178
  function BaseTransport(options) {
@@ -5142,9 +5186,9 @@ var Sentry = (function (exports) {
5142
5186
  this._api = initAPIDetails(options.dsn, options._metadata, options.tunnel);
5143
5187
  // eslint-disable-next-line deprecation/deprecation
5144
5188
  this.url = getStoreEndpointWithUrlEncodedAuth(this._api.dsn);
5145
- if (this.options.sendClientReports && global$4.document) {
5146
- global$4.document.addEventListener('visibilitychange', function () {
5147
- if (global$4.document.visibilityState === 'hidden') {
5189
+ if (this.options.sendClientReports && global$3.document) {
5190
+ global$3.document.addEventListener('visibilitychange', function () {
5191
+ if (global$3.document.visibilityState === 'hidden') {
5148
5192
  _this._flushOutcomes();
5149
5193
  }
5150
5194
  });
@@ -5201,25 +5245,18 @@ var Sentry = (function (exports) {
5201
5245
  }
5202
5246
  logger.log("Flushing outcomes:\n" + JSON.stringify(outcomes, null, 2));
5203
5247
  var url = getEnvelopeEndpointWithUrlEncodedAuth(this._api.dsn, this._api.tunnel);
5204
- // Envelope header is required to be at least an empty object
5205
- var envelopeHeader = JSON.stringify(__assign({}, (this._api.tunnel && { dsn: dsnToString(this._api.dsn) })));
5206
- var itemHeaders = JSON.stringify({
5207
- type: 'client_report',
5208
- });
5209
- var item = JSON.stringify({
5210
- timestamp: dateTimestampInSeconds(),
5211
- discarded_events: Object.keys(outcomes).map(function (key) {
5212
- var _a = __read(key.split(':'), 2), category = _a[0], reason = _a[1];
5213
- return {
5214
- reason: reason,
5215
- category: category,
5216
- quantity: outcomes[key],
5217
- };
5218
- }),
5248
+ var discardedEvents = Object.keys(outcomes).map(function (key) {
5249
+ var _a = __read(key.split(':'), 2), category = _a[0], reason = _a[1];
5250
+ return {
5251
+ reason: reason,
5252
+ category: category,
5253
+ quantity: outcomes[key],
5254
+ };
5255
+ // TODO: Improve types on discarded_events to get rid of cast
5219
5256
  });
5220
- var envelope = envelopeHeader + "\n" + itemHeaders + "\n" + item;
5257
+ var envelope = createClientReportEnvelope(discardedEvents, this._api.tunnel && dsnToString(this._api.dsn));
5221
5258
  try {
5222
- sendReport(url, envelope);
5259
+ sendReport(url, serializeEnvelope(envelope));
5223
5260
  }
5224
5261
  catch (e) {
5225
5262
  logger.error(e);
@@ -5446,8 +5483,6 @@ var Sentry = (function (exports) {
5446
5483
  return XHRTransport;
5447
5484
  }(BaseTransport));
5448
5485
 
5449
-
5450
-
5451
5486
  var index = /*#__PURE__*/Object.freeze({
5452
5487
  __proto__: null,
5453
5488
  BaseTransport: BaseTransport,
@@ -5497,7 +5532,7 @@ var Sentry = (function (exports) {
5497
5532
  return BrowserBackend;
5498
5533
  }(BaseBackend));
5499
5534
 
5500
- var global$5 = getGlobalObject();
5535
+ var global$2 = getGlobalObject();
5501
5536
  var ignoreOnError = 0;
5502
5537
  /**
5503
5538
  * @hidden
@@ -5523,7 +5558,7 @@ var Sentry = (function (exports) {
5523
5558
  * @returns The wrapped function.
5524
5559
  * @hidden
5525
5560
  */
5526
- function wrap(fn, options, before) {
5561
+ function wrap$1(fn, options, before) {
5527
5562
  // for future readers what this does is wrap a function and then create
5528
5563
  // a bi-directional wrapping between them.
5529
5564
  //
@@ -5561,7 +5596,7 @@ var Sentry = (function (exports) {
5561
5596
  before.apply(this, arguments);
5562
5597
  }
5563
5598
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
5564
- var wrappedArguments = args.map(function (arg) { return wrap(arg, options); });
5599
+ var wrappedArguments = args.map(function (arg) { return wrap$1(arg, options); });
5565
5600
  // Attempt to invoke user-land function
5566
5601
  // NOTE: If you are a Sentry user, and you are seeing this stack frame, it
5567
5602
  // means the sentry.javascript SDK caught an error invoking your application code. This
@@ -5620,7 +5655,7 @@ var Sentry = (function (exports) {
5620
5655
  */
5621
5656
  function injectReportDialog(options) {
5622
5657
  if (options === void 0) { options = {}; }
5623
- if (!global$5.document) {
5658
+ if (!global$2.document) {
5624
5659
  return;
5625
5660
  }
5626
5661
  if (!options.eventId) {
@@ -5635,14 +5670,14 @@ var Sentry = (function (exports) {
5635
5670
  }
5636
5671
  return;
5637
5672
  }
5638
- var script = global$5.document.createElement('script');
5673
+ var script = global$2.document.createElement('script');
5639
5674
  script.async = true;
5640
5675
  script.src = getReportDialogEndpoint(options.dsn, options);
5641
5676
  if (options.onLoad) {
5642
5677
  // eslint-disable-next-line @typescript-eslint/unbound-method
5643
5678
  script.onload = options.onLoad;
5644
5679
  }
5645
- var injectionPoint = global$5.document.head || global$5.document.body;
5680
+ var injectionPoint = global$2.document.head || global$2.document.body;
5646
5681
  if (injectionPoint) {
5647
5682
  injectionPoint.appendChild(script);
5648
5683
  }
@@ -5932,7 +5967,7 @@ var Sentry = (function (exports) {
5932
5967
  args[_i] = arguments[_i];
5933
5968
  }
5934
5969
  var originalCallback = args[0];
5935
- args[0] = wrap(originalCallback, {
5970
+ args[0] = wrap$1(originalCallback, {
5936
5971
  mechanism: {
5937
5972
  data: { function: getFunctionName(original) },
5938
5973
  handled: true,
@@ -5948,7 +5983,7 @@ var Sentry = (function (exports) {
5948
5983
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5949
5984
  return function (callback) {
5950
5985
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
5951
- return original.call(this, wrap(callback, {
5986
+ return original.call(this, wrap$1(callback, {
5952
5987
  mechanism: {
5953
5988
  data: {
5954
5989
  function: 'requestAnimationFrame',
@@ -5991,7 +6026,7 @@ var Sentry = (function (exports) {
5991
6026
  wrapOptions.mechanism.data.handler = getFunctionName(originalFunction);
5992
6027
  }
5993
6028
  // Otherwise wrap directly
5994
- return wrap(original, wrapOptions);
6029
+ return wrap$1(original, wrapOptions);
5995
6030
  });
5996
6031
  }
5997
6032
  });
@@ -6012,7 +6047,7 @@ var Sentry = (function (exports) {
6012
6047
  return function (eventName, fn, options) {
6013
6048
  try {
6014
6049
  if (typeof fn.handleEvent === 'function') {
6015
- fn.handleEvent = wrap(fn.handleEvent.bind(fn), {
6050
+ fn.handleEvent = wrap$1(fn.handleEvent.bind(fn), {
6016
6051
  mechanism: {
6017
6052
  data: {
6018
6053
  function: 'handleEvent',
@@ -6030,7 +6065,7 @@ var Sentry = (function (exports) {
6030
6065
  }
6031
6066
  return original.call(this, eventName,
6032
6067
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6033
- wrap(fn, {
6068
+ wrap$1(fn, {
6034
6069
  mechanism: {
6035
6070
  data: {
6036
6071
  function: 'addEventListener',
@@ -6351,7 +6386,7 @@ var Sentry = (function (exports) {
6351
6386
  return _walkErrorTree(limit, error[key], key, __spread([exception], stack));
6352
6387
  }
6353
6388
 
6354
- var global$6 = getGlobalObject();
6389
+ var global$1 = getGlobalObject();
6355
6390
  /** UserAgent */
6356
6391
  var UserAgent = /** @class */ (function () {
6357
6392
  function UserAgent() {
@@ -6367,13 +6402,13 @@ var Sentry = (function (exports) {
6367
6402
  addGlobalEventProcessor(function (event) {
6368
6403
  if (getCurrentHub().getIntegration(UserAgent)) {
6369
6404
  // if none of the information we want exists, don't bother
6370
- if (!global$6.navigator && !global$6.location && !global$6.document) {
6405
+ if (!global$1.navigator && !global$1.location && !global$1.document) {
6371
6406
  return event;
6372
6407
  }
6373
6408
  // grab as much info as exists and add it to the event
6374
- var url = (event.request && event.request.url) || (global$6.location && global$6.location.href);
6375
- var referrer = (global$6.document || {}).referrer;
6376
- var userAgent = (global$6.navigator || {}).userAgent;
6409
+ var url = (event.request && event.request.url) || (global$1.location && global$1.location.href);
6410
+ var referrer = (global$1.document || {}).referrer;
6411
+ var userAgent = (global$1.navigator || {}).userAgent;
6377
6412
  var headers = __assign(__assign(__assign({}, (event.request && event.request.headers)), (referrer && { Referer: referrer })), (userAgent && { 'User-Agent': userAgent }));
6378
6413
  var request = __assign(__assign({}, (url && { url: url })), { headers: headers });
6379
6414
  return __assign(__assign({}, event), { request: request });
@@ -6553,8 +6588,6 @@ var Sentry = (function (exports) {
6553
6588
  return undefined;
6554
6589
  }
6555
6590
 
6556
-
6557
-
6558
6591
  var BrowserIntegrations = /*#__PURE__*/Object.freeze({
6559
6592
  __proto__: null,
6560
6593
  GlobalHandlers: GlobalHandlers,
@@ -6809,8 +6842,8 @@ var Sentry = (function (exports) {
6809
6842
  * @returns The result of wrapped function call.
6810
6843
  */
6811
6844
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6812
- function wrap$1(fn) {
6813
- return wrap(fn)();
6845
+ function wrap(fn) {
6846
+ return wrap$1(fn)();
6814
6847
  }
6815
6848
  function startSessionOnHub(hub) {
6816
6849
  hub.startSession({ ignoreDuration: true });
@@ -6900,9 +6933,9 @@ var Sentry = (function (exports) {
6900
6933
  exports.showReportDialog = showReportDialog;
6901
6934
  exports.startTransaction = startTransaction;
6902
6935
  exports.withScope = withScope;
6903
- exports.wrap = wrap$1;
6936
+ exports.wrap = wrap;
6904
6937
 
6905
6938
  return exports;
6906
6939
 
6907
- }({}));
6940
+ })({});
6908
6941
  //# sourceMappingURL=bundle.js.map