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