@myinterview/widget-react 1.0.56 → 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
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import React__default, { createContext, forwardRef, useRef, useEffect, useState, useLayoutEffect, useImperativeHandle, useDebugValue, useContext, createElement, useCallback, useMemo, isValidElement, cloneElement } from 'react';
3
3
  import { createPortal } from 'react-dom';
4
4
 
5
- var commonjsGlobal$1 = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
5
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
6
6
 
7
7
  function getDefaultExportFromCjs (x) {
8
8
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -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";
@@ -8802,7 +8812,7 @@ var platform$1 = {exports: {}};
8802
8812
  var freeModule = module && !module.nodeType && module;
8803
8813
 
8804
8814
  /** Detect free variable `global` from Node.js or Browserified code and use it as `root`. */
8805
- var freeGlobal = freeExports && freeModule && typeof commonjsGlobal$1 == 'object' && commonjsGlobal$1;
8815
+ var freeGlobal = freeExports && freeModule && typeof commonjsGlobal == 'object' && commonjsGlobal;
8806
8816
  if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal)) {
8807
8817
  root = freeGlobal;
8808
8818
  }
@@ -10015,7 +10025,7 @@ var platform$1 = {exports: {}};
10015
10025
  // Export to the global object.
10016
10026
  root.platform = platform;
10017
10027
  }
10018
- }.call(commonjsGlobal$1));
10028
+ }.call(commonjsGlobal));
10019
10029
  } (platform$1, platform$1.exports));
10020
10030
 
10021
10031
  var platform = platform$1.exports;
@@ -14944,7 +14954,7 @@ const Explanation = ({ isVideoQuestion, thinkingTime }) => {
14944
14954
  };
14945
14955
 
14946
14956
  // eslint-disable-next-line @typescript-eslint/unbound-method
14947
- const objectToString$1 = Object.prototype.toString;
14957
+ const objectToString = Object.prototype.toString;
14948
14958
 
14949
14959
  /**
14950
14960
  * Checks whether given value's type is one of a few Error or Error-like
@@ -14954,7 +14964,7 @@ const objectToString$1 = Object.prototype.toString;
14954
14964
  * @returns A boolean representing the result.
14955
14965
  */
