@sentry/replay 0.4.9 → 0.5.2

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 (84) hide show
  1. package/dist/index.es.js +62 -35
  2. package/dist/index.js +60 -33
  3. package/dist/index.js.map +1 -1
  4. package/dist/{config/dist → types}/src/api/captureReplay.d.ts +0 -0
  5. package/dist/{config/dist → types}/src/api/captureReplayUpdate.d.ts +0 -0
  6. package/dist/{config/dist → types}/src/coreHandlers/getBreadcrumbHandler.d.ts +0 -0
  7. package/dist/{config/dist → types}/src/coreHandlers/getSpanHandler.d.ts +0 -0
  8. package/dist/{config/dist → types}/src/coreHandlers/handleDom.d.ts +0 -0
  9. package/dist/{config/dist → types}/src/coreHandlers/handleFetch.d.ts +0 -0
  10. package/dist/{config/dist → types}/src/coreHandlers/handleHistory.d.ts +0 -0
  11. package/dist/{config/dist → types}/src/coreHandlers/handleScope.d.ts +0 -0
  12. package/dist/{config/dist → types}/src/coreHandlers/handleXhr.d.ts +0 -0
  13. package/dist/{config/dist → types}/src/createPerformanceEntry.d.ts +0 -0
  14. package/dist/{config/dist → types}/src/eventBuffer.d.ts +0 -0
  15. package/dist/{config/dist → types}/src/flags.d.ts +0 -0
  16. package/dist/{dist → types/src}/index.d.ts +3 -4
  17. package/dist/{config/dist → types}/src/session/Session.d.ts +0 -0
  18. package/dist/{config/dist → types}/src/session/constants.d.ts +2 -2
  19. package/dist/{config/dist → types}/src/session/createSession.d.ts +0 -0
  20. package/dist/{config/dist → types}/src/session/fetchSession.d.ts +0 -0
  21. package/dist/{config/dist → types}/src/session/getSession.d.ts +0 -0
  22. package/dist/{config/dist → types}/src/session/index.d.ts +0 -0
  23. package/dist/{config/dist → types}/src/session/saveSession.d.ts +0 -0
  24. package/dist/{config/dist → types}/src/types.d.ts +2 -1
  25. package/dist/{config/dist → types}/src/util/createBreadcrumb.d.ts +0 -0
  26. package/dist/{config/dist → types}/src/util/createPayload.d.ts +0 -0
  27. package/dist/{config/dist → types}/src/util/isExpired.d.ts +0 -0
  28. package/dist/{config/dist → types}/src/util/isIngestHost.d.ts +0 -0
  29. package/dist/{config/dist → types}/src/util/isSampled.d.ts +0 -0
  30. package/dist/{config/dist → types}/src/util/isSessionExpired.d.ts +0 -0
  31. package/dist/{config/dist → types}/src/util/logger.d.ts +0 -0
  32. package/dist/{config/dist → types}/src/util/supportsSendBeacon.d.ts +0 -0
  33. package/package.json +3 -2
  34. package/dist/config/dist/jest.config.d.ts +0 -3
  35. package/dist/config/dist/jest.setup.d.ts +0 -10
  36. package/dist/config/dist/src/coreHandlers/handleFetch.test.d.ts +0 -1
  37. package/dist/config/dist/src/coreHandlers/handleScope-unit.test.d.ts +0 -1
  38. package/dist/config/dist/src/coreHandlers/handleScope.test.d.ts +0 -1
  39. package/dist/config/dist/src/coreHandlers/index.d.ts +0 -4
  40. package/dist/config/dist/src/createPerformanceEntry.test.d.ts +0 -1
  41. package/dist/config/dist/src/eventBuffer.test.d.ts +0 -1
  42. package/dist/config/dist/src/index-captureOnlyOnError.test.d.ts +0 -1
  43. package/dist/config/dist/src/index-noSticky.test.d.ts +0 -1
  44. package/dist/config/dist/src/index-sampling.test.d.ts +0 -1
  45. package/dist/config/dist/src/index.d.ts +0 -225
  46. package/dist/config/dist/src/index.test.d.ts +0 -1
  47. package/dist/config/dist/src/session/Session.test.d.ts +0 -1
  48. package/dist/config/dist/src/session/createSession.test.d.ts +0 -1
  49. package/dist/config/dist/src/session/fetchSession.test.d.ts +0 -1
  50. package/dist/config/dist/src/session/getSession.test.d.ts +0 -1
  51. package/dist/config/dist/src/session/saveSession.test.d.ts +0 -1
  52. package/dist/config/dist/src/util/isExpired.test.d.ts +0 -1
  53. package/dist/config/dist/src/util/isSampled.test.d.ts +0 -1
  54. package/dist/config/dist/src/util/isSessionExpired.test.d.ts +0 -1
  55. package/dist/config/dist/test/index.d.ts +0 -3
  56. package/dist/config/dist/test/mocks/mockRrweb.d.ts +0 -15
  57. package/dist/config/dist/test/mocks/mockSdk.d.ts +0 -11
  58. package/dist/dist/api/captureReplay.d.ts +0 -10
  59. package/dist/dist/api/captureReplayUpdate.d.ts +0 -12
  60. package/dist/dist/coreHandlers/getBreadcrumbHandler.d.ts +0 -3
  61. package/dist/dist/coreHandlers/getSpanHandler.d.ts +0 -5
  62. package/dist/dist/coreHandlers/handleDom.d.ts +0 -1
  63. package/dist/dist/coreHandlers/handleFetch.d.ts +0 -19
  64. package/dist/dist/coreHandlers/handleHistory.d.ts +0 -7
  65. package/dist/dist/coreHandlers/handleScope.d.ts +0 -2
  66. package/dist/dist/coreHandlers/handleXhr.d.ts +0 -21
  67. package/dist/dist/createPerformanceEntry.d.ts +0 -42
  68. package/dist/dist/eventBuffer.d.ts +0 -45
  69. package/dist/dist/flags.d.ts +0 -2
  70. package/dist/dist/session/Session.d.ts +0 -63
  71. package/dist/dist/session/constants.d.ts +0 -5
  72. package/dist/dist/session/createSession.d.ts +0 -19
  73. package/dist/dist/session/fetchSession.d.ts +0 -5
  74. package/dist/dist/session/getSession.d.ts +0 -28
  75. package/dist/dist/session/index.d.ts +0 -1
  76. package/dist/dist/session/saveSession.d.ts +0 -2
  77. package/dist/dist/types.d.ts +0 -90
  78. package/dist/dist/util/createBreadcrumb.d.ts +0 -4
  79. package/dist/dist/util/isExpired.d.ts +0 -5
  80. package/dist/dist/util/isIngestHost.d.ts +0 -4
  81. package/dist/dist/util/isSampled.d.ts +0 -7
  82. package/dist/dist/util/isSessionExpired.d.ts +0 -5
  83. package/dist/dist/util/logger.d.ts +0 -12
  84. package/dist/dist/util/supportsSendBeacon.d.ts +0 -4
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
- import { captureEvent, getCurrentHub, captureException, addGlobalEventProcessor } from '@sentry/core';
2
- import { uuid4, htmlTreeAsString, logger as logger$1, addInstrumentationHandler } from '@sentry/utils';
1
+ import { captureEvent, getCurrentHub, captureException, addGlobalEventProcessor, getEnvelopeEndpointWithUrlEncodedAuth } from '@sentry/core';
2
+ import { htmlTreeAsString, logger as logger$1, uuid4, addInstrumentationHandler, createEnvelope, serializeEnvelope } from '@sentry/utils';
3
3
  import { record, EventType } from 'rrweb';
