@sentry/replay 0.6.14-2 → 0.6.14-3

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/README.md CHANGED
@@ -4,7 +4,7 @@ Note: Session Replay is currently in beta.
4
4
 
5
5
  ## Pre-requisites
6
6
 
7
- For the sentry-replay integration to work, you must have the [Sentry browser SDK package](https://www.npmjs.com/package/@sentry/browser) (minimum version `7.x`), or an equivalent framework SDK (e.g. [@sentry/react](https://www.npmjs.com/package/@sentry/react)) installed.
7
+ For the sentry-replay integration to work, you must have the [Sentry browser SDK package](https://www.npmjs.com/package/@sentry/browser), or an equivalent framework SDK (e.g. [@sentry/react](https://www.npmjs.com/package/@sentry/react)) installed. The minimum version required for the SDK is `7.x`.
8
8
 
9
9
  ## Installation
10
10
 
@@ -67,19 +67,21 @@ export declare class Replay implements Integration {
67
67
  session: Session | undefined;
68
68
  constructor({ flushMinDelay, flushMaxDelay, initialFlushDelay, stickySession, useCompression, sessionSampleRate, errorSampleRate, maskAllText, maskAllInputs, blockAllMedia, blockClass, ignoreClass, maskTextClass, blockSelector, replaysSamplingRate, captureOnlyOnError, ...recordingOptions }?: ReplayConfiguration);
69
69
  /**
70
- * Because we create a transaction in `setupOnce`, we can potentially create a
71
- * transaction before some native SDK integrations have run and applied their
72
- * own global event processor. An example is:
70
+ * We previously used to create a transaction in `setupOnce` and it would
71
+ * potentially create a transaction before some native SDK integrations have run
72
+ * and applied their own global event processor. An example is:
73
73
  * https://github.com/getsentry/sentry-javascript/blob/b47ceafbdac7f8b99093ce6023726ad4687edc48/packages/browser/src/integrations/useragent.ts
74
74
  *
75
- * So we call `this.setup` in next event loop as a workaround to wait for
76
- * other global event processors to finish
75
+ * So we call `this.setup` in next event loop as a workaround to wait for other
76
+ * global event processors to finish. This is no longer needed, but keeping it
77
+ * here to avoid any future issues.
77
78
  */
78
79
  setupOnce(): void;
79
80
  /**
80
81
  * Initializes the plugin.
81
82
  *
82
- * Creates or loads a session, attaches listeners to varying events (DOM, PerformanceObserver, Recording, Sentry SDK, etc)
83
+ * Creates or loads a session, attaches listeners to varying events (DOM,
84
+ * PerformanceObserver, Recording, Sentry SDK, etc)
83
85
  */
84
86
  start(): void;
85
87
  /**
@@ -89,7 +91,8 @@ export declare class Replay implements Integration {
89
91
  */
90
92
  startRecording(): void;
91
93
  /**
92
- * Currently, this needs to be manually called (e.g. for tests). Sentry SDK does not support a teardown
94
+ * Currently, this needs to be manually called (e.g. for tests). Sentry SDK
95
+ * does not support a teardown
93
96
  */
94
97
  stop(): void;
95
98
  /**
@@ -166,7 +169,6 @@ export declare class Replay implements Integration {
166
169
  * Handler for Sentry Core SDK events.
167
170
  *
168
171
  * These specific events will create span-like objects in the recording.
169
- *
170
172
  */
171
173
  handleCoreSpanListener: (type: InstrumentationTypeSpan) => (handlerData: any) => void;
172
174
  /**
@@ -205,8 +207,9 @@ export declare class Replay implements Integration {
205
207
  */
206
208
  updateSessionActivity(lastActivity?: number): void;
207
209
  /**
208
- * Updates the user activity timestamp and resumes recording. This should be called in an event handler for a user action that we consider as the user being "active" (e.g. a mouse click).
209
- *
210
+ * Updates the user activity timestamp and resumes recording. This should be
211
+ * called in an event handler for a user action that we consider as the user
212
+ * being "active" (e.g. a mouse click).
210
213
  */
211
214
  triggerUserActivity(): Promise<void>;
212
215
  /**
package/dist/index.es.js CHANGED
@@ -1149,7 +1149,6 @@ var Replay = /** @class */ (function () {
1149
1149
  * Handler for Sentry Core SDK events.
1150
1150
  *
1151
1151
  * These specific events will create span-like objects in the recording.
1152
- *
1153
1152
  */
1154
1153
  this.handleCoreSpanListener = function (type) { return function (handlerData) {
1155
1154
  if (!_this.isEnabled) {
@@ -1163,7 +1162,6 @@ var Replay = /** @class */ (function () {
1163
1162
  if (type === 'history') {
1164
1163
  // Need to collect visited URLs
1165
1164
  _this.context.urls.push(result.name);
1166
- _this.updateUserActivity();
1167
1165
  _this.triggerUserActivity();
1168
1166
  }
1169
1167
  _this.addUpdate(function () {
@@ -1319,13 +1317,14 @@ var Replay = /** @class */ (function () {
1319
1317
  _initialized = true;
1320
1318
  }
1321
1319
  /**
1322
- * Because we create a transaction in `setupOnce`, we can potentially create a
1323
- * transaction before some native SDK integrations have run and applied their
1324
- * own global event processor. An example is:
1320
+ * We previously used to create a transaction in `setupOnce` and it would
1321
+ * potentially create a transaction before some native SDK integrations have run
1322
+ * and applied their own global event processor. An example is:
1325
1323
  * https://github.com/getsentry/sentry-javascript/blob/b47ceafbdac7f8b99093ce6023726ad4687edc48/packages/browser/src/integrations/useragent.ts
1326
1324
  *
1327
- * So we call `this.setup` in next event loop as a workaround to wait for
1328
- * other global event processors to finish
1325
+ * So we call `this.setup` in next event loop as a workaround to wait for other
1326
+ * global event processors to finish. This is no longer needed, but keeping it
1327
+ * here to avoid any future issues.
1329
1328
  */
1330
1329
  Replay.prototype.setupOnce = function () {
1331
1330
  var _this = this;
@@ -1338,7 +1337,8 @@ var Replay = /** @class */ (function () {
1338
1337
  /**
1339
1338
  * Initializes the plugin.
1340
1339
  *
1341
- * Creates or loads a session, attaches listeners to varying events (DOM, PerformanceObserver, Recording, Sentry SDK, etc)
1340
+ * Creates or loads a session, attaches listeners to varying events (DOM,
1341
+ * PerformanceObserver, Recording, Sentry SDK, etc)
1342
1342
  */
1343
1343
  Replay.prototype.start = function () {
1344
1344
  if (!isBrowser) {
@@ -1383,7 +1383,8 @@ var Replay = /** @class */ (function () {
1383
1383
  this.stopRecording = record(__assign(__assign({}, this.recordingOptions), { emit: this.handleRecordingEmit }));
1384
1384
  };
1385
1385
  /**
1386
- * Currently, this needs to be manually called (e.g. for tests). Sentry SDK does not support a teardown
1386
+ * Currently, this needs to be manually called (e.g. for tests). Sentry SDK
1387
+ * does not support a teardown
1387
1388
  */
1388
1389
  Replay.prototype.stop = function () {
1389
1390
  var _a, _b;
@@ -1647,8 +1648,9 @@ var Replay = /** @class */ (function () {
1647
1648
  }
1648
1649
  };
1649
1650
  /**
1650
- * Updates the user activity timestamp and resumes recording. This should be called in an event handler for a user action that we consider as the user being "active" (e.g. a mouse click).
1651
- *
1651
+ * Updates the user activity timestamp and resumes recording. This should be
1652
+ * called in an event handler for a user action that we consider as the user
1653
+ * being "active" (e.g. a mouse click).
1652
1654
  */
1653
1655
  Replay.prototype.triggerUserActivity = function () {
1654
1656
  return __awaiter(this, void 0, void 0, function () {
@@ -1657,7 +1659,8 @@ var Replay = /** @class */ (function () {
1657
1659
  // This case means that recording was once stopped due to inactivity.
1658
1660
  // Ensure that recording is resumed.
1659
1661
  if (!this.stopRecording) {
1660
- // Create a new session, otherwise when the user action is flushed, it will get rejected due to an expired session.
1662
+ // Create a new session, otherwise when the user action is flushed, it
1663
+ // will get rejected due to an expired session.
1661
1664
  this.loadSession({ expiry: SESSION_IDLE_DURATION });
1662
1665
  // Note: This will cause a new DOM checkout
1663
1666
  this.resume();
@@ -1762,11 +1765,7 @@ var Replay = /** @class */ (function () {
1762
1765
  if (!expired) {
1763
1766
  return true;
1764
1767
  }
1765
- // TODO: We could potentially figure out a way to save the last session,
1766
- // and produce a checkout based on a previous checkout + updates, and then
1767
- // replay the event on top. Or maybe replay the event on top of a refresh
1768
- // snapshot.
1769
- // For now create a new snapshot
1768
+ // Session is expired, trigger a full snapshot (which will create a new session)
1770
1769
  this.triggerFullSnapshot();
1771
1770
  return false;
1772
1771
  };
@@ -1818,7 +1817,7 @@ var Replay = /** @class */ (function () {
1818
1817
  Replay.prototype.runFlush = function () {
1819
1818
  var _a;
1820
1819
  return __awaiter(this, void 0, void 0, function () {
1821
- var replayId, segmentId, recordingData, err_2;
1820
+ var recordingData, replayId, segmentId, err_2;
1822
1821
  return __generator(this, function (_b) {
1823
1822
  switch (_b.label) {
1824
1823
  case 0:
@@ -1837,14 +1836,14 @@ var Replay = /** @class */ (function () {
1837
1836
  case 2:
1838
1837
  // Only attach memory event if eventBuffer is not empty
1839
1838
  _b.sent();
1840
- replayId = this.session.id;
1841
- segmentId = this.session.segmentId++;
1842
1839
  _b.label = 3;
1843
1840
  case 3:
1844
1841
  _b.trys.push([3, 6, , 7]);
1845
1842
  return [4 /*yield*/, this.eventBuffer.finish()];
1846
1843
  case 4:
1847
1844
  recordingData = _b.sent();
1845
+ replayId = this.session.id;
1846
+ segmentId = this.session.segmentId++;
1848
1847
  return [4 /*yield*/, this.sendReplay({
1849
1848
  replayId: replayId,
1850
1849
  events: recordingData,
@@ -1897,7 +1896,7 @@ var Replay = /** @class */ (function () {
1897
1896
  timestamp = new Date().getTime();
1898
1897
  sdkInfo = {
1899
1898
  name: 'sentry.javascript.integration.replay',
1900
- version: "0.6.14-2",
1899
+ version: "0.6.14-3",
1901
1900
  };
1902
1901
  return [4 /*yield*/, new Promise(function (resolve) {
1903
1902
  var _a;
package/dist/index.js CHANGED
@@ -1157,7 +1157,6 @@ var Replay = /** @class */ (function () {
1157
1157
  * Handler for Sentry Core SDK events.
1158
1158
  *
1159
1159
  * These specific events will create span-like objects in the recording.
1160
- *
1161
1160
  */
1162
1161
  this.handleCoreSpanListener = function (type) { return function (handlerData) {
1163
1162
  if (!_this.isEnabled) {
@@ -1171,7 +1170,6 @@ var Replay = /** @class */ (function () {
1171
1170
  if (type === 'history') {
1172
1171
  // Need to collect visited URLs
1173
1172
  _this.context.urls.push(result.name);
1174
- _this.updateUserActivity();
1175
1173
  _this.triggerUserActivity();
1176
1174
  }
1177
1175
  _this.addUpdate(function () {
@@ -1327,13 +1325,14 @@ var Replay = /** @class */ (function () {
1327
1325
  _initialized = true;
1328
1326
  }
1329
1327
  /**
1330
- * Because we create a transaction in `setupOnce`, we can potentially create a
1331
- * transaction before some native SDK integrations have run and applied their
1332
- * own global event processor. An example is:
1328
+ * We previously used to create a transaction in `setupOnce` and it would
1329
+ * potentially create a transaction before some native SDK integrations have run
1330
+ * and applied their own global event processor. An example is:
1333
1331
  * https://github.com/getsentry/sentry-javascript/blob/b47ceafbdac7f8b99093ce6023726ad4687edc48/packages/browser/src/integrations/useragent.ts
1334
1332
  *
1335
- * So we call `this.setup` in next event loop as a workaround to wait for
1336
- * other global event processors to finish
1333
+ * So we call `this.setup` in next event loop as a workaround to wait for other
1334
+ * global event processors to finish. This is no longer needed, but keeping it
1335
+ * here to avoid any future issues.
1337
1336
  */
1338
1337
  Replay.prototype.setupOnce = function () {
1339
1338
  var _this = this;
@@ -1346,7 +1345,8 @@ var Replay = /** @class */ (function () {
1346
1345
  /**
1347
1346
  * Initializes the plugin.
1348
1347
  *
1349
- * Creates or loads a session, attaches listeners to varying events (DOM, PerformanceObserver, Recording, Sentry SDK, etc)
1348
+ * Creates or loads a session, attaches listeners to varying events (DOM,
1349
+ * PerformanceObserver, Recording, Sentry SDK, etc)
1350
1350
  */
1351
1351
  Replay.prototype.start = function () {
1352
1352
  if (!isBrowser) {
@@ -1391,7 +1391,8 @@ var Replay = /** @class */ (function () {
1391
1391
  this.stopRecording = rrweb.record(__assign(__assign({}, this.recordingOptions), { emit: this.handleRecordingEmit }));
1392
1392
  };
1393
1393
  /**
1394
- * Currently, this needs to be manually called (e.g. for tests). Sentry SDK does not support a teardown
1394
+ * Currently, this needs to be manually called (e.g. for tests). Sentry SDK
1395
+ * does not support a teardown
1395
1396
  */
1396
1397
  Replay.prototype.stop = function () {
1397
1398
  var _a, _b;
@@ -1655,8 +1656,9 @@ var Replay = /** @class */ (function () {
1655
1656
  }
1656
1657
  };
1657
1658
  /**
1658
- * Updates the user activity timestamp and resumes recording. This should be called in an event handler for a user action that we consider as the user being "active" (e.g. a mouse click).
1659
- *
1659
+ * Updates the user activity timestamp and resumes recording. This should be
1660
+ * called in an event handler for a user action that we consider as the user
1661
+ * being "active" (e.g. a mouse click).
1660
1662
  */
1661
1663
  Replay.prototype.triggerUserActivity = function () {
1662
1664
  return __awaiter(this, void 0, void 0, function () {
@@ -1665,7 +1667,8 @@ var Replay = /** @class */ (function () {
1665
1667
  // This case means that recording was once stopped due to inactivity.
1666
1668
  // Ensure that recording is resumed.
1667
1669
  if (!this.stopRecording) {
1668
- // Create a new session, otherwise when the user action is flushed, it will get rejected due to an expired session.
1670
+ // Create a new session, otherwise when the user action is flushed, it
1671
+ // will get rejected due to an expired session.
1669
1672
  this.loadSession({ expiry: SESSION_IDLE_DURATION });
1670
1673
  // Note: This will cause a new DOM checkout
1671
1674
  this.resume();
@@ -1770,11 +1773,7 @@ var Replay = /** @class */ (function () {
1770
1773
  if (!expired) {
1771
1774
  return true;
1772
1775
  }
1773
- // TODO: We could potentially figure out a way to save the last session,
1774
- // and produce a checkout based on a previous checkout + updates, and then
1775
- // replay the event on top. Or maybe replay the event on top of a refresh
1776
- // snapshot.
1777
- // For now create a new snapshot
1776
+ // Session is expired, trigger a full snapshot (which will create a new session)
1778
1777
  this.triggerFullSnapshot();
1779
1778
  return false;
1780
1779
  };
@@ -1826,7 +1825,7 @@ var Replay = /** @class */ (function () {
1826
1825
  Replay.prototype.runFlush = function () {
1827
1826
  var _a;
1828
1827
  return __awaiter(this, void 0, void 0, function () {
1829
- var replayId, segmentId, recordingData, err_2;
1828
+ var recordingData, replayId, segmentId, err_2;
1830
1829
  return __generator(this, function (_b) {
1831
1830
  switch (_b.label) {
1832
1831
  case 0:
@@ -1845,14 +1844,14 @@ var Replay = /** @class */ (function () {
1845
1844
  case 2:
1846
1845
  // Only attach memory event if eventBuffer is not empty
1847
1846
  _b.sent();
1848
- replayId = this.session.id;
1849
- segmentId = this.session.segmentId++;
1850
1847
  _b.label = 3;
1851
1848
  case 3:
1852
1849
  _b.trys.push([3, 6, , 7]);
1853
1850
  return [4 /*yield*/, this.eventBuffer.finish()];
1854
1851
  case 4:
1855
1852
  recordingData = _b.sent();
1853
+ replayId = this.session.id;
1854
+ segmentId = this.session.segmentId++;
1856
1855
  return [4 /*yield*/, this.sendReplay({
1857
1856
  replayId: replayId,
1858
1857
  events: recordingData,
@@ -1905,7 +1904,7 @@ var Replay = /** @class */ (function () {
1905
1904
  timestamp = new Date().getTime();
1906
1905
  sdkInfo = {
1907
1906
  name: 'sentry.javascript.integration.replay',
1908
- version: "0.6.14-2",
1907
+ version: "0.6.14-3",
1909
1908
  };
1910
1909
  return [4 /*yield*/, new Promise(function (resolve) {
1911
1910
  var _a;