14956
14966
  function isError(wat) {
14957
- switch (objectToString$1.call(wat)) {
14967
+ switch (objectToString.call(wat)) {
14958
14968
  case '[object Error]':
14959
14969
  case '[object Exception]':
14960
14970
  case '[object DOMException]':
@@ -14971,7 +14981,7 @@ function isError(wat) {
14971
14981
  * @returns A boolean representing the result.
14972
14982
  */
14973
14983
  function isBuiltin(wat, className) {
14974
- return objectToString$1.call(wat) === `[object ${className}]`;
14984
+ return objectToString.call(wat) === `[object ${className}]`;
14975
14985
  }
14976
14986
 
14977
14987
  /**
@@ -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');
@@ -17697,6 +17713,8 @@ const ITEM_TYPE_TO_DATA_CATEGORY_MAP = {
17697
17713
  client_report: 'internal',
17698
17714
  user_report: 'default',
17699
17715
  profile: 'profile',
17716
+ replay_event: 'replay_event',
17717
+ replay_recording: 'replay_recording',
17700
17718
  };
17701
17719
 
17702
17720
  /**
@@ -18715,7 +18733,7 @@ class Hub {
18715
18733
  */
18716
18734
  captureEvent(event, hint) {
18717
18735
  const eventId = hint && hint.event_id ? hint.event_id : uuid4();
18718
- if (event.type !== 'transaction') {
18736
+ if (!event.type) {
18719
18737
  this._lastEventId = eventId;
18720
18738
  }
18721
18739
 
@@ -18740,7 +18758,6 @@ class Hub {
18740
18758
 
18741
18759
  if (!scope || !client) return;
18742
18760
 
18743
- // eslint-disable-next-line @typescript-eslint/unbound-method
18744
18761
  const { beforeBreadcrumb = null, maxBreadcrumbs = DEFAULT_BREADCRUMBS } =
18745
18762
  (client.getOptions && client.getOptions()) || {};
18746
18763
 
@@ -19234,7 +19251,15 @@ function createEventEnvelope(
19234
19251
  tunnel,
19235
19252
  ) {
19236
19253
  const sdkInfo = getSdkMetadataForEnvelopeHeader(metadata);
19237
- 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';
19238
19263
 
19239
19264
  enhanceEventWithSdkInfo(event, metadata && metadata.sdk);
19240
19265
 
@@ -19262,16 +19287,209 @@ function setupIntegrations(integrations) {
19262
19287
  const integrationIndex = {};
19263
19288
 
19264
19289
  integrations.forEach(integration => {
19265
- integrationIndex[integration.name] = integration;
19290
+ setupIntegration(integration, integrationIndex);
19291
+ });
19292
+
19293
+ return integrationIndex;
19294
+ }
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
+
19307
+ /**
19308
+ * Adds common information to events.
19309
+ *
19310
+ * The information includes release and environment from `options`,
19311
+ * breadcrumbs and context (extra, tags and user) from the scope.
19312
+ *
19313
+ * Information that is already present in the event is never overwritten. For
19314
+ * nested objects, such as the context, keys are merged.
19315
+ *
19316
+ * Note: This also triggers callbacks for `addGlobalEventProcessor`, but not `beforeSend`.
19317
+ *
19318
+ * @param event The original event.
19319
+ * @param hint May contain additional information about the original exception.
19320
+ * @param scope A scope containing event metadata.
19321
+ * @returns A new event with more information.
19322
+ * @hidden
19323
+ */
19324
+ function prepareEvent(
19325
+ options,
19326
+ event,
19327
+ hint,
19328
+ scope,
19329
+ ) {
19330
+ const { normalizeDepth = 3, normalizeMaxBreadth = 1000 } = options;
19331
+ const prepared = {
19332
+ ...event,
19333
+ event_id: event.event_id || hint.event_id || uuid4(),
19334
+ timestamp: event.timestamp || dateTimestampInSeconds(),
19335
+ };
19336
+
19337
+ applyClientOptions(prepared, options);
19338
+ applyIntegrationsMetadata(
19339
+ prepared,
19340
+ options.integrations.map(i => i.name),
19341
+ );
19342
+
19343
+ // If we have scope given to us, use it as the base for further modifications.
19344
+ // This allows us to prevent unnecessary copying of data if `captureContext` is not provided.
19345
+ let finalScope = scope;
19346
+ if (hint.captureContext) {
19347
+ finalScope = Scope.clone(finalScope).update(hint.captureContext);
19348
+ }
19349
+
19350
+ // We prepare the result here with a resolved Event.
19351
+ let result = resolvedSyncPromise(prepared);
19266
19352
 
19267
- if (installedIntegrations.indexOf(integration.name) === -1) {
19268
- integration.setupOnce(addGlobalEventProcessor, getCurrentHub);
19269
- installedIntegrations.push(integration.name);
19270
- (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.log(`Integration installed: ${integration.name}`);
19353
+ // This should be the last thing called, since we want that
19354
+ // {@link Hub.addEventProcessor} gets the finished prepared event.
19355
+ //
19356
+ // We need to check for the existence of `finalScope.getAttachments`
19357
+ // because `getAttachments` can be undefined if users are using an older version
19358
+ // of `@sentry/core` that does not have the `getAttachments` method.
19359
+ // See: https://github.com/getsentry/sentry-javascript/issues/5229
19360
+ if (finalScope) {
19361
+ // Collect attachments from the hint and scope
19362
+ if (finalScope.getAttachments) {
19363
+ const attachments = [...(hint.attachments || []), ...finalScope.getAttachments()];
19364
+
19365
+ if (attachments.length) {
19366
+ hint.attachments = attachments;
19367
+ }
19271
19368
  }
19369
+
19370
+ // In case we have a hub we reassign it.
19371
+ result = finalScope.applyToEvent(prepared, hint);
19372
+ }
19373
+
19374
+ return result.then(evt => {
19375
+ if (typeof normalizeDepth === 'number' && normalizeDepth > 0) {
19376
+ return normalizeEvent(evt, normalizeDepth, normalizeMaxBreadth);
19377
+ }
19378
+ return evt;
19272
19379
  });
19380
+ }
19273
19381
 
19274
- return integrationIndex;
19382
+ /**
19383
+ * Enhances event using the client configuration.
19384
+ * It takes care of all "static" values like environment, release and `dist`,
19385
+ * as well as truncating overly long values.
19386
+ * @param event event instance to be enhanced
19387
+ */
19388
+ function applyClientOptions(event, options) {
19389
+ const { environment, release, dist, maxValueLength = 250 } = options;
19390
+
19391
+ if (!('environment' in event)) {
19392
+ event.environment = 'environment' in options ? environment : 'production';
19393
+ }
19394
+
19395
+ if (event.release === undefined && release !== undefined) {
19396
+ event.release = release;
19397
+ }
19398
+
19399
+ if (event.dist === undefined && dist !== undefined) {
19400
+ event.dist = dist;
19401
+ }
19402
+
19403
+ if (event.message) {
19404
+ event.message = truncate(event.message, maxValueLength);
19405
+ }
19406
+
19407
+ const exception = event.exception && event.exception.values && event.exception.values[0];
19408
+ if (exception && exception.value) {
19409
+ exception.value = truncate(exception.value, maxValueLength);
19410
+ }
19411
+
19412
+ const request = event.request;
19413
+ if (request && request.url) {
19414
+ request.url = truncate(request.url, maxValueLength);
19415
+ }
19416
+ }
19417
+
19418
+ /**
19419
+ * This function adds all used integrations to the SDK info in the event.
19420
+ * @param event The event that will be filled with all integrations.
19421
+ */
19422
+ function applyIntegrationsMetadata(event, integrationNames) {
19423
+ if (integrationNames.length > 0) {
19424
+ event.sdk = event.sdk || {};
19425
+ event.sdk.integrations = [...(event.sdk.integrations || []), ...integrationNames];
19426
+ }
19427
+ }
19428
+
19429
+ /**
19430
+ * Applies `normalize` function on necessary `Event` attributes to make them safe for serialization.
19431
+ * Normalized keys:
19432
+ * - `breadcrumbs.data`
19433
+ * - `user`
19434
+ * - `contexts`
19435
+ * - `extra`
19436
+ * @param event Event
19437
+ * @returns Normalized event
19438
+ */
19439
+ function normalizeEvent(event, depth, maxBreadth) {
19440
+ if (!event) {
19441
+ return null;
19442
+ }
19443
+
19444
+ const normalized = {
19445
+ ...event,
19446
+ ...(event.breadcrumbs && {
19447
+ breadcrumbs: event.breadcrumbs.map(b => ({
19448
+ ...b,
19449
+ ...(b.data && {
19450
+ data: normalize(b.data, depth, maxBreadth),
19451
+ }),
19452
+ })),
19453
+ }),
19454
+ ...(event.user && {
19455
+ user: normalize(event.user, depth, maxBreadth),
19456
+ }),
19457
+ ...(event.contexts && {
19458
+ contexts: normalize(event.contexts, depth, maxBreadth),
19459
+ }),
19460
+ ...(event.extra && {
19461
+ extra: normalize(event.extra, depth, maxBreadth),
19462
+ }),
19463
+ };
19464
+
19465
+ // event.contexts.trace stores information about a Transaction. Similarly,
19466
+ // event.spans[] stores information about child Spans. Given that a
19467
+ // Transaction is conceptually a Span, normalization should apply to both
19468
+ // Transactions and Spans consistently.
19469
+ // For now the decision is to skip normalization of Transactions and Spans,
19470
+ // so this block overwrites the normalized event to add back the original
19471
+ // Transaction information prior to normalization.
19472
+ if (event.contexts && event.contexts.trace && normalized.contexts) {
19473
+ normalized.contexts.trace = event.contexts.trace;
19474
+
19475
+ // event.contexts.trace.data may contain circular/dangerous data so we need to normalize it
19476
+ if (event.contexts.trace.data) {
19477
+ normalized.contexts.trace.data = normalize(event.contexts.trace.data, depth, maxBreadth);
19478
+ }
19479
+ }
19480
+
19481
+ // event.spans[].data may contain circular/dangerous data so we need to normalize it
19482
+ if (event.spans) {
19483
+ normalized.spans = event.spans.map(span => {
19484
+ // We cannot use the spread operator here because `toJSON` on `span` is non-enumerable
19485
+ if (span.data) {
19486
+ span.data = normalize(span.data, depth, maxBreadth);
19487
+ }
19488
+ return span;
19489
+ });
19490
+ }
19491
+
19492
+ return normalized;
19275
19493
  }
19276
19494
 
19277
19495
  const ALREADY_SEEN_ERROR = "Not capturing exception because it's already been captured.";
@@ -19448,6 +19666,15 @@ class BaseClient {
19448
19666
  return this._options;
19449
19667
  }
19450
19668
 
19669
+ /**
19670
+ * @see SdkMetadata in @sentry/types
19671
+ *
19672
+ * @return The metadata of the SDK
19673
+ */
19674
+ getSdkMetadata() {
19675
+ return this._options._metadata;
19676
+ }
19677
+
19451
19678
  /**
19452
19679
  * @inheritDoc
19453
19680
  */
@@ -19510,6 +19737,13 @@ class BaseClient {
19510
19737
  }
19511
19738
  }
19512
19739
 
19740
+ /**
19741
+ * @inheritDoc
19742
+ */
19743
+ addIntegration(integration) {
19744
+ setupIntegration(integration, this._integrations);
19745
+ }
19746
+
19513
19747
  /**
19514
19748
  * @inheritDoc
19515
19749
  */
@@ -19548,7 +19782,7 @@ class BaseClient {
19548
19782
  // Note: we use `event` in replay, where we overwrite this hook.
19549
19783
 
19550
19784
  if (this._options.sendClientReports) {
19551
- // We want to track each category (error, transaction, session) separately
19785
+ // We want to track each category (error, transaction, session, replay_event) separately
19552
19786
  // but still keep the distinction between different type of outcomes.
19553
19787
  // We could use nested maps, but it's much easier to read and type this way.
19554
19788
  // A correct type for map-based implementation if we want to go that route
@@ -19645,166 +19879,8 @@ class BaseClient {
19645
19879
  * @returns A new event with more information.
19646
19880
  */
19647
19881
  _prepareEvent(event, hint, scope) {
19648
- const { normalizeDepth = 3, normalizeMaxBreadth = 1000 } = this.getOptions();
19649
- const prepared = {
19650
- ...event,
19651
- event_id: event.event_id || hint.event_id || uuid4(),
19652
- timestamp: event.timestamp || dateTimestampInSeconds(),
19653
- };
19654
-
19655
- this._applyClientOptions(prepared);
19656
- this._applyIntegrationsMetadata(prepared);
19657
-
19658
- // If we have scope given to us, use it as the base for further modifications.
19659
- // This allows us to prevent unnecessary copying of data if `captureContext` is not provided.
19660
- let finalScope = scope;
19661
- if (hint.captureContext) {
19662
- finalScope = Scope.clone(finalScope).update(hint.captureContext);
19663
- }
19664
-
19665
- // We prepare the result here with a resolved Event.
19666
- let result = resolvedSyncPromise(prepared);
19667
-
19668
- // This should be the last thing called, since we want that
19669
- // {@link Hub.addEventProcessor} gets the finished prepared event.
19670
- //
19671
- // We need to check for the existence of `finalScope.getAttachments`
19672
- // because `getAttachments` can be undefined if users are using an older version
19673
- // of `@sentry/core` that does not have the `getAttachments` method.
19674
- // See: https://github.com/getsentry/sentry-javascript/issues/5229
19675
- if (finalScope && finalScope.getAttachments) {
19676
- // Collect attachments from the hint and scope
19677
- const attachments = [...(hint.attachments || []), ...finalScope.getAttachments()];
19678
-
19679
- if (attachments.length) {
19680
- hint.attachments = attachments;
19681
- }
19682
-
19683
- // In case we have a hub we reassign it.
19684
- result = finalScope.applyToEvent(prepared, hint);
19685
- }
19686
-
19687
- return result.then(evt => {
19688
- if (typeof normalizeDepth === 'number' && normalizeDepth > 0) {
19689
- return this._normalizeEvent(evt, normalizeDepth, normalizeMaxBreadth);
19690
- }
19691
- return evt;
19692
- });
19693
- }
19694
-
19695
- /**
19696
- * Applies `normalize` function on necessary `Event` attributes to make them safe for serialization.
19697
- * Normalized keys:
19698
- * - `breadcrumbs.data`
19699
- * - `user`
19700
- * - `contexts`
19701
- * - `extra`
19702
- * @param event Event
19703
- * @returns Normalized event
19704
- */
19705
- _normalizeEvent(event, depth, maxBreadth) {
19706
- if (!event) {
19707
- return null;
19708
- }
19709
-
19710
- const normalized = {
19711
- ...event,
19712
- ...(event.breadcrumbs && {
19713
- breadcrumbs: event.breadcrumbs.map(b => ({
19714
- ...b,
19715
- ...(b.data && {
19716
- data: normalize(b.data, depth, maxBreadth),
19717
- }),
19718
- })),
19719
- }),
19720
- ...(event.user && {
19721
- user: normalize(event.user, depth, maxBreadth),
19722
- }),
19723
- ...(event.contexts && {
19724
- contexts: normalize(event.contexts, depth, maxBreadth),
19725
- }),
19726
- ...(event.extra && {
19727
- extra: normalize(event.extra, depth, maxBreadth),
19728
- }),
19729
- };
19730
-
19731
- // event.contexts.trace stores information about a Transaction. Similarly,
19732
- // event.spans[] stores information about child Spans. Given that a
19733
- // Transaction is conceptually a Span, normalization should apply to both
19734
- // Transactions and Spans consistently.
19735
- // For now the decision is to skip normalization of Transactions and Spans,
19736
- // so this block overwrites the normalized event to add back the original
19737
- // Transaction information prior to normalization.
19738
- if (event.contexts && event.contexts.trace && normalized.contexts) {
19739
- normalized.contexts.trace = event.contexts.trace;
19740
-
19741
- // event.contexts.trace.data may contain circular/dangerous data so we need to normalize it
19742
- if (event.contexts.trace.data) {
19743
- normalized.contexts.trace.data = normalize(event.contexts.trace.data, depth, maxBreadth);
19744
- }
19745
- }
19746
-
19747
- // event.spans[].data may contain circular/dangerous data so we need to normalize it
19748
- if (event.spans) {
19749
- normalized.spans = event.spans.map(span => {
19750
- // We cannot use the spread operator here because `toJSON` on `span` is non-enumerable
19751
- if (span.data) {
19752
- span.data = normalize(span.data, depth, maxBreadth);
19753
- }
19754
- return span;
19755
- });
19756
- }
19757
-
19758
- return normalized;
19759
- }
19760
-
19761
- /**
19762
- * Enhances event using the client configuration.
19763
- * It takes care of all "static" values like environment, release and `dist`,
19764
- * as well as truncating overly long values.
19765
- * @param event event instance to be enhanced
19766
- */
19767
- _applyClientOptions(event) {
19768
19882
  const options = this.getOptions();
19769
- const { environment, release, dist, maxValueLength = 250 } = options;
19770
-
19771
- if (!('environment' in event)) {
19772
- event.environment = 'environment' in options ? environment : 'production';
19773
- }
19774
-
19775
- if (event.release === undefined && release !== undefined) {
19776
- event.release = release;
19777
- }
19778
-
19779
- if (event.dist === undefined && dist !== undefined) {
19780
- event.dist = dist;
19781
- }
19782
-
19783
- if (event.message) {
19784
- event.message = truncate(event.message, maxValueLength);
19785
- }
19786
-
19787
- const exception = event.exception && event.exception.values && event.exception.values[0];
19788
- if (exception && exception.value) {
19789
- exception.value = truncate(exception.value, maxValueLength);
19790
- }
19791
-
19792
- const request = event.request;
19793
- if (request && request.url) {
19794
- request.url = truncate(request.url, maxValueLength);
19795
- }
19796
- }
19797
-
19798
- /**
19799
- * This function adds all used integrations to the SDK info in the event.
19800
- * @param event The event that will be filled with all integrations.
19801
- */
19802
- _applyIntegrationsMetadata(event) {
19803
- const integrationsArray = Object.keys(this._integrations);
19804
- if (integrationsArray.length > 0) {
19805
- event.sdk = event.sdk || {};
19806
- event.sdk.integrations = [...(event.sdk.integrations || []), ...integrationsArray];
19807
- }
19883
+ return prepareEvent(options, event, hint, scope);
19808
19884
  }
19809
19885
 
19810
19886
  /**
@@ -20059,7 +20135,9 @@ const DEFAULT_TRANSPORT_BUFFER_SIZE = 30;
20059
20135
  function createTransport(
20060
20136
  options,
20061
20137
  makeRequest,
20062
- buffer = makePromiseBuffer(options.bufferSize || DEFAULT_TRANSPORT_BUFFER_SIZE),
20138
+ buffer = makePromiseBuffer(
20139
+ options.bufferSize || DEFAULT_TRANSPORT_BUFFER_SIZE,
20140
+ ),
20063
20141
  ) {
20064
20142
  let rateLimits = {};
20065
20143
 
@@ -20104,10 +20182,11 @@ function createTransport(
20104
20182
  }
20105
20183
 
20106
20184
  rateLimits = updateRateLimits(rateLimits, response);
20185
+ return response;
20107
20186
  },
20108
20187
  error => {
20109
- (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.error('Failed while sending event:', error);
20110
20188
  recordEnvelopeLoss('network_error');
20189
+ throw error;
20111
20190
  },
20112
20191
  );
20113
20192
 
@@ -20139,7 +20218,7 @@ function getEventForEnvelopeItem(item, type) {
20139
20218
  return Array.isArray(item) ? (item )[1] : undefined;
20140
20219
  }
20141
20220
 
20142
- const SDK_VERSION = '7.28.1';
20221
+ const SDK_VERSION = '7.30.0';
20143
20222
 
20144
20223
  let originalFunctionToString;
20145
20224
 
@@ -22091,7 +22170,7 @@ class HttpContext {constructor() { HttpContext.prototype.__init.call(this); }
22091
22170
  ...(referrer && { Referer: referrer }),
22092
22171
  ...(userAgent && { 'User-Agent': userAgent }),
22093
22172
  };
22094
- const request = { ...(url && { url }), headers };
22173
+ const request = { ...event.request, ...(url && { url }), headers };
22095
22174
 
22096
22175
  return { ...event, request };
22097
22176
  }
@@ -22348,387 +22427,12 @@ const DEFAULT_SESSION_SAMPLE_RATE = 0.1;
22348
22427
  const DEFAULT_ERROR_SAMPLE_RATE = 1.0;
22349
22428
 
22350
22429
  /** The select to use for the `maskAllText` option */
22351
- const MASK_ALL_TEXT_SELECTOR = 'body *:not(style,script)';
22352
-
22353
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
22354
-
22355
- /**
22356
- * lodash (Custom Build) <https://lodash.com/>
22357
- * Build: `lodash modularize exports="npm" -o ./`
22358
- * Copyright jQuery Foundation and other contributors <https://jquery.org/>
22359
- * Released under MIT license <https://lodash.com/license>
22360
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
22361
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
22362
- */
22363
-
22364
- /** Used as the `TypeError` message for "Functions" methods. */
22365
- var FUNC_ERROR_TEXT = 'Expected a function';
22366
-
22367
- /** Used as references for various `Number` constants. */
22368
- var NAN = 0 / 0;
22369
-
22370
- /** `Object#toString` result references. */
22371
- var symbolTag = '[object Symbol]';
22430
+ const MASK_ALL_TEXT_SELECTOR = 'body *:not(style), body *:not(script)';
22372
22431
 
22373
- /** Used to match leading and trailing whitespace. */
22374
- var reTrim = /^\s+|\s+$/g;
22375
-
22376
- /** Used to detect bad signed hexadecimal string values. */
22377
- var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
22378
-
22379
- /** Used to detect binary string values. */
22380
- var reIsBinary = /^0b[01]+$/i;
22381
-
22382
- /** Used to detect octal string values. */
22383
- var reIsOctal = /^0o[0-7]+$/i;
22384
-
22385
- /** Built-in method references without a dependency on `root`. */
22386
- var freeParseInt = parseInt;
22387
-
22388
- /** Detect free variable `global` from Node.js. */
22389
- var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
22390
-
22391
- /** Detect free variable `self`. */
22392
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
22393
-
22394
- /** Used as a reference to the global object. */
22395
- var root = freeGlobal || freeSelf;
22396
-
22397
- /** Used for built-in method references. */
22398
- var objectProto = Object.prototype;
22399
-
22400
- /**
22401
- * Used to resolve the
22402
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
22403
- * of values.
22404
- */
22405
- var objectToString = objectProto.toString;
22406
-
22407
- /* Built-in method references for those with the same name as other `lodash` methods. */
22408
- var nativeMax = Math.max,
22409
- nativeMin = Math.min;
22410
-
22411
- /**
22412
- * Gets the timestamp of the number of milliseconds that have elapsed since
22413
- * the Unix epoch (1 January 1970 00:00:00 UTC).
22414
- *
22415
- * @static
22416
- * @memberOf _
22417
- * @since 2.4.0
22418
- * @category Date
22419
- * @returns {number} Returns the timestamp.
22420
- * @example
22421
- *
22422
- * _.defer(function(stamp) {
22423
- * console.log(_.now() - stamp);
22424
- * }, _.now());
22425
- * // => Logs the number of milliseconds it took for the deferred invocation.
22426
- */
22427
- var now = function() {
22428
- return root.Date.now();
22429
- };
22430
-
22431
- /**
22432
- * Creates a debounced function that delays invoking `func` until after `wait`
22433
- * milliseconds have elapsed since the last time the debounced function was
22434
- * invoked. The debounced function comes with a `cancel` method to cancel
22435
- * delayed `func` invocations and a `flush` method to immediately invoke them.
22436
- * Provide `options` to indicate whether `func` should be invoked on the
22437
- * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
22438
- * with the last arguments provided to the debounced function. Subsequent
22439
- * calls to the debounced function return the result of the last `func`
22440
- * invocation.
22441
- *
22442
- * **Note:** If `leading` and `trailing` options are `true`, `func` is
22443
- * invoked on the trailing edge of the timeout only if the debounced function
22444
- * is invoked more than once during the `wait` timeout.
22445
- *
22446
- * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
22447
- * until to the next tick, similar to `setTimeout` with a timeout of `0`.
22448
- *
22449
- * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
22450
- * for details over the differences between `_.debounce` and `_.throttle`.
22451
- *
22452
- * @static
22453
- * @memberOf _
22454
- * @since 0.1.0
22455
- * @category Function
22456
- * @param {Function} func The function to debounce.
22457
- * @param {number} [wait=0] The number of milliseconds to delay.
22458
- * @param {Object} [options={}] The options object.
22459
- * @param {boolean} [options.leading=false]
22460
- * Specify invoking on the leading edge of the timeout.
22461
- * @param {number} [options.maxWait]
22462
- * The maximum time `func` is allowed to be delayed before it's invoked.
22463
- * @param {boolean} [options.trailing=true]
22464
- * Specify invoking on the trailing edge of the timeout.
22465
- * @returns {Function} Returns the new debounced function.
22466
- * @example
22467
- *
22468
- * // Avoid costly calculations while the window size is in flux.
22469
- * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
22470
- *
22471
- * // Invoke `sendMail` when clicked, debouncing subsequent calls.
22472
- * jQuery(element).on('click', _.debounce(sendMail, 300, {
22473
- * 'leading': true,
22474
- * 'trailing': false
22475
- * }));
22476
- *
22477
- * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
22478
- * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
22479
- * var source = new EventSource('/stream');
22480
- * jQuery(source).on('message', debounced);
22481
- *
22482
- * // Cancel the trailing debounced invocation.
22483
- * jQuery(window).on('popstate', debounced.cancel);
22484
- */
22485
- function debounce(func, wait, options) {
22486
- var lastArgs,
22487
- lastThis,
22488
- maxWait,
22489
- result,
22490
- timerId,
22491
- lastCallTime,
22492
- lastInvokeTime = 0,
22493
- leading = false,
22494
- maxing = false,
22495
- trailing = true;
22496
-
22497
- if (typeof func != 'function') {
22498
- throw new TypeError(FUNC_ERROR_TEXT);
22499
- }
22500
- wait = toNumber(wait) || 0;
22501
- if (isObject$1(options)) {
22502
- leading = !!options.leading;
22503
- maxing = 'maxWait' in options;
22504
- maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
22505
- trailing = 'trailing' in options ? !!options.trailing : trailing;
22506
- }
22507
-
22508
- function invokeFunc(time) {
22509
- var args = lastArgs,
22510
- thisArg = lastThis;
22511
-
22512
- lastArgs = lastThis = undefined;
22513
- lastInvokeTime = time;
22514
- result = func.apply(thisArg, args);
22515
- return result;
22516
- }
22517
-
22518
- function leadingEdge(time) {
22519
- // Reset any `maxWait` timer.
22520
- lastInvokeTime = time;
22521
- // Start the timer for the trailing edge.
22522
- timerId = setTimeout(timerExpired, wait);
22523
- // Invoke the leading edge.
22524
- return leading ? invokeFunc(time) : result;
22525
- }
22526
-
22527
- function remainingWait(time) {
22528
- var timeSinceLastCall = time - lastCallTime,
22529
- timeSinceLastInvoke = time - lastInvokeTime,
22530
- result = wait - timeSinceLastCall;
22531
-
22532
- return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
22533
- }
22534
-
22535
- function shouldInvoke(time) {
22536
- var timeSinceLastCall = time - lastCallTime,
22537
- timeSinceLastInvoke = time - lastInvokeTime;
22538
-
22539
- // Either this is the first call, activity has stopped and we're at the
22540
- // trailing edge, the system time has gone backwards and we're treating
22541
- // it as the trailing edge, or we've hit the `maxWait` limit.
22542
- return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
22543
- (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
22544
- }
22545
-
22546
- function timerExpired() {
22547
- var time = now();
22548
- if (shouldInvoke(time)) {
22549
- return trailingEdge(time);
22550
- }
22551
- // Restart the timer.
22552
- timerId = setTimeout(timerExpired, remainingWait(time));
22553
- }
22554
-
22555
- function trailingEdge(time) {
22556
- timerId = undefined;
22557
-
22558
- // Only invoke if we have `lastArgs` which means `func` has been
22559
- // debounced at least once.
22560
- if (trailing && lastArgs) {
22561
- return invokeFunc(time);
22562
- }
22563
- lastArgs = lastThis = undefined;
22564
- return result;
22565
- }
22566
-
22567
- function cancel() {
22568
- if (timerId !== undefined) {
22569
- clearTimeout(timerId);
22570
- }
22571
- lastInvokeTime = 0;
22572
- lastArgs = lastCallTime = lastThis = timerId = undefined;
22573
- }
22574
-
22575
- function flush() {
22576
- return timerId === undefined ? result : trailingEdge(now());
22577
- }
22578
-
22579
- function debounced() {
22580
- var time = now(),
22581
- isInvoking = shouldInvoke(time);
22582
-
22583
- lastArgs = arguments;
22584
- lastThis = this;
22585
- lastCallTime = time;
22586
-
22587
- if (isInvoking) {
22588
- if (timerId === undefined) {
22589
- return leadingEdge(lastCallTime);
22590
- }
22591
- if (maxing) {
22592
- // Handle invocations in a tight loop.
22593
- timerId = setTimeout(timerExpired, wait);
22594
- return invokeFunc(lastCallTime);
22595
- }
22596
- }
22597
- if (timerId === undefined) {
22598
- timerId = setTimeout(timerExpired, wait);
22599
- }
22600
- return result;
22601
- }
22602
- debounced.cancel = cancel;
22603
- debounced.flush = flush;
22604
- return debounced;
22605
- }
22606
-
22607
- /**
22608
- * Checks if `value` is the
22609
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
22610
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
22611
- *
22612
- * @static
22613
- * @memberOf _
22614
- * @since 0.1.0
22615
- * @category Lang
22616
- * @param {*} value The value to check.
22617
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
22618
- * @example
22619
- *
22620
- * _.isObject({});
22621
- * // => true
22622
- *
22623
- * _.isObject([1, 2, 3]);
22624
- * // => true
22625
- *
22626
- * _.isObject(_.noop);
22627
- * // => true
22628
- *
22629
- * _.isObject(null);
22630
- * // => false
22631
- */
22632
- function isObject$1(value) {
22633
- var type = typeof value;
22634
- return !!value && (type == 'object' || type == 'function');
22635
- }
22636
-
22637
- /**
22638
- * Checks if `value` is object-like. A value is object-like if it's not `null`
22639
- * and has a `typeof` result of "object".
22640
- *
22641
- * @static
22642
- * @memberOf _
22643
- * @since 4.0.0
22644
- * @category Lang
22645
- * @param {*} value The value to check.
22646
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
22647
- * @example
22648
- *
22649
- * _.isObjectLike({});
22650
- * // => true
22651
- *
22652
- * _.isObjectLike([1, 2, 3]);
22653
- * // => true
22654
- *
22655
- * _.isObjectLike(_.noop);
22656
- * // => false
22657
- *
22658
- * _.isObjectLike(null);
22659
- * // => false
22660
- */
22661
- function isObjectLike(value) {
22662
- return !!value && typeof value == 'object';
22663
- }
22664
-
22665
- /**
22666
- * Checks if `value` is classified as a `Symbol` primitive or object.
22667
- *
22668
- * @static
22669
- * @memberOf _
22670
- * @since 4.0.0
22671
- * @category Lang
22672
- * @param {*} value The value to check.
22673
- * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
22674
- * @example
22675
- *
22676
- * _.isSymbol(Symbol.iterator);
22677
- * // => true
22678
- *
22679
- * _.isSymbol('abc');
22680
- * // => false
22681
- */
22682
- function isSymbol(value) {
22683
- return typeof value == 'symbol' ||
22684
- (isObjectLike(value) && objectToString.call(value) == symbolTag);
22685
- }
22686
-
22687
- /**
22688
- * Converts `value` to a number.
22689
- *
22690
- * @static
22691
- * @memberOf _
22692
- * @since 4.0.0
22693
- * @category Lang
22694
- * @param {*} value The value to process.
22695
- * @returns {number} Returns the number.
22696
- * @example
22697
- *
22698
- * _.toNumber(3.2);
22699
- * // => 3.2
22700
- *
22701
- * _.toNumber(Number.MIN_VALUE);
22702
- * // => 5e-324
22703
- *
22704
- * _.toNumber(Infinity);
22705
- * // => Infinity
22706
- *
22707
- * _.toNumber('3.2');
22708
- * // => 3.2
22709
- */
22710
- function toNumber(value) {
22711
- if (typeof value == 'number') {
22712
- return value;
22713
- }
22714
- if (isSymbol(value)) {
22715
- return NAN;
22716
- }
22717
- if (isObject$1(value)) {
22718
- var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
22719
- value = isObject$1(other) ? (other + '') : other;
22720
- }
22721
- if (typeof value != 'string') {
22722
- return value === 0 ? value : +value;
22723
- }
22724
- value = value.replace(reTrim, '');
22725
- var isBinary = reIsBinary.test(value);
22726
- return (isBinary || reIsOctal.test(value))
22727
- ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
22728
- : (reIsBadHex.test(value) ? NAN : +value);
22729
- }
22730
-
22731
- var lodash_debounce = debounce;
22432
+ /** Default flush delays */
22433
+ const DEFAULT_FLUSH_MIN_DELAY = 5000;
22434
+ const DEFAULT_FLUSH_MAX_DELAY = 15000;
22435
+ const INITIAL_FLUSH_DELAY = 5000;
22732
22436
 
22733
22437
  /*! *****************************************************************************
22734
22438
  Copyright (c) Microsoft Corporation.
@@ -29736,6 +29440,9 @@ var fdt = new u8(32);
29736
29440
  for (var i = 0; i < 32; ++i)
29737
29441
  fdt[i] = 5;
29738
29442
 
29443
+ /**
29444
+ * Create a breadcrumb for a replay.
29445
+ */
29739
29446
  function createBreadcrumb(
29740
29447
  breadcrumb,
29741
29448
  ) {
@@ -29746,6 +29453,9 @@ function createBreadcrumb(
29746
29453
  };
29747
29454
  }
29748
29455
 
29456
+ /**
29457
+ * An event handler to react to DOM events.
29458
+ */
29749
29459
  function handleDom(handlerData) {
29750
29460
  // Taken from https://github.com/getsentry/sentry-javascript/blob/master/packages/browser/src/integrations/breadcrumbs.ts#L112
29751
29461
  let target;
@@ -29788,6 +29498,9 @@ function isEventWithTarget(event) {
29788
29498
 
29789
29499
  let _LAST_BREADCRUMB = null;
29790
29500
 
29501
+ /**
29502
+ * An event handler to handle scope changes.
29503
+ */
29791
29504
  function handleScope(scope) {
29792
29505
  const newBreadcrumb = scope.getLastBreadcrumb();
29793
29506
 
@@ -29810,6 +29523,9 @@ function handleScope(scope) {
29810
29523
  return createBreadcrumb(newBreadcrumb);
29811
29524
  }
29812
29525
 
29526
+ /**
29527
+ * An event handler to react to breadcrumbs.
29528
+ */
29813
29529
  function breadcrumbHandler(type, handlerData) {
29814
29530
  if (type === 'scope') {
29815
29531
  return handleScope(handlerData );
@@ -29946,6 +29662,9 @@ function handleFetchSpanListener(replay) {
29946
29662
  };
29947
29663
  }
29948
29664
 
29665
+ /**
29666
+ * Returns true if we think the given event is an error originating inside of rrweb.
29667
+ */
29949
29668
  function isRrwebError(event) {
29950
29669
  if (event.type || !_optionalChain([event, 'access', _ => _.exception, 'optionalAccess', _2 => _2.values, 'optionalAccess', _3 => _3.length])) {
29951
29670
  return false;
@@ -29967,10 +29686,7 @@ function isRrwebError(event) {
29967
29686
  function handleGlobalEventListener(replay) {
29968
29687
  return (event) => {
29969
29688
  // Do not apply replayId to the root event
29970
- if (
29971
- // @ts-ignore new event type
29972
- event.type === REPLAY_EVENT_NAME
29973
- ) {
29689
+ if (event.type === REPLAY_EVENT_NAME) {
29974
29690
  // Replays have separate set of breadcrumbs, do not include breadcrumbs
29975
29691
  // from core SDK
29976
29692
  delete event.breadcrumbs;
@@ -29986,7 +29702,7 @@ function handleGlobalEventListener(replay) {
29986
29702
 
29987
29703
  // Only tag transactions with replayId if not waiting for an error
29988
29704
  // @ts-ignore private
29989
- if (event.type !== 'transaction' || replay.recordingMode === 'session') {
29705
+ if (!event.type || replay.recordingMode === 'session') {
29990
29706
  event.tags = { ...event.tags, replayId: _optionalChain([replay, 'access', _5 => _5.session, 'optionalAccess', _6 => _6.id]) };
29991
29707
  }
29992
29708
 
@@ -30299,9 +30015,12 @@ const ENTRY_TYPES = {
30299
30015
  // @ts-ignore TODO: entry type does not fit the create* functions entry type
30300
30016
  navigation: createNavigationEntry,
30301
30017
  // @ts-ignore TODO: entry type does not fit the create* functions entry type
30302
- ['largest-contentful-paint']: createLargestContentfulPaint,
30018
+ 'largest-contentful-paint': createLargestContentfulPaint,
30303
30019
  };
30304
30020
 
30021
+ /**
30022
+ * Create replay performance entries from the browser performance entries.
30023
+ */
30305
30024
  function createPerformanceEntries(entries) {
30306
30025
  return entries.map(createPerformanceEntry).filter(Boolean) ;
30307
30026
  }
@@ -30320,8 +30039,6 @@ function getAbsoluteTime(time) {
30320
30039
  return ((browserPerformanceTimeOrigin || WINDOW.performance.timeOrigin) + time) / 1000;
30321
30040
  }
30322
30041
 
30323
- // TODO: type definition!
30324
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
30325
30042
  function createPaintEntry(entry) {
30326
30043
  const { duration, entryType, name, startTime } = entry;
30327
30044
 
@@ -30334,8 +30051,6 @@ function createPaintEntry(entry) {
30334
30051
  };
30335
30052
  }
30336
30053
 
30337
- // TODO: type definition!
30338
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
30339
30054
  function createNavigationEntry(entry) {
30340
30055
  // TODO: There looks to be some more interesting bits in here (domComplete, domContentLoaded)
30341
30056
  const { entryType, name, duration, domComplete, startTime, transferSize, type } = entry;
@@ -30357,8 +30072,6 @@ function createNavigationEntry(entry) {
30357
30072
  };
30358
30073
  }
30359
30074
 
30360
- // TODO: type definition!
30361
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
30362
30075
  function createResourceEntry(entry) {
30363
30076
  const { entryType, initiatorType, name, responseEnd, startTime, encodedBodySize, transferSize } = entry;
30364
30077
 
@@ -30379,9 +30092,9 @@ function createResourceEntry(entry) {
30379
30092
  };
30380
30093
  }
30381
30094
 
30382
- // TODO: type definition!
30383
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
30384
- function createLargestContentfulPaint(entry) {
30095
+ function createLargestContentfulPaint(
30096
+ entry,
30097
+ ) {
30385
30098
  const { duration, entryType, startTime, size } = entry;
30386
30099
 
30387
30100
  const start = getAbsoluteTime(startTime);
@@ -30406,6 +30119,9 @@ function t(t){let e=t.length;for(;--e>=0;)t[e]=0}const e=new Uint8Array([0,0,0,0
30406
30119
 
30407
30120
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
30408
30121
 
30122
+ /**
30123
+ * Create an event buffer for replays.
30124
+ */
30409
30125
  function createEventBuffer({ useCompression }) {
30410
30126
  // eslint-disable-next-line no-restricted-globals
30411
30127
  if (useCompression && window.Worker) {
@@ -30436,14 +30152,14 @@ class EventBufferArray {
30436
30152
  this._events = [];
30437
30153
  }
30438
30154
 
30439
- destroy() {
30440
- this._events = [];
30441
- }
30442
-
30443
30155
  get length() {
30444
30156
  return this._events.length;
30445
30157
  }
30446
30158
 
30159
+ destroy() {
30160
+ this._events = [];
30161
+ }
30162
+
30447
30163
  addEvent(event, isCheckout) {
30448
30164
  if (isCheckout) {
30449
30165
  this._events = [event];
@@ -30465,7 +30181,10 @@ class EventBufferArray {
30465
30181
  }
30466
30182
  }
30467
30183
 
30468
- // exporting for testing
30184
+ /**
30185
+ * Event buffer that uses a web worker to compress events.
30186
+ * Exported only for testing.
30187
+ */
30469
30188
  class EventBufferCompressionWorker {
30470
30189
 
30471
30190
  __init() {this._eventBufferItemLength = 0;}
@@ -30475,12 +30194,6 @@ class EventBufferCompressionWorker {
30475
30194
  this._worker = worker;
30476
30195
  }
30477
30196
 
30478
- destroy() {
30479
- (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.log('[Replay] Destroying compression worker');
30480
- _optionalChain([this, 'access', _ => _._worker, 'optionalAccess', _2 => _2.terminate, 'call', _3 => _3()]);
30481
- this._worker = null;
30482
- }
30483
-
30484
30197
  /**
30485
30198
  * Note that this may not reflect what is actually in the event buffer. This
30486
30199
  * is only a local count of the buffer size since `addEvent` is async.
@@ -30489,6 +30202,18 @@ class EventBufferCompressionWorker {
30489
30202
  return this._eventBufferItemLength;
30490
30203
  }
30491
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
+ */
30492
30217
  async addEvent(event, isCheckout) {
30493
30218
  if (isCheckout) {
30494
30219
  // This event is a checkout, make sure worker buffer is cleared before
@@ -30503,6 +30228,9 @@ class EventBufferCompressionWorker {
30503
30228
  return this._sendEventToWorker(event);
30504
30229
  }
30505
30230
 
30231
+ /**
30232
+ * Finish the event buffer and return the compressed data.
30233
+ */
30506
30234
  finish() {
30507
30235
  return this._finishRequest(this._getAndIncrementId());
30508
30236
  }
@@ -30553,6 +30281,9 @@ class EventBufferCompressionWorker {
30553
30281
  });
30554
30282
  }
30555
30283
 
30284
+ /**
30285
+ * Send the event to the worker.
30286
+ */
30556
30287
  _sendEventToWorker(event) {
30557
30288
  const promise = this._postMessage({
30558
30289
  id: this._getAndIncrementId(),
@@ -30566,6 +30297,9 @@ class EventBufferCompressionWorker {
30566
30297
  return promise;
30567
30298
  }
30568
30299
 
30300
+ /**
30301
+ * Finish the request and return the compressed data from the worker.
30302
+ */
30569
30303
  async _finishRequest(id) {
30570
30304
  const promise = this._postMessage({ id, method: 'finish', args: [] });
30571
30305
 
@@ -30575,6 +30309,7 @@ class EventBufferCompressionWorker {
30575
30309
  return promise ;
30576
30310
  }
30577
30311
 
30312
+ /** Get the current ID and increment it for the next call. */
30578
30313
  _getAndIncrementId() {
30579
30314
  return this._id++;
30580
30315
  }
@@ -30632,6 +30367,9 @@ function isSessionExpired(session, idleTimeout, targetTime = +new Date()) {
30632
30367
  );
30633
30368
  }
30634
30369
 
30370
+ /**
30371
+ * Save a session to session storage.
30372
+ */
30635
30373
  function saveSession(session) {
30636
30374
  const hasSessionStorage = 'sessionStorage' in WINDOW;
30637
30375
  if (!hasSessionStorage) {
@@ -30786,7 +30524,30 @@ function addMemoryEntry(replay) {
30786
30524
  }
30787
30525
  }
30788
30526
 
30789
- 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({
30790
30551
  events,
30791
30552
  headers,
30792
30553
  }
@@ -30813,59 +30574,99 @@ function createPayload({
30813
30574
  return payloadWithSequence;
30814
30575
  }
30815
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
+ */
30816
30581
  function createReplayEnvelope(
30817
30582
  replayEvent,
30818
- payloadWithSequence,
30583
+ recordingData,
30819
30584
  dsn,
30820
30585
  tunnel,
30821
30586
  ) {
30822
30587
  return createEnvelope(
30823
30588
  createEventEnvelopeHeaders(replayEvent, getSdkMetadataForEnvelopeHeader(replayEvent), tunnel, dsn),
30824
30589
  [
30825
- // @ts-ignore New types
30826
30590
  [{ type: 'replay_event' }, replayEvent],
30827
30591
  [
30828
30592
  {
30829
- // @ts-ignore setting envelope
30830
30593
  type: 'replay_recording',
30831
- length: payloadWithSequence.length,
30594
+ length: recordingData.length,
30832
30595
  },
30833
- // @ts-ignore: Type 'string' is not assignable to type 'ClientReport'.ts(2322)
30834
- payloadWithSequence,
30596
+ recordingData,
30835
30597
  ],
30836
30598
  ],
30837
30599
  );
30838
30600
  }
30839
30601
 
30840
- async function getReplayEvent({
30841
- client,
30842
- scope,
30843
- replayId: event_id,
30844
- event,
30845
- }
30602
+ /**
30603
+ * Heavily simplified debounce function based on lodash.debounce.
30604
+ *
30605
+ * This function takes a callback function (@param fun) and delays its invocation
30606
+ * by @param wait milliseconds. Optionally, a maxWait can be specified in @param options,
30607
+ * which ensures that the callback is invoked at least once after the specified max. wait time.
30608
+ *
30609
+ * @param func the function whose invocation is to be debounced
30610
+ * @param wait the minimum time until the function is invoked after it was called once
30611
+ * @param options the options object, which can contain the `maxWait` property
30612
+ *
30613
+ * @returns the debounced version of the function, which needs to be called at least once to start the
30614
+ * debouncing process. Subsequent calls will reset the debouncing timer and, in case @paramfunc
30615
+ * was already invoked in the meantime, return @param func's return value.
30616
+ * The debounced function has two additional properties:
30617
+ * - `flush`: Invokes the debounced function immediately and returns its return value
30618
+ * - `cancel`: Cancels the debouncing process and resets the debouncing timer
30619
+ */
30620
+ function debounce(func, wait, options) {
30621
+ let callbackReturnValue;
30846
30622
 
30847
- ) {
30848
- // XXX: This event does not trigger `beforeSend` in SDK
30849
- // @ts-ignore private api
30850
- const preparedEvent = await client._prepareEvent(event, { event_id }, scope);
30623
+ let timerId;
30624
+ let maxTimerId;
30851
30625
 
30852
- if (preparedEvent) {
30853
- // extract the SDK name because `client._prepareEvent` doesn't add it to the event
30854
- const metadata = client.getOptions() && client.getOptions()._metadata;
30855
- const { name } = (metadata && metadata.sdk) || {};
30626
+ const maxWait = options && options.maxWait ? Math.max(options.maxWait, wait) : 0;
30856
30627
 
30857
- preparedEvent.sdk = {
30858
- ...preparedEvent.sdk,
30859
- version: "7.28.1",
30860
- name,
30861
- };
30628
+ function invokeFunc() {
30629
+ cancelTimers();
30630
+ callbackReturnValue = func();
30631
+ return callbackReturnValue;
30862
30632
  }
30863
30633
 
30864
- return preparedEvent;
30634
+ function cancelTimers() {
30635
+ timerId !== undefined && clearTimeout(timerId);
30636
+ maxTimerId !== undefined && clearTimeout(maxTimerId);
30637
+ timerId = maxTimerId = undefined;
30638
+ }
30639
+
30640
+ function flush() {
30641
+ if (timerId !== undefined || maxTimerId !== undefined) {
30642
+ return invokeFunc();
30643
+ }
30644
+ return callbackReturnValue;
30645
+ }
30646
+
30647
+ function debounced() {
30648
+ if (timerId) {
30649
+ clearTimeout(timerId);
30650
+ }
30651
+ timerId = setTimeout(invokeFunc, wait);
30652
+
30653
+ if (maxWait && maxTimerId === undefined) {
30654
+ maxTimerId = setTimeout(invokeFunc, maxWait);
30655
+ }
30656
+
30657
+ return callbackReturnValue;
30658
+ }
30659
+
30660
+ debounced.cancel = cancelTimers;
30661
+ debounced.flush = flush;
30662
+ return debounced;
30865
30663
  }
30866
30664
 
30867
30665
  let _originalRecordDroppedEvent;
30868
30666
 
30667
+ /**
30668
+ * Overwrite the `recordDroppedEvent` method on the client, so we can find out which events were dropped.
30669
+ * */
30869
30670
  function overwriteRecordDroppedEvent(errorIds) {
30870
30671
  const client = getCurrentHub().getClient();
30871
30672
 
@@ -30880,7 +30681,7 @@ function overwriteRecordDroppedEvent(errorIds) {
30880
30681
  category,
30881
30682
  event,
30882
30683
  ) => {
30883
- if (event && event.event_id) {
30684
+ if (event && !event.type && event.event_id) {
30884
30685
  errorIds.delete(event.event_id);
30885
30686
  }
30886
30687
 
@@ -30891,6 +30692,9 @@ function overwriteRecordDroppedEvent(errorIds) {
30891
30692
  _originalRecordDroppedEvent = _originalCallback;
30892
30693
  }
30893
30694
 
30695
+ /**
30696
+ * Restore the original method.
30697
+ * */
30894
30698
  function restoreRecordDroppedEvent() {
30895
30699
  const client = getCurrentHub().getClient();
30896
30700
 
@@ -30901,6 +30705,42 @@ function restoreRecordDroppedEvent() {
30901
30705
  client.recordDroppedEvent = _originalRecordDroppedEvent;
30902
30706
  }
30903
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
+
30904
30744
  /* eslint-disable max-lines */ // TODO: We might want to split this file up
30905
30745
 
30906
30746
  /**
@@ -30910,6 +30750,9 @@ function restoreRecordDroppedEvent() {
30910
30750
  const BASE_RETRY_INTERVAL = 5000;
30911
30751
  const MAX_RETRY_COUNT = 3;
30912
30752
 
30753
+ /**
30754
+ * The main replay container class, which holds all the state and methods for recording and sending replays.
30755
+ */
30913
30756
  class ReplayContainer {
30914
30757
  __init() {this.eventBuffer = null;}
30915
30758
 
@@ -30977,7 +30820,7 @@ class ReplayContainer {
30977
30820
  this._recordingOptions = recordingOptions;
30978
30821
  this._options = options;
30979
30822
 
30980
- this._debouncedFlush = lodash_debounce(() => this.flush(), this._options.flushMinDelay, {
30823
+ this._debouncedFlush = debounce(() => this.flush(), this._options.flushMinDelay, {
30981
30824
  maxWait: this._options.flushMaxDelay,
30982
30825
  });
30983
30826
  }
@@ -31706,7 +31549,6 @@ class ReplayContainer {
31706
31549
  // A flush is about to happen, cancel any queued flushes
31707
31550
  _optionalChain([this, 'access', _30 => _30._debouncedFlush, 'optionalAccess', _31 => _31.cancel, 'call', _32 => _32()]);
31708
31551
 
31709
- // No existing flush in progress, proceed with flushing.
31710
31552
  // this._flushLock acts as a lock so that future calls to `flush()`
31711
31553
  // will be blocked until this promise resolves
31712
31554
  if (!this._flushLock) {
@@ -31739,8 +31581,8 @@ class ReplayContainer {
31739
31581
  */
31740
31582
  flushImmediate() {
31741
31583
  this._debouncedFlush();
31742
- // `.flush` is provided by lodash.debounce
31743
- return this._debouncedFlush.flush();
31584
+ // `.flush` is provided by the debounced function, analogously to lodash.debounce
31585
+ return this._debouncedFlush.flush() ;
31744
31586
  }
31745
31587
 
31746
31588
  /**
@@ -31753,7 +31595,7 @@ class ReplayContainer {
31753
31595
  includeReplayStartTimestamp,
31754
31596
  eventContext,
31755
31597
  }) {
31756
- const payloadWithSequence = createPayload({
31598
+ const recordingData = createRecordingData({
31757
31599
  events,
31758
31600
  headers: {
31759
31601
  segment_id,
@@ -31770,7 +31612,7 @@ class ReplayContainer {
31770
31612
  const transport = client && client.getTransport();
31771
31613
  const dsn = _optionalChain([client, 'optionalAccess', _33 => _33.getDsn, 'call', _34 => _34()]);
31772
31614
 
31773
- if (!client || !scope || !transport || !dsn) {
31615
+ if (!client || !scope || !transport || !dsn || !this.session || !this.session.sampled) {
31774
31616
  return;
31775
31617
  }
31776
31618
 
@@ -31784,12 +31626,15 @@ class ReplayContainer {
31784
31626
  urls,
31785
31627
  replay_id: replayId,
31786
31628
  segment_id,
31629
+ replay_type: this.session.sampled,
31787
31630
  };
31788
31631
 
31789
- const replayEvent = await getReplayEvent({ scope, client, replayId, event: baseEvent });
31632
+ const replayEvent = await prepareReplayEvent({ scope, client, replayId, event: baseEvent });
31790
31633
 
31791
31634
  if (!replayEvent) {
31792
- (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.error('[Replay] An event processor returned null, will not send replay.');
31635
+ // Taken from baseclient's `_processEvent` method, where this is handled for errors/transactions
31636
+ client.recordDroppedEvent('event_processor', 'replay_event', baseEvent);
31637
+ (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.log('An event processor returned `null`, will not send event.');
31793
31638
  return;
31794
31639
  }
31795
31640
 
@@ -31797,7 +31642,6 @@ class ReplayContainer {
31797
31642
  ...replayEvent.tags,
31798
31643
  sessionSampleRate: this._options.sessionSampleRate,
31799
31644
  errorSampleRate: this._options.errorSampleRate,
31800
- replayType: _optionalChain([this, 'access', _35 => _35.session, 'optionalAccess', _36 => _36.sampled]),
31801
31645
  };
31802
31646
 
31803
31647
  /*
@@ -31816,6 +31660,7 @@ class ReplayContainer {
31816
31660
  ],
31817
31661
  "replay_id": "eventId",
31818
31662
  "segment_id": 3,
31663
+ "replay_type": "error",
31819
31664
  "platform": "javascript",
31820
31665
  "event_id": "eventId",
31821
31666
  "environment": "production",
@@ -31831,20 +31676,22 @@ class ReplayContainer {
31831
31676
  "tags": {
31832
31677
  "sessionSampleRate": 1,
31833
31678
  "errorSampleRate": 0,
31834
- "replayType": "error"
31835
31679
  }
31836
31680
  }
31837
31681
  */
31838
31682
 
31839
- const envelope = createReplayEnvelope(replayEvent, payloadWithSequence, dsn, client.getOptions().tunnel);
31683
+ const envelope = createReplayEnvelope(replayEvent, recordingData, dsn, client.getOptions().tunnel);
31840
31684
 
31841
31685
  try {
31842
- return transport.send(envelope);
31686
+ return await transport.send(envelope);
31843
31687
  } catch (e) {
31844
31688
  throw new Error(UNABLE_TO_SEND_REPLAY);
31845
31689
  }
31846
31690
  }
31847
31691
 
31692
+ /**
31693
+ * Reset the counter of retries for sending replays.
31694
+ */
31848
31695
  resetRetries() {
31849
31696
  this._retryCount = 0;
31850
31697
  this._retryInterval = BASE_RETRY_INTERVAL;
@@ -31919,15 +31766,26 @@ class ReplayContainer {
31919
31766
  }
31920
31767
  }
31921
31768
 
31769
+ /**
31770
+ * Returns true if we are in the browser.
31771
+ */
31922
31772
  function isBrowser() {
31923
31773
  // eslint-disable-next-line no-restricted-globals
31924
- 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';
31925
31780
  }
31926
31781
 
31927
31782
  const MEDIA_SELECTORS = 'img,image,svg,path,rect,area,video,object,picture,embed,map,audio';
31928
31783
 
31929
31784
  let _initialized = false;
31930
31785
 
31786
+ /**
31787
+ * The main replay integration class, to be passed to `init({ integrations: [] })`.
31788
+ */
31931
31789
  class Replay {
31932
31790
  /**
31933
31791
  * @inheritDoc
@@ -31943,23 +31801,16 @@ class Replay {
31943
31801
  * Options to pass to `rrweb.record()`
31944
31802
  */
31945
31803
 
31946
- get _isInitialized() {
31947
- return _initialized;
31948
- }
31949
-
31950
- set _isInitialized(value) {
31951
- _initialized = value;
31952
- }
31953
-
31954
31804
  constructor({
31955
- flushMinDelay = 5000,
31956
- flushMaxDelay = 15000,
31957
- initialFlushDelay = 5000,
31805
+ flushMinDelay = DEFAULT_FLUSH_MIN_DELAY,
31806
+ flushMaxDelay = DEFAULT_FLUSH_MAX_DELAY,
31807
+ initialFlushDelay = INITIAL_FLUSH_DELAY,
31958
31808
  stickySession = true,
31959
31809
  useCompression = true,
31960
31810
  sessionSampleRate,
31961
31811
  errorSampleRate,
31962
- maskAllText = true,
31812
+ maskAllText,
31813
+ maskTextSelector,
31963
31814
  maskAllInputs = true,
31964
31815
  blockAllMedia = true,
31965
31816
  _experiments = {},
@@ -31974,6 +31825,7 @@ class Replay {
31974
31825
  blockClass,
31975
31826
  ignoreClass,
31976
31827
  maskTextClass,
31828
+ maskTextSelector,
31977
31829
  blockSelector,
31978
31830
  ...recordingOptions,
31979
31831
  };
@@ -31986,7 +31838,7 @@ class Replay {
31986
31838
  sessionSampleRate: DEFAULT_SESSION_SAMPLE_RATE,
31987
31839
  errorSampleRate: DEFAULT_ERROR_SAMPLE_RATE,
31988
31840
  useCompression,
31989
- maskAllText,
31841
+ maskAllText: typeof maskAllText === 'boolean' ? maskAllText : !maskTextSelector,
31990
31842
  blockAllMedia,
31991
31843
  _experiments,
31992
31844
  };
@@ -32030,13 +31882,23 @@ Sentry.init({ replaysOnErrorSampleRate: ${errorSampleRate} })`,
32030
31882
  : `${this.recordingOptions.blockSelector},${MEDIA_SELECTORS}`;
32031
31883
  }
32032
31884
 
32033
- if (isBrowser() && this._isInitialized) {
31885
+ if (this._isInitialized && isBrowser()) {
32034
31886
  throw new Error('Multiple Sentry Session Replay instances are not supported');
32035
31887
  }
32036
31888
 
32037
31889
  this._isInitialized = true;
32038
31890
  }
32039
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
+
32040
31902
  /**
32041
31903
  * We previously used to create a transaction in `setupOnce` and it would
32042
31904
  * potentially create a transaction before some native SDK integrations have run
@@ -32084,6 +31946,7 @@ Sentry.init({ replaysOnErrorSampleRate: ${errorSampleRate} })`,
32084
31946
  this._replay.stop();
32085
31947
  }
32086
31948
 
31949
+ /** Setup the integration. */
32087
31950
  _setup() {
32088
31951
  // Client is not available in constructor, so we need to wait until setupOnce
32089
31952
  this._loadReplayOptionsFromClient();
@@ -37955,7 +37818,7 @@ var Preview = /*#__PURE__*/(0, _react.lazy)(function () {
37955
37818
  });
37956
37819
  });
37957
37820
  var IS_BROWSER = typeof window !== 'undefined' && window.document;
37958
- var IS_GLOBAL = typeof commonjsGlobal$1 !== 'undefined' && commonjsGlobal$1.window && commonjsGlobal$1.window.document;
37821
+ var IS_GLOBAL = typeof commonjsGlobal !== 'undefined' && commonjsGlobal.window && commonjsGlobal.window.document;
37959
37822
  var SUPPORTED_PROPS = Object.keys(_props.propTypes); // Return null when rendering on the server
37960
37823
  // as Suspense is not supported yet
37961
37824