4
4
 
5
5
  /******************************************************************************
@@ -89,8 +89,7 @@ function __spreadArray(to, from, pack) {
89
89
  }
90
90
 
91
91
  var REPLAY_SESSION_KEY = 'sentryReplaySession';
92
- var ROOT_REPLAY_NAME = 'sentry-replay';
93
- var REPLAY_EVENT_NAME = 'sentry-replay-event';
92
+ var REPLAY_EVENT_NAME = 'replay_event';
94
93
  // The idle limit for a session
95
94
  var SESSION_IDLE_DURATION = 900000; // 15 minutes
96
95
  // Grace period to keep a session when a user changes tabs or hides window
@@ -99,29 +98,28 @@ var VISIBILITY_CHANGE_TIMEOUT = SESSION_IDLE_DURATION;
99
98
  function captureReplay(_a) {
100
99
  var session = _a.session, initialState = _a.initialState, errorIds = _a.errorIds, traceIds = _a.traceIds, urls = _a.urls;
101
100
  captureEvent({
102
- message: ROOT_REPLAY_NAME,
103
- tags: { segmentId: session.segmentId, url: initialState.url },
104
- timestamp: initialState.timestamp / 1000,
105
- // @ts-expect-error replay event type accepts this
101
+ // @ts-expect-error replay_event is a new event type
102
+ type: REPLAY_EVENT_NAME,
103
+ replay_start_timestamp: initialState.timestamp / 1000,
106
104
  error_ids: errorIds,
107
105
  trace_ids: traceIds,
108
106
  urls: urls,
107
+ replay_id: session.id,
108
+ segment_id: session.segmentId, // TODO: Should this increment?
109
109
  }, { event_id: session.id });
110
110
  }
111
111
 
112
112
  function captureReplayUpdate(_a) {
113
113
  var session = _a.session, timestamp = _a.timestamp, errorIds = _a.errorIds, traceIds = _a.traceIds, urls = _a.urls;
114
114
  captureEvent({
115
- timestamp: timestamp / 1000,
116
- message: "".concat(REPLAY_EVENT_NAME, "-").concat(uuid4().substring(16)),
117
- // @ts-expect-error replay event type accepts this
115
+ // @ts-expect-error replay_event is a new event type
116
+ type: REPLAY_EVENT_NAME,
117
+ replay_start_timestamp: timestamp / 1000,
118
118
  error_ids: errorIds,
119
119
  trace_ids: traceIds,
120
120
  urls: urls,
121
- tags: {
122
- replayId: session.id,
123
- segmentId: session.segmentId++,
124
- },
121
+ replay_id: session.id,
122
+ segment_id: ++session.segmentId,
125
123
  });
126
124
  }
127
125
 
@@ -465,6 +463,26 @@ function getSession(_a) {
465
463
  return { type: 'new', session: newSession };
466
464
  }
467
465
 
466
+ function createPayload(_a) {
467
+ var events = _a.events, headers = _a.headers;
468
+ var payloadWithSequence;
469
+ // XXX: newline is needed to separate sequence id from events
470
+ var replayHeaders = "".concat(JSON.stringify(headers), "\n");
471
+ if (typeof events === 'string') {
472
+ payloadWithSequence = "".concat(replayHeaders).concat(events);
473
+ }
474
+ else {
475
+ var enc = new TextEncoder();
476
+ // XXX: newline is needed to separate sequence id from events
477
+ var sequence = enc.encode(replayHeaders);
478
+ // Merge the two Uint8Arrays
479
+ payloadWithSequence = new Uint8Array(sequence.length + events.length);
480
+ payloadWithSequence.set(sequence);
481
+ payloadWithSequence.set(events, sequence.length);
482
+ }
483
+ return payloadWithSequence;
484
+ }
485
+
468
486
  /**
469
487
  * Determine if there is browser support for `navigator.sendBeacon`
470
488
  */
