@amplitude/plugin-session-replay-browser 1.23.7-feat-zoning.0 → 1.24.1
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/session-replay.js +7 -7
- package/lib/cjs/session-replay.js.map +1 -1
- package/lib/cjs/typings/session-replay.d.ts +9 -1
- package/lib/cjs/typings/session-replay.d.ts.map +1 -1
- package/lib/cjs/typings/session-replay.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/esm/session-replay.js +7 -7
- package/lib/esm/session-replay.js.map +1 -1
- package/lib/esm/typings/session-replay.d.ts +9 -1
- package/lib/esm/typings/session-replay.d.ts.map +1 -1
- package/lib/esm/typings/session-replay.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/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/plugin-session-replay-browser-min.js +1 -1
- package/lib/scripts/plugin-session-replay-browser-min.js.gz +0 -0
- package/lib/scripts/plugin-session-replay-browser-min.js.map +1 -1
- package/package.json +4 -4
|
@@ -28,13 +28,13 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
28
28
|
this.srInitOptions = this.options;
|
|
29
29
|
}
|
|
30
30
|
SessionReplayPlugin.prototype.setup = function (config, _client) {
|
|
31
|
-
var _a, _b, _c, _d, _e, _f;
|
|
31
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
32
32
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
33
33
|
var identityStore, userProperties, error_1;
|
|
34
|
-
return tslib_1.__generator(this, function (
|
|
35
|
-
switch (
|
|
34
|
+
return tslib_1.__generator(this, function (_j) {
|
|
35
|
+
switch (_j.label) {
|
|
36
36
|
case 0:
|
|
37
|
-
|
|
37
|
+
_j.trys.push([0, 2, , 3]);
|
|
38
38
|
/* istanbul ignore next */
|
|
39
39
|
config === null || config === void 0 ? void 0 : config.loggerProvider.log("Installing @amplitude/plugin-session-replay, version ".concat(version_1.VERSION, "."));
|
|
40
40
|
this.config = config;
|
|
@@ -78,7 +78,7 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
78
78
|
version: { type: 'plugin', version: version_1.VERSION },
|
|
79
79
|
performanceConfig: this.options.performanceConfig,
|
|
80
80
|
storeType: this.options.storeType,
|
|
81
|
-
|
|
81
|
+
useWebWorker: (_g = this.options.useWebWorker) !== null && _g !== void 0 ? _g : (_h = this.options.experimental) === null || _h === void 0 ? void 0 : _h.useWebWorker,
|
|
82
82
|
userProperties: userProperties,
|
|
83
83
|
omitElementTags: this.options.omitElementTags,
|
|
84
84
|
applyBackgroundColorToBlockedElements: this.options.applyBackgroundColorToBlockedElements,
|
|
@@ -89,10 +89,10 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
89
89
|
};
|
|
90
90
|
return [4 /*yield*/, this.sessionReplay.init(config.apiKey, this.srInitOptions).promise];
|
|
91
91
|
case 1:
|
|
92
|
-
|
|
92
|
+
_j.sent();
|
|
93
93
|
return [3 /*break*/, 3];
|
|
94
94
|
case 2:
|
|
95
|
-
error_1 =
|
|
95
|
+
error_1 = _j.sent();
|
|
96
96
|
/* istanbul ignore next */
|
|
97
97
|
config === null || config === void 0 ? void 0 : config.loggerProvider.error("Session Replay: Failed to initialize due to ".concat(error_1.message));
|
|
98
98
|
return [3 /*break*/, 3];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":";;;;AAAA,4DAAoH;AACpH,4EAU2C;AAC3C,8EAA2E;AAC3E,qCAAgD;AAEhD,qCAAoC;AAEpC;IAoBE,6BAAY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,CAAC,CAAC;iBACzG;;;;KACF;IAED,wDAA0B,GAA1B;QACE,OAAO,IAAI,CAAC,aAAa,CAAC,0BAA0B,EAAE,CAAC;IACzD,CAAC;IAnLM,8BAAU,GAAG,0CAA0C,CAAC;IAoLjE,0BAAC;CAAA,AArLD,IAqLC;AArLY,kDAAmB;AAuLzB,IAAM,mBAAmB,GAAyD,UACvF,OAA8B;IAE9B,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC,CAAC;AAJW,QAAA,mBAAmB,uBAI9B","sourcesContent":["import { BrowserClient, BrowserConfig, EnrichmentPlugin, Event, SpecialEventType } from '@amplitude/analytics-core';\nimport {\n init,\n setSessionId,\n getSessionId,\n getSessionReplayProperties,\n flush,\n shutdown,\n evaluateTargetingAndCapture,\n AmplitudeSessionReplay,\n SessionReplayOptions as SessionReplayBrowserOptions,\n} from '@amplitude/session-replay-browser';\nimport { getAnalyticsConnector } from '@amplitude/analytics-client-common';\nimport { parseUserProperties } from './helpers';\nimport { SessionReplayOptions } from './typings/session-replay';\nimport { VERSION } from './version';\n\nexport class SessionReplayPlugin implements EnrichmentPlugin<BrowserClient, BrowserConfig> {\n static pluginName = '@amplitude/plugin-session-replay-browser';\n name = SessionReplayPlugin.pluginName;\n type = 'enrichment' as const;\n // this.config is defined in setup() which will always be called first\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: BrowserConfig | null = null;\n options: SessionReplayOptions;\n srInitOptions: SessionReplayBrowserOptions;\n sessionReplay: AmplitudeSessionReplay = {\n flush: flush,\n getSessionId: getSessionId,\n getSessionReplayProperties: getSessionReplayProperties,\n init: init,\n setSessionId: setSessionId,\n shutdown: shutdown,\n evaluateTargetingAndCapture: evaluateTargetingAndCapture,\n };\n\n constructor(options?: SessionReplayOptions) {\n this.options = { forceSessionTracking: false, ...options };\n this.srInitOptions = this.options;\n }\n\n async setup(config: BrowserConfig, _client: BrowserClient) {\n try {\n /* istanbul ignore next */\n config?.loggerProvider.log(`Installing @amplitude/plugin-session-replay, version ${VERSION}.`);\n\n this.config = config;\n\n if (this.options.forceSessionTracking) {\n if (typeof config.defaultTracking === 'boolean') {\n if (config.defaultTracking === false) {\n config.defaultTracking = {\n pageViews: false,\n formInteractions: false,\n fileDownloads: false,\n sessions: true,\n };\n }\n } else {\n config.defaultTracking = {\n ...config.defaultTracking,\n sessions: true,\n };\n }\n }\n const identityStore = getAnalyticsConnector(this.config.instanceName).identityStore;\n const userProperties = identityStore.getIdentity().userProperties;\n\n this.srInitOptions = {\n instanceName: this.config.instanceName,\n deviceId: this.options.deviceId ?? this.config.deviceId,\n optOut: this.config.optOut,\n sessionId: this.options.customSessionId ? undefined : this.config.sessionId,\n loggerProvider: this.config.loggerProvider,\n logLevel: this.config.logLevel,\n flushMaxRetries: this.config.flushMaxRetries,\n serverZone: this.config.serverZone,\n configServerUrl: this.options.configServerUrl || this.config.remoteConfig?.serverUrl,\n trackServerUrl: this.options.trackServerUrl,\n sampleRate: this.options.sampleRate,\n privacyConfig: {\n blockSelector: this.options.privacyConfig?.blockSelector,\n maskSelector: this.options.privacyConfig?.maskSelector,\n unmaskSelector: this.options.privacyConfig?.unmaskSelector,\n defaultMaskLevel: this.options.privacyConfig?.defaultMaskLevel,\n },\n debugMode: this.options.debugMode,\n shouldInlineStylesheet: this.options.shouldInlineStylesheet,\n version: { type: 'plugin', version: VERSION },\n performanceConfig: this.options.performanceConfig,\n storeType: this.options.storeType,\n experimental: this.options.experimental,\n userProperties: userProperties,\n omitElementTags: this.options.omitElementTags,\n applyBackgroundColorToBlockedElements: this.options.applyBackgroundColorToBlockedElements,\n interactionConfig: this.options.interactionConfig,\n captureDocumentTitle: this.options.captureDocumentTitle,\n enableUrlChangePolling: this.options.enableUrlChangePolling,\n urlChangePollingInterval: this.options.urlChangePollingInterval,\n };\n\n await this.sessionReplay.init(config.apiKey, this.srInitOptions).promise;\n } catch (error) {\n /* istanbul ignore next */\n config?.loggerProvider.error(`Session Replay: Failed to initialize due to ${(error as Error).message}`);\n }\n }\n\n async onSessionIdChanged(sessionId: number): Promise<void> {\n this.config?.loggerProvider.debug(\n `Analytics session id is changed to ${sessionId}, SR session id is ${String(this.sessionReplay.getSessionId())}.`,\n );\n await this.sessionReplay.setSessionId(sessionId).promise;\n }\n\n async onOptOutChanged(optOut: boolean): Promise<void> {\n this.config?.loggerProvider.debug(\n `optOut is changed to ${String(optOut)}, calling ${\n optOut ? 'sessionReplay.shutdown()' : 'sessionReplay.init()'\n }.`,\n );\n // TODO: compare optOut with this.sessionReplay.getOptOut().\n // Need to add getOptOut() to the interface AmplitudeSessionReplay first.\n if (optOut) {\n this.sessionReplay.shutdown();\n } else {\n this.config != null && (await this.sessionReplay.init(this.config.apiKey, this.srInitOptions).promise);\n }\n }\n\n async execute(event: Event) {\n try {\n if (this.options.customSessionId) {\n const sessionId = this.options.customSessionId(event);\n if (sessionId) {\n // On event, synchronize the session id to the custom session id from the event. This may\n // suffer from offline/delayed events messing up the state stored\n if (sessionId !== this.sessionReplay.getSessionId()) {\n await this.sessionReplay.setSessionId(sessionId).promise;\n }\n\n const sessionRecordingProperties = this.sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n } else {\n // On event, synchronize the session id to the what's on the browserConfig (source of truth)\n // Choosing not to read from event object here, concerned about offline/delayed events messing up the state stored\n // in SR.\n const sessionId: string | number | undefined = this.config?.sessionId;\n if (sessionId && sessionId !== this.sessionReplay.getSessionId()) {\n await this.sessionReplay.setSessionId(sessionId).promise;\n }\n\n // Treating config.sessionId as source of truth, if the event's session id doesn't match, the\n // event is not of the current session (offline/late events). In that case, don't tag the events\n if (sessionId && sessionId === event.session_id) {\n let userProperties;\n if (event.event_type === SpecialEventType.IDENTIFY) {\n userProperties = parseUserProperties(event);\n }\n await this.sessionReplay.evaluateTargetingAndCapture({ event, userProperties });\n const sessionRecordingProperties = this.sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n }\n\n return Promise.resolve(event);\n } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: Failed to enrich event due to ${(error as Error).message}`);\n return Promise.resolve(event);\n }\n }\n\n async teardown(): Promise<void> {\n try {\n this.sessionReplay.shutdown();\n // the following are initialized in setup() which will always be called first\n // here we reset them to null to prevent memory leaks\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.config = null;\n } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: teardown failed due to ${(error as Error).message}`);\n }\n }\n\n getSessionReplayProperties() {\n return this.sessionReplay.getSessionReplayProperties();\n }\n}\n\nexport const sessionReplayPlugin: (options?: SessionReplayOptions) => EnrichmentPlugin = (\n options?: SessionReplayOptions,\n) => {\n return new SessionReplayPlugin(options);\n};\n"]}
|
|
1
|
+
{"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":";;;;AAAA,4DAAoH;AACpH,4EAU2C;AAC3C,8EAA2E;AAC3E,qCAAgD;AAEhD,qCAAoC;AAEpC;IAoBE,6BAAY,OAA8B;QAlB1C,SAAI,GAAG,mBAAmB,CAAC,UAAU,CAAC;QACtC,SAAI,GAAG,YAAqB,CAAC;QAC7B,sEAAsE;QACtE,6DAA6D;QAC7D,aAAa;QACb,WAAM,GAAyB,IAAI,CAAC;QAGpC,kBAAa,GAA2B;YACtC,KAAK,EAAE,8BAAK;YACZ,YAAY,EAAE,qCAAY;YAC1B,0BAA0B,EAAE,mDAA0B;YACtD,IAAI,EAAE,6BAAI;YACV,YAAY,EAAE,qCAAY;YAC1B,QAAQ,EAAE,iCAAQ;YAClB,2BAA2B,EAAE,oDAA2B;SACzD,CAAC;QAGA,IAAI,CAAC,OAAO,sBAAK,oBAAoB,EAAE,KAAK,IAAK,OAAO,CAAE,CAAC;QAC3D,IAAI,CAAC,aAAa,GAAG,IAA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n setSessionId,\n getSessionId,\n getSessionReplayProperties,\n flush,\n shutdown,\n evaluateTargetingAndCapture,\n AmplitudeSessionReplay,\n SessionReplayOptions as SessionReplayBrowserOptions,\n} from '@amplitude/session-replay-browser';\nimport { getAnalyticsConnector } from '@amplitude/analytics-client-common';\nimport { parseUserProperties } from './helpers';\nimport { SessionReplayOptions } from './typings/session-replay';\nimport { VERSION } from './version';\n\nexport class SessionReplayPlugin implements EnrichmentPlugin<BrowserClient, BrowserConfig> {\n static pluginName = '@amplitude/plugin-session-replay-browser';\n name = SessionReplayPlugin.pluginName;\n type = 'enrichment' as const;\n // this.config is defined in setup() which will always be called first\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: BrowserConfig | null = null;\n options: SessionReplayOptions;\n srInitOptions: SessionReplayBrowserOptions;\n sessionReplay: AmplitudeSessionReplay = {\n flush: flush,\n getSessionId: getSessionId,\n getSessionReplayProperties: getSessionReplayProperties,\n init: init,\n setSessionId: setSessionId,\n shutdown: shutdown,\n evaluateTargetingAndCapture: evaluateTargetingAndCapture,\n };\n\n constructor(options?: SessionReplayOptions) {\n this.options = { forceSessionTracking: false, ...options };\n this.srInitOptions = this.options;\n }\n\n async setup(config: BrowserConfig, _client: BrowserClient) {\n try {\n /* istanbul ignore next */\n config?.loggerProvider.log(`Installing @amplitude/plugin-session-replay, version ${VERSION}.`);\n\n this.config = config;\n\n if (this.options.forceSessionTracking) {\n if (typeof config.defaultTracking === 'boolean') {\n if (config.defaultTracking === false) {\n config.defaultTracking = {\n pageViews: false,\n formInteractions: false,\n fileDownloads: false,\n sessions: true,\n };\n }\n } else {\n config.defaultTracking = {\n ...config.defaultTracking,\n sessions: true,\n };\n }\n }\n const identityStore = getAnalyticsConnector(this.config.instanceName).identityStore;\n const userProperties = identityStore.getIdentity().userProperties;\n\n this.srInitOptions = {\n instanceName: this.config.instanceName,\n deviceId: this.options.deviceId ?? this.config.deviceId,\n optOut: this.config.optOut,\n sessionId: this.options.customSessionId ? undefined : this.config.sessionId,\n loggerProvider: this.config.loggerProvider,\n logLevel: this.config.logLevel,\n flushMaxRetries: this.config.flushMaxRetries,\n serverZone: this.config.serverZone,\n configServerUrl: this.options.configServerUrl || this.config.remoteConfig?.serverUrl,\n trackServerUrl: this.options.trackServerUrl,\n sampleRate: this.options.sampleRate,\n privacyConfig: {\n blockSelector: this.options.privacyConfig?.blockSelector,\n maskSelector: this.options.privacyConfig?.maskSelector,\n unmaskSelector: this.options.privacyConfig?.unmaskSelector,\n defaultMaskLevel: this.options.privacyConfig?.defaultMaskLevel,\n },\n debugMode: this.options.debugMode,\n shouldInlineStylesheet: this.options.shouldInlineStylesheet,\n version: { type: 'plugin', version: VERSION },\n performanceConfig: this.options.performanceConfig,\n storeType: this.options.storeType,\n useWebWorker: this.options.useWebWorker ?? this.options.experimental?.useWebWorker,\n userProperties: userProperties,\n omitElementTags: this.options.omitElementTags,\n applyBackgroundColorToBlockedElements: this.options.applyBackgroundColorToBlockedElements,\n interactionConfig: this.options.interactionConfig,\n captureDocumentTitle: this.options.captureDocumentTitle,\n enableUrlChangePolling: this.options.enableUrlChangePolling,\n urlChangePollingInterval: this.options.urlChangePollingInterval,\n };\n\n await this.sessionReplay.init(config.apiKey, this.srInitOptions).promise;\n } catch (error) {\n /* istanbul ignore next */\n config?.loggerProvider.error(`Session Replay: Failed to initialize due to ${(error as Error).message}`);\n }\n }\n\n async onSessionIdChanged(sessionId: number): Promise<void> {\n this.config?.loggerProvider.debug(\n `Analytics session id is changed to ${sessionId}, SR session id is ${String(this.sessionReplay.getSessionId())}.`,\n );\n await this.sessionReplay.setSessionId(sessionId).promise;\n }\n\n async onOptOutChanged(optOut: boolean): Promise<void> {\n this.config?.loggerProvider.debug(\n `optOut is changed to ${String(optOut)}, calling ${\n optOut ? 'sessionReplay.shutdown()' : 'sessionReplay.init()'\n }.`,\n );\n // TODO: compare optOut with this.sessionReplay.getOptOut().\n // Need to add getOptOut() to the interface AmplitudeSessionReplay first.\n if (optOut) {\n this.sessionReplay.shutdown();\n } else {\n this.config != null && (await this.sessionReplay.init(this.config.apiKey, this.srInitOptions).promise);\n }\n }\n\n async execute(event: Event) {\n try {\n if (this.options.customSessionId) {\n const sessionId = this.options.customSessionId(event);\n if (sessionId) {\n // On event, synchronize the session id to the custom session id from the event. This may\n // suffer from offline/delayed events messing up the state stored\n if (sessionId !== this.sessionReplay.getSessionId()) {\n await this.sessionReplay.setSessionId(sessionId).promise;\n }\n\n const sessionRecordingProperties = this.sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n } else {\n // On event, synchronize the session id to the what's on the browserConfig (source of truth)\n // Choosing not to read from event object here, concerned about offline/delayed events messing up the state stored\n // in SR.\n const sessionId: string | number | undefined = this.config?.sessionId;\n if (sessionId && sessionId !== this.sessionReplay.getSessionId()) {\n await this.sessionReplay.setSessionId(sessionId).promise;\n }\n\n // Treating config.sessionId as source of truth, if the event's session id doesn't match, the\n // event is not of the current session (offline/late events). In that case, don't tag the events\n if (sessionId && sessionId === event.session_id) {\n let userProperties;\n if (event.event_type === SpecialEventType.IDENTIFY) {\n userProperties = parseUserProperties(event);\n }\n await this.sessionReplay.evaluateTargetingAndCapture({ event, userProperties });\n const sessionRecordingProperties = this.sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n }\n\n return Promise.resolve(event);\n } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: Failed to enrich event due to ${(error as Error).message}`);\n return Promise.resolve(event);\n }\n }\n\n async teardown(): Promise<void> {\n try {\n this.sessionReplay.shutdown();\n // the following are initialized in setup() which will always be called first\n // here we reset them to null to prevent memory leaks\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.config = null;\n } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: teardown failed due to ${(error as Error).message}`);\n }\n }\n\n getSessionReplayProperties() {\n return this.sessionReplay.getSessionReplayProperties();\n }\n}\n\nexport const sessionReplayPlugin: (options?: SessionReplayOptions) => EnrichmentPlugin = (\n options?: SessionReplayOptions,\n) => {\n return new SessionReplayPlugin(options);\n};\n"]}
|
|
@@ -70,6 +70,13 @@ export interface SessionReplayOptions {
|
|
|
70
70
|
* @see {@link StandaloneSessionReplayOptions.storeType}
|
|
71
71
|
*/
|
|
72
72
|
storeType?: StoreType;
|
|
73
|
+
/**
|
|
74
|
+
* If true, the SDK will compress replay events using a web worker.
|
|
75
|
+
* This offloads compression to a separate thread, improving performance on the main thread.
|
|
76
|
+
*
|
|
77
|
+
* @defaultValue false
|
|
78
|
+
*/
|
|
79
|
+
useWebWorker?: boolean;
|
|
73
80
|
/**
|
|
74
81
|
* Override the device ID for session replay.
|
|
75
82
|
*/
|
|
@@ -81,7 +88,8 @@ export interface SessionReplayOptions {
|
|
|
81
88
|
*/
|
|
82
89
|
customSessionId?: (event: Event) => string | undefined;
|
|
83
90
|
/**
|
|
84
|
-
* @
|
|
91
|
+
* @deprecated Use `useWebWorker` instead. This will be removed in a future version.
|
|
92
|
+
* @see {@link StandaloneSessionReplayOptions.useWebWorker}
|
|
85
93
|
*/
|
|
86
94
|
experimental?: {
|
|
87
95
|
useWebWorker: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../../src/typings/session-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EACL,SAAS,EAGV,MAAM,mCAAmC,CAAC;AAE3C,MAAM,MAAM,SAAS,GACjB,OAAO,GACP,QAAQ,GACR,cAAc,CAAC;AAEnB,MAAM,WAAW,0BAA0B;IACzC,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAClC,gBAAgB,CAAC,EAAE,SAAS,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,8BAA8B;IAC7C,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,WAAW,8BAA8B;IAC7C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,0BAA0B,CAAC;IAC3C;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC;;OAEG;IACH,iBAAiB,CAAC,EAAE,8BAA8B,CAAC;IACnD;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,GAAG,SAAS,CAAC;IACvD
|
|
1
|
+
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../../src/typings/session-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA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IACtB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,GAAG,SAAS,CAAC;IACvD;;;OAGG;IACH,YAAY,CAAC,EAAE;QACb,YAAY,EAAE,OAAO,CAAC;KACvB,CAAC;IACF;;OAEG;IACH,eAAe,CAAC,EAAE;QAChB,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;IACF;;OAEG;IACH,qCAAqC,CAAC,EAAE,OAAO,CAAC;IAEhD,iBAAiB,CAAC,EAAE,8BAA8B,CAAC;IAEnD;;;;;;;OAOG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC;;;;;OAKG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../../src/typings/session-replay.ts"],"names":[],"mappings":"","sourcesContent":["import { Event } from '@amplitude/analytics-core';\nimport {\n StoreType,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n type SessionReplayOptions as StandaloneSessionReplayOptions, // used for documentation\n} from '@amplitude/session-replay-browser';\n\nexport type MaskLevel =\n | 'light' // only mask a subset of inputs that’s deemed sensitive - password, credit card, telephone #, email. These are information we never want to capture.\n | 'medium' // mask all inputs\n | 'conservative'; // mask all inputs and all texts\n\nexport interface SessionReplayPrivacyConfig {\n blockSelector?: string | string[];\n defaultMaskLevel?: MaskLevel;\n maskSelector?: string[];\n unmaskSelector?: string[];\n}\n\nexport interface SessionReplayPerformanceConfig {\n enabled: boolean;\n timeout?: number;\n}\n\n/**\n * UGC filter rule.\n */\nexport type UGCFilterRule = {\n /**\n * The selector of the UGC element.\n */\n selector: string;\n /**\n * The replacement text for the UGC element.\n */\n replacement: string;\n};\n\nexport interface SessionReplayInteractionConfig {\n trackEveryNms?: number;\n enabled: boolean; // defaults to false\n batch: boolean; // defaults to false\n /**\n * UGC filter rules.\n */\n ugcFilterRules?: UGCFilterRule[];\n}\n\nexport interface SessionReplayOptions {\n /**\n * @see {@link StandaloneSessionReplayOptions.sampleRate}\n */\n sampleRate?: number;\n /**\n * @see {@link StandaloneSessionReplayOptions.privacyConfig}\n */\n privacyConfig?: SessionReplayPrivacyConfig;\n /**\n * @see {@link StandaloneSessionReplayOptions.debugMode}\n */\n debugMode?: boolean;\n /**\n * If this is enabled we will force the browser SDK to also send start and end session events.\n */\n forceSessionTracking?: boolean;\n /**\n * @see {@link StandaloneSessionReplayOptions.configServerUrl}\n */\n configServerUrl?: string;\n /**\n * @see {@link StandaloneSessionReplayOptions.trackServerUrl}\n */\n trackServerUrl?: string;\n /**\n * @see {@link StandaloneSessionReplayOptions.shouldInlineStylesheet}\n */\n shouldInlineStylesheet?: boolean;\n /**\n * @see {@link StandaloneSessionReplayOptions.performanceConfig}\n */\n performanceConfig?: SessionReplayPerformanceConfig;\n /**\n * @see {@link StandaloneSessionReplayOptions.storeType}\n */\n storeType?: StoreType;\n /**\n * Override the device ID for session replay.\n */\n deviceId?: string;\n /**\n * Dynamically overrides the session ID for replay. Ensure stability to avoid frequent restarts.\n * @param event Browser SDK event\n * @returns The session ID for the session replay.\n */\n customSessionId?: (event: Event) => string | undefined;\n /**\n * @see {@link StandaloneSessionReplayOptions.
|
|
1
|
+
{"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../../src/typings/session-replay.ts"],"names":[],"mappings":"","sourcesContent":["import { Event } from '@amplitude/analytics-core';\nimport {\n StoreType,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n type SessionReplayOptions as StandaloneSessionReplayOptions, // used for documentation\n} from '@amplitude/session-replay-browser';\n\nexport type MaskLevel =\n | 'light' // only mask a subset of inputs that’s deemed sensitive - password, credit card, telephone #, email. These are information we never want to capture.\n | 'medium' // mask all inputs\n | 'conservative'; // mask all inputs and all texts\n\nexport interface SessionReplayPrivacyConfig {\n blockSelector?: string | string[];\n defaultMaskLevel?: MaskLevel;\n maskSelector?: string[];\n unmaskSelector?: string[];\n}\n\nexport interface SessionReplayPerformanceConfig {\n enabled: boolean;\n timeout?: number;\n}\n\n/**\n * UGC filter rule.\n */\nexport type UGCFilterRule = {\n /**\n * The selector of the UGC element.\n */\n selector: string;\n /**\n * The replacement text for the UGC element.\n */\n replacement: string;\n};\n\nexport interface SessionReplayInteractionConfig {\n trackEveryNms?: number;\n enabled: boolean; // defaults to false\n batch: boolean; // defaults to false\n /**\n * UGC filter rules.\n */\n ugcFilterRules?: UGCFilterRule[];\n}\n\nexport interface SessionReplayOptions {\n /**\n * @see {@link StandaloneSessionReplayOptions.sampleRate}\n */\n sampleRate?: number;\n /**\n * @see {@link StandaloneSessionReplayOptions.privacyConfig}\n */\n privacyConfig?: SessionReplayPrivacyConfig;\n /**\n * @see {@link StandaloneSessionReplayOptions.debugMode}\n */\n debugMode?: boolean;\n /**\n * If this is enabled we will force the browser SDK to also send start and end session events.\n */\n forceSessionTracking?: boolean;\n /**\n * @see {@link StandaloneSessionReplayOptions.configServerUrl}\n */\n configServerUrl?: string;\n /**\n * @see {@link StandaloneSessionReplayOptions.trackServerUrl}\n */\n trackServerUrl?: string;\n /**\n * @see {@link StandaloneSessionReplayOptions.shouldInlineStylesheet}\n */\n shouldInlineStylesheet?: boolean;\n /**\n * @see {@link StandaloneSessionReplayOptions.performanceConfig}\n */\n performanceConfig?: SessionReplayPerformanceConfig;\n /**\n * @see {@link StandaloneSessionReplayOptions.storeType}\n */\n storeType?: StoreType;\n /**\n * If true, the SDK will compress replay events using a web worker.\n * This offloads compression to a separate thread, improving performance on the main thread.\n *\n * @defaultValue false\n */\n useWebWorker?: boolean;\n /**\n * Override the device ID for session replay.\n */\n deviceId?: string;\n /**\n * Dynamically overrides the session ID for replay. Ensure stability to avoid frequent restarts.\n * @param event Browser SDK event\n * @returns The session ID for the session replay.\n */\n customSessionId?: (event: Event) => string | undefined;\n /**\n * @deprecated Use `useWebWorker` instead. This will be removed in a future version.\n * @see {@link StandaloneSessionReplayOptions.useWebWorker}\n */\n experimental?: {\n useWebWorker: boolean;\n };\n /**\n * @see {@link StandaloneSessionReplayOptions.omitElementTags}\n */\n omitElementTags?: {\n script?: boolean;\n comment?: boolean;\n };\n /**\n * If true, applies a background color to blocked elements for visual masking. Defaults to false.\n */\n applyBackgroundColorToBlockedElements?: boolean;\n\n interactionConfig?: SessionReplayInteractionConfig;\n\n /**\n * Enables URL change polling as a fallback for SPA route tracking.\n * When enabled, the SDK will periodically check for URL changes every second\n * in addition to patching the History API. This is useful for edge cases where\n * route changes might bypass the standard History API methods.\n *\n * @defaultValue false\n */\n enableUrlChangePolling?: boolean;\n /**\n * Specifies the interval in milliseconds for URL change polling when enableUrlChangePolling is true.\n * The SDK will check for URL changes at this interval as a fallback for SPA route tracking.\n *\n * @defaultValue 1000\n */\n urlChangePollingInterval?: number;\n /**\n * Whether to capture document title in URL change events.\n * When disabled, the title field will be empty in URL change events.\n *\n * @defaultValue false\n */\n captureDocumentTitle?: boolean;\n}\n"]}
|
package/lib/cjs/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "1.
|
|
1
|
+
export declare const VERSION = "1.24.1";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/lib/cjs/version.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,WAAW,CAAC"}
|
package/lib/cjs/version.js
CHANGED
package/lib/cjs/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAA,oDAAoD;AACvC,QAAA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAA,oDAAoD;AACvC,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// Autogenerated by `yarn version-file`. DO NOT EDIT\nexport const VERSION = '1.24.1';\n"]}
|
|
@@ -25,13 +25,13 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
25
25
|
this.srInitOptions = this.options;
|
|
26
26
|
}
|
|
27
27
|
SessionReplayPlugin.prototype.setup = function (config, _client) {
|
|
28
|
-
var _a, _b, _c, _d, _e, _f;
|
|
28
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
29
29
|
return __awaiter(this, void 0, void 0, function () {
|
|
30
30
|
var identityStore, userProperties, error_1;
|
|
31
|
-
return __generator(this, function (
|
|
32
|
-
switch (
|
|
31
|
+
return __generator(this, function (_j) {
|
|
32
|
+
switch (_j.label) {
|
|
33
33
|
case 0:
|
|
34
|
-
|
|
34
|
+
_j.trys.push([0, 2, , 3]);
|
|
35
35
|
/* istanbul ignore next */
|
|
36
36
|
config === null || config === void 0 ? void 0 : config.loggerProvider.log("Installing @amplitude/plugin-session-replay, version ".concat(VERSION, "."));
|
|
37
37
|
this.config = config;
|
|
@@ -75,7 +75,7 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
75
75
|
version: { type: 'plugin', version: VERSION },
|
|
76
76
|
performanceConfig: this.options.performanceConfig,
|
|
77
77
|
storeType: this.options.storeType,
|
|
78
|
-
|
|
78
|
+
useWebWorker: (_g = this.options.useWebWorker) !== null && _g !== void 0 ? _g : (_h = this.options.experimental) === null || _h === void 0 ? void 0 : _h.useWebWorker,
|
|
79
79
|
userProperties: userProperties,
|
|
80
80
|
omitElementTags: this.options.omitElementTags,
|
|
81
81
|
applyBackgroundColorToBlockedElements: this.options.applyBackgroundColorToBlockedElements,
|
|
@@ -86,10 +86,10 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
86
86
|
};
|
|
87
87
|
return [4 /*yield*/, this.sessionReplay.init(config.apiKey, this.srInitOptions).promise];
|
|
88
88
|
case 1:
|
|
89
|
-
|
|
89
|
+
_j.sent();
|
|
90
90
|
return [3 /*break*/, 3];
|
|
91
91
|
case 2:
|
|
92
|
-
error_1 =
|
|
92
|
+
error_1 = _j.sent();
|
|
93
93
|
/* istanbul ignore next */
|
|
94
94
|
config === null || config === void 0 ? void 0 : config.loggerProvider.error("Session Replay: Failed to initialize due to ".concat(error_1.message));
|
|
95
95
|
return [3 /*break*/, 3];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":";AAAA,OAAO,EAAyD,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AACpH,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,YAAY,EACZ,0BAA0B,EAC1B,KAAK,EACL,QAAQ,EACR,2BAA2B,GAG5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;IAoBE,6BAAY,OAA8B;QAlB1C,SAAI,GAAG,mBAAmB,CAAC,UAAU,CAAC;QACtC,SAAI,GAAG,YAAqB,CAAC;QAC7B,sEAAsE;QACtE,6DAA6D;QAC7D,aAAa;QACb,WAAM,GAAyB,IAAI,CAAC;QAGpC,kBAAa,GAA2B;YACtC,KAAK,EAAE,KAAK;YACZ,YAAY,EAAE,YAAY;YAC1B,0BAA0B,EAAE,0BAA0B;YACtD,IAAI,EAAE,IAAI;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C;AAC1C,CAAC,CAAC","sourcesContent":["import { BrowserClient, BrowserConfig, EnrichmentPlugin, Event, SpecialEventType } from '@amplitude/analytics-core';\nimport {\n init,\n setSessionId,\n getSessionId,\n getSessionReplayProperties,\n flush,\n shutdown,\n evaluateTargetingAndCapture,\n AmplitudeSessionReplay,\n SessionReplayOptions as SessionReplayBrowserOptions,\n} from '@amplitude/session-replay-browser';\nimport { getAnalyticsConnector } from '@amplitude/analytics-client-common';\nimport { parseUserProperties } from './helpers';\nimport { SessionReplayOptions } from './typings/session-replay';\nimport { VERSION } from './version';\n\nexport class SessionReplayPlugin implements EnrichmentPlugin<BrowserClient, BrowserConfig> {\n static pluginName = '@amplitude/plugin-session-replay-browser';\n name = SessionReplayPlugin.pluginName;\n type = 'enrichment' as const;\n // this.config is defined in setup() which will always be called first\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: BrowserConfig | null = null;\n options: SessionReplayOptions;\n srInitOptions: SessionReplayBrowserOptions;\n sessionReplay: AmplitudeSessionReplay = {\n flush: flush,\n getSessionId: getSessionId,\n getSessionReplayProperties: getSessionReplayProperties,\n init: init,\n setSessionId: setSessionId,\n shutdown: shutdown,\n evaluateTargetingAndCapture: evaluateTargetingAndCapture,\n };\n\n constructor(options?: SessionReplayOptions) {\n this.options = { forceSessionTracking: false, ...options };\n this.srInitOptions = this.options;\n }\n\n async setup(config: BrowserConfig, _client: BrowserClient) {\n try {\n /* istanbul ignore next */\n config?.loggerProvider.log(`Installing @amplitude/plugin-session-replay, version ${VERSION}.`);\n\n this.config = config;\n\n if (this.options.forceSessionTracking) {\n if (typeof config.defaultTracking === 'boolean') {\n if (config.defaultTracking === false) {\n config.defaultTracking = {\n pageViews: false,\n formInteractions: false,\n fileDownloads: false,\n sessions: true,\n };\n }\n } else {\n config.defaultTracking = {\n ...config.defaultTracking,\n sessions: true,\n };\n }\n }\n const identityStore = getAnalyticsConnector(this.config.instanceName).identityStore;\n const userProperties = identityStore.getIdentity().userProperties;\n\n this.srInitOptions = {\n instanceName: this.config.instanceName,\n deviceId: this.options.deviceId ?? this.config.deviceId,\n optOut: this.config.optOut,\n sessionId: this.options.customSessionId ? undefined : this.config.sessionId,\n loggerProvider: this.config.loggerProvider,\n logLevel: this.config.logLevel,\n flushMaxRetries: this.config.flushMaxRetries,\n serverZone: this.config.serverZone,\n configServerUrl: this.options.configServerUrl || this.config.remoteConfig?.serverUrl,\n trackServerUrl: this.options.trackServerUrl,\n sampleRate: this.options.sampleRate,\n privacyConfig: {\n blockSelector: this.options.privacyConfig?.blockSelector,\n maskSelector: this.options.privacyConfig?.maskSelector,\n unmaskSelector: this.options.privacyConfig?.unmaskSelector,\n defaultMaskLevel: this.options.privacyConfig?.defaultMaskLevel,\n },\n debugMode: this.options.debugMode,\n shouldInlineStylesheet: this.options.shouldInlineStylesheet,\n version: { type: 'plugin', version: VERSION },\n performanceConfig: this.options.performanceConfig,\n storeType: this.options.storeType,\n experimental: this.options.experimental,\n userProperties: userProperties,\n omitElementTags: this.options.omitElementTags,\n applyBackgroundColorToBlockedElements: this.options.applyBackgroundColorToBlockedElements,\n interactionConfig: this.options.interactionConfig,\n captureDocumentTitle: this.options.captureDocumentTitle,\n enableUrlChangePolling: this.options.enableUrlChangePolling,\n urlChangePollingInterval: this.options.urlChangePollingInterval,\n };\n\n await this.sessionReplay.init(config.apiKey, this.srInitOptions).promise;\n } catch (error) {\n /* istanbul ignore next */\n config?.loggerProvider.error(`Session Replay: Failed to initialize due to ${(error as Error).message}`);\n }\n }\n\n async onSessionIdChanged(sessionId: number): Promise<void> {\n this.config?.loggerProvider.debug(\n `Analytics session id is changed to ${sessionId}, SR session id is ${String(this.sessionReplay.getSessionId())}.`,\n );\n await this.sessionReplay.setSessionId(sessionId).promise;\n }\n\n async onOptOutChanged(optOut: boolean): Promise<void> {\n this.config?.loggerProvider.debug(\n `optOut is changed to ${String(optOut)}, calling ${\n optOut ? 'sessionReplay.shutdown()' : 'sessionReplay.init()'\n }.`,\n );\n // TODO: compare optOut with this.sessionReplay.getOptOut().\n // Need to add getOptOut() to the interface AmplitudeSessionReplay first.\n if (optOut) {\n this.sessionReplay.shutdown();\n } else {\n this.config != null && (await this.sessionReplay.init(this.config.apiKey, this.srInitOptions).promise);\n }\n }\n\n async execute(event: Event) {\n try {\n if (this.options.customSessionId) {\n const sessionId = this.options.customSessionId(event);\n if (sessionId) {\n // On event, synchronize the session id to the custom session id from the event. This may\n // suffer from offline/delayed events messing up the state stored\n if (sessionId !== this.sessionReplay.getSessionId()) {\n await this.sessionReplay.setSessionId(sessionId).promise;\n }\n\n const sessionRecordingProperties = this.sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n } else {\n // On event, synchronize the session id to the what's on the browserConfig (source of truth)\n // Choosing not to read from event object here, concerned about offline/delayed events messing up the state stored\n // in SR.\n const sessionId: string | number | undefined = this.config?.sessionId;\n if (sessionId && sessionId !== this.sessionReplay.getSessionId()) {\n await this.sessionReplay.setSessionId(sessionId).promise;\n }\n\n // Treating config.sessionId as source of truth, if the event's session id doesn't match, the\n // event is not of the current session (offline/late events). In that case, don't tag the events\n if (sessionId && sessionId === event.session_id) {\n let userProperties;\n if (event.event_type === SpecialEventType.IDENTIFY) {\n userProperties = parseUserProperties(event);\n }\n await this.sessionReplay.evaluateTargetingAndCapture({ event, userProperties });\n const sessionRecordingProperties = this.sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n }\n\n return Promise.resolve(event);\n } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: Failed to enrich event due to ${(error as Error).message}`);\n return Promise.resolve(event);\n }\n }\n\n async teardown(): Promise<void> {\n try {\n this.sessionReplay.shutdown();\n // the following are initialized in setup() which will always be called first\n // here we reset them to null to prevent memory leaks\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.config = null;\n } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: teardown failed due to ${(error as Error).message}`);\n }\n }\n\n getSessionReplayProperties() {\n return this.sessionReplay.getSessionReplayProperties();\n }\n}\n\nexport const sessionReplayPlugin: (options?: SessionReplayOptions) => EnrichmentPlugin = (\n options?: SessionReplayOptions,\n) => {\n return new SessionReplayPlugin(options);\n};\n"]}
|
|
1
|
+
{"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":";AAAA,OAAO,EAAyD,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AACpH,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,YAAY,EACZ,0BAA0B,EAC1B,KAAK,EACL,QAAQ,EACR,2BAA2B,GAG5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;IAoBE,6BAAY,OAA8B;QAlB1C,SAAI,GAAG,mBAAmB,CAAC,UAAU,CAAC;QACtC,SAAI,GAAG,YAAqB,CAAC;QAC7B,sEAAsE;QACtE,6DAA6D;QAC7D,aAAa;QACb,WAAM,GAAyB,IAAI,CAAC;QAGpC,kBAAa,GAA2B;YACtC,KAAK,EAAE,KAAK;YACZ,YAAY,EAAE,YAAY;YAC1B,0BAA0B,EAAE,0BAA0B;YACtD,IAAI,EAAE,IAAI;YACV,YAAY,EAAE,YAAY;YAC1B,QAAQ,EAAE,QAAQ;YAClB,2BAA2B,EAAE,2BAA2B;SACzD,CAAC;QAGA,IAAI,CAAC,OAAO,cAAK,oBAAoB,EAAE,KAAK,IAAK,OAAO,CAAE,CAAC;QAC3D,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC;IACpC,CAAC;IAEK,mCAAK,GAAX,UAAY,MAAqB,EAAE,O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IAAI,CAAC,aAAa,CAAC,0BAA0B,EAAE,CAAC;wBACnF,KAAK,CAAC,gBAAgB,yBACjB,KAAK,CAAC,gBAAgB,GACtB,0BAA0B,CAC9B,CAAC;;4BAIN,sBAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAC;;;wBAE9B,0BAA0B;wBAC1B,MAAA,IAAI,CAAC,MAAM,0CAAE,cAAc,CAAC,KAAK,CAAC,wDAAkD,OAAe,CAAC,OAAO,CAAE,CAAC,CAAC;wBAC/G,sBAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAC;;;;;KAEjC;IAEK,sCAAQ,GAAd;;;;gBACE,IAAI;oBACF,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;oBAC9B,6EAA6E;oBAC7E,qDAAqD;oBACrD,6DAA6D;oBAC7D,aAAa;oBACb,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;iBACpB;gBAAC,OAAO,KAAK,EAAE;oBACd,0BAA0B;oBAC1B,MAAA,IAAI,CAAC,MAAM,0CAAE,cAAc,CAAC,KAAK,CAAC,iDAA2C,KAAe,CAAC,OAAO,CAAE,CAAC,CAAC;iBACzG;;;;KACF;IAED,wDAA0B,GAA1B;QACE,OAAO,IAAI,CAAC,aAAa,CAAC,0BAA0B,EAAE,CAAC;IACzD,CAAC;IAnLM,8BAAU,GAAG,0CAA0C,CAAC;IAoLjE,0BAAC;CAAA,AArLD,IAqLC;SArLY,mBAAmB;AAuLhC,MAAM,CAAC,IAAM,mBAAmB,GAAyD,UACvF,OAA8B;IAE9B,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC,CAAC","sourcesContent":["import { BrowserClient, BrowserConfig, EnrichmentPlugin, Event, SpecialEventType } from '@amplitude/analytics-core';\nimport {\n init,\n setSessionId,\n getSessionId,\n getSessionReplayProperties,\n flush,\n shutdown,\n evaluateTargetingAndCapture,\n AmplitudeSessionReplay,\n SessionReplayOptions as SessionReplayBrowserOptions,\n} from '@amplitude/session-replay-browser';\nimport { getAnalyticsConnector } from '@amplitude/analytics-client-common';\nimport { parseUserProperties } from './helpers';\nimport { SessionReplayOptions } from './typings/session-replay';\nimport { VERSION } from './version';\n\nexport class SessionReplayPlugin implements EnrichmentPlugin<BrowserClient, BrowserConfig> {\n static pluginName = '@amplitude/plugin-session-replay-browser';\n name = SessionReplayPlugin.pluginName;\n type = 'enrichment' as const;\n // this.config is defined in setup() which will always be called first\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: BrowserConfig | null = null;\n options: SessionReplayOptions;\n srInitOptions: SessionReplayBrowserOptions;\n sessionReplay: AmplitudeSessionReplay = {\n flush: flush,\n getSessionId: getSessionId,\n getSessionReplayProperties: getSessionReplayProperties,\n init: init,\n setSessionId: setSessionId,\n shutdown: shutdown,\n evaluateTargetingAndCapture: evaluateTargetingAndCapture,\n };\n\n constructor(options?: SessionReplayOptions) {\n this.options = { forceSessionTracking: false, ...options };\n this.srInitOptions = this.options;\n }\n\n async setup(config: BrowserConfig, _client: BrowserClient) {\n try {\n /* istanbul ignore next */\n config?.loggerProvider.log(`Installing @amplitude/plugin-session-replay, version ${VERSION}.`);\n\n this.config = config;\n\n if (this.options.forceSessionTracking) {\n if (typeof config.defaultTracking === 'boolean') {\n if (config.defaultTracking === false) {\n config.defaultTracking = {\n pageViews: false,\n formInteractions: false,\n fileDownloads: false,\n sessions: true,\n };\n }\n } else {\n config.defaultTracking = {\n ...config.defaultTracking,\n sessions: true,\n };\n }\n }\n const identityStore = getAnalyticsConnector(this.config.instanceName).identityStore;\n const userProperties = identityStore.getIdentity().userProperties;\n\n this.srInitOptions = {\n instanceName: this.config.instanceName,\n deviceId: this.options.deviceId ?? this.config.deviceId,\n optOut: this.config.optOut,\n sessionId: this.options.customSessionId ? undefined : this.config.sessionId,\n loggerProvider: this.config.loggerProvider,\n logLevel: this.config.logLevel,\n flushMaxRetries: this.config.flushMaxRetries,\n serverZone: this.config.serverZone,\n configServerUrl: this.options.configServerUrl || this.config.remoteConfig?.serverUrl,\n trackServerUrl: this.options.trackServerUrl,\n sampleRate: this.options.sampleRate,\n privacyConfig: {\n blockSelector: this.options.privacyConfig?.blockSelector,\n maskSelector: this.options.privacyConfig?.maskSelector,\n unmaskSelector: this.options.privacyConfig?.unmaskSelector,\n defaultMaskLevel: this.options.privacyConfig?.defaultMaskLevel,\n },\n debugMode: this.options.debugMode,\n shouldInlineStylesheet: this.options.shouldInlineStylesheet,\n version: { type: 'plugin', version: VERSION },\n performanceConfig: this.options.performanceConfig,\n storeType: this.options.storeType,\n useWebWorker: this.options.useWebWorker ?? this.options.experimental?.useWebWorker,\n userProperties: userProperties,\n omitElementTags: this.options.omitElementTags,\n applyBackgroundColorToBlockedElements: this.options.applyBackgroundColorToBlockedElements,\n interactionConfig: this.options.interactionConfig,\n captureDocumentTitle: this.options.captureDocumentTitle,\n enableUrlChangePolling: this.options.enableUrlChangePolling,\n urlChangePollingInterval: this.options.urlChangePollingInterval,\n };\n\n await this.sessionReplay.init(config.apiKey, this.srInitOptions).promise;\n } catch (error) {\n /* istanbul ignore next */\n config?.loggerProvider.error(`Session Replay: Failed to initialize due to ${(error as Error).message}`);\n }\n }\n\n async onSessionIdChanged(sessionId: number): Promise<void> {\n this.config?.loggerProvider.debug(\n `Analytics session id is changed to ${sessionId}, SR session id is ${String(this.sessionReplay.getSessionId())}.`,\n );\n await this.sessionReplay.setSessionId(sessionId).promise;\n }\n\n async onOptOutChanged(optOut: boolean): Promise<void> {\n this.config?.loggerProvider.debug(\n `optOut is changed to ${String(optOut)}, calling ${\n optOut ? 'sessionReplay.shutdown()' : 'sessionReplay.init()'\n }.`,\n );\n // TODO: compare optOut with this.sessionReplay.getOptOut().\n // Need to add getOptOut() to the interface AmplitudeSessionReplay first.\n if (optOut) {\n this.sessionReplay.shutdown();\n } else {\n this.config != null && (await this.sessionReplay.init(this.config.apiKey, this.srInitOptions).promise);\n }\n }\n\n async execute(event: Event) {\n try {\n if (this.options.customSessionId) {\n const sessionId = this.options.customSessionId(event);\n if (sessionId) {\n // On event, synchronize the session id to the custom session id from the event. This may\n // suffer from offline/delayed events messing up the state stored\n if (sessionId !== this.sessionReplay.getSessionId()) {\n await this.sessionReplay.setSessionId(sessionId).promise;\n }\n\n const sessionRecordingProperties = this.sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n } else {\n // On event, synchronize the session id to the what's on the browserConfig (source of truth)\n // Choosing not to read from event object here, concerned about offline/delayed events messing up the state stored\n // in SR.\n const sessionId: string | number | undefined = this.config?.sessionId;\n if (sessionId && sessionId !== this.sessionReplay.getSessionId()) {\n await this.sessionReplay.setSessionId(sessionId).promise;\n }\n\n // Treating config.sessionId as source of truth, if the event's session id doesn't match, the\n // event is not of the current session (offline/late events). In that case, don't tag the events\n if (sessionId && sessionId === event.session_id) {\n let userProperties;\n if (event.event_type === SpecialEventType.IDENTIFY) {\n userProperties = parseUserProperties(event);\n }\n await this.sessionReplay.evaluateTargetingAndCapture({ event, userProperties });\n const sessionRecordingProperties = this.sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n }\n\n return Promise.resolve(event);\n } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: Failed to enrich event due to ${(error as Error).message}`);\n return Promise.resolve(event);\n }\n }\n\n async teardown(): Promise<void> {\n try {\n this.sessionReplay.shutdown();\n // the following are initialized in setup() which will always be called first\n // here we reset them to null to prevent memory leaks\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.config = null;\n } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: teardown failed due to ${(error as Error).message}`);\n }\n }\n\n getSessionReplayProperties() {\n return this.sessionReplay.getSessionReplayProperties();\n }\n}\n\nexport const sessionReplayPlugin: (options?: SessionReplayOptions) => EnrichmentPlugin = (\n options?: SessionReplayOptions,\n) => {\n return new SessionReplayPlugin(options);\n};\n"]}
|
|
@@ -70,6 +70,13 @@ export interface SessionReplayOptions {
|
|
|
70
70
|
* @see {@link StandaloneSessionReplayOptions.storeType}
|
|
71
71
|
*/
|
|
72
72
|
storeType?: StoreType;
|
|
73
|
+
/**
|
|
74
|
+
* If true, the SDK will compress replay events using a web worker.
|
|
75
|
+
* This offloads compression to a separate thread, improving performance on the main thread.
|
|
76
|
+
*
|
|
77
|
+
* @defaultValue false
|
|
78
|
+
*/
|
|
79
|
+
useWebWorker?: boolean;
|
|
73
80
|
/**
|
|
74
81
|
* Override the device ID for session replay.
|
|
75
82
|
*/
|
|
@@ -81,7 +88,8 @@ export interface SessionReplayOptions {
|
|
|
81
88
|
*/
|
|
82
89
|
customSessionId?: (event: Event) => string | undefined;
|
|
83
90
|
/**
|
|
84
|
-
* @
|
|
91
|
+
* @deprecated Use `useWebWorker` instead. This will be removed in a future version.
|
|
92
|
+
* @see {@link StandaloneSessionReplayOptions.useWebWorker}
|
|
85
93
|
*/
|
|
86
94
|
experimental?: {
|
|
87
95
|
useWebWorker: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../../src/typings/session-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EACL,SAAS,EAGV,MAAM,mCAAmC,CAAC;AAE3C,MAAM,MAAM,SAAS,GACjB,OAAO,GACP,QAAQ,GACR,cAAc,CAAC;AAEnB,MAAM,WAAW,0BAA0B;IACzC,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAClC,gBAAgB,CAAC,EAAE,SAAS,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,8BAA8B;IAC7C,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,WAAW,8BAA8B;IAC7C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,0BAA0B,CAAC;IAC3C;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC;;OAEG;IACH,iBAAiB,CAAC,EAAE,8BAA8B,CAAC;IACnD;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,GAAG,SAAS,CAAC;IACvD
|
|
1
|
+
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../../src/typings/session-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EACL,SAAS,EAGV,MAAM,mCAAmC,CAAC;AAE3C,MAAM,MAAM,SAAS,GACjB,OAAO,GACP,QA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ClB;;;;OAIG;IACH,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,GAAG,SAAS,CAAC;IACvD;;;OAGG;IACH,YAAY,CAAC,EAAE;QACb,YAAY,EAAE,OAAO,CAAC;KACvB,CAAC;IACF;;OAEG;IACH,eAAe,CAAC,EAAE;QAChB,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;IACF;;OAEG;IACH,qCAAqC,CAAC,EAAE,OAAO,CAAC;IAEhD,iBAAiB,CAAC,EAAE,8BAA8B,CAAC;IAEnD;;;;;;;OAOG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC;;;;;OAKG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../../src/typings/session-replay.ts"],"names":[],"mappings":"","sourcesContent":["import { Event } from '@amplitude/analytics-core';\nimport {\n StoreType,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n type SessionReplayOptions as StandaloneSessionReplayOptions, // used for documentation\n} from '@amplitude/session-replay-browser';\n\nexport type MaskLevel =\n | 'light' // only mask a subset of inputs that’s deemed sensitive - password, credit card, telephone #, email. These are information we never want to capture.\n | 'medium' // mask all inputs\n | 'conservative'; // mask all inputs and all texts\n\nexport interface SessionReplayPrivacyConfig {\n blockSelector?: string | string[];\n defaultMaskLevel?: MaskLevel;\n maskSelector?: string[];\n unmaskSelector?: string[];\n}\n\nexport interface SessionReplayPerformanceConfig {\n enabled: boolean;\n timeout?: number;\n}\n\n/**\n * UGC filter rule.\n */\nexport type UGCFilterRule = {\n /**\n * The selector of the UGC element.\n */\n selector: string;\n /**\n * The replacement text for the UGC element.\n */\n replacement: string;\n};\n\nexport interface SessionReplayInteractionConfig {\n trackEveryNms?: number;\n enabled: boolean; // defaults to false\n batch: boolean; // defaults to false\n /**\n * UGC filter rules.\n */\n ugcFilterRules?: UGCFilterRule[];\n}\n\nexport interface SessionReplayOptions {\n /**\n * @see {@link StandaloneSessionReplayOptions.sampleRate}\n */\n sampleRate?: number;\n /**\n * @see {@link StandaloneSessionReplayOptions.privacyConfig}\n */\n privacyConfig?: SessionReplayPrivacyConfig;\n /**\n * @see {@link StandaloneSessionReplayOptions.debugMode}\n */\n debugMode?: boolean;\n /**\n * If this is enabled we will force the browser SDK to also send start and end session events.\n */\n forceSessionTracking?: boolean;\n /**\n * @see {@link StandaloneSessionReplayOptions.configServerUrl}\n */\n configServerUrl?: string;\n /**\n * @see {@link StandaloneSessionReplayOptions.trackServerUrl}\n */\n trackServerUrl?: string;\n /**\n * @see {@link StandaloneSessionReplayOptions.shouldInlineStylesheet}\n */\n shouldInlineStylesheet?: boolean;\n /**\n * @see {@link StandaloneSessionReplayOptions.performanceConfig}\n */\n performanceConfig?: SessionReplayPerformanceConfig;\n /**\n * @see {@link StandaloneSessionReplayOptions.storeType}\n */\n storeType?: StoreType;\n /**\n * Override the device ID for session replay.\n */\n deviceId?: string;\n /**\n * Dynamically overrides the session ID for replay. Ensure stability to avoid frequent restarts.\n * @param event Browser SDK event\n * @returns The session ID for the session replay.\n */\n customSessionId?: (event: Event) => string | undefined;\n /**\n * @see {@link StandaloneSessionReplayOptions.
|
|
1
|
+
{"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../../src/typings/session-replay.ts"],"names":[],"mappings":"","sourcesContent":["import { Event } from '@amplitude/analytics-core';\nimport {\n StoreType,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n type SessionReplayOptions as StandaloneSessionReplayOptions, // used for documentation\n} from '@amplitude/session-replay-browser';\n\nexport type MaskLevel =\n | 'light' // only mask a subset of inputs that’s deemed sensitive - password, credit card, telephone #, email. These are information we never want to capture.\n | 'medium' // mask all inputs\n | 'conservative'; // mask all inputs and all texts\n\nexport interface SessionReplayPrivacyConfig {\n blockSelector?: string | string[];\n defaultMaskLevel?: MaskLevel;\n maskSelector?: string[];\n unmaskSelector?: string[];\n}\n\nexport interface SessionReplayPerformanceConfig {\n enabled: boolean;\n timeout?: number;\n}\n\n/**\n * UGC filter rule.\n */\nexport type UGCFilterRule = {\n /**\n * The selector of the UGC element.\n */\n selector: string;\n /**\n * The replacement text for the UGC element.\n */\n replacement: string;\n};\n\nexport interface SessionReplayInteractionConfig {\n trackEveryNms?: number;\n enabled: boolean; // defaults to false\n batch: boolean; // defaults to false\n /**\n * UGC filter rules.\n */\n ugcFilterRules?: UGCFilterRule[];\n}\n\nexport interface SessionReplayOptions {\n /**\n * @see {@link StandaloneSessionReplayOptions.sampleRate}\n */\n sampleRate?: number;\n /**\n * @see {@link StandaloneSessionReplayOptions.privacyConfig}\n */\n privacyConfig?: SessionReplayPrivacyConfig;\n /**\n * @see {@link StandaloneSessionReplayOptions.debugMode}\n */\n debugMode?: boolean;\n /**\n * If this is enabled we will force the browser SDK to also send start and end session events.\n */\n forceSessionTracking?: boolean;\n /**\n * @see {@link StandaloneSessionReplayOptions.configServerUrl}\n */\n configServerUrl?: string;\n /**\n * @see {@link StandaloneSessionReplayOptions.trackServerUrl}\n */\n trackServerUrl?: string;\n /**\n * @see {@link StandaloneSessionReplayOptions.shouldInlineStylesheet}\n */\n shouldInlineStylesheet?: boolean;\n /**\n * @see {@link StandaloneSessionReplayOptions.performanceConfig}\n */\n performanceConfig?: SessionReplayPerformanceConfig;\n /**\n * @see {@link StandaloneSessionReplayOptions.storeType}\n */\n storeType?: StoreType;\n /**\n * If true, the SDK will compress replay events using a web worker.\n * This offloads compression to a separate thread, improving performance on the main thread.\n *\n * @defaultValue false\n */\n useWebWorker?: boolean;\n /**\n * Override the device ID for session replay.\n */\n deviceId?: string;\n /**\n * Dynamically overrides the session ID for replay. Ensure stability to avoid frequent restarts.\n * @param event Browser SDK event\n * @returns The session ID for the session replay.\n */\n customSessionId?: (event: Event) => string | undefined;\n /**\n * @deprecated Use `useWebWorker` instead. This will be removed in a future version.\n * @see {@link StandaloneSessionReplayOptions.useWebWorker}\n */\n experimental?: {\n useWebWorker: boolean;\n };\n /**\n * @see {@link StandaloneSessionReplayOptions.omitElementTags}\n */\n omitElementTags?: {\n script?: boolean;\n comment?: boolean;\n };\n /**\n * If true, applies a background color to blocked elements for visual masking. Defaults to false.\n */\n applyBackgroundColorToBlockedElements?: boolean;\n\n interactionConfig?: SessionReplayInteractionConfig;\n\n /**\n * Enables URL change polling as a fallback for SPA route tracking.\n * When enabled, the SDK will periodically check for URL changes every second\n * in addition to patching the History API. This is useful for edge cases where\n * route changes might bypass the standard History API methods.\n *\n * @defaultValue false\n */\n enableUrlChangePolling?: boolean;\n /**\n * Specifies the interval in milliseconds for URL change polling when enableUrlChangePolling is true.\n * The SDK will check for URL changes at this interval as a fallback for SPA route tracking.\n *\n * @defaultValue 1000\n */\n urlChangePollingInterval?: number;\n /**\n * Whether to capture document title in URL change events.\n * When disabled, the title field will be empty in URL change events.\n *\n * @defaultValue false\n */\n captureDocumentTitle?: boolean;\n}\n"]}
|
package/lib/esm/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "1.
|
|
1
|
+
export declare const VERSION = "1.24.1";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/lib/esm/version.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,WAAW,CAAC"}
|
package/lib/esm/version.js
CHANGED
package/lib/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,CAAC,IAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// Autogenerated by `yarn version-file`. DO NOT EDIT\nexport const VERSION = '1.24.1';\n"]}
|