@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/esm/index.js CHANGED
@@ -395,21 +395,85 @@ function getLocationHref() {
395
395
  }
396
396
  }
397
397
 
398
- /** An error emitted by Sentry SDKs and related utilities. */
399
- class SentryError extends Error {
400
- /** Display name of this error instance. */
398
+ /** Prefix for logging strings */
399
+ const PREFIX = 'Sentry Logger ';
401
400
 
402
- constructor( message, logLevel = 'warn') {
403
- super(message);this.message = message;
404
- this.name = new.target.prototype.constructor.name;
405
- // This sets the prototype to be `Error`, not `SentryError`. It's unclear why we do this, but commenting this line
406
- // out causes various (seemingly totally unrelated) playwright tests consistently time out. FYI, this makes
407
- // instances of `SentryError` fail `obj instanceof SentryError` checks.
408
- Object.setPrototypeOf(this, new.target.prototype);
409
- this.logLevel = logLevel;
401
+ const CONSOLE_LEVELS = ['debug', 'info', 'warn', 'error', 'log', 'assert', 'trace'] ;
402
+
403
+ /**
404
+ * Temporarily disable sentry console instrumentations.
405
+ *
406
+ * @param callback The function to run against the original `console` messages
407
+ * @returns The results of the callback
408
+ */
409
+ function consoleSandbox(callback) {
410
+ if (!('console' in GLOBAL_OBJ)) {
411
+ return callback();
412
+ }
413
+
414
+ const originalConsole = GLOBAL_OBJ.console ;
415
+ const wrappedLevels = {};
416
+
417
+ // Restore all wrapped console methods
418
+ CONSOLE_LEVELS.forEach(level => {
419
+ // TODO(v7): Remove this check as it's only needed for Node 6
420
+ const originalWrappedFunc =
421
+ originalConsole[level] && (originalConsole[level] ).__sentry_original__;
422
+ if (level in originalConsole && originalWrappedFunc) {
423
+ wrappedLevels[level] = originalConsole[level] ;
424
+ originalConsole[level] = originalWrappedFunc ;
425
+ }
426
+ });
427
+
428
+ try {
429
+ return callback();
430
+ } finally {
431
+ // Revert restoration to wrapped state
432
+ Object.keys(wrappedLevels).forEach(level => {
433
+ originalConsole[level] = wrappedLevels[level ];
434
+ });
410
435
  }
411
436
  }
412
437
 
438
+ function makeLogger() {
439
+ let enabled = false;
440
+ const logger = {
441
+ enable: () => {
442
+ enabled = true;
443
+ },
444
+ disable: () => {
445
+ enabled = false;
446
+ },
447
+ };
448
+
449
+ if ((typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__)) {
450
+ CONSOLE_LEVELS.forEach(name => {
451
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
452
+ logger[name] = (...args) => {
453
+ if (enabled) {
454
+ consoleSandbox(() => {
455
+ GLOBAL_OBJ.console[name](`${PREFIX}[${name}]:`, ...args);
456
+ });
457
+ }
458
+ };
459
+ });
460
+ } else {
461
+ CONSOLE_LEVELS.forEach(name => {
462
+ logger[name] = () => undefined;
463
+ });
464
+ }
465
+
466
+ return logger ;
467
+ }
468
+
469
+ // Ensure we only have a single logger instance, even if multiple versions of @sentry/utils are being used
470
+ let logger;
471
+ if ((typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__)) {
472
+ logger = getGlobalSingleton('logger', makeLogger);
473
+ } else {
474
+ logger = makeLogger();
475
+ }
476
+
413
477
  /** Regular expression used to parse a Dsn. */
414
478
  const DSN_REGEX = /^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)([\w.-]+)(?::(\d+))?\/(.+)/;
415
479
 
@@ -438,13 +502,16 @@ function dsnToString(dsn, withPassword = false) {
438
502
  * Parses a Dsn from a given string.
439
503
  *
440
504
  * @param str A Dsn as string
441
- * @returns Dsn as DsnComponents
505
+ * @returns Dsn as DsnComponents or undefined if @param str is not a valid DSN string
442
506
  */
443
507
  function dsnFromString(str) {
444
508
  const match = DSN_REGEX.exec(str);
445
509
 
446
510
  if (!match) {
447
- throw new SentryError(`Invalid Sentry Dsn: ${str}`);
511
+ // This should be logged to the console
512
+ // eslint-disable-next-line no-console
513
+ console.error(`Invalid Sentry Dsn: ${str}`);
514
+ return undefined;
448
515
  }
449
516
 
450
517
  const [protocol, publicKey, pass = '', host, port = '', lastPath] = match.slice(1);
@@ -481,117 +548,67 @@ function dsnFromComponents(components) {
481
548
 
482
549
  function validateDsn(dsn) {
483
550
  if (!(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__)) {
484
- return;
551
+ return true;
485
552
  }
486
553
 
487
554
  const { port, projectId, protocol } = dsn;
488
555
 
489
556
  const requiredComponents = ['protocol', 'publicKey', 'host', 'projectId'];
490
- requiredComponents.forEach(component => {
557
+ const hasMissingRequiredComponent = requiredComponents.find(component => {
491
558
  if (!dsn[component]) {
492
- throw new SentryError(`Invalid Sentry Dsn: ${component} missing`);
559
+ logger.error(`Invalid Sentry Dsn: ${component} missing`);
560
+ return true;
493
561
  }
562
+ return false;
494
563
  });
495
564
 
565
+ if (hasMissingRequiredComponent) {
566
+ return false;
567
+ }
568
+
496
569
  if (!projectId.match(/^\d+$/)) {
497
- throw new SentryError(`Invalid Sentry Dsn: Invalid projectId ${projectId}`);
570
+ logger.error(`Invalid Sentry Dsn: Invalid projectId ${projectId}`);
571
+ return false;
498
572
  }
499
573
 
500
574
  if (!isValidProtocol(protocol)) {
501
- throw new SentryError(`Invalid Sentry Dsn: Invalid protocol ${protocol}`);
575
+ logger.error(`Invalid Sentry Dsn: Invalid protocol ${protocol}`);
576
+ return false;
502
577
  }
503
578
 
504
579
  if (port && isNaN(parseInt(port, 10))) {
505
- throw new SentryError(`Invalid Sentry Dsn: Invalid port ${port}`);
580
+ logger.error(`Invalid Sentry Dsn: Invalid port ${port}`);
581
+ return false;
506
582
  }
507
583
 
508
584
  return true;
509
585
  }
510
586
 
511
- /** The Sentry Dsn, identifying a Sentry instance and project. */
512
- function makeDsn(from) {
513
- const components = typeof from === 'string' ? dsnFromString(from) : dsnFromComponents(from);
514
- validateDsn(components);
515
- return components;
516
- }
517
-
518
- /** Prefix for logging strings */
519
- const PREFIX = 'Sentry Logger ';
520
-
521
- const CONSOLE_LEVELS = ['debug', 'info', 'warn', 'error', 'log', 'assert', 'trace'] ;
522
-
523
587
  /**
524
- * Temporarily disable sentry console instrumentations.
525
- *
526
- * @param callback The function to run against the original `console` messages
527
- * @returns The results of the callback
588
+ * Creates a valid Sentry Dsn object, identifying a Sentry instance and project.
589
+ * @returns a valid DsnComponents object or `undefined` if @param from is an invalid DSN source
528
590
  */
529
- function consoleSandbox(callback) {
530
- if (!('console' in GLOBAL_OBJ)) {
531
- return callback();
532
- }
533
-
534
- const originalConsole = GLOBAL_OBJ.console ;
535
- const wrappedLevels = {};
536
-
537
- // Restore all wrapped console methods
538
- CONSOLE_LEVELS.forEach(level => {
539
- // TODO(v7): Remove this check as it's only needed for Node 6
540
- const originalWrappedFunc =
541
- originalConsole[level] && (originalConsole[level] ).__sentry_original__;
542
- if (level in originalConsole && originalWrappedFunc) {
543
- wrappedLevels[level] = originalConsole[level] ;
544
- originalConsole[level] = originalWrappedFunc ;
545
- }
546
- });
547
-
548
- try {
549
- return callback();
550
- } finally {
551
- // Revert restoration to wrapped state
552
- Object.keys(wrappedLevels).forEach(level => {
553
- originalConsole[level] = wrappedLevels[level ];
554
- });
591
+ function makeDsn(from) {
592
+ const components = typeof from === 'string' ? dsnFromString(from) : dsnFromComponents(from);
593
+ if (!components || !validateDsn(components)) {
594
+ return undefined;
555
595
  }
596
+ return components;
556
597
  }
557
598
 
558
- function makeLogger() {
559
- let enabled = false;
560
- const logger = {
561
- enable: () => {
562
- enabled = true;
563
- },
564
- disable: () => {
565
- enabled = false;
566
- },
567
- };
599
+ /** An error emitted by Sentry SDKs and related utilities. */
600
+ class SentryError extends Error {
601
+ /** Display name of this error instance. */
568
602
 
569
- if ((typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__)) {
570
- CONSOLE_LEVELS.forEach(name => {
571
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
572
- logger[name] = (...args) => {
573
- if (enabled) {
574
- consoleSandbox(() => {
575
- GLOBAL_OBJ.console[name](`${PREFIX}[${name}]:`, ...args);
576
- });
577
- }
578
- };
579
- });
580
- } else {
581
- CONSOLE_LEVELS.forEach(name => {
582
- logger[name] = () => undefined;
583
- });
603
+ constructor( message, logLevel = 'warn') {
604
+ super(message);this.message = message;
605
+ this.name = new.target.prototype.constructor.name;
606
+ // This sets the prototype to be `Error`, not `SentryError`. It's unclear why we do this, but commenting this line
607
+ // out causes various (seemingly totally unrelated) playwright tests consistently time out. FYI, this makes
608
+ // instances of `SentryError` fail `obj instanceof SentryError` checks.
609
+ Object.setPrototypeOf(this, new.target.prototype);
610
+ this.logLevel = logLevel;
584
611
  }
585
-
586
- return logger ;
587
- }
588
-
589
- // Ensure we only have a single logger instance, even if multiple versions of @sentry/utils are being used
590
- let logger;
591
- if ((typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__)) {
592
- logger = getGlobalSingleton('logger', makeLogger);
593
- } else {
594
- logger = makeLogger();
595
612
  }
596
613
 
597
614
  /**
@@ -5091,16 +5108,20 @@ class BaseClient {
5091
5108
  */
5092
5109
  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);
5093
5110
  this._options = options;
5111
+
5094
5112
  if (options.dsn) {
5095
5113
  this._dsn = makeDsn(options.dsn);
5114
+ } else {
5115
+ (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.warn('No DSN provided, client will not do anything.');
5116
+ }
5117
+
5118
+ if (this._dsn) {
5096
5119
  const url = getEnvelopeEndpointWithUrlEncodedAuth(this._dsn, options);
5097
5120
  this._transport = options.transport({
5098
5121
  recordDroppedEvent: this.recordDroppedEvent.bind(this),
5099
5122
  ...options.transportOptions,
5100
5123
  url,
5101
5124
  });
5102
- } else {
5103
- (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.warn('No DSN provided, client will not do anything.');
5104
5125
  }
5105
5126
  }
5106
5127
 
@@ -5819,7 +5840,7 @@ function getEventForEnvelopeItem(item, type) {
5819
5840
  return Array.isArray(item) ? (item )[1] : undefined;
5820
5841
  }
5821
5842
 
5822
- const SDK_VERSION = '7.52.1';
5843
+ const SDK_VERSION = '7.53.0';
5823
5844
 
5824
5845
  let originalFunctionToString;
5825
5846
 
@@ -11571,6 +11592,23 @@ var NodeType;
11571
11592
  NodeType[NodeType["Comment"] = 5] = "Comment";
11572
11593
  })(NodeType || (NodeType = {}));
11573
11594
 
11595
+ /* eslint-disable @typescript-eslint/naming-convention */
11596
+
11597
+ var EventType; (function (EventType) {
11598
+ const DomContentLoaded = 0; EventType[EventType["DomContentLoaded"] = DomContentLoaded] = "DomContentLoaded";
11599
+ const Load = 1; EventType[EventType["Load"] = Load] = "Load";
11600
+ const FullSnapshot = 2; EventType[EventType["FullSnapshot"] = FullSnapshot] = "FullSnapshot";
11601
+ const IncrementalSnapshot = 3; EventType[EventType["IncrementalSnapshot"] = IncrementalSnapshot] = "IncrementalSnapshot";
11602
+ const Meta = 4; EventType[EventType["Meta"] = Meta] = "Meta";
11603
+ const Custom = 5; EventType[EventType["Custom"] = Custom] = "Custom";
11604
+ const Plugin = 6; EventType[EventType["Plugin"] = Plugin] = "Plugin";
11605
+ })(EventType || (EventType = {}));
11606
+
11607
+ /**
11608
+ * This is a partial copy of rrweb's eventWithTime type which only contains the properties
11609
+ * we specifcally need in the SDK.
11610
+ */
11611
+
11574
11612
  /**
11575
11613
  * Converts a timestamp to ms, if it was in s, or keeps it as ms.
11576
11614
  */
@@ -11613,7 +11651,18 @@ async function addEvent(
11613
11651
  replay.eventBuffer.clear();
11614
11652
  }
11615
11653
 
11616
- return await replay.eventBuffer.addEvent(event);
11654
+ const replayOptions = replay.getOptions();
11655
+
11656
+ const eventAfterPossibleCallback =
11657
+ typeof replayOptions.beforeAddRecordingEvent === 'function' && event.type === EventType.Custom
11658
+ ? replayOptions.beforeAddRecordingEvent(event)
11659
+ : event;
11660
+
11661
+ if (!eventAfterPossibleCallback) {
11662
+ return;
11663
+ }
11664
+
11665
+ return await replay.eventBuffer.addEvent(eventAfterPossibleCallback);
11617
11666
  } catch (error) {
11618
11667
  (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.error(error);
11619
11668
  await replay.stop('addEvent');
@@ -14589,23 +14638,6 @@ function debounce(func, wait, options) {
14589
14638
  return debounced;
14590
14639
  }
14591
14640
 
14592
- /* eslint-disable @typescript-eslint/naming-convention */
14593
-
14594
- var EventType; (function (EventType) {
14595
- const DomContentLoaded = 0; EventType[EventType["DomContentLoaded"] = DomContentLoaded] = "DomContentLoaded";
14596
- const Load = 1; EventType[EventType["Load"] = Load] = "Load";
14597
- const FullSnapshot = 2; EventType[EventType["FullSnapshot"] = FullSnapshot] = "FullSnapshot";
14598
- const IncrementalSnapshot = 3; EventType[EventType["IncrementalSnapshot"] = IncrementalSnapshot] = "IncrementalSnapshot";
14599
- const Meta = 4; EventType[EventType["Meta"] = Meta] = "Meta";
14600
- const Custom = 5; EventType[EventType["Custom"] = Custom] = "Custom";
14601
- const Plugin = 6; EventType[EventType["Plugin"] = Plugin] = "Plugin";
14602
- })(EventType || (EventType = {}));
14603
-
14604
- /**
14605
- * This is a partial copy of rrweb's eventWithTime type which only contains the properties
14606
- * we specifcally need in the SDK.
14607
- */
14608
-
14609
14641
  /**
14610
14642
  * Handler for recording events.
14611
14643
  *
@@ -14679,6 +14711,30 @@ function getHandleRecordingEmit(replay) {
14679
14711
  }
14680
14712
  }
14681
14713
 
14714
+ const options = replay.getOptions();
14715
+
14716
+ // TODO: We want this as an experiment so that we can test
14717
+ // internally and create metrics before making this the default
14718
+ if (options._experiments.delayFlushOnCheckout) {
14719
+ // If the full snapshot is due to an initial load, we will not have
14720
+ // a previous session ID. In this case, we want to buffer events
14721
+ // for a set amount of time before flushing. This can help avoid
14722
+ // capturing replays of users that immediately close the window.
14723
+ setTimeout(() => replay.conditionalFlush(), options._experiments.delayFlushOnCheckout);
14724
+
14725
+ // Cancel any previously debounced flushes to ensure there are no [near]
14726
+ // simultaneous flushes happening. The latter request should be
14727
+ // insignificant in this case, so wait for additional user interaction to
14728
+ // trigger a new flush.
14729
+ //
14730
+ // This can happen because there's no guarantee that a recording event
14731
+ // happens first. e.g. a mouse click can happen and trigger a debounced
14732
+ // flush before the checkout.
14733
+ replay.cancelFlush();
14734
+
14735
+ return true;
14736
+ }
14737
+
14682
14738
  // Flush immediately so that we do not miss the first segment, otherwise
14683
14739
  // it can prevent loading on the UI. This will cause an increase in short
14684
14740
  // replays (e.g. opening and closing a tab quickly), but these can be
@@ -15444,7 +15500,17 @@ class ReplayContainer {
15444
15500
  }
15445
15501
 
15446
15502
  /**
15447
- *
15503
+ * Only flush if `this.recordingMode === 'session'`
15504
+ */
15505
+ conditionalFlush() {
15506
+ if (this.recordingMode === 'buffer') {
15507
+ return Promise.resolve();
15508
+ }
15509
+
15510
+ return this.flushImmediate();
15511
+ }
15512
+
15513
+ /**
15448
15514
  * Always flush via `_debouncedFlush` so that we do not have flushes triggered
15449
15515
  * from calling both `flush` and `_debouncedFlush`. Otherwise, there could be
15450
15516
  * cases of mulitple flushes happening closely together.
@@ -15455,6 +15521,13 @@ class ReplayContainer {
15455
15521
  return this._debouncedFlush.flush() ;
15456
15522
  }
15457
15523
 
15524
+ /**
15525
+ * Cancels queued up flushes.
15526
+ */
15527
+ cancelFlush() {
15528
+ this._debouncedFlush.cancel();
15529
+ }
15530
+
15458
15531
  /** Get the current sesion (=replay) ID */
15459
15532
  getSessionId() {
15460
15533
  return this.session && this.session.id;
@@ -15704,7 +15777,7 @@ class ReplayContainer {
15704
15777
  // Send replay when the page/tab becomes hidden. There is no reason to send
15705
15778
  // replay if it becomes visible, since no actions we care about were done
15706
15779
  // while it was hidden
15707
- this._conditionalFlush();
15780
+ void this.conditionalFlush();
15708
15781
  }
15709
15782
 
15710
15783
  /**
@@ -15788,17 +15861,6 @@ class ReplayContainer {
15788
15861
  return Promise.all(createPerformanceSpans(this, createPerformanceEntries(entries)));
15789
15862
  }
15790
15863
 
15791
- /**
15792
- * Only flush if `this.recordingMode === 'session'`
15793
- */
15794
- _conditionalFlush() {
15795
- if (this.recordingMode === 'buffer') {
15796
- return;
15797
- }
15798
-
15799
- void this.flushImmediate();
15800
- }
15801
-
15802
15864
  /**
15803
15865
  * Clear _context
15804
15866
  */
@@ -16160,6 +16222,8 @@ class Replay {
16160
16222
  ignore = [],
16161
16223
  maskFn,
16162
16224
 
16225
+ beforeAddRecordingEvent,
16226
+
16163
16227
  // eslint-disable-next-line deprecation/deprecation
16164
16228
  blockClass,
16165
16229
  // eslint-disable-next-line deprecation/deprecation
@@ -16217,6 +16281,7 @@ class Replay {
16217
16281
  networkCaptureBodies,
16218
16282
  networkRequestHeaders: _getMergedNetworkHeaders(networkRequestHeaders),
16219
16283
  networkResponseHeaders: _getMergedNetworkHeaders(networkResponseHeaders),
16284
+ beforeAddRecordingEvent,
16220
16285
 
16221
16286
  _experiments,
16222
16287
  };
@@ -30427,7 +30492,7 @@ const configGenerator = () => {
30427
30492
  let release;
30428
30493
  try {
30429
30494
  environment !== null && environment !== void 0 ? environment : (environment = "staging");
30430
- release !== null && release !== void 0 ? release : (release = "1.1.23");
30495
+ release !== null && release !== void 0 ? release : (release = "1.1.23-from-21-to-dev");
30431
30496
  }
30432
30497
  catch (_a) {
30433
30498
  console.error('sentry configGenerator error');