@@ -799,10 +817,11 @@ var SentryReplay = /** @class */ (function () {
799
817
  * when an error occurs.
800
818
  **/
801
819
  this.handleGlobalEvent = function (event) {
802
- var _a, _b;
820
+ var _a;
803
821
  // Do not apply replayId to the root event
804
- if (event.message === ROOT_REPLAY_NAME ||
805
- ((_a = event.message) === null || _a === void 0 ? void 0 : _a.startsWith(REPLAY_EVENT_NAME))) {
822
+ if (
823
+ // @ts-expect-error new event type
824
+ event.type === REPLAY_EVENT_NAME) {
806
825
  // Replays have separate set of breadcrumbs, do not include breadcrumbs
807
826
  // from core SDK
808
827
  delete event.breadcrumbs;
@@ -810,7 +829,7 @@ var SentryReplay = /** @class */ (function () {
810
829
  }
811
830
  event.tags = __assign(__assign({}, event.tags), { replayId: _this.session.id });
812
831
  if (event.type === 'transaction') {
813
- _this.context.traceIds.add(String(((_b = event.contexts) === null || _b === void 0 ? void 0 : _b.trace.trace_id) || ''));
832
+ _this.context.traceIds.add(String(((_a = event.contexts) === null || _a === void 0 ? void 0 : _a.trace.trace_id) || ''));
814
833
  return event;
815
834
  }
816
835
  // XXX: Is it safe to assume that all other events are error events?
@@ -974,12 +993,6 @@ var SentryReplay = /** @class */ (function () {
974
993
  this.recordingOptions.checkoutEveryNms = 60000;
975
994
  }
976
995
  }
977
- SentryReplay.attachmentUrlFromDsn = function (dsn, eventId) {
978
- var host = dsn.host, projectId = dsn.projectId, protocol = dsn.protocol, publicKey = dsn.publicKey;
979
- var port = dsn.port !== '' ? ":".concat(dsn.port) : '';
980
- var path = dsn.path !== '' ? "/".concat(dsn.path) : '';
981
- return "".concat(protocol, "://").concat(host).concat(port).concat(path, "/api/").concat(projectId, "/events/").concat(eventId, "/attachments/?sentry_key=").concat(publicKey, "&sentry_version=7&sentry_client=replay");
982
- };
983
996
  /**
984
997
  * Because we create a transaction in `setupOnce`, we can potentially create a
985
998
  * transaction before some native SDK integrations have run and applied their
@@ -1408,27 +1421,41 @@ var SentryReplay = /** @class */ (function () {
1408
1421
  SentryReplay.prototype.sendReplayRequest = function (_a) {
1409
1422
  var endpoint = _a.endpoint, events = _a.events;
1410
1423
  return __awaiter(this, void 0, void 0, function () {
1411
- var formData, payloadBlob;
1424
+ var payloadWithSequence, envelope;
1412
1425
  return __generator(this, function (_b) {
1413
1426
  switch (_b.label) {
1414
1427
  case 0:
1415
- formData = new FormData();
1416
- payloadBlob = new Blob([events], {
1417
- type: 'application/json',
1428
+ payloadWithSequence = createPayload({
1429
+ events: events,
1430
+ headers: {
1431
+ segment_id: this.session.segmentId,
1432
+ },
1418
1433
  });
1419
- logger.log('blob size in bytes: ', payloadBlob.size);
1420
- formData.append('rrweb', payloadBlob, "rrweb-".concat(new Date().getTime(), ".json"));
1434
+ envelope = createEnvelope({
1435
+ event_id: this.session.id,
1436
+ sent_at: new Date().toISOString(),
1437
+ sdk: { name: 'sentry.javascript.integration.replay', version: '1.0.0' },
1438
+ }, [
1439
+ [
1440
+ {
1441
+ // @ts-expect-error setting envelope
1442
+ type: 'replay_recording',
1443
+ length: payloadWithSequence.length,
1444
+ },
1445
+ payloadWithSequence,
1446
+ ],
1447
+ ]);
1421
1448
  // If sendBeacon is supported and payload is smol enough...
1422
- if (supportsSendBeacon() && payloadBlob.size <= 65535) {
1449
+ if (supportsSendBeacon() && events.length <= 65536) {
1423
1450
  logger.log("uploading attachment via sendBeacon()");
1424
- window.navigator.sendBeacon(endpoint, formData);
1451
+ window.navigator.sendBeacon(endpoint, serializeEnvelope(envelope));
1425
1452
  return [2 /*return*/];
1426
1453
  }
1427
1454
  // Otherwise use `fetch`, which *WILL* get cancelled on page reloads/unloads
1428
1455
  logger.log("uploading attachment via fetch()");
1429
1456
  return [4 /*yield*/, fetch(endpoint, {
1430
1457
  method: 'POST',
1431
- body: formData,
1458
+ body: serializeEnvelope(envelope),
1432
1459
  })];
1433
1460
  case 1:
1434
1461
  _b.sent();
@@ -1456,7 +1483,7 @@ var SentryReplay = /** @class */ (function () {
1456
1483
  return [2 /*return*/];
1457
1484
  }
1458
1485
  client = getCurrentHub().getClient();
1459
- endpoint = SentryReplay.attachmentUrlFromDsn(client.getDsn(), eventId);
1486
+ endpoint = getEnvelopeEndpointWithUrlEncodedAuth(client.getDsn());
1460
1487
  _b.label = 1;
1461
1488
  case 1:
1462
1489
  _b.trys.push([1, 3, , 8]);
package/dist/index.js CHANGED
@@ -93,8 +93,7 @@ function __spreadArray(to, from, pack) {
93
93
  }
94
94
 
95
95
  var REPLAY_SESSION_KEY = 'sentryReplaySession';
96
- var ROOT_REPLAY_NAME = 'sentry-replay';
97
- var REPLAY_EVENT_NAME = 'sentry-replay-event';
96
+ var REPLAY_EVENT_NAME = 'replay_event';
98
97
  // The idle limit for a session
99
98
  var SESSION_IDLE_DURATION = 900000; // 15 minutes
100
99
  // Grace period to keep a session when a user changes tabs or hides window
@@ -103,29 +102,28 @@ var VISIBILITY_CHANGE_TIMEOUT = SESSION_IDLE_DURATION;
103
102
  function captureReplay(_a) {
104
103
  var session = _a.session, initialState = _a.initialState, errorIds = _a.errorIds, traceIds = _a.traceIds, urls = _a.urls;
105
104
  core.captureEvent({
106
- message: ROOT_REPLAY_NAME,
107
- tags: { segmentId: session.segmentId, url: initialState.url },
108
- timestamp: initialState.timestamp / 1000,
109
- // @ts-expect-error replay event type accepts this
105
+ // @ts-expect-error replay_event is a new event type
106
+ type: REPLAY_EVENT_NAME,
107
+ replay_start_timestamp: initialState.timestamp / 1000,
110
108
  error_ids: errorIds,
111
109
  trace_ids: traceIds,
112
110
  urls: urls,
111
+ replay_id: session.id,
112
+ segment_id: session.segmentId, // TODO: Should this increment?
113
113
  }, { event_id: session.id });
114
114
  }
115
115
 
116
116
  function captureReplayUpdate(_a) {
117
117
  var session = _a.session, timestamp = _a.timestamp, errorIds = _a.errorIds, traceIds = _a.traceIds, urls = _a.urls;
118
118
  core.captureEvent({
119
- timestamp: timestamp / 1000,
120
- message: "".concat(REPLAY_EVENT_NAME, "-").concat(utils.uuid4().substring(16)),
121
- // @ts-expect-error replay event type accepts this
119
+ // @ts-expect-error replay_event is a new event type
120
+ type: REPLAY_EVENT_NAME,
121
+ replay_start_timestamp: timestamp / 1000,
122
122
  error_ids: errorIds,
123
123
  trace_ids: traceIds,
124
124
  urls: urls,
125
- tags: {
126
- replayId: session.id,
127
- segmentId: session.segmentId++,
128
- },
125
+ replay_id: session.id,
126
+ segment_id: ++session.segmentId,
129
127
  });
130
128
  }
131
129
 
@@ -469,6 +467,26 @@ function getSession(_a) {
469
467
  return { type: 'new', session: newSession };
470
468
  }
471
469
 
470
+ function createPayload(_a) {
471
+ var events = _a.events, headers = _a.headers;
472
+ var payloadWithSequence;
473
+ // XXX: newline is needed to separate sequence id from events
474
+ var replayHeaders = "".concat(JSON.stringify(headers), "\n");
475
+ if (typeof events === 'string') {
476
+ payloadWithSequence = "".concat(replayHeaders).concat(events);
477
+ }
478
+ else {
479
+ var enc = new TextEncoder();
480
+ // XXX: newline is needed to separate sequence id from events
481
+ var sequence = enc.encode(replayHeaders);
482
+ // Merge the two Uint8Arrays
483
+ payloadWithSequence = new Uint8Array(sequence.length + events.length);
484
+ payloadWithSequence.set(sequence);
485
+ payloadWithSequence.set(events, sequence.length);
486
+ }
487
+ return payloadWithSequence;
488
+ }
489
+
472
490
  /**
473
491
  * Determine if there is browser support for `navigator.sendBeacon`
474
492
  */
@@ -803,10 +821,11 @@ var SentryReplay = /** @class */ (function () {
803
821
  * when an error occurs.
804
822
  **/
805
823
  this.handleGlobalEvent = function (event) {
806
- var _a, _b;
824
+ var _a;
807
825
  // Do not apply replayId to the root event
808
- if (event.message === ROOT_REPLAY_NAME ||
809
- ((_a = event.message) === null || _a === void 0 ? void 0 : _a.startsWith(REPLAY_EVENT_NAME))) {
826
+ if (
827
+ // @ts-expect-error new event type
828
+ event.type === REPLAY_EVENT_NAME) {
810
829
  // Replays have separate set of breadcrumbs, do not include breadcrumbs
811
830
  // from core SDK
812
831
  delete event.breadcrumbs;
@@ -814,7 +833,7 @@ var SentryReplay = /** @class */ (function () {
814
833
  }
815
834
  event.tags = __assign(__assign({}, event.tags), { replayId: _this.session.id });
816
835
  if (event.type === 'transaction') {
817
- _this.context.traceIds.add(String(((_b = event.contexts) === null || _b === void 0 ? void 0 : _b.trace.trace_id) || ''));
836
+ _this.context.traceIds.add(String(((_a = event.contexts) === null || _a === void 0 ? void 0 : _a.trace.trace_id) || ''));
818
837
  return event;
819
838
  }
820
839
  // XXX: Is it safe to assume that all other events are error events?
@@ -978,12 +997,6 @@ var SentryReplay = /** @class */ (function () {
978
997
  this.recordingOptions.checkoutEveryNms = 60000;
979
998
  }
980
999
  }
981
- SentryReplay.attachmentUrlFromDsn = function (dsn, eventId) {
982
- var host = dsn.host, projectId = dsn.projectId, protocol = dsn.protocol, publicKey = dsn.publicKey;
983
- var port = dsn.port !== '' ? ":".concat(dsn.port) : '';
984
- var path = dsn.path !== '' ? "/".concat(dsn.path) : '';
985
- return "".concat(protocol, "://").concat(host).concat(port).concat(path, "/api/").concat(projectId, "/events/").concat(eventId, "/attachments/?sentry_key=").concat(publicKey, "&sentry_version=7&sentry_client=replay");
986
- };
987
1000
  /**
988
1001
  * Because we create a transaction in `setupOnce`, we can potentially create a
989
1002
  * transaction before some native SDK integrations have run and applied their
@@ -1412,27 +1425,41 @@ var SentryReplay = /** @class */ (function () {
1412
1425
  SentryReplay.prototype.sendReplayRequest = function (_a) {
1413
1426
  var endpoint = _a.endpoint, events = _a.events;
1414
1427
  return __awaiter(this, void 0, void 0, function () {
1415
- var formData, payloadBlob;
1428
+ var payloadWithSequence, envelope;
1416
1429
  return __generator(this, function (_b) {
1417
1430
  switch (_b.label) {
1418
1431
  case 0:
1419
- formData = new FormData();
1420
- payloadBlob = new Blob([events], {
1421
- type: 'application/json',
1432
+ payloadWithSequence = createPayload({
1433
+ events: events,
1434
+ headers: {
1435
+ segment_id: this.session.segmentId,
1436
+ },
1422
1437
  });
1423
- logger.log('blob size in bytes: ', payloadBlob.size);
1424
- formData.append('rrweb', payloadBlob, "rrweb-".concat(new Date().getTime(), ".json"));
1438
+ envelope = utils.createEnvelope({
1439
+ event_id: this.session.id,
1440
+ sent_at: new Date().toISOString(),
1441
+ sdk: { name: 'sentry.javascript.integration.replay', version: '1.0.0' },
1442
+ }, [
1443
+ [
1444
+ {
1445
+ // @ts-expect-error setting envelope
1446
+ type: 'replay_recording',
1447
+ length: payloadWithSequence.length,
1448
+ },
1449
+ payloadWithSequence,
1450
+ ],
1451
+ ]);
1425
1452
  // If sendBeacon is supported and payload is smol enough...
1426
- if (supportsSendBeacon() && payloadBlob.size <= 65535) {
1453
+ if (supportsSendBeacon() && events.length <= 65536) {
1427
1454
  logger.log("uploading attachment via sendBeacon()");
1428
- window.navigator.sendBeacon(endpoint, formData);
1455
+ window.navigator.sendBeacon(endpoint, utils.serializeEnvelope(envelope));
1429
1456
  return [2 /*return*/];
1430
1457
  }
1431
1458
  // Otherwise use `fetch`, which *WILL* get cancelled on page reloads/unloads
1432
1459
  logger.log("uploading attachment via fetch()");
1433
1460
  return [4 /*yield*/, fetch(endpoint, {
1434
1461
  method: 'POST',
1435
- body: formData,
1462
+ body: utils.serializeEnvelope(envelope),
1436
1463
  })];
1437
1464
  case 1:
1438
1465
  _b.sent();
@@ -1460,7 +1487,7 @@ var SentryReplay = /** @class */ (function () {
1460
1487
  return [2 /*return*/];
1461
1488
  }
1462
1489
  client = core.getCurrentHub().getClient();
1463
- endpoint = SentryReplay.attachmentUrlFromDsn(client.getDsn(), eventId);
1490
+ endpoint = core.getEnvelopeEndpointWithUrlEncodedAuth(client.getDsn());
1464
1491
  _b.label = 1;
1465
1492
  case 1:
1466
1493
  _b.trys.push([1, 3, , 8]);