@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/esm/index.js CHANGED
@@ -370,21 +370,85 @@ function getLocationHref() {
370
370
  }
371
371
  }
372
372
 
373
- /** An error emitted by Sentry SDKs and related utilities. */
374
- class SentryError extends Error {
375
- /** Display name of this error instance. */
373
+ /** Prefix for logging strings */
374
+ const PREFIX = 'Sentry Logger ';
376
375
 
377
- constructor( message, logLevel = 'warn') {
378
- super(message);this.message = message;
379
- this.name = new.target.prototype.constructor.name;
380
- // This sets the prototype to be `Error`, not `SentryError`. It's unclear why we do this, but commenting this line
381
- // out causes various (seemingly totally unrelated) playwright tests consistently time out. FYI, this makes
382
- // instances of `SentryError` fail `obj instanceof SentryError` checks.
383
- Object.setPrototypeOf(this, new.target.prototype);
384
- this.logLevel = logLevel;
376
+ const CONSOLE_LEVELS = ['debug', 'info', 'warn', 'error', 'log', 'assert', 'trace'] ;
377
+
378
+ /**
379
+ * Temporarily disable sentry console instrumentations.
380
+ *
381
+ * @param callback The function to run against the original `console` messages
382
+ * @returns The results of the callback
383
+ */
384
+ function consoleSandbox(callback) {
385
+ if (!('console' in GLOBAL_OBJ)) {
386
+ return callback();
387
+ }
388
+
389
+ const originalConsole = GLOBAL_OBJ.console ;
390
+ const wrappedLevels = {};
391
+
392
+ // Restore all wrapped console methods
393
+ CONSOLE_LEVELS.forEach(level => {
394
+ // TODO(v7): Remove this check as it's only needed for Node 6
395
+ const originalWrappedFunc =
396
+ originalConsole[level] && (originalConsole[level] ).__sentry_original__;
397
+ if (level in originalConsole && originalWrappedFunc) {
398
+ wrappedLevels[level] = originalConsole[level] ;
399
+ originalConsole[level] = originalWrappedFunc ;
400
+ }
401
+ });
402
+
403
+ try {
404
+ return callback();
405
+ } finally {
406
+ // Revert restoration to wrapped state
407
+ Object.keys(wrappedLevels).forEach(level => {
408
+ originalConsole[level] = wrappedLevels[level ];
409
+ });
385
410
  }
386
411
  }
387
412
 
413
+ function makeLogger() {
414
+ let enabled = false;
415
+ const logger = {
416
+ enable: () => {
417
+ enabled = true;
418
+ },
419
+ disable: () => {
420
+ enabled = false;
421
+ },
422
+ };
423
+
424
+ if ((typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__)) {
425
+ CONSOLE_LEVELS.forEach(name => {
426
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
427
+ logger[name] = (...args) => {
428
+ if (enabled) {
429
+ consoleSandbox(() => {
430
+ GLOBAL_OBJ.console[name](`${PREFIX}[${name}]:`, ...args);
431
+ });
432
+ }
433
+ };
434
+ });
435
+ } else {
436
+ CONSOLE_LEVELS.forEach(name => {
437
+ logger[name] = () => undefined;
438
+ });
439
+ }
440
+
441
+ return logger ;
442
+ }
443
+
444
+ // Ensure we only have a single logger instance, even if multiple versions of @sentry/utils are being used
445
+ let logger;
446
+ if ((typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__)) {
447
+ logger = getGlobalSingleton('logger', makeLogger);
448
+ } else {
449
+ logger = makeLogger();
450
+ }
451
+
388
452
  /** Regular expression used to parse a Dsn. */
389
453
  const DSN_REGEX = /^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)([\w.-]+)(?::(\d+))?\/(.+)/;
390
454
 
@@ -413,13 +477,16 @@ function dsnToString(dsn, withPassword = false) {
413
477
  * Parses a Dsn from a given string.
414
478
  *
415
479
  * @param str A Dsn as string
416
- * @returns Dsn as DsnComponents
480
+ * @returns Dsn as DsnComponents or undefined if @param str is not a valid DSN string
417
481
  */
418
482
  function dsnFromString(str) {
419
483
  const match = DSN_REGEX.exec(str);
420
484
 
421
485
  if (!match) {
422
- throw new SentryError(`Invalid Sentry Dsn: ${str}`);
486
+ // This should be logged to the console
487
+ // eslint-disable-next-line no-console
488
+ console.error(`Invalid Sentry Dsn: ${str}`);
489
+ return undefined;
423
490
  }
424
491
 
425
492
  const [protocol, publicKey, pass = '', host, port = '', lastPath] = match.slice(1);
@@ -456,117 +523,67 @@ function dsnFromComponents(components) {
456
523
 
457
524
  function validateDsn(dsn) {
458
525
  if (!(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__)) {
459
- return;
526
+ return true;
460
527
  }
461
528
 
462
529
  const { port, projectId, protocol } = dsn;
463
530
 
464
531
  const requiredComponents = ['protocol', 'publicKey', 'host', 'projectId'];
465
- requiredComponents.forEach(component => {
532
+ const hasMissingRequiredComponent = requiredComponents.find(component => {
466
533
  if (!dsn[component]) {
467
- throw new SentryError(`Invalid Sentry Dsn: ${component} missing`);
534
+ logger.error(`Invalid Sentry Dsn: ${component} missing`);
535
+ return true;
468
536
  }
537
+ return false;
469
538
  });
470
539
 
540
+ if (hasMissingRequiredComponent) {
541
+ return false;
542
+ }
543
+
471
544
  if (!projectId.match(/^\d+$/)) {
472
- throw new SentryError(`Invalid Sentry Dsn: Invalid projectId ${projectId}`);
545
+ logger.error(`Invalid Sentry Dsn: Invalid projectId ${projectId}`);
546
+ return false;
473
547
  }
474
548
 
475
549
  if (!isValidProtocol(protocol)) {
476
- throw new SentryError(`Invalid Sentry Dsn: Invalid protocol ${protocol}`);
550
+ logger.error(`Invalid Sentry Dsn: Invalid protocol ${protocol}`);
551
+ return false;
477
552
  }
478
553
 
479
554
  if (port && isNaN(parseInt(port, 10))) {
480
- throw new SentryError(`Invalid Sentry Dsn: Invalid port ${port}`);
555
+ logger.error(`Invalid Sentry Dsn: Invalid port ${port}`);
556
+ return false;
481
557
  }
482
558
 
483
559
  return true;
484
560
  }
485
561
 
486
- /** The Sentry Dsn, identifying a Sentry instance and project. */
487
- function makeDsn(from) {
488
- const components = typeof from === 'string' ? dsnFromString(from) : dsnFromComponents(from);
489
- validateDsn(components);
490
- return components;
491
- }
492
-
493
- /** Prefix for logging strings */
494
- const PREFIX = 'Sentry Logger ';
495
-
496
- const CONSOLE_LEVELS = ['debug', 'info', 'warn', 'error', 'log', 'assert', 'trace'] ;
497
-
498
562
  /**
499
- * Temporarily disable sentry console instrumentations.
500
- *
501
- * @param callback The function to run against the original `console` messages
502
- * @returns The results of the callback
563
+ * Creates a valid Sentry Dsn object, identifying a Sentry instance and project.
564
+ * @returns a valid DsnComponents object or `undefined` if @param from is an invalid DSN source
503
565
  */
504
- function consoleSandbox(callback) {
505
- if (!('console' in GLOBAL_OBJ)) {
506
- return callback();
507
- }
508
-
509
- const originalConsole = GLOBAL_OBJ.console ;
510
- const wrappedLevels = {};
511
-
512
- // Restore all wrapped console methods
513
- CONSOLE_LEVELS.forEach(level => {
514
- // TODO(v7): Remove this check as it's only needed for Node 6
515
- const originalWrappedFunc =
516
- originalConsole[level] && (originalConsole[level] ).__sentry_original__;
517
- if (level in originalConsole && originalWrappedFunc) {
518
- wrappedLevels[level] = originalConsole[level] ;
519
- originalConsole[level] = originalWrappedFunc ;
520
- }
521
- });
522
-
523
- try {
524
- return callback();
525
- } finally {
526
- // Revert restoration to wrapped state
527
- Object.keys(wrappedLevels).forEach(level => {
528
- originalConsole[level] = wrappedLevels[level ];
529
- });
566
+ function makeDsn(from) {
567
+ const components = typeof from === 'string' ? dsnFromString(from) : dsnFromComponents(from);
568
+ if (!components || !validateDsn(components)) {
569
+ return undefined;
530
570
  }
571
+ return components;
531
572
  }
532
573
 
533
- function makeLogger() {
534
- let enabled = false;
535
- const logger = {
536
- enable: () => {
537
- enabled = true;
538
- },
539
- disable: () => {
540
- enabled = false;
541
- },
542
- };
574
+ /** An error emitted by Sentry SDKs and related utilities. */
575
+ class SentryError extends Error {
576
+ /** Display name of this error instance. */
543
577
 
544
- if ((typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__)) {
545
- CONSOLE_LEVELS.forEach(name => {
546
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
547
- logger[name] = (...args) => {
548
- if (enabled) {
549
- consoleSandbox(() => {
550
- GLOBAL_OBJ.console[name](`${PREFIX}[${name}]:`, ...args);
551
- });
552
- }
553
- };
554
- });
555
- } else {
556
- CONSOLE_LEVELS.forEach(name => {
557
- logger[name] = () => undefined;
558
- });
578
+ constructor( message, logLevel = 'warn') {
579
+ super(message);this.message = message;
580
+ this.name = new.target.prototype.constructor.name;
581
+ // This sets the prototype to be `Error`, not `SentryError`. It's unclear why we do this, but commenting this line
582
+ // out causes various (seemingly totally unrelated) playwright tests consistently time out. FYI, this makes
583
+ // instances of `SentryError` fail `obj instanceof SentryError` checks.
584
+ Object.setPrototypeOf(this, new.target.prototype);
585
+ this.logLevel = logLevel;
559
586
  }
560
-
561
- return logger ;
562
- }
563
-
564
- // Ensure we only have a single logger instance, even if multiple versions of @sentry/utils are being used
565
- let logger;
566
- if ((typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__)) {
567
- logger = getGlobalSingleton('logger', makeLogger);
568
- } else {
569
- logger = makeLogger();
570
587
  }
571
588
 
572
589
  /**
@@ -5066,16 +5083,20 @@ class BaseClient {
5066
5083
  */
5067
5084
  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);
5068
5085
  this._options = options;
5086
+
5069
5087
  if (options.dsn) {
5070
5088
  this._dsn = makeDsn(options.dsn);
5089
+ } else {
5090
+ (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.warn('No DSN provided, client will not do anything.');
5091
+ }
5092
+
5093
+ if (this._dsn) {
5071
5094
  const url = getEnvelopeEndpointWithUrlEncodedAuth(this._dsn, options);
5072
5095
  this._transport = options.transport({
5073
5096
  recordDroppedEvent: this.recordDroppedEvent.bind(this),
5074
5097
  ...options.transportOptions,
5075
5098
  url,
5076
5099
  });
5077
- } else {
5078
- (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.warn('No DSN provided, client will not do anything.');
5079
5100
  }
5080
5101
  }
5081
5102
 
@@ -5794,7 +5815,7 @@ function getEventForEnvelopeItem(item, type) {
5794
5815
  return Array.isArray(item) ? (item )[1] : undefined;
5795
5816
  }
5796
5817
 
5797
- const SDK_VERSION = '7.52.1';
5818
+ const SDK_VERSION = '7.53.0';
5798
5819
 
5799
5820
  let originalFunctionToString;
5800
5821
 
@@ -11546,6 +11567,23 @@ var NodeType;
11546
11567
  NodeType[NodeType["Comment"] = 5] = "Comment";
11547
11568
  })(NodeType || (NodeType = {}));
11548
11569
 
11570
+ /* eslint-disable @typescript-eslint/naming-convention */
11571
+
11572
+ var EventType; (function (EventType) {
11573
+ const DomContentLoaded = 0; EventType[EventType["DomContentLoaded"] = DomContentLoaded] = "DomContentLoaded";
11574
+ const Load = 1; EventType[EventType["Load"] = Load] = "Load";
11575
+ const FullSnapshot = 2; EventType[EventType["FullSnapshot"] = FullSnapshot] = "FullSnapshot";
11576
+ const IncrementalSnapshot = 3; EventType[EventType["IncrementalSnapshot"] = IncrementalSnapshot] = "IncrementalSnapshot";
11577
+ const Meta = 4; EventType[EventType["Meta"] = Meta] = "Meta";
11578
+ const Custom = 5; EventType[EventType["Custom"] = Custom] = "Custom";
11579
+ const Plugin = 6; EventType[EventType["Plugin"] = Plugin] = "Plugin";
11580
+ })(EventType || (EventType = {}));
11581
+
11582
+ /**
11583
+ * This is a partial copy of rrweb's eventWithTime type which only contains the properties
11584
+ * we specifcally need in the SDK.
11585
+ */
11586
+
11549
11587
  /**
11550
11588
  * Converts a timestamp to ms, if it was in s, or keeps it as ms.
11551
11589
  */
@@ -11588,7 +11626,18 @@ async function addEvent(
11588
11626
  replay.eventBuffer.clear();
11589
11627
  }
11590
11628
 
11591
- return await replay.eventBuffer.addEvent(event);
11629
+ const replayOptions = replay.getOptions();
11630
+
11631
+ const eventAfterPossibleCallback =
11632
+ typeof replayOptions.beforeAddRecordingEvent === 'function' && event.type === EventType.Custom
11633
+ ? replayOptions.beforeAddRecordingEvent(event)
11634
+ : event;
11635
+
11636
+ if (!eventAfterPossibleCallback) {
11637
+ return;
11638
+ }
11639
+
11640
+ return await replay.eventBuffer.addEvent(eventAfterPossibleCallback);
11592
11641
  } catch (error) {
11593
11642
  (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.error(error);
11594
11643
  await replay.stop('addEvent');
@@ -14564,23 +14613,6 @@ function debounce(func, wait, options) {
14564
14613
  return debounced;
14565
14614
  }
14566
14615
 
14567
- /* eslint-disable @typescript-eslint/naming-convention */
14568
-
14569
- var EventType; (function (EventType) {
14570
- const DomContentLoaded = 0; EventType[EventType["DomContentLoaded"] = DomContentLoaded] = "DomContentLoaded";
14571
- const Load = 1; EventType[EventType["Load"] = Load] = "Load";
14572
- const FullSnapshot = 2; EventType[EventType["FullSnapshot"] = FullSnapshot] = "FullSnapshot";
14573
- const IncrementalSnapshot = 3; EventType[EventType["IncrementalSnapshot"] = IncrementalSnapshot] = "IncrementalSnapshot";
14574
- const Meta = 4; EventType[EventType["Meta"] = Meta] = "Meta";
14575
- const Custom = 5; EventType[EventType["Custom"] = Custom] = "Custom";
14576
- const Plugin = 6; EventType[EventType["Plugin"] = Plugin] = "Plugin";
14577
- })(EventType || (EventType = {}));
14578
-
14579
- /**
14580
- * This is a partial copy of rrweb's eventWithTime type which only contains the properties
14581
- * we specifcally need in the SDK.
14582
- */
14583
-
14584
14616
  /**
14585
14617
  * Handler for recording events.
14586
14618
  *
@@ -14654,6 +14686,30 @@ function getHandleRecordingEmit(replay) {
14654
14686
  }
14655
14687
  }
14656
14688
 
14689
+ const options = replay.getOptions();
14690
+
14691
+ // TODO: We want this as an experiment so that we can test
14692
+ // internally and create metrics before making this the default
14693
+ if (options._experiments.delayFlushOnCheckout) {
14694
+ // If the full snapshot is due to an initial load, we will not have
14695
+ // a previous session ID. In this case, we want to buffer events
14696
+ // for a set amount of time before flushing. This can help avoid
14697
+ // capturing replays of users that immediately close the window.
14698
+ setTimeout(() => replay.conditionalFlush(), options._experiments.delayFlushOnCheckout);
14699
+
14700
+ // Cancel any previously debounced flushes to ensure there are no [near]
14701
+ // simultaneous flushes happening. The latter request should be
14702
+ // insignificant in this case, so wait for additional user interaction to
14703
+ // trigger a new flush.
14704
+ //
14705
+ // This can happen because there's no guarantee that a recording event
14706
+ // happens first. e.g. a mouse click can happen and trigger a debounced
14707
+ // flush before the checkout.
14708
+ replay.cancelFlush();
14709
+
14710
+ return true;
14711
+ }
14712
+
14657
14713
  // Flush immediately so that we do not miss the first segment, otherwise
14658
14714
  // it can prevent loading on the UI. This will cause an increase in short
14659
14715
  // replays (e.g. opening and closing a tab quickly), but these can be
@@ -15419,7 +15475,17 @@ class ReplayContainer {
15419
15475
  }
15420
15476
 
15421
15477
  /**
15422
- *
15478
+ * Only flush if `this.recordingMode === 'session'`
15479
+ */
15480
+ conditionalFlush() {
15481
+ if (this.recordingMode === 'buffer') {
15482
+ return Promise.resolve();
15483
+ }
15484
+
15485
+ return this.flushImmediate();
15486
+ }
15487
+
15488
+ /**
15423
15489
  * Always flush via `_debouncedFlush` so that we do not have flushes triggered
15424
15490
  * from calling both `flush` and `_debouncedFlush`. Otherwise, there could be
15425
15491
  * cases of mulitple flushes happening closely together.
@@ -15430,6 +15496,13 @@ class ReplayContainer {
15430
15496
  return this._debouncedFlush.flush() ;
15431
15497
  }
15432
15498
 
15499
+ /**
15500
+ * Cancels queued up flushes.
15501
+ */
15502
+ cancelFlush() {
15503
+ this._debouncedFlush.cancel();
15504
+ }
15505
+
15433
15506
  /** Get the current sesion (=replay) ID */
15434
15507
  getSessionId() {
15435
15508
  return this.session && this.session.id;
@@ -15679,7 +15752,7 @@ class ReplayContainer {
15679
15752
  // Send replay when the page/tab becomes hidden. There is no reason to send
15680
15753
  // replay if it becomes visible, since no actions we care about were done
15681
15754
  // while it was hidden
15682
- this._conditionalFlush();
15755
+ void this.conditionalFlush();
15683
15756
  }
15684
15757
 
15685
15758
  /**
@@ -15763,17 +15836,6 @@ class ReplayContainer {
15763
15836
  return Promise.all(createPerformanceSpans(this, createPerformanceEntries(entries)));
15764
15837
  }
15765
15838
 
15766
- /**
15767
- * Only flush if `this.recordingMode === 'session'`
15768
- */
15769
- _conditionalFlush() {
15770
- if (this.recordingMode === 'buffer') {
15771
- return;
15772
- }
15773
-
15774
- void this.flushImmediate();
15775
- }
15776
-
15777
15839
  /**
15778
15840
  * Clear _context
15779
15841
  */
@@ -16135,6 +16197,8 @@ class Replay {
16135
16197
  ignore = [],
16136
16198
  maskFn,
16137
16199
 
16200
+ beforeAddRecordingEvent,
16201
+
16138
16202
  // eslint-disable-next-line deprecation/deprecation
16139
16203
  blockClass,
16140
16204
  // eslint-disable-next-line deprecation/deprecation
@@ -16192,6 +16256,7 @@ class Replay {
16192
16256
  networkCaptureBodies,
16193
16257
  networkRequestHeaders: _getMergedNetworkHeaders(networkRequestHeaders),
16194
16258
  networkResponseHeaders: _getMergedNetworkHeaders(networkResponseHeaders),
16259
+ beforeAddRecordingEvent,
16195
16260
 
16196
16261
  _experiments,
16197
16262
  };
@@ -30398,7 +30463,7 @@ const configGenerator = () => {
30398
30463
  let release;
30399
30464
  try {
30400
30465
  environment !== null && environment !== void 0 ? environment : (environment = "staging");
30401
- release !== null && release !== void 0 ? release : (release = "1.1.23");
30466
+ release !== null && release !== void 0 ? release : (release = "1.1.23-binary-check-one");
30402
30467
  }
30403
30468
  catch (_a) {
30404
30469
  console.error('sentry configGenerator error');