@myinterview/widget-react 1.1.23-beta-78ffddc → 1.1.23-binary-check-one

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