@amplitude/session-replay-browser 1.52.0-codexsemantic-review-integration.0 → 1.52.0
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/lib/cjs/config/joined-config.d.ts +1 -0
- package/lib/cjs/config/joined-config.d.ts.map +1 -1
- package/lib/cjs/config/joined-config.js +10 -1
- package/lib/cjs/config/joined-config.js.map +1 -1
- package/lib/cjs/config/local-config.d.ts +3 -3
- package/lib/cjs/config/local-config.d.ts.map +1 -1
- package/lib/cjs/config/local-config.js +5 -3
- package/lib/cjs/config/local-config.js.map +1 -1
- package/lib/cjs/config/types.d.ts +17 -9
- package/lib/cjs/config/types.d.ts.map +1 -1
- package/lib/cjs/config/types.js.map +1 -1
- package/lib/cjs/helpers.d.ts.map +1 -1
- package/lib/cjs/helpers.js +7 -4
- package/lib/cjs/helpers.js.map +1 -1
- package/lib/cjs/hooks/click.d.ts +2 -8
- package/lib/cjs/hooks/click.d.ts.map +1 -1
- package/lib/cjs/hooks/click.js +3 -42
- package/lib/cjs/hooks/click.js.map +1 -1
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.d.ts.map +1 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/plugins/url-tracking-plugin.d.ts +0 -3
- package/lib/cjs/plugins/url-tracking-plugin.d.ts.map +1 -1
- package/lib/cjs/plugins/url-tracking-plugin.js +9 -16
- package/lib/cjs/plugins/url-tracking-plugin.js.map +1 -1
- package/lib/cjs/semantic-identity.d.ts +1 -1
- package/lib/cjs/semantic-identity.d.ts.map +1 -1
- package/lib/cjs/semantic-identity.js +4 -3
- package/lib/cjs/semantic-identity.js.map +1 -1
- package/lib/cjs/semantic-types.d.ts +45 -0
- package/lib/cjs/semantic-types.d.ts.map +1 -0
- package/lib/cjs/semantic-types.js +3 -0
- package/lib/cjs/semantic-types.js.map +1 -0
- package/lib/cjs/semantic.d.ts +9 -12
- package/lib/cjs/semantic.d.ts.map +1 -1
- package/lib/cjs/semantic.js +17 -90
- package/lib/cjs/semantic.js.map +1 -1
- package/lib/cjs/session-replay.d.ts +39 -2
- package/lib/cjs/session-replay.d.ts.map +1 -1
- package/lib/cjs/session-replay.js +267 -132
- package/lib/cjs/session-replay.js.map +1 -1
- package/lib/cjs/utils/rrweb.d.ts +0 -3
- package/lib/cjs/utils/rrweb.d.ts.map +1 -1
- package/lib/cjs/utils/rrweb.js.map +1 -1
- package/lib/cjs/version.d.ts +1 -1
- package/lib/cjs/version.d.ts.map +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/cjs/version.js.map +1 -1
- package/lib/cjs/window-focus.d.ts +40 -0
- package/lib/cjs/window-focus.d.ts.map +1 -0
- package/lib/cjs/window-focus.js +182 -0
- package/lib/cjs/window-focus.js.map +1 -0
- package/lib/esm/config/joined-config.d.ts +1 -0
- package/lib/esm/config/joined-config.d.ts.map +1 -1
- package/lib/esm/config/joined-config.js +10 -1
- package/lib/esm/config/joined-config.js.map +1 -1
- package/lib/esm/config/local-config.d.ts +3 -3
- package/lib/esm/config/local-config.d.ts.map +1 -1
- package/lib/esm/config/local-config.js +5 -3
- package/lib/esm/config/local-config.js.map +1 -1
- package/lib/esm/config/types.d.ts +17 -9
- package/lib/esm/config/types.d.ts.map +1 -1
- package/lib/esm/config/types.js.map +1 -1
- package/lib/esm/helpers.d.ts.map +1 -1
- package/lib/esm/helpers.js +8 -5
- package/lib/esm/helpers.js.map +1 -1
- package/lib/esm/hooks/click.d.ts +2 -8
- package/lib/esm/hooks/click.d.ts.map +1 -1
- package/lib/esm/hooks/click.js +3 -42
- package/lib/esm/hooks/click.js.map +1 -1
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.d.ts.map +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/plugins/url-tracking-plugin.d.ts +0 -3
- package/lib/esm/plugins/url-tracking-plugin.d.ts.map +1 -1
- package/lib/esm/plugins/url-tracking-plugin.js +9 -16
- package/lib/esm/plugins/url-tracking-plugin.js.map +1 -1
- package/lib/esm/semantic-identity.d.ts +1 -1
- package/lib/esm/semantic-identity.d.ts.map +1 -1
- package/lib/esm/semantic-identity.js +4 -3
- package/lib/esm/semantic-identity.js.map +1 -1
- package/lib/esm/semantic-types.d.ts +45 -0
- package/lib/esm/semantic-types.d.ts.map +1 -0
- package/lib/esm/semantic-types.js +2 -0
- package/lib/esm/semantic-types.js.map +1 -0
- package/lib/esm/semantic.d.ts +9 -12
- package/lib/esm/semantic.d.ts.map +1 -1
- package/lib/esm/semantic.js +17 -90
- package/lib/esm/semantic.js.map +1 -1
- package/lib/esm/session-replay.d.ts +39 -2
- package/lib/esm/session-replay.d.ts.map +1 -1
- package/lib/esm/session-replay.js +267 -132
- package/lib/esm/session-replay.js.map +1 -1
- package/lib/esm/utils/rrweb.d.ts +0 -3
- package/lib/esm/utils/rrweb.d.ts.map +1 -1
- package/lib/esm/utils/rrweb.js.map +1 -1
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.d.ts.map +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/esm/version.js.map +1 -1
- package/lib/esm/window-focus.d.ts +40 -0
- package/lib/esm/window-focus.d.ts.map +1 -0
- package/lib/esm/window-focus.js +179 -0
- package/lib/esm/window-focus.js.map +1 -0
- package/lib/scripts/index-min.js +1 -1
- package/lib/scripts/index-min.js.gz +0 -0
- package/lib/scripts/index-min.js.map +1 -1
- package/lib/scripts/session-replay-browser-min.js +1 -1
- package/lib/scripts/session-replay-browser-min.js.gz +0 -0
- package/lib/scripts/session-replay-browser-min.js.map +1 -1
- package/package.json +4 -4
|
@@ -4,7 +4,6 @@ exports.SessionReplay = void 0;
|
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var semantic_1 = require("./semantic");
|
|
6
6
|
var semantic_identity_1 = require("./semantic-identity");
|
|
7
|
-
var finder_1 = require("./libs/finder");
|
|
8
7
|
var session_replay_dom_privacy_1 = require("@amplitude/session-replay-dom-privacy");
|
|
9
8
|
var analytics_core_1 = require("@amplitude/analytics-core");
|
|
10
9
|
// Import only specific types to avoid pulling in the entire rrweb-types package
|
|
@@ -25,6 +24,7 @@ var sampling_1 = require("./sampling");
|
|
|
25
24
|
var version_1 = require("./version");
|
|
26
25
|
var url_tracking_plugin_1 = require("./plugins/url-tracking-plugin");
|
|
27
26
|
var cross_origin_iframes_1 = require("./cross-origin-iframes");
|
|
27
|
+
var window_focus_1 = require("./window-focus");
|
|
28
28
|
var SessionReplay = /** @class */ (function () {
|
|
29
29
|
function SessionReplay() {
|
|
30
30
|
var _this = this;
|
|
@@ -67,6 +67,7 @@ var SessionReplay = /** @class */ (function () {
|
|
|
67
67
|
*/
|
|
68
68
|
this.startChildRecordingOnSetup = false;
|
|
69
69
|
this.pendingEmitEvents = [];
|
|
70
|
+
this.windowFocus = new window_focus_1.WindowFocusTracker();
|
|
70
71
|
/** Current page URL, kept in sync with SPA navigations for URL-based masking */
|
|
71
72
|
this.currentPageUrl = '';
|
|
72
73
|
this.recordEventsPendingShouldLogMetadata = null;
|
|
@@ -95,20 +96,70 @@ var SessionReplay = /** @class */ (function () {
|
|
|
95
96
|
globalScope.removeEventListener('beforeunload', _this.pageLeaveListener);
|
|
96
97
|
!teardown && globalScope.addEventListener('beforeunload', _this.pageLeaveListener);
|
|
97
98
|
}
|
|
99
|
+
// Tab switches fire visibilitychange on the document. Focus does not: a background
|
|
100
|
+
// tab can stay blurred without ever hiding, and hidden tabs often never regain focus
|
|
101
|
+
// until this event. Guarded because unit-test scopes sometimes stub document.
|
|
102
|
+
var documentRef = globalScope.document;
|
|
103
|
+
if ((documentRef === null || documentRef === void 0 ? void 0 : documentRef.addEventListener) && documentRef.removeEventListener) {
|
|
104
|
+
documentRef.removeEventListener('visibilitychange', _this.visibilityListener);
|
|
105
|
+
!teardown && documentRef.addEventListener('visibilitychange', _this.visibilityListener);
|
|
106
|
+
}
|
|
98
107
|
}
|
|
99
108
|
};
|
|
100
109
|
this.blurListener = function () {
|
|
101
|
-
|
|
110
|
+
// Blur covers window switches that do not hide the document (a second window
|
|
111
|
+
// beside this one). Drain the idle queue first: sendEvents only ships what is
|
|
112
|
+
// already in the store, and the mutations for the screen the user just left
|
|
113
|
+
// are often still waiting on requestIdleCallback.
|
|
114
|
+
_this.scheduleHiddenSend();
|
|
115
|
+
_this.windowFocus.noteBlur();
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Tab show/hide. `focus` is the wrong signal for this: it also fires for iframes
|
|
119
|
+
* and editors, which is why `captureFullSnapshotOnFocus` defaults off. A document
|
|
120
|
+
* visibility change happens once per real tab switch.
|
|
121
|
+
*
|
|
122
|
+
* Hidden: flush queued mutations so playback is not left on the last snapshot that
|
|
123
|
+
* happened to be in the store.
|
|
124
|
+
* Visible: take one checkout snapshot of this document and send it. Incremental
|
|
125
|
+
* events from another tab use that tab's node ids and are dropped, so without a
|
|
126
|
+
* fresh checkout the player stays on whichever snapshot it last applied.
|
|
127
|
+
*/
|
|
128
|
+
this.visibilityListener = function () {
|
|
129
|
+
var _a, _b;
|
|
130
|
+
var visibilityState = (_b = (_a = (0, analytics_core_1.getGlobalScope)()) === null || _a === void 0 ? void 0 : _a.document) === null || _b === void 0 ? void 0 : _b.visibilityState;
|
|
131
|
+
if (visibilityState === 'hidden') {
|
|
132
|
+
_this.windowFocus.onDocumentHidden();
|
|
133
|
+
_this.scheduleHiddenSend();
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (visibilityState === 'visible') {
|
|
137
|
+
// The deferred hide upload has not run. This send includes those events
|
|
138
|
+
// plus the checkout snapshot. Drop the external-focus flag so the focus
|
|
139
|
+
// event that follows a tab return does not take a second checkout.
|
|
140
|
+
_this.windowFocus.onDocumentVisible();
|
|
141
|
+
_this.cancelHiddenSend();
|
|
142
|
+
_this.captureVisibleTab();
|
|
143
|
+
}
|
|
102
144
|
};
|
|
103
145
|
this.focusListener = function () {
|
|
104
146
|
var _a;
|
|
105
147
|
if (!_this.recordingEnabled) {
|
|
106
148
|
return;
|
|
107
149
|
}
|
|
150
|
+
var focusFromOutside = _this.windowFocus.consumeArrivedFromOutside();
|
|
151
|
+
// Another window of the same session stayed visible, so visibilitychange never
|
|
152
|
+
// fired. One checkout replaces the replayed document; otherwise that window's
|
|
153
|
+
// incremental adds share node ids and append onto this one.
|
|
154
|
+
if (focusFromOutside) {
|
|
155
|
+
_this.captureVisibleTab();
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
108
158
|
if (_this.recordCancelCallback && _this.recordFunction) {
|
|
109
159
|
// Recording is already active. The on-focus full snapshot is tunable: when
|
|
110
160
|
// `captureFullSnapshotOnFocus` is false we skip it entirely so high focus-churn pages
|
|
111
161
|
// don't generate a full snapshot (and, with eager send, a network request) per focus.
|
|
162
|
+
// Returning to a backgrounded tab is handled by visibilityListener instead.
|
|
112
163
|
if (((_a = _this.config) === null || _a === void 0 ? void 0 : _a.captureFullSnapshotOnFocus) === false) {
|
|
113
164
|
return;
|
|
114
165
|
}
|
|
@@ -129,11 +180,12 @@ var SessionReplay = /** @class */ (function () {
|
|
|
129
180
|
* prevent duplicate listener actions from firing.
|
|
130
181
|
*/
|
|
131
182
|
this.pageLeaveListener = function (e) {
|
|
132
|
-
|
|
183
|
+
// Drop the deferred hide upload. It must not resolve before the beacon below
|
|
184
|
+
// copies the buffer. Unload order is visibilitychange(hidden), then pagehide.
|
|
185
|
+
_this.cancelHiddenSend();
|
|
133
186
|
// Synchronously drain any events still queued in the requestIdleCallback
|
|
134
187
|
// pipeline so they are available to send before the page unloads.
|
|
135
|
-
|
|
136
|
-
_this.sendEvents();
|
|
188
|
+
_this.flushPendingReplayEvents();
|
|
137
189
|
_this.pageLeaveFns.forEach(function (fn) {
|
|
138
190
|
fn(e);
|
|
139
191
|
});
|
|
@@ -267,21 +319,19 @@ var SessionReplay = /** @class */ (function () {
|
|
|
267
319
|
});
|
|
268
320
|
});
|
|
269
321
|
};
|
|
270
|
-
this.stopRecordingEvents = function (
|
|
271
|
-
var _a, _b, _c
|
|
272
|
-
if (reason === void 0) { reason = 'targeting'; }
|
|
273
|
-
if (state === void 0) { state = 'stop'; }
|
|
322
|
+
this.stopRecordingEvents = function () {
|
|
323
|
+
var _a, _b, _c;
|
|
274
324
|
try {
|
|
275
|
-
(
|
|
325
|
+
_this.useSemanticAdapter(function (adapter) { return adapter.stop(); });
|
|
276
326
|
_this.loggerProvider.log('Session Replay capture stopping.');
|
|
277
327
|
_this.recordCancelCallback && _this.recordCancelCallback();
|
|
278
328
|
_this.recordCancelCallback = null;
|
|
279
|
-
(
|
|
280
|
-
(
|
|
329
|
+
(_a = _this.networkObservers) === null || _a === void 0 ? void 0 : _a.stop();
|
|
330
|
+
(_b = _this.crossOriginIframeCoordinator) === null || _b === void 0 ? void 0 : _b.stop();
|
|
281
331
|
_this.crossOriginIframeCoordinator = null;
|
|
282
332
|
// Remove the child-mode parent signal listener so a later mode change
|
|
283
333
|
// (e.g. crossOriginIframes disabled) does not leave a stale listener.
|
|
284
|
-
(
|
|
334
|
+
(_c = _this.crossOriginParentSignalCleanup) === null || _c === void 0 ? void 0 : _c.call(_this);
|
|
285
335
|
_this.crossOriginParentSignalCleanup = null;
|
|
286
336
|
}
|
|
287
337
|
catch (error) {
|
|
@@ -352,18 +402,18 @@ var SessionReplay = /** @class */ (function () {
|
|
|
352
402
|
return currentUrl != null ? { url: currentUrl } : undefined;
|
|
353
403
|
};
|
|
354
404
|
SessionReplay.prototype._init = function (apiKey, options) {
|
|
355
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p
|
|
405
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
356
406
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
357
|
-
var now,
|
|
358
|
-
var e_2,
|
|
407
|
+
var now, _q, _r, joinedConfig, localConfig, remoteConfig, scrollWatcher, managers, storeType, compressionWorkerScript, trackDestinationWorkerScript, globalScope, _s, compressionScript, trackDestinationScript, rrwebEventManager, error_1, typedError, payloadBatcher, interactionEventManager, error_2, typedError, onFullSnapshotProcessed, pending_2, pending_1, pending_1_1, _t, event_1, sessionId, messenger, needsUrlTracking;
|
|
408
|
+
var e_2, _u;
|
|
359
409
|
var _this = this;
|
|
360
|
-
return tslib_1.__generator(this, function (
|
|
361
|
-
switch (
|
|
410
|
+
return tslib_1.__generator(this, function (_v) {
|
|
411
|
+
switch (_v.label) {
|
|
362
412
|
case 0:
|
|
363
413
|
// Re-init should always tear down any previous URL-change subscription, even when the
|
|
364
414
|
// next config has no targeting config and we don't subscribe again.
|
|
365
415
|
(_a = this.urlChangeCleanup) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
366
|
-
(
|
|
416
|
+
this.useSemanticAdapter(function (adapter) { return adapter.stop(); });
|
|
367
417
|
this.semanticAdapter = undefined;
|
|
368
418
|
// A new init always allows capture again. `stop()` only pauses the current instance.
|
|
369
419
|
this.recordingEnabled = true;
|
|
@@ -377,19 +427,19 @@ var SessionReplay = /** @class */ (function () {
|
|
|
377
427
|
(0, replay_start_time_store_1.pruneStaleReplayStartTimes)(apiKey, now, this.loggerProvider);
|
|
378
428
|
this.sessionStartTime =
|
|
379
429
|
options.sessionId !== undefined
|
|
380
|
-
? (
|
|
430
|
+
? (_b = (0, replay_start_time_store_1.getOrInitReplayStartTime)(apiKey, options.sessionId, now, this.loggerProvider)) !== null && _b !== void 0 ? _b : now
|
|
381
431
|
: now;
|
|
382
|
-
|
|
432
|
+
_q = this;
|
|
383
433
|
return [4 /*yield*/, (0, joined_config_1.createSessionReplayJoinedConfigGenerator)(apiKey, options)];
|
|
384
434
|
case 1:
|
|
385
|
-
|
|
435
|
+
_q.joinedConfigGenerator = _v.sent();
|
|
386
436
|
return [4 /*yield*/, this.joinedConfigGenerator.generateJoinedConfig()];
|
|
387
437
|
case 2:
|
|
388
|
-
|
|
438
|
+
_r = _v.sent(), joinedConfig = _r.joinedConfig, localConfig = _r.localConfig, remoteConfig = _r.remoteConfig;
|
|
389
439
|
this.config = joinedConfig;
|
|
390
|
-
this.setMetadata(options.sessionId, joinedConfig, localConfig, remoteConfig, (
|
|
440
|
+
this.setMetadata(options.sessionId, joinedConfig, localConfig, remoteConfig, (_c = options.version) === null || _c === void 0 ? void 0 : _c.version, version_1.VERSION, (_d = options.version) === null || _d === void 0 ? void 0 : _d.type);
|
|
391
441
|
this.pageLeaveFns = [];
|
|
392
|
-
if (options.sessionId && ((
|
|
442
|
+
if (options.sessionId && ((_e = this.config.interactionConfig) === null || _e === void 0 ? void 0 : _e.enabled)) {
|
|
393
443
|
scrollWatcher = scroll_1.ScrollWatcher.default({
|
|
394
444
|
sessionId: options.sessionId,
|
|
395
445
|
type: 'interaction',
|
|
@@ -400,7 +450,7 @@ var SessionReplay = /** @class */ (function () {
|
|
|
400
450
|
}
|
|
401
451
|
managers = [];
|
|
402
452
|
storeType = this.config.storeType;
|
|
403
|
-
if (storeType === 'idb' && !((
|
|
453
|
+
if (storeType === 'idb' && !((_f = (0, analytics_core_1.getGlobalScope)()) === null || _f === void 0 ? void 0 : _f.indexedDB)) {
|
|
404
454
|
storeType = 'memory';
|
|
405
455
|
this.loggerProvider.warn('Could not use preferred indexedDB storage, reverting to in memory option.');
|
|
406
456
|
}
|
|
@@ -409,42 +459,42 @@ var SessionReplay = /** @class */ (function () {
|
|
|
409
459
|
if (!(this.config.useWebWorker && globalScope && globalScope.Worker)) return [3 /*break*/, 4];
|
|
410
460
|
return [4 /*yield*/, Promise.resolve().then(function () { return tslib_1.__importStar(require('./worker')); })];
|
|
411
461
|
case 3:
|
|
412
|
-
|
|
462
|
+
_s = _v.sent(), compressionScript = _s.compressionScript, trackDestinationScript = _s.trackDestinationScript;
|
|
413
463
|
compressionWorkerScript = compressionScript;
|
|
414
464
|
trackDestinationWorkerScript = trackDestinationScript;
|
|
415
|
-
|
|
465
|
+
_v.label = 4;
|
|
416
466
|
case 4:
|
|
417
|
-
|
|
467
|
+
_v.trys.push([4, 6, , 7]);
|
|
418
468
|
return [4 /*yield*/, (0, events_manager_1.createEventsManager)({
|
|
419
469
|
config: this.config,
|
|
420
470
|
type: 'replay',
|
|
421
|
-
minInterval: (
|
|
422
|
-
maxInterval: (
|
|
471
|
+
minInterval: (_g = this.config.flushIntervalConfig) === null || _g === void 0 ? void 0 : _g.minIntervalMs,
|
|
472
|
+
maxInterval: (_h = this.config.flushIntervalConfig) === null || _h === void 0 ? void 0 : _h.maxIntervalMs,
|
|
423
473
|
maxPersistedEventsSize: this.config.maxPersistedEventsSizeBytes,
|
|
424
474
|
storeType: storeType,
|
|
425
475
|
trackDestinationWorkerScript: trackDestinationWorkerScript,
|
|
426
476
|
shouldSend: function () { return !_this.isBelowMinSessionDuration(); },
|
|
427
477
|
})];
|
|
428
478
|
case 5:
|
|
429
|
-
rrwebEventManager =
|
|
479
|
+
rrwebEventManager = _v.sent();
|
|
430
480
|
this.rrwebEventManager = rrwebEventManager;
|
|
431
481
|
managers.push({ name: 'replay', manager: rrwebEventManager });
|
|
432
482
|
return [3 /*break*/, 7];
|
|
433
483
|
case 6:
|
|
434
|
-
error_1 =
|
|
484
|
+
error_1 = _v.sent();
|
|
435
485
|
typedError = error_1;
|
|
436
486
|
this.loggerProvider.warn("Error occurred while creating replay events manager: ".concat(typedError.toString()));
|
|
437
487
|
return [3 /*break*/, 7];
|
|
438
488
|
case 7:
|
|
439
|
-
if (!((
|
|
489
|
+
if (!((_j = this.config.interactionConfig) === null || _j === void 0 ? void 0 : _j.enabled)) return [3 /*break*/, 11];
|
|
440
490
|
payloadBatcher = this.config.interactionConfig.batch ? click_1.clickBatcher : click_1.clickNonBatcher;
|
|
441
|
-
|
|
491
|
+
_v.label = 8;
|
|
442
492
|
case 8:
|
|
443
|
-
|
|
493
|
+
_v.trys.push([8, 10, , 11]);
|
|
444
494
|
return [4 /*yield*/, (0, events_manager_1.createEventsManager)({
|
|
445
495
|
config: this.config,
|
|
446
496
|
type: 'interaction',
|
|
447
|
-
minInterval: (
|
|
497
|
+
minInterval: (_k = this.config.interactionConfig.trackEveryNms) !== null && _k !== void 0 ? _k : constants_1.INTERACTION_MIN_INTERVAL,
|
|
448
498
|
maxInterval: constants_1.INTERACTION_MAX_INTERVAL,
|
|
449
499
|
maxPersistedEventsSize: this.config.maxPersistedEventsSizeBytes,
|
|
450
500
|
payloadBatcher: payloadBatcher,
|
|
@@ -452,11 +502,11 @@ var SessionReplay = /** @class */ (function () {
|
|
|
452
502
|
trackDestinationWorkerScript: trackDestinationWorkerScript,
|
|
453
503
|
})];
|
|
454
504
|
case 9:
|
|
455
|
-
interactionEventManager =
|
|
505
|
+
interactionEventManager = _v.sent();
|
|
456
506
|
managers.push({ name: 'interaction', manager: interactionEventManager });
|
|
457
507
|
return [3 /*break*/, 11];
|
|
458
508
|
case 10:
|
|
459
|
-
error_2 =
|
|
509
|
+
error_2 = _v.sent();
|
|
460
510
|
typedError = error_2;
|
|
461
511
|
this.loggerProvider.warn("Error occurred while creating interaction events manager: ".concat(typedError.toString()));
|
|
462
512
|
return [3 /*break*/, 11];
|
|
@@ -474,14 +524,14 @@ var SessionReplay = /** @class */ (function () {
|
|
|
474
524
|
pending_2 = this.pendingEmitEvents.splice(0);
|
|
475
525
|
try {
|
|
476
526
|
for (pending_1 = tslib_1.__values(pending_2), pending_1_1 = pending_1.next(); !pending_1_1.done; pending_1_1 = pending_1.next()) {
|
|
477
|
-
|
|
527
|
+
_t = pending_1_1.value, event_1 = _t.event, sessionId = _t.sessionId;
|
|
478
528
|
this.eventCompressor.enqueueEvent(event_1, sessionId);
|
|
479
529
|
}
|
|
480
530
|
}
|
|
481
531
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
482
532
|
finally {
|
|
483
533
|
try {
|
|
484
|
-
if (pending_1_1 && !pending_1_1.done && (
|
|
534
|
+
if (pending_1_1 && !pending_1_1.done && (_u = pending_1.return)) _u.call(pending_1);
|
|
485
535
|
}
|
|
486
536
|
finally { if (e_2) throw e_2.error; }
|
|
487
537
|
}
|
|
@@ -518,11 +568,11 @@ var SessionReplay = /** @class */ (function () {
|
|
|
518
568
|
], false);
|
|
519
569
|
return [4 /*yield*/, this.initializeNetworkObservers()];
|
|
520
570
|
case 12:
|
|
521
|
-
|
|
571
|
+
_v.sent();
|
|
522
572
|
// Enable background capture when this page is opened by the Amplitude app
|
|
523
573
|
// (window.opener exists). Uses the shared messenger singleton so that if
|
|
524
574
|
// autocapture is also loaded, both share a single messenger and script load.
|
|
525
|
-
if ((
|
|
575
|
+
if ((_l = (0, analytics_core_1.getGlobalScope)()) === null || _l === void 0 ? void 0 : _l.opener) {
|
|
526
576
|
messenger = (0, analytics_core_1.getOrCreateWindowMessenger)();
|
|
527
577
|
(0, analytics_core_1.enableBackgroundCapture)(messenger);
|
|
528
578
|
messenger.setup(tslib_1.__assign({ logger: this.loggerProvider }, (this.config.serverZone && { endpoint: analytics_core_1.AMPLITUDE_ORIGINS_MAP[this.config.serverZone] })));
|
|
@@ -531,8 +581,8 @@ var SessionReplay = /** @class */ (function () {
|
|
|
531
581
|
this.teardownEventListeners(false);
|
|
532
582
|
return [4 /*yield*/, this.evaluateTargetingAndCapture({ userProperties: options.userProperties, page: this.getCurrentPageForTargeting() }, true)];
|
|
533
583
|
case 13:
|
|
534
|
-
|
|
535
|
-
needsUrlTracking = this.config.targetingConfig || ((
|
|
584
|
+
_v.sent();
|
|
585
|
+
needsUrlTracking = this.config.targetingConfig || ((_p = (_o = (_m = this.config.privacyConfig) === null || _m === void 0 ? void 0 : _m.urlMaskLevels) === null || _o === void 0 ? void 0 : _o.length) !== null && _p !== void 0 ? _p : 0) > 0;
|
|
536
586
|
if (needsUrlTracking) {
|
|
537
587
|
this.setupUrlChangeListener();
|
|
538
588
|
}
|
|
@@ -573,7 +623,9 @@ var SessionReplay = /** @class */ (function () {
|
|
|
573
623
|
}
|
|
574
624
|
isSessionChange = previousSessionId !== sessionId;
|
|
575
625
|
if (isSessionChange && ((_c = (_b = this.config) === null || _b === void 0 ? void 0 : _b.semanticCapture) === null || _c === void 0 ? void 0 : _c.enabled) && this.semanticAdapter) {
|
|
576
|
-
|
|
626
|
+
// Keep rrweb recording through the async config/targeting pass, as it does
|
|
627
|
+
// without semantic capture. Only detach the old session's semantic runtime.
|
|
628
|
+
this.useSemanticAdapter(function (adapter) { return adapter.stop(); });
|
|
577
629
|
}
|
|
578
630
|
// Drop any beacon-buffered events from the previous session BEFORE installing the
|
|
579
631
|
// new identifiers / start time. Otherwise the page-leave beacon path could attribute
|
|
@@ -654,6 +706,78 @@ var SessionReplay = /** @class */ (function () {
|
|
|
654
706
|
this.eventCount++;
|
|
655
707
|
return eventProperties;
|
|
656
708
|
};
|
|
709
|
+
/** Move idle-queued rrweb events into the store, then ship the current sequence. */
|
|
710
|
+
SessionReplay.prototype.flushPendingReplayEvents = function () {
|
|
711
|
+
var _a;
|
|
712
|
+
(_a = this.eventCompressor) === null || _a === void 0 ? void 0 : _a.flushQueue();
|
|
713
|
+
this.sendEvents();
|
|
714
|
+
};
|
|
715
|
+
/**
|
|
716
|
+
* Flush now, upload on the next macrotask. The flush is synchronous so a
|
|
717
|
+
* following `pagehide` still sees the events in the beacon buffer. The upload
|
|
718
|
+
* waits so a memory-store `sendEvents` cannot clear that buffer before the
|
|
719
|
+
* beacon copies it. A tab switch never reaches `pagehide`, so the timer uploads.
|
|
720
|
+
*/
|
|
721
|
+
SessionReplay.prototype.scheduleHiddenSend = function () {
|
|
722
|
+
var _this = this;
|
|
723
|
+
var _a;
|
|
724
|
+
(_a = this.eventCompressor) === null || _a === void 0 ? void 0 : _a.flushQueue();
|
|
725
|
+
if (this.hiddenFlushTimer !== undefined) {
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
var schedule = this.hostSetTimeout();
|
|
729
|
+
this.hiddenFlushTimer = schedule(function () {
|
|
730
|
+
_this.hiddenFlushTimer = undefined;
|
|
731
|
+
_this.sendEvents();
|
|
732
|
+
}, 0);
|
|
733
|
+
};
|
|
734
|
+
SessionReplay.prototype.cancelHiddenSend = function () {
|
|
735
|
+
if (this.hiddenFlushTimer === undefined) {
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
this.hostClearTimeout()(this.hiddenFlushTimer);
|
|
739
|
+
this.hiddenFlushTimer = undefined;
|
|
740
|
+
};
|
|
741
|
+
SessionReplay.prototype.hostSetTimeout = function () {
|
|
742
|
+
var globalScope = (0, analytics_core_1.getGlobalScope)();
|
|
743
|
+
if (typeof (globalScope === null || globalScope === void 0 ? void 0 : globalScope.setTimeout) === 'function') {
|
|
744
|
+
return globalScope.setTimeout.bind(globalScope);
|
|
745
|
+
}
|
|
746
|
+
return setTimeout;
|
|
747
|
+
};
|
|
748
|
+
SessionReplay.prototype.hostClearTimeout = function () {
|
|
749
|
+
var globalScope = (0, analytics_core_1.getGlobalScope)();
|
|
750
|
+
if (typeof (globalScope === null || globalScope === void 0 ? void 0 : globalScope.clearTimeout) === 'function') {
|
|
751
|
+
return globalScope.clearTimeout.bind(globalScope);
|
|
752
|
+
}
|
|
753
|
+
return clearTimeout;
|
|
754
|
+
};
|
|
755
|
+
/**
|
|
756
|
+
* Checkout the DOM the user can actually see, then send it. Queued mutations are
|
|
757
|
+
* flushed first so they stay ordered ahead of the new snapshot.
|
|
758
|
+
*/
|
|
759
|
+
SessionReplay.prototype.captureVisibleTab = function () {
|
|
760
|
+
var _a;
|
|
761
|
+
if (!this.recordingEnabled) {
|
|
762
|
+
return;
|
|
763
|
+
}
|
|
764
|
+
(_a = this.eventCompressor) === null || _a === void 0 ? void 0 : _a.flushQueue();
|
|
765
|
+
if (this.recordCancelCallback && this.recordFunction) {
|
|
766
|
+
try {
|
|
767
|
+
// `true` is an rrweb checkout: the player drops the previous mirror and
|
|
768
|
+
// paints this snapshot instead of applying it onto an older document.
|
|
769
|
+
this.recordFunction.takeFullSnapshot(true);
|
|
770
|
+
}
|
|
771
|
+
catch (error) {
|
|
772
|
+
this.loggerProvider.warn('Failed to take full snapshot when the tab became visible:', error);
|
|
773
|
+
}
|
|
774
|
+
this.sendEvents();
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
if (!this.recordEventsInFlight) {
|
|
778
|
+
void this.recordEvents(false);
|
|
779
|
+
}
|
|
780
|
+
};
|
|
657
781
|
SessionReplay.prototype.sendEvents = function (sessionId) {
|
|
658
782
|
var _a, _b;
|
|
659
783
|
var sessionIdToSend = sessionId || ((_a = this.identifiers) === null || _a === void 0 ? void 0 : _a.sessionId);
|
|
@@ -902,71 +1026,67 @@ var SessionReplay = /** @class */ (function () {
|
|
|
902
1026
|
return !this.recordingEnabled || generation !== this.recordingGeneration;
|
|
903
1027
|
};
|
|
904
1028
|
SessionReplay.prototype._recordEvents = function (shouldLogMetadata) {
|
|
905
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
1029
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
906
1030
|
if (shouldLogMetadata === void 0) { shouldLogMetadata = true; }
|
|
907
1031
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
908
|
-
var config, shouldRecord, sessionId, generation, recordFunction, networkLoggingConfig, trackUrl, ignoredUrls, interactionConfig, loggingConfig,
|
|
1032
|
+
var config, shouldRecord, sessionId, generation, recordFunction, networkLoggingConfig, trackUrl, ignoredUrls, interactionConfig, loggingConfig, hooks, ugcFilterRules, crossOriginIframesEnabled, coordinateChildren, childMode, plugins, error_5;
|
|
909
1033
|
var _this = this;
|
|
910
|
-
return tslib_1.__generator(this, function (
|
|
911
|
-
switch (
|
|
1034
|
+
return tslib_1.__generator(this, function (_j) {
|
|
1035
|
+
switch (_j.label) {
|
|
912
1036
|
case 0:
|
|
913
1037
|
config = this.config;
|
|
914
1038
|
shouldRecord = this.getShouldRecord();
|
|
915
1039
|
sessionId = (_a = this.identifiers) === null || _a === void 0 ? void 0 : _a.sessionId;
|
|
916
1040
|
if (!shouldRecord || !sessionId || !config) {
|
|
917
|
-
if (
|
|
918
|
-
this.stopRecordingEvents(
|
|
919
|
-
}
|
|
1041
|
+
if (this.semanticAdapter && this.recordCancelCallback)
|
|
1042
|
+
this.stopRecordingEvents();
|
|
920
1043
|
return [2 /*return*/];
|
|
921
1044
|
}
|
|
922
|
-
this.stopRecordingEvents(
|
|
1045
|
+
this.stopRecordingEvents();
|
|
923
1046
|
generation = this.recordingGeneration;
|
|
924
1047
|
return [4 /*yield*/, this.getRecordFunction()];
|
|
925
1048
|
case 1:
|
|
926
|
-
recordFunction =
|
|
1049
|
+
recordFunction = _j.sent();
|
|
927
1050
|
// May be undefined if cannot import rrweb-record
|
|
928
1051
|
if (!recordFunction || this.shouldAbandonRecordStart(generation)) {
|
|
929
1052
|
return [2 /*return*/];
|
|
930
1053
|
}
|
|
931
1054
|
return [4 /*yield*/, this.initializeNetworkObservers()];
|
|
932
1055
|
case 2:
|
|
933
|
-
|
|
1056
|
+
_j.sent();
|
|
934
1057
|
if (this.shouldAbandonRecordStart(generation)) {
|
|
935
1058
|
return [2 /*return*/];
|
|
936
1059
|
}
|
|
937
|
-
networkLoggingConfig = (
|
|
1060
|
+
networkLoggingConfig = (_b = config.loggingConfig) === null || _b === void 0 ? void 0 : _b.network;
|
|
938
1061
|
trackUrl = (0, helpers_1.getServerUrl)(config.serverZone, config.trackServerUrl);
|
|
939
1062
|
ignoredUrls = [constants_1.SESSION_REPLAY_SERVER_URL, constants_1.SESSION_REPLAY_EU_URL, constants_1.SESSION_REPLAY_STAGING_URL, trackUrl];
|
|
940
|
-
(
|
|
1063
|
+
(_c = this.networkObservers) === null || _c === void 0 ? void 0 : _c.start(function (event) {
|
|
941
1064
|
if (ignoredUrls.some(function (url) { return event.url.startsWith(url); }))
|
|
942
1065
|
return;
|
|
943
1066
|
void _this.addCustomRRWebEvent(constants_1.CustomRRwebEvent.FETCH_REQUEST, event);
|
|
944
1067
|
}, networkLoggingConfig);
|
|
945
1068
|
interactionConfig = config.interactionConfig, loggingConfig = config.loggingConfig;
|
|
946
|
-
|
|
947
|
-
?
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
mouseInteraction = clickHandler.createSharedHook(heatmapHook, function (event) { var _a; return (_a = _this.semanticAdapter) === null || _a === void 0 ? void 0 : _a.click(event); });
|
|
961
|
-
}
|
|
962
|
-
hooks = tslib_1.__assign(tslib_1.__assign({}, (mouseInteraction ? { mouseInteraction: mouseInteraction } : {})), ((interactionConfig === null || interactionConfig === void 0 ? void 0 : interactionConfig.enabled) ? { scroll: this.scrollHook } : {}));
|
|
1069
|
+
hooks = (interactionConfig === null || interactionConfig === void 0 ? void 0 : interactionConfig.enabled)
|
|
1070
|
+
? {
|
|
1071
|
+
mouseInteraction: this.eventsManager &&
|
|
1072
|
+
((_d = this.clickHandler) === null || _d === void 0 ? void 0 : _d.createHook({
|
|
1073
|
+
eventsManager: this.eventsManager,
|
|
1074
|
+
sessionId: sessionId,
|
|
1075
|
+
deviceIdFn: this.getDeviceId.bind(this),
|
|
1076
|
+
mirror: recordFunction.mirror,
|
|
1077
|
+
ugcFilterRules: (_e = interactionConfig.ugcFilterRules) !== null && _e !== void 0 ? _e : [],
|
|
1078
|
+
performanceOptions: (_f = config.performanceConfig) === null || _f === void 0 ? void 0 : _f.interaction,
|
|
1079
|
+
})),
|
|
1080
|
+
scroll: this.scrollHook,
|
|
1081
|
+
}
|
|
1082
|
+
: {};
|
|
963
1083
|
ugcFilterRules = (interactionConfig === null || interactionConfig === void 0 ? void 0 : interactionConfig.enabled) && interactionConfig.ugcFilterRules ? interactionConfig.ugcFilterRules : [];
|
|
964
1084
|
this.loggerProvider.log("Session Replay capture beginning for ".concat(sessionId, "."));
|
|
965
|
-
|
|
1085
|
+
_j.label = 3;
|
|
966
1086
|
case 3:
|
|
967
|
-
|
|
968
|
-
crossOriginIframesEnabled = !!((
|
|
969
|
-
coordinateChildren = ((
|
|
1087
|
+
_j.trys.push([3, 5, , 6]);
|
|
1088
|
+
crossOriginIframesEnabled = !!((_g = config.crossOriginIframes) === null || _g === void 0 ? void 0 : _g.enabled);
|
|
1089
|
+
coordinateChildren = ((_h = config.crossOriginIframes) === null || _h === void 0 ? void 0 : _h.coordinateChildren) !== false;
|
|
970
1090
|
childMode = crossOriginIframesEnabled && (0, cross_origin_iframes_1.isInIframe)();
|
|
971
1091
|
if (childMode && coordinateChildren) {
|
|
972
1092
|
// Child mode: don't self-start; wait for a start signal from the parent.
|
|
@@ -1003,24 +1123,17 @@ var SessionReplay = /** @class */ (function () {
|
|
|
1003
1123
|
this.startChildRecordingOnSetup = false;
|
|
1004
1124
|
return [4 /*yield*/, this.getRecordingPlugins(loggingConfig)];
|
|
1005
1125
|
case 4:
|
|
1006
|
-
plugins =
|
|
1126
|
+
plugins = _j.sent();
|
|
1007
1127
|
if (this.shouldAbandonRecordStart(generation)) {
|
|
1008
1128
|
return [2 /*return*/];
|
|
1009
1129
|
}
|
|
1010
1130
|
this.prepareSemanticCapture(config, sessionId);
|
|
1011
1131
|
this.recordCancelCallback = recordFunction(tslib_1.__assign(tslib_1.__assign({}, this.buildRRWebRecordOptions(config, hooks, function (event) {
|
|
1012
|
-
|
|
1013
|
-
// The terminal state contains no page or user data and must land before rrweb stops.
|
|
1014
|
-
var semanticStop = ((_b = (_a = _this.config) === null || _a === void 0 ? void 0 : _a.semanticCapture) === null || _b === void 0 ? void 0 : _b.enabled) &&
|
|
1015
|
-
_this.semanticAdapter &&
|
|
1016
|
-
event.type === rrweb_types_1.EventType.Custom &&
|
|
1017
|
-
event.data.tag === 'amp-semantic/recording' &&
|
|
1018
|
-
((_c = event.data.payload) === null || _c === void 0 ? void 0 : _c.state) === 'stop';
|
|
1019
|
-
if ((_this.shouldOptOut() || !_this.recordingEnabled) && !semanticStop) {
|
|
1132
|
+
if (_this.shouldOptOut() || !_this.recordingEnabled) {
|
|
1020
1133
|
_this.loggerProvider.log(_this.shouldOptOut()
|
|
1021
1134
|
? "Opting session ".concat(sessionId, " out of recording due to optOut config.")
|
|
1022
1135
|
: "Session Replay capture stopping for ".concat(sessionId, "."));
|
|
1023
|
-
_this.stopRecordingEvents(
|
|
1136
|
+
_this.stopRecordingEvents();
|
|
1024
1137
|
_this.sendEvents();
|
|
1025
1138
|
return;
|
|
1026
1139
|
}
|
|
@@ -1036,10 +1149,10 @@ var SessionReplay = /** @class */ (function () {
|
|
|
1036
1149
|
// Buffer the event so it can be flushed once the compressor is initialized.
|
|
1037
1150
|
_this.pendingEmitEvents.push({ event: event, sessionId: sessionId });
|
|
1038
1151
|
}
|
|
1039
|
-
(
|
|
1152
|
+
_this.useSemanticAdapter(function (adapter) { return adapter.event(event); });
|
|
1040
1153
|
}, 'Error while capturing replay: ')), { plugins: plugins, recordCrossOriginIframes: crossOriginIframesEnabled }));
|
|
1041
1154
|
if (this.recordCancelCallback)
|
|
1042
|
-
(
|
|
1155
|
+
this.useSemanticAdapter(function (adapter) { return adapter.recordingReady(); });
|
|
1043
1156
|
if (crossOriginIframesEnabled && !childMode && coordinateChildren) {
|
|
1044
1157
|
if (!this.crossOriginIframeCoordinator) {
|
|
1045
1158
|
this.crossOriginIframeCoordinator = new cross_origin_iframes_1.CrossOriginIframeCoordinator();
|
|
@@ -1052,8 +1165,8 @@ var SessionReplay = /** @class */ (function () {
|
|
|
1052
1165
|
}
|
|
1053
1166
|
return [3 /*break*/, 6];
|
|
1054
1167
|
case 5:
|
|
1055
|
-
error_5 =
|
|
1056
|
-
(
|
|
1168
|
+
error_5 = _j.sent();
|
|
1169
|
+
this.useSemanticAdapter(function (adapter) { return adapter.stop(); });
|
|
1057
1170
|
this.loggerProvider.warn('Failed to initialize session replay:', error_5);
|
|
1058
1171
|
return [3 /*break*/, 6];
|
|
1059
1172
|
case 6: return [2 /*return*/];
|
|
@@ -1061,51 +1174,69 @@ var SessionReplay = /** @class */ (function () {
|
|
|
1061
1174
|
});
|
|
1062
1175
|
});
|
|
1063
1176
|
};
|
|
1177
|
+
SessionReplay.prototype.useSemanticAdapter = function (operation) {
|
|
1178
|
+
var adapter = this.semanticAdapter;
|
|
1179
|
+
if (!adapter)
|
|
1180
|
+
return;
|
|
1181
|
+
try {
|
|
1182
|
+
operation(adapter);
|
|
1183
|
+
}
|
|
1184
|
+
catch (error) {
|
|
1185
|
+
// A supplied controller must not interrupt rrweb recording or its teardown.
|
|
1186
|
+
this.semanticAdapter = undefined;
|
|
1187
|
+
this.loggerProvider.debug('Semantic capture failed:', error);
|
|
1188
|
+
try {
|
|
1189
|
+
adapter.stop();
|
|
1190
|
+
}
|
|
1191
|
+
catch (stopError) {
|
|
1192
|
+
this.loggerProvider.debug('Semantic capture stop failed:', stopError);
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
};
|
|
1064
1196
|
SessionReplay.prototype.prepareSemanticCapture = function (config, sessionId) {
|
|
1065
1197
|
var _this = this;
|
|
1066
|
-
var _a
|
|
1198
|
+
var _a;
|
|
1067
1199
|
var scope = (0, analytics_core_1.getGlobalScope)();
|
|
1068
1200
|
if (!(scope === null || scope === void 0 ? void 0 : scope.document))
|
|
1069
1201
|
return;
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1202
|
+
var semanticCapture = config.semanticCapture;
|
|
1203
|
+
var createCapture = semanticCapture === null || semanticCapture === void 0 ? void 0 : semanticCapture.createCapture;
|
|
1204
|
+
if (!(semanticCapture === null || semanticCapture === void 0 ? void 0 : semanticCapture.enabled) || typeof createCapture !== 'function') {
|
|
1205
|
+
this.useSemanticAdapter(function (adapter) { return adapter.stop(); });
|
|
1206
|
+
this.useSemanticAdapter(function (adapter) { return adapter.prepare({ enabled: false }, sessionId); });
|
|
1073
1207
|
return;
|
|
1074
1208
|
}
|
|
1075
|
-
if (
|
|
1076
|
-
this.
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
},
|
|
1105
|
-
onError: function (error) { return _this.loggerProvider.debug('Semantic capture error:', error); },
|
|
1106
|
-
});
|
|
1209
|
+
if (((_a = this.semanticAdapter) === null || _a === void 0 ? void 0 : _a.createCapture) !== createCapture) {
|
|
1210
|
+
this.useSemanticAdapter(function (adapter) { return adapter.stop(); });
|
|
1211
|
+
this.semanticAdapter = undefined;
|
|
1212
|
+
try {
|
|
1213
|
+
this.semanticAdapter = new semantic_1.ReplaySemanticAdapter(createCapture, {
|
|
1214
|
+
document: scope.document,
|
|
1215
|
+
window: scope,
|
|
1216
|
+
sdk: "@amplitude/session-replay-browser@".concat(version_1.VERSION),
|
|
1217
|
+
getPrivacy: function () { var _a, _b; return (_b = (_a = _this.config) === null || _a === void 0 ? void 0 : _a.privacyConfig) !== null && _b !== void 0 ? _b : {}; },
|
|
1218
|
+
getIdentity: function () { return (0, semantic_identity_1.getSemanticIdentity)(scope); },
|
|
1219
|
+
getAnalyticsContext: function () { var _a, _b; return (_b = (_a = _this.config) === null || _a === void 0 ? void 0 : _a.semanticAnalyticsContext) !== null && _b !== void 0 ? _b : { present: false, autocapture: [] }; },
|
|
1220
|
+
inlineStylesheet: config.shouldInlineStylesheet,
|
|
1221
|
+
emit: function (event) {
|
|
1222
|
+
if (_this.recordCancelCallback && _this.recordFunction) {
|
|
1223
|
+
try {
|
|
1224
|
+
_this.recordFunction.addCustomEvent("amp-semantic/".concat(event.name), event.payload);
|
|
1225
|
+
}
|
|
1226
|
+
catch (error) {
|
|
1227
|
+
_this.loggerProvider.debug('Error while adding semantic replay capture event:', error);
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
},
|
|
1231
|
+
onError: function (error) { return _this.loggerProvider.debug('Semantic capture error:', error); },
|
|
1232
|
+
});
|
|
1233
|
+
}
|
|
1234
|
+
catch (error) {
|
|
1235
|
+
this.loggerProvider.debug('Semantic capture initialization failed:', error);
|
|
1236
|
+
return;
|
|
1237
|
+
}
|
|
1107
1238
|
}
|
|
1108
|
-
this.
|
|
1239
|
+
this.useSemanticAdapter(function (adapter) { return adapter.prepare(semanticCapture, sessionId); });
|
|
1109
1240
|
};
|
|
1110
1241
|
SessionReplay.prototype.buildRRWebRecordOptions = function (config, hooks, emit, errorLogPrefix) {
|
|
1111
1242
|
var _this = this;
|
|
@@ -1191,7 +1322,9 @@ var SessionReplay = /** @class */ (function () {
|
|
|
1191
1322
|
this.recordingEnabled = false;
|
|
1192
1323
|
this.startChildRecordingOnSetup = false;
|
|
1193
1324
|
this.recordingGeneration++;
|
|
1194
|
-
this.
|
|
1325
|
+
this.cancelHiddenSend();
|
|
1326
|
+
this.windowFocus.stop();
|
|
1327
|
+
this.stopRecordingEvents();
|
|
1195
1328
|
this.sendEvents();
|
|
1196
1329
|
};
|
|
1197
1330
|
SessionReplay.prototype.flush = function (useRetry) {
|
|
@@ -1213,11 +1346,13 @@ var SessionReplay = /** @class */ (function () {
|
|
|
1213
1346
|
this.recordingEnabled = false;
|
|
1214
1347
|
this.startChildRecordingOnSetup = false;
|
|
1215
1348
|
this.recordingGeneration++;
|
|
1349
|
+
this.cancelHiddenSend();
|
|
1350
|
+
this.windowFocus.stop();
|
|
1216
1351
|
(_a = this.urlChangeCleanup) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
1217
1352
|
(_b = this.crossOriginParentSignalCleanup) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
1218
1353
|
this.crossOriginParentSignalCleanup = null;
|
|
1219
1354
|
this.teardownEventListeners(true);
|
|
1220
|
-
this.stopRecordingEvents(
|
|
1355
|
+
this.stopRecordingEvents();
|
|
1221
1356
|
this.sendEvents();
|
|
1222
1357
|
};
|
|
1223
1358
|
SessionReplay.prototype.mapSDKType = function (sdkType) {
|