@sentry/replay 0.6.14-4 → 0.6.14-6

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/index.es.js CHANGED
@@ -324,7 +324,7 @@ function saveSession(session) {
324
324
  window.sessionStorage.setItem(REPLAY_SESSION_KEY, JSON.stringify(session));
325
325
  }
326
326
  catch (_a) {
327
- // this shouldn't happen
327
+ // Ignore potential SecurityError exceptions
328
328
  }
329
329
  }
330
330
 
@@ -468,11 +468,12 @@ function fetchSession(_a) {
468
468
  if (!hasSessionStorage) {
469
469
  return null;
470
470
  }
471
- var sessionStringFromStorage = window.sessionStorage.getItem(REPLAY_SESSION_KEY);
472
- if (!sessionStringFromStorage) {
473
- return null;
474
- }
475
471
  try {
472
+ // This can throw if cookies are disabled
473
+ var sessionStringFromStorage = window.sessionStorage.getItem(REPLAY_SESSION_KEY);
474
+ if (!sessionStringFromStorage) {
475
+ return null;
476
+ }
476
477
  var sessionObj = JSON.parse(sessionStringFromStorage);
477
478
  return new Session(sessionObj,
478
479
  // We are assuming that if there is a saved item, then the session is sticky,
@@ -1382,7 +1383,13 @@ var Replay = /** @class */ (function () {
1382
1383
  * Note that this will cause a new DOM checkout
1383
1384
  */
1384
1385
  Replay.prototype.startRecording = function () {
1385
- this.stopRecording = record(__assign(__assign({}, this.recordingOptions), { emit: this.handleRecordingEmit }));
1386
+ try {
1387
+ this.stopRecording = record(__assign(__assign({}, this.recordingOptions), { emit: this.handleRecordingEmit }));
1388
+ }
1389
+ catch (err) {
1390
+ logger.error(err);
1391
+ captureInternalException(err);
1392
+ }
1386
1393
  };
1387
1394
  /**
1388
1395
  * Currently, this needs to be manually called (e.g. for tests). Sentry SDK
@@ -1393,22 +1400,35 @@ var Replay = /** @class */ (function () {
1393
1400
  if (!isBrowser) {
1394
1401
  return;
1395
1402
  }
1396
- logger.log('Stopping Replays');
1397
- this.isEnabled = false;
1398
- this.removeListeners();
1399
- (_a = this.stopRecording) === null || _a === void 0 ? void 0 : _a.call(this);
1400
- (_b = this.eventBuffer) === null || _b === void 0 ? void 0 : _b.destroy();
1401
- this.eventBuffer = null;
1403
+ try {
1404
+ logger.log('Stopping Replays');
1405
+ this.isEnabled = false;
1406
+ this.removeListeners();
1407
+ (_a = this.stopRecording) === null || _a === void 0 ? void 0 : _a.call(this);
1408
+ (_b = this.eventBuffer) === null || _b === void 0 ? void 0 : _b.destroy();
1409
+ this.eventBuffer = null;
1410
+ }
1411
+ catch (err) {
1412
+ logger.error(err);
1413
+ captureInternalException(err);
1414
+ }
1402
1415
  };
1403
1416
  /**
1404
1417
  * Pause some replay functionality. See comments for `isPaused`.
1405
1418
  * This differs from stop as this only stops DOM recording, it is
1406
- * not as thorough of a shutdown as `stop()`. */
1419
+ * not as thorough of a shutdown as `stop()`.
1420
+ */
1407
1421
  Replay.prototype.pause = function () {
1408
1422
  this.isPaused = true;
1409
- if (this.stopRecording) {
1410
- this.stopRecording();
1411
- this.stopRecording = undefined;
1423
+ try {
1424
+ if (this.stopRecording) {
1425
+ this.stopRecording();
1426
+ this.stopRecording = undefined;
1427
+ }
1428
+ }
1429
+ catch (err) {
1430
+ logger.error(err);
1431
+ captureInternalException(err);
1412
1432
  }
1413
1433
  };
1414
1434
  /**
@@ -1422,8 +1442,14 @@ var Replay = /** @class */ (function () {
1422
1442
  this.startRecording();
1423
1443
  };
1424
1444
  Replay.prototype.clearSession = function () {
1425
- deleteSession();
1426
- this.session = undefined;
1445
+ try {
1446
+ deleteSession();
1447
+ this.session = undefined;
1448
+ }
1449
+ catch (err) {
1450
+ logger.error(err);
1451
+ captureInternalException(err);
1452
+ }
1427
1453
  };
1428
1454
  /**
1429
1455
  * Loads a session from storage, or creates a new one if it does not exist or
@@ -1469,22 +1495,28 @@ var Replay = /** @class */ (function () {
1469
1495
  */
1470
1496
  Replay.prototype.addListeners = function () {
1471
1497
  var _this = this;
1472
- document.addEventListener('visibilitychange', this.handleVisibilityChange);
1473
- window.addEventListener('blur', this.handleWindowBlur);
1474
- window.addEventListener('focus', this.handleWindowFocus);
1475
- // There is no way to remove these listeners, so ensure they are only added once
1476
- if (!this.hasInitializedCoreListeners) {
1477
- // Listeners from core SDK //
1478
- var scope = getCurrentHub().getScope();
1479
- scope === null || scope === void 0 ? void 0 : scope.addScopeListener(this.handleCoreBreadcrumbListener('scope'));
1480
- addInstrumentationHandler('dom', this.handleCoreBreadcrumbListener('dom'));
1481
- addInstrumentationHandler('fetch', this.handleCoreSpanListener('fetch'));
1482
- addInstrumentationHandler('xhr', this.handleCoreSpanListener('xhr'));
1483
- addInstrumentationHandler('history', this.handleCoreSpanListener('history'));
1484
- // Tag all (non replay) events that get sent to Sentry with the current
1485
- // replay ID so that we can reference them later in the UI
1486
- addGlobalEventProcessor(this.handleGlobalEvent);
1487
- this.hasInitializedCoreListeners = true;
1498
+ try {
1499
+ document.addEventListener('visibilitychange', this.handleVisibilityChange);
1500
+ window.addEventListener('blur', this.handleWindowBlur);
1501
+ window.addEventListener('focus', this.handleWindowFocus);
1502
+ // There is no way to remove these listeners, so ensure they are only added once
1503
+ if (!this.hasInitializedCoreListeners) {
1504
+ // Listeners from core SDK //
1505
+ var scope = getCurrentHub().getScope();
1506
+ scope === null || scope === void 0 ? void 0 : scope.addScopeListener(this.handleCoreBreadcrumbListener('scope'));
1507
+ addInstrumentationHandler('dom', this.handleCoreBreadcrumbListener('dom'));
1508
+ addInstrumentationHandler('fetch', this.handleCoreSpanListener('fetch'));
1509
+ addInstrumentationHandler('xhr', this.handleCoreSpanListener('xhr'));
1510
+ addInstrumentationHandler('history', this.handleCoreSpanListener('history'));
1511
+ // Tag all (non replay) events that get sent to Sentry with the current
1512
+ // replay ID so that we can reference them later in the UI
1513
+ addGlobalEventProcessor(this.handleGlobalEvent);
1514
+ this.hasInitializedCoreListeners = true;
1515
+ }
1516
+ }
1517
+ catch (err) {
1518
+ logger.error(err);
1519
+ captureInternalException(err);
1488
1520
  }
1489
1521
  // PerformanceObserver //
1490
1522
  if (!('PerformanceObserver' in window)) {
@@ -1520,12 +1552,18 @@ var Replay = /** @class */ (function () {
1520
1552
  * Cleans up listeners that were created in `addListeners`
1521
1553
  */
1522
1554
  Replay.prototype.removeListeners = function () {
1523
- document.removeEventListener('visibilitychange', this.handleVisibilityChange);
1524
- window.removeEventListener('blur', this.handleWindowBlur);
1525
- window.removeEventListener('focus', this.handleWindowFocus);
1526
- if (this.performanceObserver) {
1527
- this.performanceObserver.disconnect();
1528
- this.performanceObserver = null;
1555
+ try {
1556
+ document.removeEventListener('visibilitychange', this.handleVisibilityChange);
1557
+ window.removeEventListener('blur', this.handleWindowBlur);
1558
+ window.removeEventListener('focus', this.handleWindowFocus);
1559
+ if (this.performanceObserver) {
1560
+ this.performanceObserver.disconnect();
1561
+ this.performanceObserver = null;
1562
+ }
1563
+ }
1564
+ catch (err) {
1565
+ logger.error(err);
1566
+ captureInternalException(err);
1529
1567
  }
1530
1568
  };
1531
1569
  /**
@@ -1898,7 +1936,7 @@ var Replay = /** @class */ (function () {
1898
1936
  currentTimestamp = new Date().getTime();
1899
1937
  sdkInfo = {
1900
1938
  name: 'sentry.javascript.integration.replay',
1901
- version: "0.6.14-4",
1939
+ version: "0.6.14-6",
1902
1940
  };
1903
1941
  return [4 /*yield*/, new Promise(function (resolve) {
1904
1942
  var _a;
package/dist/index.js CHANGED
@@ -332,7 +332,7 @@ function saveSession(session) {
332
332
  window.sessionStorage.setItem(REPLAY_SESSION_KEY, JSON.stringify(session));
333
333
  }
334
334
  catch (_a) {
335
- // this shouldn't happen
335
+ // Ignore potential SecurityError exceptions
336
336
  }
337
337
  }
338
338
 
@@ -476,11 +476,12 @@ function fetchSession(_a) {
476
476
  if (!hasSessionStorage) {
477
477
  return null;
478
478
  }
479
- var sessionStringFromStorage = window.sessionStorage.getItem(REPLAY_SESSION_KEY);
480
- if (!sessionStringFromStorage) {
481
- return null;
482
- }
483
479
  try {
480
+ // This can throw if cookies are disabled
481
+ var sessionStringFromStorage = window.sessionStorage.getItem(REPLAY_SESSION_KEY);
482
+ if (!sessionStringFromStorage) {
483
+ return null;
484
+ }
484
485
  var sessionObj = JSON.parse(sessionStringFromStorage);
485
486
  return new Session(sessionObj,
486
487
  // We are assuming that if there is a saved item, then the session is sticky,
@@ -1390,7 +1391,13 @@ var Replay = /** @class */ (function () {
1390
1391
  * Note that this will cause a new DOM checkout
1391
1392
  */
1392
1393
  Replay.prototype.startRecording = function () {
1393
- this.stopRecording = rrweb.record(__assign(__assign({}, this.recordingOptions), { emit: this.handleRecordingEmit }));
1394
+ try {
1395
+ this.stopRecording = rrweb.record(__assign(__assign({}, this.recordingOptions), { emit: this.handleRecordingEmit }));
1396
+ }
1397
+ catch (err) {
1398
+ logger.error(err);
1399
+ captureInternalException(err);
1400
+ }
1394
1401
  };
1395
1402
  /**
1396
1403
  * Currently, this needs to be manually called (e.g. for tests). Sentry SDK
@@ -1401,22 +1408,35 @@ var Replay = /** @class */ (function () {
1401
1408
  if (!isBrowser) {
1402
1409
  return;
1403
1410
  }
1404
- logger.log('Stopping Replays');
1405
- this.isEnabled = false;
1406
- this.removeListeners();
1407
- (_a = this.stopRecording) === null || _a === void 0 ? void 0 : _a.call(this);
1408
- (_b = this.eventBuffer) === null || _b === void 0 ? void 0 : _b.destroy();
1409
- this.eventBuffer = null;
1411
+ try {
1412
+ logger.log('Stopping Replays');
1413
+ this.isEnabled = false;
1414
+ this.removeListeners();
1415
+ (_a = this.stopRecording) === null || _a === void 0 ? void 0 : _a.call(this);
1416
+ (_b = this.eventBuffer) === null || _b === void 0 ? void 0 : _b.destroy();
1417
+ this.eventBuffer = null;
1418
+ }
1419
+ catch (err) {
1420
+ logger.error(err);
1421
+ captureInternalException(err);
1422
+ }
1410
1423
  };
1411
1424
  /**
1412
1425
  * Pause some replay functionality. See comments for `isPaused`.
1413
1426
  * This differs from stop as this only stops DOM recording, it is
1414
- * not as thorough of a shutdown as `stop()`. */
1427
+ * not as thorough of a shutdown as `stop()`.
1428
+ */
1415
1429
  Replay.prototype.pause = function () {
1416
1430
  this.isPaused = true;
1417
- if (this.stopRecording) {
1418
- this.stopRecording();
1419
- this.stopRecording = undefined;
1431
+ try {
1432
+ if (this.stopRecording) {
1433
+ this.stopRecording();
1434
+ this.stopRecording = undefined;
1435
+ }
1436
+ }
1437
+ catch (err) {
1438
+ logger.error(err);
1439
+ captureInternalException(err);
1420
1440
  }
1421
1441
  };
1422
1442
  /**
@@ -1430,8 +1450,14 @@ var Replay = /** @class */ (function () {
1430
1450
  this.startRecording();
1431
1451
  };
1432
1452
  Replay.prototype.clearSession = function () {
1433
- deleteSession();
1434
- this.session = undefined;
1453
+ try {
1454
+ deleteSession();
1455
+ this.session = undefined;
1456
+ }
1457
+ catch (err) {
1458
+ logger.error(err);
1459
+ captureInternalException(err);
1460
+ }
1435
1461
  };
1436
1462
  /**
1437
1463
  * Loads a session from storage, or creates a new one if it does not exist or
@@ -1477,22 +1503,28 @@ var Replay = /** @class */ (function () {
1477
1503
  */
1478
1504
  Replay.prototype.addListeners = function () {
1479
1505
  var _this = this;
1480
- document.addEventListener('visibilitychange', this.handleVisibilityChange);
1481
- window.addEventListener('blur', this.handleWindowBlur);
1482
- window.addEventListener('focus', this.handleWindowFocus);
1483
- // There is no way to remove these listeners, so ensure they are only added once
1484
- if (!this.hasInitializedCoreListeners) {
1485
- // Listeners from core SDK //
1486
- var scope = core.getCurrentHub().getScope();
1487
- scope === null || scope === void 0 ? void 0 : scope.addScopeListener(this.handleCoreBreadcrumbListener('scope'));
1488
- utils.addInstrumentationHandler('dom', this.handleCoreBreadcrumbListener('dom'));
1489
- utils.addInstrumentationHandler('fetch', this.handleCoreSpanListener('fetch'));
1490
- utils.addInstrumentationHandler('xhr', this.handleCoreSpanListener('xhr'));
1491
- utils.addInstrumentationHandler('history', this.handleCoreSpanListener('history'));
1492
- // Tag all (non replay) events that get sent to Sentry with the current
1493
- // replay ID so that we can reference them later in the UI
1494
- core.addGlobalEventProcessor(this.handleGlobalEvent);
1495
- this.hasInitializedCoreListeners = true;
1506
+ try {
1507
+ document.addEventListener('visibilitychange', this.handleVisibilityChange);
1508
+ window.addEventListener('blur', this.handleWindowBlur);
1509
+ window.addEventListener('focus', this.handleWindowFocus);
1510
+ // There is no way to remove these listeners, so ensure they are only added once
1511
+ if (!this.hasInitializedCoreListeners) {
1512
+ // Listeners from core SDK //
1513
+ var scope = core.getCurrentHub().getScope();
1514
+ scope === null || scope === void 0 ? void 0 : scope.addScopeListener(this.handleCoreBreadcrumbListener('scope'));
1515
+ utils.addInstrumentationHandler('dom', this.handleCoreBreadcrumbListener('dom'));
1516
+ utils.addInstrumentationHandler('fetch', this.handleCoreSpanListener('fetch'));
1517
+ utils.addInstrumentationHandler('xhr', this.handleCoreSpanListener('xhr'));
1518
+ utils.addInstrumentationHandler('history', this.handleCoreSpanListener('history'));
1519
+ // Tag all (non replay) events that get sent to Sentry with the current
1520
+ // replay ID so that we can reference them later in the UI
1521
+ core.addGlobalEventProcessor(this.handleGlobalEvent);
1522
+ this.hasInitializedCoreListeners = true;
1523
+ }
1524
+ }
1525
+ catch (err) {
1526
+ logger.error(err);
1527
+ captureInternalException(err);
1496
1528
  }
1497
1529
  // PerformanceObserver //
1498
1530
  if (!('PerformanceObserver' in window)) {
@@ -1528,12 +1560,18 @@ var Replay = /** @class */ (function () {
1528
1560
  * Cleans up listeners that were created in `addListeners`
1529
1561
  */
1530
1562
  Replay.prototype.removeListeners = function () {
1531
- document.removeEventListener('visibilitychange', this.handleVisibilityChange);
1532
- window.removeEventListener('blur', this.handleWindowBlur);
1533
- window.removeEventListener('focus', this.handleWindowFocus);
1534
- if (this.performanceObserver) {
1535
- this.performanceObserver.disconnect();
1536
- this.performanceObserver = null;
1563
+ try {
1564
+ document.removeEventListener('visibilitychange', this.handleVisibilityChange);
1565
+ window.removeEventListener('blur', this.handleWindowBlur);
1566
+ window.removeEventListener('focus', this.handleWindowFocus);
1567
+ if (this.performanceObserver) {
1568
+ this.performanceObserver.disconnect();
1569
+ this.performanceObserver = null;
1570
+ }
1571
+ }
1572
+ catch (err) {
1573
+ logger.error(err);
1574
+ captureInternalException(err);
1537
1575
  }
1538
1576
  };
1539
1577
  /**
@@ -1906,7 +1944,7 @@ var Replay = /** @class */ (function () {
1906
1944
  currentTimestamp = new Date().getTime();
1907
1945
  sdkInfo = {
1908
1946
  name: 'sentry.javascript.integration.replay',
1909
- version: "0.6.14-4",
1947
+ version: "0.6.14-6",
1910
1948
  };
1911
1949
  return [4 /*yield*/, new Promise(function (resolve) {
1912
1950
  var _a;