@myinterview/widget-react 1.0.57-ada6b21 → 1.0.57

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/dist/esm/index.js CHANGED
@@ -7630,7 +7630,7 @@ function useMachine(getMachine) {
7630
7630
  ? State.create(options.state)
7631
7631
  : service.machine.initialState);
7632
7632
  }
7633
- return service.state;
7633
+ return service.getSnapshot();
7634
7634
  }, [service]);
7635
7635
  var isEqual = useCallback(function (prevState, nextState) {
7636
7636
  if (service.status === InterpreterStatus.NotStarted) {
@@ -7662,6 +7662,42 @@ function useMachine(getMachine) {
7662
7662
  return [storeSnapshot, service.send, service];
7663
7663
  }
7664
7664
 
7665
+ (undefined && undefined.__read) || function (o, n) {
7666
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
7667
+ if (!m) return o;
7668
+ var i = m.call(o), r, ar = [], e;
7669
+ try {
7670
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
7671
+ }
7672
+ catch (error) { e = { error: error }; }
7673
+ finally {
7674
+ try {
7675
+ if (r && !r.done && (m = i["return"])) m.call(i);
7676
+ }
7677
+ finally { if (e) throw e.error; }
7678
+ }
7679
+ return ar;
7680
+ };
7681
+ (undefined && undefined.__values) || function(o) {
7682
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
7683
+ if (m) return m.call(o);
7684
+ if (o && typeof o.length === "number") return {
7685
+ next: function () {
7686
+ if (o && i >= o.length) o = void 0;
7687
+ return { value: o && o[i++], done: !o };
7688
+ }
7689
+ };
7690
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
7691
+ };
7692
+ function getServiceSnapshot(service) {
7693
+ return service.status !== 0
7694
+ ? service.getSnapshot()
7695
+ : service.machine.initialState;
7696
+ }
7697
+ function isService(actor) {
7698
+ return 'state' in actor && 'machine' in actor;
7699
+ }
7700
+
7665
7701
  function isActorWithState(actorRef) {
7666
7702
  return 'state' in actorRef;
7667
7703
  }
@@ -7670,7 +7706,9 @@ function isDeferredActor(actorRef) {
7670
7706
  }
7671
7707
  function defaultGetSnapshot(actorRef) {
7672
7708
  return 'getSnapshot' in actorRef
7673
- ? actorRef.getSnapshot()
7709
+ ? isService(actorRef)
7710
+ ? getServiceSnapshot(actorRef)
7711
+ : actorRef.getSnapshot()
7674
7712
  : isActorWithState(actorRef)
7675
7713
  ? actorRef.state
7676
7714
  : undefined;
@@ -7719,34 +7757,6 @@ function useActor(actorRef, getSnapshot) {
7719
7757
  return [storeSnapshot, send];
7720
7758
  }
7721
7759
 
7722
- (undefined && undefined.__read) || function (o, n) {
7723
- var m = typeof Symbol === "function" && o[Symbol.iterator];
7724
- if (!m) return o;
7725
- var i = m.call(o), r, ar = [], e;
7726
- try {
7727
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
7728
- }
7729
- catch (error) { e = { error: error }; }
7730
- finally {
7731
- try {
7732
- if (r && !r.done && (m = i["return"])) m.call(i);
7733
- }
7734
- finally { if (e) throw e.error; }
7735
- }
7736
- return ar;
7737
- };
7738
- (undefined && undefined.__values) || function(o) {
7739
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
7740
- if (m) return m.call(o);
7741
- if (o && typeof o.length === "number") return {
7742
- next: function () {
7743
- if (o && i >= o.length) o = void 0;
7744
- return { value: o && o[i++], done: !o };
7745
- }
7746
- };
7747
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
7748
- };
7749
-
7750
7760
  var SPEED_TEST_LEVEL;
7751
7761
  (function (SPEED_TEST_LEVEL) {
7752
7762
  SPEED_TEST_LEVEL[SPEED_TEST_LEVEL["LOW"] = 0] = "LOW";
@@ -15688,9 +15698,7 @@ function urlEncode(object) {
15688
15698
  * @returns An Event or Error turned into an object - or the value argurment itself, when value is neither an Event nor
15689
15699
  * an Error.
15690
15700
  */
15691
- function convertToPlainObject(
15692
- value,
15693
- )
15701
+ function convertToPlainObject(value)
15694
15702
 
15695
15703
  {
15696
15704
  if (isError(value)) {
@@ -15883,6 +15891,14 @@ function createStackParser(...parsers) {
15883
15891
  const frames = [];
15884
15892
 
15885
15893
  for (const line of stack.split('\n').slice(skipFirst)) {
15894
+ // Ignore lines over 1kb as they are unlikely to be stack frames.
15895
+ // Many of the regular expressions use backtracking which results in run time that increases exponentially with
15896
+ // input size. Huge strings can result in hangs/Denial of Service:
15897
+ // https://github.com/getsentry/sentry-javascript/issues/2286
15898
+ if (line.length > 1024) {
15899
+ continue;
15900
+ }
15901
+
15886
15902
  // https://github.com/getsentry/sentry-javascript/issues/5459
15887
15903
  // Remove webpack (error: *) wrappers
15888
15904
  const cleanedLine = line.replace(/\(error: (.*)\)/, '$1');
@@ -18717,7 +18733,7 @@ class Hub {
18717
18733
  */
18718
18734
  captureEvent(event, hint) {
18719
18735
  const eventId = hint && hint.event_id ? hint.event_id : uuid4();
18720
- if (event.type !== 'transaction') {
18736
+ if (!event.type) {
18721
18737
  this._lastEventId = eventId;
18722
18738
  }
18723
18739
 
@@ -18742,7 +18758,6 @@ class Hub {
18742
18758
 
18743
18759
  if (!scope || !client) return;
18744
18760
 
18745
- // eslint-disable-next-line @typescript-eslint/unbound-method
18746
18761
  const { beforeBreadcrumb = null, maxBreadcrumbs = DEFAULT_BREADCRUMBS } =
18747
18762
  (client.getOptions && client.getOptions()) || {};
18748
18763
 
@@ -19236,7 +19251,15 @@ function createEventEnvelope(
19236
19251
  tunnel,
19237
19252
  ) {
19238
19253
  const sdkInfo = getSdkMetadataForEnvelopeHeader(metadata);
19239
- const eventType = event.type || 'event';
19254
+
19255
+ /*
19256
+ Note: Due to TS, event.type may be `replay_event`, theoretically.
19257
+ In practice, we never call `createEventEnvelope` with `replay_event` type,
19258
+ and we'd have to adjut a looot of types to make this work properly.
19259
+ We want to avoid casting this around, as that could lead to bugs (e.g. when we add another type)
19260
+ So the safe choice is to really guard against the replay_event type here.
19261
+ */
19262
+ const eventType = event.type && event.type !== 'replay_event' ? event.type : 'event';
19240
19263
 
19241
19264
  enhanceEventWithSdkInfo(event, metadata && metadata.sdk);
19242
19265
 
@@ -19264,18 +19287,23 @@ function setupIntegrations(integrations) {
19264
19287
  const integrationIndex = {};
19265
19288
 
19266
19289
  integrations.forEach(integration => {
19267
- integrationIndex[integration.name] = integration;
19268
-
19269
- if (installedIntegrations.indexOf(integration.name) === -1) {
19270
- integration.setupOnce(addGlobalEventProcessor, getCurrentHub);
19271
- installedIntegrations.push(integration.name);
19272
- (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.log(`Integration installed: ${integration.name}`);
19273
- }
19290
+ setupIntegration(integration, integrationIndex);
19274
19291
  });
19275
19292
 
19276
19293
  return integrationIndex;
19277
19294
  }
19278
19295
 
19296
+ /** Setup a single integration. */
19297
+ function setupIntegration(integration, integrationIndex) {
19298
+ integrationIndex[integration.name] = integration;
19299
+
19300
+ if (installedIntegrations.indexOf(integration.name) === -1) {
19301
+ integration.setupOnce(addGlobalEventProcessor, getCurrentHub);
19302
+ installedIntegrations.push(integration.name);
19303
+ (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.log(`Integration installed: ${integration.name}`);
19304
+ }
19305
+ }
19306
+
19279
19307
  /**
19280
19308
  * Adds common information to events.
19281
19309
  *
@@ -19709,6 +19737,13 @@ class BaseClient {
19709
19737
  }
19710
19738
  }
19711
19739
 
19740
+ /**
19741
+ * @inheritDoc
19742
+ */
19743
+ addIntegration(integration) {
19744
+ setupIntegration(integration, this._integrations);
19745
+ }
19746
+
19712
19747
  /**
19713
19748
  * @inheritDoc
19714
19749
  */
@@ -20100,7 +20135,9 @@ const DEFAULT_TRANSPORT_BUFFER_SIZE = 30;
20100
20135
  function createTransport(
20101
20136
  options,
20102
20137
  makeRequest,
20103
- buffer = makePromiseBuffer(options.bufferSize || DEFAULT_TRANSPORT_BUFFER_SIZE),
20138
+ buffer = makePromiseBuffer(
20139
+ options.bufferSize || DEFAULT_TRANSPORT_BUFFER_SIZE,
20140
+ ),
20104
20141
  ) {
20105
20142
  let rateLimits = {};
20106
20143
 
@@ -20145,10 +20182,11 @@ function createTransport(
20145
20182
  }
20146
20183
 
20147
20184
  rateLimits = updateRateLimits(rateLimits, response);
20185
+ return response;
20148
20186
  },
20149
20187
  error => {
20150
- (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.error('Failed while sending event:', error);
20151
20188
  recordEnvelopeLoss('network_error');
20189
+ throw error;
20152
20190
  },
20153
20191
  );
20154
20192
 
@@ -20180,7 +20218,7 @@ function getEventForEnvelopeItem(item, type) {
20180
20218
  return Array.isArray(item) ? (item )[1] : undefined;
20181
20219
  }
20182
20220
 
20183
- const SDK_VERSION = '7.29.0';
20221
+ const SDK_VERSION = '7.30.0';
20184
20222
 
20185
20223
  let originalFunctionToString;
20186
20224
 
@@ -22132,7 +22170,7 @@ class HttpContext {constructor() { HttpContext.prototype.__init.call(this); }
22132
22170
  ...(referrer && { Referer: referrer }),
22133
22171
  ...(userAgent && { 'User-Agent': userAgent }),
22134
22172
  };
22135
- const request = { ...(url && { url }), headers };
22173
+ const request = { ...event.request, ...(url && { url }), headers };
22136
22174
 
22137
22175
  return { ...event, request };
22138
22176
  }
@@ -29402,6 +29440,9 @@ var fdt = new u8(32);
29402
29440
  for (var i = 0; i < 32; ++i)
29403
29441
  fdt[i] = 5;
29404
29442
 
29443
+ /**
29444
+ * Create a breadcrumb for a replay.
29445
+ */
29405
29446
  function createBreadcrumb(
29406
29447
  breadcrumb,
29407
29448
  ) {
@@ -29412,6 +29453,9 @@ function createBreadcrumb(
29412
29453
  };
29413
29454
  }
29414
29455
 
29456
+ /**
29457
+ * An event handler to react to DOM events.
29458
+ */
29415
29459
  function handleDom(handlerData) {
29416
29460
  // Taken from https://github.com/getsentry/sentry-javascript/blob/master/packages/browser/src/integrations/breadcrumbs.ts#L112
29417
29461
  let target;
@@ -29454,6 +29498,9 @@ function isEventWithTarget(event) {
29454
29498
 
29455
29499
  let _LAST_BREADCRUMB = null;
29456
29500
 
29501
+ /**
29502
+ * An event handler to handle scope changes.
29503
+ */
29457
29504
  function handleScope(scope) {
29458
29505
  const newBreadcrumb = scope.getLastBreadcrumb();
29459
29506
 
@@ -29476,6 +29523,9 @@ function handleScope(scope) {
29476
29523
  return createBreadcrumb(newBreadcrumb);
29477
29524
  }
29478
29525
 
29526
+ /**
29527
+ * An event handler to react to breadcrumbs.
29528
+ */
29479
29529
  function breadcrumbHandler(type, handlerData) {
29480
29530
  if (type === 'scope') {
29481
29531
  return handleScope(handlerData );
@@ -29612,6 +29662,9 @@ function handleFetchSpanListener(replay) {
29612
29662
  };
29613
29663
  }
29614
29664
 
29665
+ /**
29666
+ * Returns true if we think the given event is an error originating inside of rrweb.
29667
+ */
29615
29668
  function isRrwebError(event) {
29616
29669
  if (event.type || !_optionalChain([event, 'access', _ => _.exception, 'optionalAccess', _2 => _2.values, 'optionalAccess', _3 => _3.length])) {
29617
29670
  return false;
@@ -29633,10 +29686,7 @@ function isRrwebError(event) {
29633
29686
  function handleGlobalEventListener(replay) {
29634
29687
  return (event) => {
29635
29688
  // Do not apply replayId to the root event
29636
- if (
29637
- // @ts-ignore new event type
29638
- event.type === REPLAY_EVENT_NAME
29639
- ) {
29689
+ if (event.type === REPLAY_EVENT_NAME) {
29640
29690
  // Replays have separate set of breadcrumbs, do not include breadcrumbs
29641
29691
  // from core SDK
29642
29692
  delete event.breadcrumbs;
@@ -29652,7 +29702,7 @@ function handleGlobalEventListener(replay) {
29652
29702
 
29653
29703
  // Only tag transactions with replayId if not waiting for an error
29654
29704
  // @ts-ignore private
29655
- if (event.type !== 'transaction' || replay.recordingMode === 'session') {
29705
+ if (!event.type || replay.recordingMode === 'session') {
29656
29706
  event.tags = { ...event.tags, replayId: _optionalChain([replay, 'access', _5 => _5.session, 'optionalAccess', _6 => _6.id]) };
29657
29707
  }
29658
29708
 
@@ -29965,9 +30015,12 @@ const ENTRY_TYPES = {
29965
30015
  // @ts-ignore TODO: entry type does not fit the create* functions entry type
29966
30016
  navigation: createNavigationEntry,
29967
30017
  // @ts-ignore TODO: entry type does not fit the create* functions entry type
29968
- ['largest-contentful-paint']: createLargestContentfulPaint,
30018
+ 'largest-contentful-paint': createLargestContentfulPaint,
29969
30019
  };
29970
30020
 
30021
+ /**
30022
+ * Create replay performance entries from the browser performance entries.
30023
+ */
29971
30024
  function createPerformanceEntries(entries) {
29972
30025
  return entries.map(createPerformanceEntry).filter(Boolean) ;
29973
30026
  }
@@ -29986,8 +30039,6 @@ function getAbsoluteTime(time) {
29986
30039
  return ((browserPerformanceTimeOrigin || WINDOW.performance.timeOrigin) + time) / 1000;
29987
30040
  }
29988
30041
 
29989
- // TODO: type definition!
29990
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
29991
30042
  function createPaintEntry(entry) {
29992
30043
  const { duration, entryType, name, startTime } = entry;
29993
30044
 
@@ -30000,8 +30051,6 @@ function createPaintEntry(entry) {
30000
30051
  };
30001
30052
  }
30002
30053
 
30003
- // TODO: type definition!
30004
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
30005
30054
  function createNavigationEntry(entry) {
30006
30055
  // TODO: There looks to be some more interesting bits in here (domComplete, domContentLoaded)
30007
30056
  const { entryType, name, duration, domComplete, startTime, transferSize, type } = entry;
@@ -30023,8 +30072,6 @@ function createNavigationEntry(entry) {
30023
30072
  };
30024
30073
  }
30025
30074
 
30026
- // TODO: type definition!
30027
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
30028
30075
  function createResourceEntry(entry) {
30029
30076
  const { entryType, initiatorType, name, responseEnd, startTime, encodedBodySize, transferSize } = entry;
30030
30077
 
@@ -30045,9 +30092,9 @@ function createResourceEntry(entry) {
30045
30092
  };
30046
30093
  }
30047
30094
 
30048
- // TODO: type definition!
30049
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
30050
- function createLargestContentfulPaint(entry) {
30095
+ function createLargestContentfulPaint(
30096
+ entry,
30097
+ ) {
30051
30098
  const { duration, entryType, startTime, size } = entry;
30052
30099
 
30053
30100
  const start = getAbsoluteTime(startTime);
@@ -30072,6 +30119,9 @@ function t(t){let e=t.length;for(;--e>=0;)t[e]=0}const e=new Uint8Array([0,0,0,0
30072
30119
 
30073
30120
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
30074
30121
 
30122
+ /**
30123
+ * Create an event buffer for replays.
30124
+ */
30075
30125
  function createEventBuffer({ useCompression }) {
30076
30126
  // eslint-disable-next-line no-restricted-globals
30077
30127
  if (useCompression && window.Worker) {
@@ -30102,14 +30152,14 @@ class EventBufferArray {
30102
30152
  this._events = [];
30103
30153
  }
30104
30154
 
30105
- destroy() {
30106
- this._events = [];
30107
- }
30108
-
30109
30155
  get length() {
30110
30156
  return this._events.length;
30111
30157
  }
30112
30158
 
30159
+ destroy() {
30160
+ this._events = [];
30161
+ }
30162
+
30113
30163
  addEvent(event, isCheckout) {
30114
30164
  if (isCheckout) {
30115
30165
  this._events = [event];
@@ -30131,7 +30181,10 @@ class EventBufferArray {
30131
30181
  }
30132
30182
  }
30133
30183
 
30134
- // exporting for testing
30184
+ /**
30185
+ * Event buffer that uses a web worker to compress events.
30186
+ * Exported only for testing.
30187
+ */
30135
30188
  class EventBufferCompressionWorker {
30136
30189
 
30137
30190
  __init() {this._eventBufferItemLength = 0;}
@@ -30141,12 +30194,6 @@ class EventBufferCompressionWorker {
30141
30194
  this._worker = worker;
30142
30195
  }
30143
30196
 
30144
- destroy() {
30145
- (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.log('[Replay] Destroying compression worker');
30146
- _optionalChain([this, 'access', _ => _._worker, 'optionalAccess', _2 => _2.terminate, 'call', _3 => _3()]);
30147
- this._worker = null;
30148
- }
30149
-
30150
30197
  /**
30151
30198
  * Note that this may not reflect what is actually in the event buffer. This
30152
30199
  * is only a local count of the buffer size since `addEvent` is async.
@@ -30155,6 +30202,18 @@ class EventBufferCompressionWorker {
30155
30202
  return this._eventBufferItemLength;
30156
30203
  }
30157
30204
 
30205
+ /**
30206
+ * Destroy the event buffer.
30207
+ */
30208
+ destroy() {
30209
+ (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.log('[Replay] Destroying compression worker');
30210
+ _optionalChain([this, 'access', _ => _._worker, 'optionalAccess', _2 => _2.terminate, 'call', _3 => _3()]);
30211
+ this._worker = null;
30212
+ }
30213
+
30214
+ /**
30215
+ * Add an event to the event buffer.
30216
+ */
30158
30217
  async addEvent(event, isCheckout) {
30159
30218
  if (isCheckout) {
30160
30219
  // This event is a checkout, make sure worker buffer is cleared before
@@ -30169,6 +30228,9 @@ class EventBufferCompressionWorker {
30169
30228
  return this._sendEventToWorker(event);
30170
30229
  }
30171
30230
 
30231
+ /**
30232
+ * Finish the event buffer and return the compressed data.
30233
+ */
30172
30234
  finish() {
30173
30235
  return this._finishRequest(this._getAndIncrementId());
30174
30236
  }
@@ -30219,6 +30281,9 @@ class EventBufferCompressionWorker {
30219
30281
  });
30220
30282
  }
30221
30283
 
30284
+ /**
30285
+ * Send the event to the worker.
30286
+ */
30222
30287
  _sendEventToWorker(event) {
30223
30288
  const promise = this._postMessage({
30224
30289
  id: this._getAndIncrementId(),
@@ -30232,6 +30297,9 @@ class EventBufferCompressionWorker {
30232
30297
  return promise;
30233
30298
  }
30234
30299
 
30300
+ /**
30301
+ * Finish the request and return the compressed data from the worker.
30302
+ */
30235
30303
  async _finishRequest(id) {
30236
30304
  const promise = this._postMessage({ id, method: 'finish', args: [] });
30237
30305
 
@@ -30241,6 +30309,7 @@ class EventBufferCompressionWorker {
30241
30309
  return promise ;
30242
30310
  }
30243
30311
 
30312
+ /** Get the current ID and increment it for the next call. */
30244
30313
  _getAndIncrementId() {
30245
30314
  return this._id++;
30246
30315
  }
@@ -30298,6 +30367,9 @@ function isSessionExpired(session, idleTimeout, targetTime = +new Date()) {
30298
30367
  );
30299
30368
  }
30300
30369
 
30370
+ /**
30371
+ * Save a session to session storage.
30372
+ */
30301
30373
  function saveSession(session) {
30302
30374
  const hasSessionStorage = 'sessionStorage' in WINDOW;
30303
30375
  if (!hasSessionStorage) {
@@ -30452,7 +30524,30 @@ function addMemoryEntry(replay) {
30452
30524
  }
30453
30525
  }
30454
30526
 
30455
- function createPayload({
30527
+ function createMemoryEntry(memoryEntry) {
30528
+ const { jsHeapSizeLimit, totalJSHeapSize, usedJSHeapSize } = memoryEntry;
30529
+ // we don't want to use `getAbsoluteTime` because it adds the event time to the
30530
+ // time origin, so we get the current timestamp instead
30531
+ const time = new Date().getTime() / 1000;
30532
+ return {
30533
+ type: 'memory',
30534
+ name: 'memory',
30535
+ start: time,
30536
+ end: time,
30537
+ data: {
30538
+ memory: {
30539
+ jsHeapSizeLimit,
30540
+ totalJSHeapSize,
30541
+ usedJSHeapSize,
30542
+ },
30543
+ },
30544
+ };
30545
+ }
30546
+
30547
+ /**
30548
+ * Create the recording data ready to be sent.
30549
+ */
30550
+ function createRecordingData({
30456
30551
  events,
30457
30552
  headers,
30458
30553
  }
@@ -30479,6 +30574,10 @@ function createPayload({
30479
30574
  return payloadWithSequence;
30480
30575
  }
30481
30576
 
30577
+ /**
30578
+ * Create a replay envelope ready to be sent.
30579
+ * This includes both the replay event, as well as the recording data.
30580
+ */
30482
30581
  function createReplayEnvelope(
30483
30582
  replayEvent,
30484
30583
  recordingData,
@@ -30563,41 +30662,11 @@ function debounce(func, wait, options) {
30563
30662
  return debounced;
30564
30663
  }
30565
30664
 
30566
- async function getReplayEvent({
30567
- client,
30568
- scope,
30569
- replayId: event_id,
30570
- event,
30571
- }
30572
-
30573
- ) {
30574
- const preparedEvent = (await prepareEvent(client.getOptions(), event, { event_id }, scope)) ;
30575
-
30576
- // If e.g. a global event processor returned null
30577
- if (!preparedEvent) {
30578
- return null;
30579
- }
30580
-
30581
- // This normally happens in browser client "_prepareEvent"
30582
- // but since we do not use this private method from the client, but rather the plain import
30583
- // we need to do this manually.
30584
- preparedEvent.platform = preparedEvent.platform || 'javascript';
30585
-
30586
- // extract the SDK name because `client._prepareEvent` doesn't add it to the event
30587
- const metadata = client.getSdkMetadata && client.getSdkMetadata();
30588
- const name = (metadata && metadata.sdk && metadata.sdk.name) || 'sentry.javascript.unknown';
30589
-
30590
- preparedEvent.sdk = {
30591
- ...preparedEvent.sdk,
30592
- version: "7.29.0",
30593
- name,
30594
- };
30595
-
30596
- return preparedEvent;
30597
- }
30598
-
30599
30665
  let _originalRecordDroppedEvent;
30600
30666
 
30667
+ /**
30668
+ * Overwrite the `recordDroppedEvent` method on the client, so we can find out which events were dropped.
30669
+ * */
30601
30670
  function overwriteRecordDroppedEvent(errorIds) {
30602
30671
  const client = getCurrentHub().getClient();
30603
30672
 
@@ -30623,6 +30692,9 @@ function overwriteRecordDroppedEvent(errorIds) {
30623
30692
  _originalRecordDroppedEvent = _originalCallback;
30624
30693
  }
30625
30694
 
30695
+ /**
30696
+ * Restore the original method.
30697
+ * */
30626
30698
  function restoreRecordDroppedEvent() {
30627
30699
  const client = getCurrentHub().getClient();
30628
30700
 
@@ -30633,6 +30705,42 @@ function restoreRecordDroppedEvent() {
30633
30705
  client.recordDroppedEvent = _originalRecordDroppedEvent;
30634
30706
  }
30635
30707
 
30708
+ /**
30709
+ * Prepare a replay event & enrich it with the SDK metadata.
30710
+ */
30711
+ async function prepareReplayEvent({
30712
+ client,
30713
+ scope,
30714
+ replayId: event_id,
30715
+ event,
30716
+ }
30717
+
30718
+ ) {
30719
+ const preparedEvent = (await prepareEvent(client.getOptions(), event, { event_id }, scope)) ;
30720
+
30721
+ // If e.g. a global event processor returned null
30722
+ if (!preparedEvent) {
30723
+ return null;
30724
+ }
30725
+
30726
+ // This normally happens in browser client "_prepareEvent"
30727
+ // but since we do not use this private method from the client, but rather the plain import
30728
+ // we need to do this manually.
30729
+ preparedEvent.platform = preparedEvent.platform || 'javascript';
30730
+
30731
+ // extract the SDK name because `client._prepareEvent` doesn't add it to the event
30732
+ const metadata = client.getSdkMetadata && client.getSdkMetadata();
30733
+ const name = (metadata && metadata.sdk && metadata.sdk.name) || 'sentry.javascript.unknown';
30734
+
30735
+ preparedEvent.sdk = {
30736
+ ...preparedEvent.sdk,
30737
+ version: "7.30.0",
30738
+ name,
30739
+ };
30740
+
30741
+ return preparedEvent;
30742
+ }
30743
+
30636
30744
  /* eslint-disable max-lines */ // TODO: We might want to split this file up
30637
30745
 
30638
30746
  /**
@@ -30642,6 +30750,9 @@ function restoreRecordDroppedEvent() {
30642
30750
  const BASE_RETRY_INTERVAL = 5000;
30643
30751
  const MAX_RETRY_COUNT = 3;
30644
30752
 
30753
+ /**
30754
+ * The main replay container class, which holds all the state and methods for recording and sending replays.
30755
+ */
30645
30756
  class ReplayContainer {
30646
30757
  __init() {this.eventBuffer = null;}
30647
30758
 
@@ -31484,7 +31595,7 @@ class ReplayContainer {
31484
31595
  includeReplayStartTimestamp,
31485
31596
  eventContext,
31486
31597
  }) {
31487
- const payloadWithSequence = createPayload({
31598
+ const recordingData = createRecordingData({
31488
31599
  events,
31489
31600
  headers: {
31490
31601
  segment_id,
@@ -31501,7 +31612,7 @@ class ReplayContainer {
31501
31612
  const transport = client && client.getTransport();
31502
31613
  const dsn = _optionalChain([client, 'optionalAccess', _33 => _33.getDsn, 'call', _34 => _34()]);
31503
31614
 
31504
- if (!client || !scope || !transport || !dsn) {
31615
+ if (!client || !scope || !transport || !dsn || !this.session || !this.session.sampled) {
31505
31616
  return;
31506
31617
  }
31507
31618
 
@@ -31515,9 +31626,10 @@ class ReplayContainer {
31515
31626
  urls,
31516
31627
  replay_id: replayId,
31517
31628
  segment_id,
31629
+ replay_type: this.session.sampled,
31518
31630
  };
31519
31631
 
31520
- const replayEvent = await getReplayEvent({ scope, client, replayId, event: baseEvent });
31632
+ const replayEvent = await prepareReplayEvent({ scope, client, replayId, event: baseEvent });
31521
31633
 
31522
31634
  if (!replayEvent) {
31523
31635
  // Taken from baseclient's `_processEvent` method, where this is handled for errors/transactions
@@ -31530,7 +31642,6 @@ class ReplayContainer {
31530
31642
  ...replayEvent.tags,
31531
31643
  sessionSampleRate: this._options.sessionSampleRate,
31532
31644
  errorSampleRate: this._options.errorSampleRate,
31533
- replayType: _optionalChain([this, 'access', _35 => _35.session, 'optionalAccess', _36 => _36.sampled]),
31534
31645
  };
31535
31646
 
31536
31647
  /*
@@ -31549,6 +31660,7 @@ class ReplayContainer {
31549
31660
  ],
31550
31661
  "replay_id": "eventId",
31551
31662
  "segment_id": 3,
31663
+ "replay_type": "error",
31552
31664
  "platform": "javascript",
31553
31665
  "event_id": "eventId",
31554
31666
  "environment": "production",
@@ -31564,12 +31676,11 @@ class ReplayContainer {
31564
31676
  "tags": {
31565
31677
  "sessionSampleRate": 1,
31566
31678
  "errorSampleRate": 0,
31567
- "replayType": "error"
31568
31679
  }
31569
31680
  }
31570
31681
  */
31571
31682
 
31572
- const envelope = createReplayEnvelope(replayEvent, payloadWithSequence, dsn, client.getOptions().tunnel);
31683
+ const envelope = createReplayEnvelope(replayEvent, recordingData, dsn, client.getOptions().tunnel);
31573
31684
 
31574
31685
  try {
31575
31686
  return await transport.send(envelope);
@@ -31578,6 +31689,9 @@ class ReplayContainer {
31578
31689
  }
31579
31690
  }
31580
31691
 
31692
+ /**
31693
+ * Reset the counter of retries for sending replays.
31694
+ */
31581
31695
  resetRetries() {
31582
31696
  this._retryCount = 0;
31583
31697
  this._retryInterval = BASE_RETRY_INTERVAL;
@@ -31652,15 +31766,26 @@ class ReplayContainer {
31652
31766
  }
31653
31767
  }
31654
31768
 
31769
+ /**
31770
+ * Returns true if we are in the browser.
31771
+ */
31655
31772
  function isBrowser() {
31656
31773
  // eslint-disable-next-line no-restricted-globals
31657
- return typeof window !== 'undefined' && !isNodeEnv();
31774
+ return typeof window !== 'undefined' && (!isNodeEnv() || isElectronNodeRenderer());
31775
+ }
31776
+
31777
+ // Electron renderers with nodeIntegration enabled are detected as Node.js so we specifically test for them
31778
+ function isElectronNodeRenderer() {
31779
+ return typeof process !== 'undefined' && (process ).type === 'renderer';
31658
31780
  }
31659
31781
 
31660
31782
  const MEDIA_SELECTORS = 'img,image,svg,path,rect,area,video,object,picture,embed,map,audio';
31661
31783
 
31662
31784
  let _initialized = false;
31663
31785
 
31786
+ /**
31787
+ * The main replay integration class, to be passed to `init({ integrations: [] })`.
31788
+ */
31664
31789
  class Replay {
31665
31790
  /**
31666
31791
  * @inheritDoc
@@ -31676,14 +31801,6 @@ class Replay {
31676
31801
  * Options to pass to `rrweb.record()`
31677
31802
  */
31678
31803
 
31679
- get _isInitialized() {
31680
- return _initialized;
31681
- }
31682
-
31683
- set _isInitialized(value) {
31684
- _initialized = value;
31685
- }
31686
-
31687
31804
  constructor({
31688
31805
  flushMinDelay = DEFAULT_FLUSH_MIN_DELAY,
31689
31806
  flushMaxDelay = DEFAULT_FLUSH_MAX_DELAY,
@@ -31765,13 +31882,23 @@ Sentry.init({ replaysOnErrorSampleRate: ${errorSampleRate} })`,
31765
31882
  : `${this.recordingOptions.blockSelector},${MEDIA_SELECTORS}`;
31766
31883
  }
31767
31884
 
31768
- if (isBrowser() && this._isInitialized) {
31885
+ if (this._isInitialized && isBrowser()) {
31769
31886
  throw new Error('Multiple Sentry Session Replay instances are not supported');
31770
31887
  }
31771
31888
 
31772
31889
  this._isInitialized = true;
31773
31890
  }
31774
31891
 
31892
+ /** If replay has already been initialized */
31893
+ get _isInitialized() {
31894
+ return _initialized;
31895
+ }
31896
+
31897
+ /** Update _isInitialized */
31898
+ set _isInitialized(value) {
31899
+ _initialized = value;
31900
+ }
31901
+
31775
31902
  /**
31776
31903
  * We previously used to create a transaction in `setupOnce` and it would
31777
31904
  * potentially create a transaction before some native SDK integrations have run
@@ -31819,6 +31946,7 @@ Sentry.init({ replaysOnErrorSampleRate: ${errorSampleRate} })`,
31819
31946
  this._replay.stop();
31820
31947
  }
31821
31948
 
31949
+ /** Setup the integration. */
31822
31950
  _setup() {
31823
31951
  // Client is not available in constructor, so we need to wait until setupOnce
31824
31952
  this._loadReplayOptionsFromClient();