@myinterview/widget-react 1.1.23-development-3a50d6c → 1.1.23-from-21-to-dev

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/cjs/index.js CHANGED
@@ -421,21 +421,85 @@ function getLocationHref() {
421
421
  }
422
422
  }
423
423
 
424
- /** An error emitted by Sentry SDKs and related utilities. */
425
- class SentryError extends Error {
426
- /** Display name of this error instance. */
424
+ /** Prefix for logging strings */
425
+ const PREFIX = 'Sentry Logger ';
427
426
 
428
- constructor( message, logLevel = 'warn') {
429
- super(message);this.message = message;
430
- this.name = new.target.prototype.constructor.name;
431
- // This sets the prototype to be `Error`, not `SentryError`. It's unclear why we do this, but commenting this line
432
- // out causes various (seemingly totally unrelated) playwright tests consistently time out. FYI, this makes
433
- // instances of `SentryError` fail `obj instanceof SentryError` checks.
434
- Object.setPrototypeOf(this, new.target.prototype);
435
- this.logLevel = logLevel;
427
+ const CONSOLE_LEVELS = ['debug', 'info', 'warn', 'error', 'log', 'assert', 'trace'] ;
428
+
429
+ /**
430
+ * Temporarily disable sentry console instrumentations.
431
+ *
432
+ * @param callback The function to run against the original `console` messages
433
+ * @returns The results of the callback
434
+ */
435
+ function consoleSandbox(callback) {
436
+ if (!('console' in GLOBAL_OBJ)) {
437
+ return callback();
438
+ }
439
+
440
+ const originalConsole = GLOBAL_OBJ.console ;
441
+ const wrappedLevels = {};
442
+
443
+ // Restore all wrapped console methods
444
+ CONSOLE_LEVELS.forEach(level => {
445
+ // TODO(v7): Remove this check as it's only needed for Node 6
446
+ const originalWrappedFunc =
447
+ originalConsole[level] && (originalConsole[level] ).__sentry_original__;
448
+ if (level in originalConsole && originalWrappedFunc) {
449
+ wrappedLevels[level] = originalConsole[level] ;
450
+ originalConsole[level] = originalWrappedFunc ;
451
+ }
452
+ });
453
+
454
+ try {
455
+ return callback();
456
+ } finally {
457
+ // Revert restoration to wrapped state
458
+ Object.keys(wrappedLevels).forEach(level => {
459
+ originalConsole[level] = wrappedLevels[level ];
460
+ });
436
461
  }
437
462
  }
438
463
 
464
+ function makeLogger() {
465
+ let enabled = false;
466
+ const logger = {
467
+ enable: () => {
468
+ enabled = true;
469
+ },
470
+ disable: () => {
471
+ enabled = false;
472
+ },
473
+ };
474
+
475
+ if ((typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__)) {
476
+ CONSOLE_LEVELS.forEach(name => {
477
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
478
+ logger[name] = (...args) => {
479
+ if (enabled) {
480
+ consoleSandbox(() => {
481
+ GLOBAL_OBJ.console[name](`${PREFIX}[${name}]:`, ...args);
482
+ });
483
+ }
484
+ };
485
+ });
486
+ } else {
487
+ CONSOLE_LEVELS.forEach(name => {
488
+ logger[name] = () => undefined;
489
+ });
490
+ }
491
+
492
+ return logger ;
493
+ }
494
+
495
+ // Ensure we only have a single logger instance, even if multiple versions of @sentry/utils are being used
496
+ let logger;
497
+ if ((typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__)) {
498
+ logger = getGlobalSingleton('logger', makeLogger);
499
+ } else {
500
+ logger = makeLogger();
501
+ }
502
+
439
503
  /** Regular expression used to parse a Dsn. */
440
504
  const DSN_REGEX = /^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)([\w.-]+)(?::(\d+))?\/(.+)/;
441
505
 
@@ -464,13 +528,16 @@ function dsnToString(dsn, withPassword = false) {
464
528
  * Parses a Dsn from a given string.
465
529
  *
466
530
  * @param str A Dsn as string
467
- * @returns Dsn as DsnComponents
531
+ * @returns Dsn as DsnComponents or undefined if @param str is not a valid DSN string
468
532
  */
469
533
  function dsnFromString(str) {
470
534
  const match = DSN_REGEX.exec(str);
471
535
 
472
536
  if (!match) {
473
- throw new SentryError(`Invalid Sentry Dsn: ${str}`);
537
+ // This should be logged to the console
538
+ // eslint-disable-next-line no-console
539
+ console.error(`Invalid Sentry Dsn: ${str}`);
540
+ return undefined;
474
541
  }
475
542
 
476
543
  const [protocol, publicKey, pass = '', host, port = '', lastPath] = match.slice(1);
@@ -507,117 +574,67 @@ function dsnFromComponents(components) {
507
574
 
508
575
  function validateDsn(dsn) {
509
576
  if (!(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__)) {
510
- return;
577
+ return true;
511
578
  }
512
579
 
513
580
  const { port, projectId, protocol } = dsn;
514
581
 
515
582
  const requiredComponents = ['protocol', 'publicKey', 'host', 'projectId'];
516
- requiredComponents.forEach(component => {
583
+ const hasMissingRequiredComponent = requiredComponents.find(component => {
517
584
  if (!dsn[component]) {
518
- throw new SentryError(`Invalid Sentry Dsn: ${component} missing`);
585
+ logger.error(`Invalid Sentry Dsn: ${component} missing`);
586
+ return true;
519
587
  }
588
+ return false;
520
589
  });
521
590
 
591
+ if (hasMissingRequiredComponent) {
592
+ return false;
593
+ }
594
+
522
595
  if (!projectId.match(/^\d+$/)) {
523
- throw new SentryError(`Invalid Sentry Dsn: Invalid projectId ${projectId}`);
596
+ logger.error(`Invalid Sentry Dsn: Invalid projectId ${projectId}`);
597
+ return false;
524
598
  }
525
599
 
526
600
  if (!isValidProtocol(protocol)) {
527
- throw new SentryError(`Invalid Sentry Dsn: Invalid protocol ${protocol}`);
601
+ logger.error(`Invalid Sentry Dsn: Invalid protocol ${protocol}`);
602
+ return false;
528
603
  }
529
604
 
530
605
  if (port && isNaN(parseInt(port, 10))) {
531
- throw new SentryError(`Invalid Sentry Dsn: Invalid port ${port}`);
606
+ logger.error(`Invalid Sentry Dsn: Invalid port ${port}`);
607
+ return false;
532
608
  }
533
609
 
534
610
  return true;
535
611
  }
536
612
 
537
- /** The Sentry Dsn, identifying a Sentry instance and project. */
538
- function makeDsn(from) {
539
- const components = typeof from === 'string' ? dsnFromString(from) : dsnFromComponents(from);
540
- validateDsn(components);
541
- return components;
542
- }
543
-
544
- /** Prefix for logging strings */
545
- const PREFIX = 'Sentry Logger ';
546
-
547
- const CONSOLE_LEVELS = ['debug', 'info', 'warn', 'error', 'log', 'assert', 'trace'] ;
548
-
549
613
  /**
550
- * Temporarily disable sentry console instrumentations.
551
- *
552
- * @param callback The function to run against the original `console` messages
553
- * @returns The results of the callback
614
+ * Creates a valid Sentry Dsn object, identifying a Sentry instance and project.
615
+ * @returns a valid DsnComponents object or `undefined` if @param from is an invalid DSN source
554
616
  */
555
- function consoleSandbox(callback) {
556
- if (!('console' in GLOBAL_OBJ)) {
557
- return callback();
558
- }
559
-
560
- const originalConsole = GLOBAL_OBJ.console ;
561
- const wrappedLevels = {};
562
-
563
- // Restore all wrapped console methods
564
- CONSOLE_LEVELS.forEach(level => {
565
- // TODO(v7): Remove this check as it's only needed for Node 6
566
- const originalWrappedFunc =
567
- originalConsole[level] && (originalConsole[level] ).__sentry_original__;
568
- if (level in originalConsole && originalWrappedFunc) {
569
- wrappedLevels[level] = originalConsole[level] ;
570
- originalConsole[level] = originalWrappedFunc ;
571
- }
572
- });
573
-
574
- try {
575
- return callback();
576
- } finally {
577
- // Revert restoration to wrapped state
578
- Object.keys(wrappedLevels).forEach(level => {
579
- originalConsole[level] = wrappedLevels[level ];
580
- });
617
+ function makeDsn(from) {
618
+ const components = typeof from === 'string' ? dsnFromString(from) : dsnFromComponents(from);
619
+ if (!components || !validateDsn(components)) {
620
+ return undefined;
581
621
  }
622
+ return components;
582
623
  }
583
624
 
584
- function makeLogger() {
585
- let enabled = false;
586
- const logger = {
587
- enable: () => {
588
- enabled = true;
589
- },
590
- disable: () => {
591
- enabled = false;
592
- },
593
- };
625
+ /** An error emitted by Sentry SDKs and related utilities. */
626
+ class SentryError extends Error {
627
+ /** Display name of this error instance. */
594
628
 
595
- if ((typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__)) {
596
- CONSOLE_LEVELS.forEach(name => {
597
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
598
- logger[name] = (...args) => {
599
- if (enabled) {
600
- consoleSandbox(() => {
601
- GLOBAL_OBJ.console[name](`${PREFIX}[${name}]:`, ...args);
602
- });
603
- }
604
- };
605
- });
606
- } else {
607
- CONSOLE_LEVELS.forEach(name => {
608
- logger[name] = () => undefined;
609
- });
629
+ constructor( message, logLevel = 'warn') {
630
+ super(message);this.message = message;
631
+ this.name = new.target.prototype.constructor.name;
632
+ // This sets the prototype to be `Error`, not `SentryError`. It's unclear why we do this, but commenting this line
633
+ // out causes various (seemingly totally unrelated) playwright tests consistently time out. FYI, this makes
634
+ // instances of `SentryError` fail `obj instanceof SentryError` checks.
635
+ Object.setPrototypeOf(this, new.target.prototype);
636
+ this.logLevel = logLevel;
610
637
  }
611
-
612
- return logger ;
613
- }
614
-
615
- // Ensure we only have a single logger instance, even if multiple versions of @sentry/utils are being used
616
- let logger;
617
- if ((typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__)) {
618
- logger = getGlobalSingleton('logger', makeLogger);
619
- } else {
620
- logger = makeLogger();
621
638
  }
622
639
 
623
640
  /**
@@ -5117,16 +5134,20 @@ class BaseClient {
5117
5134
  */
5118
5135
  constructor(options) {BaseClient.prototype.__init.call(this);BaseClient.prototype.__init2.call(this);BaseClient.prototype.__init3.call(this);BaseClient.prototype.__init4.call(this);BaseClient.prototype.__init5.call(this);
5119
5136
  this._options = options;
5137
+
5120
5138
  if (options.dsn) {
5121
5139
  this._dsn = makeDsn(options.dsn);
5140
+ } else {
5141
+ (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.warn('No DSN provided, client will not do anything.');
5142
+ }
5143
+
5144
+ if (this._dsn) {
5122
5145
  const url = getEnvelopeEndpointWithUrlEncodedAuth(this._dsn, options);
5123
5146
  this._transport = options.transport({
5124
5147
  recordDroppedEvent: this.recordDroppedEvent.bind(this),
5125
5148
  ...options.transportOptions,
5126
5149
  url,
5127
5150
  });
5128
- } else {
5129
- (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.warn('No DSN provided, client will not do anything.');
5130
5151
  }
5131
5152
  }
5132
5153
 
@@ -5845,7 +5866,7 @@ function getEventForEnvelopeItem(item, type) {
5845
5866
  return Array.isArray(item) ? (item )[1] : undefined;
5846
5867
  }
5847
5868
 
5848
- const SDK_VERSION = '7.52.1';
5869
+ const SDK_VERSION = '7.53.0';
5849
5870
 
5850
5871
  let originalFunctionToString;
5851
5872
 
@@ -11597,6 +11618,23 @@ var NodeType;
11597
11618
  NodeType[NodeType["Comment"] = 5] = "Comment";
11598
11619
  })(NodeType || (NodeType = {}));
11599
11620
 
11621
+ /* eslint-disable @typescript-eslint/naming-convention */
11622
+
11623
+ var EventType; (function (EventType) {
11624
+ const DomContentLoaded = 0; EventType[EventType["DomContentLoaded"] = DomContentLoaded] = "DomContentLoaded";
11625
+ const Load = 1; EventType[EventType["Load"] = Load] = "Load";
11626
+ const FullSnapshot = 2; EventType[EventType["FullSnapshot"] = FullSnapshot] = "FullSnapshot";
11627
+ const IncrementalSnapshot = 3; EventType[EventType["IncrementalSnapshot"] = IncrementalSnapshot] = "IncrementalSnapshot";
11628
+ const Meta = 4; EventType[EventType["Meta"] = Meta] = "Meta";
11629
+ const Custom = 5; EventType[EventType["Custom"] = Custom] = "Custom";
11630
+ const Plugin = 6; EventType[EventType["Plugin"] = Plugin] = "Plugin";
11631
+ })(EventType || (EventType = {}));
11632
+
11633
+ /**
11634
+ * This is a partial copy of rrweb's eventWithTime type which only contains the properties
11635
+ * we specifcally need in the SDK.
11636
+ */
11637
+
11600
11638
  /**
11601
11639
  * Converts a timestamp to ms, if it was in s, or keeps it as ms.
11602
11640
  */
@@ -11639,7 +11677,18 @@ async function addEvent(
11639
11677
  replay.eventBuffer.clear();
11640
11678
  }
11641
11679
 
11642
- return await replay.eventBuffer.addEvent(event);
11680
+ const replayOptions = replay.getOptions();
11681
+
11682
+ const eventAfterPossibleCallback =
11683
+ typeof replayOptions.beforeAddRecordingEvent === 'function' && event.type === EventType.Custom
11684
+ ? replayOptions.beforeAddRecordingEvent(event)
11685
+ : event;
11686
+
11687
+ if (!eventAfterPossibleCallback) {
11688
+ return;
11689
+ }
11690
+
11691
+ return await replay.eventBuffer.addEvent(eventAfterPossibleCallback);
11643
11692
  } catch (error) {
11644
11693
  (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.error(error);
11645
11694
  await replay.stop('addEvent');
@@ -14615,23 +14664,6 @@ function debounce(func, wait, options) {
14615
14664
  return debounced;
14616
14665
  }
14617
14666
 
14618
- /* eslint-disable @typescript-eslint/naming-convention */
14619
-
14620
- var EventType; (function (EventType) {
14621
- const DomContentLoaded = 0; EventType[EventType["DomContentLoaded"] = DomContentLoaded] = "DomContentLoaded";
14622
- const Load = 1; EventType[EventType["Load"] = Load] = "Load";
14623
- const FullSnapshot = 2; EventType[EventType["FullSnapshot"] = FullSnapshot] = "FullSnapshot";
14624
- const IncrementalSnapshot = 3; EventType[EventType["IncrementalSnapshot"] = IncrementalSnapshot] = "IncrementalSnapshot";
14625
- const Meta = 4; EventType[EventType["Meta"] = Meta] = "Meta";
14626
- const Custom = 5; EventType[EventType["Custom"] = Custom] = "Custom";
14627
- const Plugin = 6; EventType[EventType["Plugin"] = Plugin] = "Plugin";
14628
- })(EventType || (EventType = {}));
14629
-
14630
- /**
14631
- * This is a partial copy of rrweb's eventWithTime type which only contains the properties
14632
- * we specifcally need in the SDK.
14633
- */
14634
-
14635
14667
  /**
14636
14668
  * Handler for recording events.
14637
14669
  *
@@ -14705,6 +14737,30 @@ function getHandleRecordingEmit(replay) {
14705
14737
  }
14706
14738
  }
14707
14739
 
14740
+ const options = replay.getOptions();
14741
+
14742
+ // TODO: We want this as an experiment so that we can test
14743
+ // internally and create metrics before making this the default
14744
+ if (options._experiments.delayFlushOnCheckout) {
14745
+ // If the full snapshot is due to an initial load, we will not have
14746
+ // a previous session ID. In this case, we want to buffer events
14747
+ // for a set amount of time before flushing. This can help avoid
14748
+ // capturing replays of users that immediately close the window.
14749
+ setTimeout(() => replay.conditionalFlush(), options._experiments.delayFlushOnCheckout);
14750
+
14751
+ // Cancel any previously debounced flushes to ensure there are no [near]
14752
+ // simultaneous flushes happening. The latter request should be
14753
+ // insignificant in this case, so wait for additional user interaction to
14754
+ // trigger a new flush.
14755
+ //
14756
+ // This can happen because there's no guarantee that a recording event
14757
+ // happens first. e.g. a mouse click can happen and trigger a debounced
14758
+ // flush before the checkout.
14759
+ replay.cancelFlush();
14760
+
14761
+ return true;
14762
+ }
14763
+
14708
14764
  // Flush immediately so that we do not miss the first segment, otherwise
14709
14765
  // it can prevent loading on the UI. This will cause an increase in short
14710
14766
  // replays (e.g. opening and closing a tab quickly), but these can be
@@ -15470,7 +15526,17 @@ class ReplayContainer {
15470
15526
  }
15471
15527
 
15472
15528
  /**
15473
- *
15529
+ * Only flush if `this.recordingMode === 'session'`
15530
+ */
15531
+ conditionalFlush() {
15532
+ if (this.recordingMode === 'buffer') {
15533
+ return Promise.resolve();
15534
+ }
15535
+
15536
+ return this.flushImmediate();
15537
+ }
15538
+
15539
+ /**
15474
15540
  * Always flush via `_debouncedFlush` so that we do not have flushes triggered
15475
15541
  * from calling both `flush` and `_debouncedFlush`. Otherwise, there could be
15476
15542
  * cases of mulitple flushes happening closely together.
@@ -15481,6 +15547,13 @@ class ReplayContainer {
15481
15547
  return this._debouncedFlush.flush() ;
15482
15548
  }
15483
15549
 
15550
+ /**
15551
+ * Cancels queued up flushes.
15552
+ */
15553
+ cancelFlush() {
15554
+ this._debouncedFlush.cancel();
15555
+ }
15556
+
15484
15557
  /** Get the current sesion (=replay) ID */
15485
15558
  getSessionId() {
15486
15559
  return this.session && this.session.id;
@@ -15730,7 +15803,7 @@ class ReplayContainer {
15730
15803
  // Send replay when the page/tab becomes hidden. There is no reason to send
15731
15804
  // replay if it becomes visible, since no actions we care about were done
15732
15805
  // while it was hidden
15733
- this._conditionalFlush();
15806
+ void this.conditionalFlush();
15734
15807
  }
15735
15808
 
15736
15809
  /**
@@ -15814,17 +15887,6 @@ class ReplayContainer {
15814
15887
  return Promise.all(createPerformanceSpans(this, createPerformanceEntries(entries)));
15815
15888
  }
15816
15889
 
15817
- /**
15818
- * Only flush if `this.recordingMode === 'session'`
15819
- */
15820
- _conditionalFlush() {
15821
- if (this.recordingMode === 'buffer') {
15822
- return;
15823
- }
15824
-
15825
- void this.flushImmediate();
15826
- }
15827
-
15828
15890
  /**
15829
15891
  * Clear _context
15830
15892
  */
@@ -16186,6 +16248,8 @@ class Replay {
16186
16248
  ignore = [],
16187
16249
  maskFn,
16188
16250
 
16251
+ beforeAddRecordingEvent,
16252
+
16189
16253
  // eslint-disable-next-line deprecation/deprecation
16190
16254
  blockClass,
16191
16255
  // eslint-disable-next-line deprecation/deprecation
@@ -16243,6 +16307,7 @@ class Replay {
16243
16307
  networkCaptureBodies,
16244
16308
  networkRequestHeaders: _getMergedNetworkHeaders(networkRequestHeaders),
16245
16309
  networkResponseHeaders: _getMergedNetworkHeaders(networkResponseHeaders),
16310
+ beforeAddRecordingEvent,
16246
16311
 
16247
16312
  _experiments,
16248
16313
  };
@@ -30453,7 +30518,7 @@ const configGenerator = () => {
30453
30518
  let release;
30454
30519
  try {
30455
30520
  environment !== null && environment !== void 0 ? environment : (environment = "staging");
30456
- release !== null && release !== void 0 ? release : (release = "1.1.23");
30521
+ release !== null && release !== void 0 ? release : (release = "1.1.23-from-21-to-dev");
30457
30522
  }
30458
30523
  catch (_a) {
30459
30524
  console.error('sentry configGenerator error');