@sentry/browser 6.18.0 → 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,4 +1,4 @@
1
- /*! @sentry/browser 6.18.0 (70c1d77) | 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
  /*! *****************************************************************************
@@ -2377,6 +2377,48 @@ var Sentry = (function (exports) {
2377
2377
  return dateNow;
2378
2378
  }))();
2379
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
+ }
2421
+
2380
2422
  /**
2381
2423
  * Absolute maximum number of breadcrumbs added to an event.
2382
2424
  * The `maxBreadcrumbs` option cannot be higher than this value.
@@ -4478,7 +4520,7 @@ var Sentry = (function (exports) {
4478
4520
  hub.bindClient(client);
4479
4521
  }
4480
4522
 
4481
- var SDK_VERSION = '6.18.0';
4523
+ var SDK_VERSION = '6.18.1-beta.0';
4482
4524
 
4483
4525
  var originalFunctionToString;
4484
4526
  /** Patch toString calls to return proper name for wrapped functions */
@@ -5203,25 +5245,18 @@ var Sentry = (function (exports) {
5203
5245
  }
5204
5246
  logger.log("Flushing outcomes:\n" + JSON.stringify(outcomes, null, 2));
5205
5247
  var url = getEnvelopeEndpointWithUrlEncodedAuth(this._api.dsn, this._api.tunnel);
5206
- // Envelope header is required to be at least an empty object
5207
- var envelopeHeader = JSON.stringify(__assign({}, (this._api.tunnel && { dsn: dsnToString(this._api.dsn) })));
5208
- var itemHeaders = JSON.stringify({
5209
- type: 'client_report',
5210
- });
5211
- var item = JSON.stringify({
5212
- timestamp: dateTimestampInSeconds(),
5213
- discarded_events: Object.keys(outcomes).map(function (key) {
5214
- var _a = __read(key.split(':'), 2), category = _a[0], reason = _a[1];
5215
- return {
5216
- reason: reason,
5217
- category: category,
5218
- quantity: outcomes[key],
5219
- };
5220
- }),
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
5221
5256
  });
5222
- var envelope = envelopeHeader + "\n" + itemHeaders + "\n" + item;
5257
+ var envelope = createClientReportEnvelope(discardedEvents, this._api.tunnel && dsnToString(this._api.dsn));
5223
5258
  try {
5224
- sendReport(url, envelope);
5259
+ sendReport(url, serializeEnvelope(envelope));
5225
5260
  }
5226
5261
  catch (e) {
5227
5262
  logger.error(e);