@amplitude/session-replay-browser 1.42.0 → 1.42.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/config/local-config.d.ts +1 -4
- package/lib/cjs/config/local-config.d.ts.map +1 -1
- package/lib/cjs/config/local-config.js +8 -8
- package/lib/cjs/config/local-config.js.map +1 -1
- package/lib/cjs/config/types.d.ts +2 -13
- package/lib/cjs/config/types.d.ts.map +1 -1
- package/lib/cjs/config/types.js.map +1 -1
- package/lib/cjs/constants.d.ts +3 -1
- package/lib/cjs/constants.d.ts.map +1 -1
- package/lib/cjs/constants.js +13 -2
- package/lib/cjs/constants.js.map +1 -1
- package/lib/cjs/events/base-events-store.d.ts +4 -4
- package/lib/cjs/events/base-events-store.d.ts.map +1 -1
- package/lib/cjs/events/base-events-store.js +42 -8
- package/lib/cjs/events/base-events-store.js.map +1 -1
- package/lib/cjs/events/event-compressor.d.ts +5 -0
- package/lib/cjs/events/event-compressor.d.ts.map +1 -1
- package/lib/cjs/events/event-compressor.js +39 -4
- package/lib/cjs/events/event-compressor.js.map +1 -1
- package/lib/cjs/events/events-manager.d.ts.map +1 -1
- package/lib/cjs/events/events-manager.js +22 -1
- package/lib/cjs/events/events-manager.js.map +1 -1
- package/lib/cjs/session-replay.d.ts.map +1 -1
- package/lib/cjs/session-replay.js +20 -22
- package/lib/cjs/session-replay.js.map +1 -1
- package/lib/cjs/track-destination.d.ts +2 -1
- package/lib/cjs/track-destination.d.ts.map +1 -1
- package/lib/cjs/track-destination.js +80 -29
- package/lib/cjs/track-destination.js.map +1 -1
- package/lib/cjs/utils/rrweb.d.ts +9 -0
- 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.js +1 -1
- package/lib/cjs/version.js.map +1 -1
- package/lib/cjs/worker/index.js +1 -1
- package/lib/esm/config/local-config.d.ts +1 -4
- package/lib/esm/config/local-config.d.ts.map +1 -1
- package/lib/esm/config/local-config.js +10 -10
- package/lib/esm/config/local-config.js.map +1 -1
- package/lib/esm/config/types.d.ts +2 -13
- package/lib/esm/config/types.d.ts.map +1 -1
- package/lib/esm/config/types.js.map +1 -1
- package/lib/esm/constants.d.ts +3 -1
- package/lib/esm/constants.d.ts.map +1 -1
- package/lib/esm/constants.js +12 -1
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/events/base-events-store.d.ts +4 -4
- package/lib/esm/events/base-events-store.d.ts.map +1 -1
- package/lib/esm/events/base-events-store.js +42 -8
- package/lib/esm/events/base-events-store.js.map +1 -1
- package/lib/esm/events/event-compressor.d.ts +5 -0
- package/lib/esm/events/event-compressor.d.ts.map +1 -1
- package/lib/esm/events/event-compressor.js +39 -4
- package/lib/esm/events/event-compressor.js.map +1 -1
- package/lib/esm/events/events-manager.d.ts.map +1 -1
- package/lib/esm/events/events-manager.js +22 -1
- package/lib/esm/events/events-manager.js.map +1 -1
- package/lib/esm/session-replay.d.ts.map +1 -1
- package/lib/esm/session-replay.js +20 -22
- package/lib/esm/session-replay.js.map +1 -1
- package/lib/esm/track-destination.d.ts +2 -1
- package/lib/esm/track-destination.d.ts.map +1 -1
- package/lib/esm/track-destination.js +81 -30
- package/lib/esm/track-destination.js.map +1 -1
- package/lib/esm/utils/rrweb.d.ts +9 -0
- 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.js +1 -1
- package/lib/esm/version.js.map +1 -1
- package/lib/esm/worker/index.js +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/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/lib/scripts/worker-min.js +1 -1
- package/lib/scripts/worker-min.js.gz +0 -0
- package/package.json +3 -3
|
@@ -21,15 +21,12 @@ export declare class SessionReplayLocalConfig extends Config implements ISession
|
|
|
21
21
|
performanceConfig?: SessionReplayPerformanceConfig;
|
|
22
22
|
useWebWorker?: boolean;
|
|
23
23
|
applyBackgroundColorToBlockedElements?: boolean;
|
|
24
|
-
omitElementTags?: {
|
|
25
|
-
script?: boolean;
|
|
26
|
-
comment?: boolean;
|
|
27
|
-
};
|
|
28
24
|
enableUrlChangePolling?: boolean;
|
|
29
25
|
urlChangePollingInterval?: number;
|
|
30
26
|
captureDocumentTitle?: boolean;
|
|
31
27
|
captureAdoptedStyleSheets?: boolean;
|
|
32
28
|
crossOriginIframes?: CrossOriginIframesConfig;
|
|
29
|
+
fullSnapshotIntervalMs?: number;
|
|
33
30
|
constructor(apiKey: string, options: SessionReplayOptions);
|
|
34
31
|
}
|
|
35
32
|
//# sourceMappingURL=local-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-config.d.ts","sourceRoot":"","sources":["../../../src/config/local-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"local-config.d.ts","sourceRoot":"","sources":["../../../src/config/local-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAQrF,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EACL,wBAAwB,IAAI,yBAAyB,EACrD,wBAAwB,EACxB,iBAAiB,EACjB,aAAa,EACb,8BAA8B,EAC9B,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAIjB,eAAO,MAAM,gBAAgB;;;;;CAK3B,CAAC;AAEH,qBAAa,wBAAyB,SAAQ,MAAO,YAAW,yBAAyB;IACvF,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,SAAS,EAAE,SAAS,CAAC;IACrB,iBAAiB,CAAC,EAAE,8BAA8B,CAAC;IACnD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,qCAAqC,CAAC,EAAE,OAAO,CAAC;IAChD,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,kBAAkB,CAAC,EAAE,wBAAwB,CAAC;IAC9C,sBAAsB,CAAC,EAAE,MAAM,CAAC;gBAEpB,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB;CA6D1D"}
|
|
@@ -17,7 +17,7 @@ var SessionReplayLocalConfig = /** @class */ (function (_super) {
|
|
|
17
17
|
tslib_1.__extends(SessionReplayLocalConfig, _super);
|
|
18
18
|
function SessionReplayLocalConfig(apiKey, options) {
|
|
19
19
|
var _this = this;
|
|
20
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
20
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
21
21
|
var defaultConfig = (0, exports.getDefaultConfig)();
|
|
22
22
|
_this = _super.call(this, tslib_1.__assign(tslib_1.__assign({ transportProvider: defaultConfig.transportProvider, loggerProvider: new logger_1.SafeLoggerProvider(options.loggerProvider || defaultConfig.loggerProvider) }, options), { apiKey: apiKey })) || this;
|
|
23
23
|
_this.flushMaxRetries =
|
|
@@ -37,9 +37,12 @@ var SessionReplayLocalConfig = /** @class */ (function (_super) {
|
|
|
37
37
|
_this.enableUrlChangePolling = (_c = options.enableUrlChangePolling) !== null && _c !== void 0 ? _c : false;
|
|
38
38
|
_this.urlChangePollingInterval = (_d = options.urlChangePollingInterval) !== null && _d !== void 0 ? _d : constants_1.DEFAULT_URL_CHANGE_POLLING_INTERVAL;
|
|
39
39
|
_this.captureDocumentTitle = (_e = options.captureDocumentTitle) !== null && _e !== void 0 ? _e : false;
|
|
40
|
-
if (options.
|
|
41
|
-
_this.
|
|
40
|
+
if (options.fullSnapshotIntervalMs !== undefined) {
|
|
41
|
+
_this.fullSnapshotIntervalMs = options.fullSnapshotIntervalMs;
|
|
42
42
|
}
|
|
43
|
+
// Auto-include .amp-unmask as a default unmaskSelector entry so it works
|
|
44
|
+
// symmetrically with amp-mask/amp-block without requiring explicit config (SR-2945).
|
|
45
|
+
_this.privacyConfig = tslib_1.__assign(tslib_1.__assign({}, ((_f = options.privacyConfig) !== null && _f !== void 0 ? _f : {})), { unmaskSelector: Array.from(new Set(tslib_1.__spreadArray([".".concat(constants_1.UNMASK_TEXT_CLASS)], tslib_1.__read(((_h = (_g = options.privacyConfig) === null || _g === void 0 ? void 0 : _g.unmaskSelector) !== null && _h !== void 0 ? _h : [])), false))) });
|
|
43
46
|
if (options.interactionConfig) {
|
|
44
47
|
_this.interactionConfig = options.interactionConfig;
|
|
45
48
|
// validate ugcFilterRules, throw error if invalid - throw error at the beginning of the config
|
|
@@ -56,14 +59,11 @@ var SessionReplayLocalConfig = /** @class */ (function (_super) {
|
|
|
56
59
|
}
|
|
57
60
|
else {
|
|
58
61
|
var legacyOptions = options;
|
|
59
|
-
if (((
|
|
62
|
+
if (((_j = legacyOptions.experimental) === null || _j === void 0 ? void 0 : _j.useWebWorker) !== undefined) {
|
|
60
63
|
_this.useWebWorker = legacyOptions.experimental.useWebWorker;
|
|
61
64
|
}
|
|
62
65
|
}
|
|
63
|
-
|
|
64
|
-
_this.omitElementTags = options.omitElementTags;
|
|
65
|
-
}
|
|
66
|
-
_this.captureAdoptedStyleSheets = (_g = options.captureAdoptedStyleSheets) !== null && _g !== void 0 ? _g : true;
|
|
66
|
+
_this.captureAdoptedStyleSheets = (_k = options.captureAdoptedStyleSheets) !== null && _k !== void 0 ? _k : true;
|
|
67
67
|
if (options.crossOriginIframes) {
|
|
68
68
|
_this.crossOriginIframes = options.crossOriginIframes;
|
|
69
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-config.js","sourceRoot":"","sources":["../../../src/config/local-config.ts"],"names":[],"mappings":";;;;AAAA,4DAAqF;AACrF,
|
|
1
|
+
{"version":3,"file":"local-config.js","sourceRoot":"","sources":["../../../src/config/local-config.ts"],"names":[],"mappings":";;;;AAAA,4DAAqF;AACrF,0CAMsB;AAUtB,oCAA+C;AAC/C,sCAAoD;AAE7C,IAAM,gBAAgB,GAAG,cAAM,OAAA,CAAC;IACrC,eAAe,EAAE,CAAC;IAClB,QAAQ,EAAE,yBAAQ,CAAC,IAAI;IACvB,cAAc,EAAE,IAAI,uBAAM,EAAE;IAC5B,iBAAiB,EAAE,IAAI,+BAAc,EAAE;CACxC,CAAC,EALoC,CAKpC,CAAC;AALU,QAAA,gBAAgB,oBAK1B;AAEH;IAA8C,oDAAM;IAqBlD,kCAAY,MAAc,EAAE,OAA6B;QAAzD,iBA4DC;;QA3DC,IAAM,aAAa,GAAG,IAAA,wBAAgB,GAAE,CAAC;gBACzC,sDACE,iBAAiB,EAAE,aAAa,CAAC,iBAAiB,EAClD,cAAc,EAAE,IAAI,2BAAkB,CAAC,OAAO,CAAC,cAAc,IAAI,aAAa,CAAC,cAAc,CAAC,IAC3F,OAAO,KACV,MAAM,QAAA,IACN;QACF,KAAI,CAAC,eAAe;YAClB,OAAO,CAAC,eAAe,KAAK,SAAS,IAAI,OAAO,CAAC,eAAe,IAAI,aAAa,CAAC,eAAe;gB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BAAE,WAAI,6BAAiB,CAAE,kBAAK,CAAC,MAAA,MAAA,OAAO,CAAC,aAAa,0CAAE,cAAc,mCAAI,EAAE,CAAC,UAAE,CAAC,GACjH,CAAC;QACF,IAAI,OAAO,CAAC,iBAAiB,EAAE;YAC7B,KAAI,CAAC,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;YAEnD,+FAA+F;YAC/F,IAAI,KAAI,CAAC,iBAAiB,CAAC,cAAc,EAAE;gBACzC,IAAA,gCAAsB,EAAC,KAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC;aAC/D;SACF;QACD,IAAI,OAAO,CAAC,SAAS,EAAE;YACrB,KAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;SACpC;QACD,iGAAiG;QACjG,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE;YACtC,KAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;SAC1C;aAAM;YACL,IAAM,aAAa,GAAG,OAAwD,CAAC;YAC/E,IAAI,CAAA,MAAA,aAAa,CAAC,YAAY,0CAAE,YAAY,MAAK,SAAS,EAAE;gBAC1D,KAAI,CAAC,YAAY,GAAG,aAAa,CAAC,YAAY,CAAC,YAAY,CAAC;aAC7D;SACF;QACD,KAAI,CAAC,yBAAyB,GAAG,MAAA,OAAO,CAAC,yBAAyB,mCAAI,IAAI,CAAC;QAC3E,IAAI,OAAO,CAAC,kBAAkB,EAAE;YAC9B,KAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;SACtD;;IACH,CAAC;IACH,+BAAC;AAAD,CAAC,AAlFD,CAA8C,uBAAM,GAkFnD;AAlFY,4DAAwB","sourcesContent":["import { Config, Logger, FetchTransport, LogLevel } from '@amplitude/analytics-core';\nimport {\n DEFAULT_PERFORMANCE_CONFIG,\n DEFAULT_SAMPLE_RATE,\n DEFAULT_SERVER_ZONE,\n DEFAULT_URL_CHANGE_POLLING_INTERVAL,\n UNMASK_TEXT_CLASS,\n} from '../constants';\nimport { SessionReplayOptions, StoreType } from '../typings/session-replay';\nimport {\n SessionReplayLocalConfig as ISessionReplayLocalConfig,\n CrossOriginIframesConfig,\n InteractionConfig,\n PrivacyConfig,\n SessionReplayPerformanceConfig,\n SessionReplayVersion,\n} from './types';\nimport { SafeLoggerProvider } from '../logger';\nimport { validateUGCFilterRules } from '../helpers';\n\nexport const getDefaultConfig = () => ({\n flushMaxRetries: 2,\n logLevel: LogLevel.Warn,\n loggerProvider: new Logger(),\n transportProvider: new FetchTransport(),\n});\n\nexport class SessionReplayLocalConfig extends Config implements ISessionReplayLocalConfig {\n apiKey: string;\n sampleRate: number;\n privacyConfig?: PrivacyConfig;\n interactionConfig?: InteractionConfig;\n debugMode?: boolean;\n configServerUrl?: string;\n trackServerUrl?: string;\n shouldInlineStylesheet?: boolean;\n version?: SessionReplayVersion;\n storeType: StoreType;\n performanceConfig?: SessionReplayPerformanceConfig;\n useWebWorker?: boolean;\n applyBackgroundColorToBlockedElements?: boolean;\n enableUrlChangePolling?: boolean;\n urlChangePollingInterval?: number;\n captureDocumentTitle?: boolean;\n captureAdoptedStyleSheets?: boolean;\n crossOriginIframes?: CrossOriginIframesConfig;\n fullSnapshotIntervalMs?: number;\n\n constructor(apiKey: string, options: SessionReplayOptions) {\n const defaultConfig = getDefaultConfig();\n super({\n transportProvider: defaultConfig.transportProvider,\n loggerProvider: new SafeLoggerProvider(options.loggerProvider || defaultConfig.loggerProvider),\n ...options,\n apiKey,\n });\n this.flushMaxRetries =\n options.flushMaxRetries !== undefined && options.flushMaxRetries <= defaultConfig.flushMaxRetries\n ? options.flushMaxRetries\n : defaultConfig.flushMaxRetries;\n\n this.apiKey = apiKey;\n this.sampleRate = options.sampleRate || DEFAULT_SAMPLE_RATE;\n this.serverZone = options.serverZone || DEFAULT_SERVER_ZONE;\n this.configServerUrl = options.configServerUrl;\n this.trackServerUrl = options.trackServerUrl;\n this.shouldInlineStylesheet = options.shouldInlineStylesheet;\n this.version = options.version;\n this.performanceConfig = options.performanceConfig || DEFAULT_PERFORMANCE_CONFIG;\n this.storeType = options.storeType ?? 'memory';\n this.applyBackgroundColorToBlockedElements = options.applyBackgroundColorToBlockedElements ?? false;\n this.enableUrlChangePolling = options.enableUrlChangePolling ?? false;\n this.urlChangePollingInterval = options.urlChangePollingInterval ?? DEFAULT_URL_CHANGE_POLLING_INTERVAL;\n this.captureDocumentTitle = options.captureDocumentTitle ?? false;\n if (options.fullSnapshotIntervalMs !== undefined) {\n this.fullSnapshotIntervalMs = options.fullSnapshotIntervalMs;\n }\n\n // Auto-include .amp-unmask as a default unmaskSelector entry so it works\n // symmetrically with amp-mask/amp-block without requiring explicit config (SR-2945).\n this.privacyConfig = {\n ...(options.privacyConfig ?? {}),\n unmaskSelector: Array.from(new Set([`.${UNMASK_TEXT_CLASS}`, ...(options.privacyConfig?.unmaskSelector ?? [])])),\n };\n if (options.interactionConfig) {\n this.interactionConfig = options.interactionConfig;\n\n // validate ugcFilterRules, throw error if invalid - throw error at the beginning of the config\n if (this.interactionConfig.ugcFilterRules) {\n validateUGCFilterRules(this.interactionConfig.ugcFilterRules);\n }\n }\n if (options.debugMode) {\n this.debugMode = options.debugMode;\n }\n // Support both new useWebWorker and legacy experimental.useWebWorker for backwards compatibility\n if (options.useWebWorker !== undefined) {\n this.useWebWorker = options.useWebWorker;\n } else {\n const legacyOptions = options as { experimental?: { useWebWorker?: boolean } };\n if (legacyOptions.experimental?.useWebWorker !== undefined) {\n this.useWebWorker = legacyOptions.experimental.useWebWorker;\n }\n }\n this.captureAdoptedStyleSheets = options.captureAdoptedStyleSheets ?? true;\n if (options.crossOriginIframes) {\n this.crossOriginIframes = options.crossOriginIframes;\n }\n }\n}\n"]}
|
|
@@ -170,19 +170,6 @@ export interface SessionReplayLocalConfig extends IConfig {
|
|
|
170
170
|
userProperties?: {
|
|
171
171
|
[key: string]: any;
|
|
172
172
|
};
|
|
173
|
-
/**
|
|
174
|
-
* Remove certain parts of the DOM from being captured. These are typically ignored when blocking by selectors.
|
|
175
|
-
*/
|
|
176
|
-
omitElementTags?: {
|
|
177
|
-
/**
|
|
178
|
-
* If true, removes script tags from the DOM, but not noscript tags.
|
|
179
|
-
*/
|
|
180
|
-
script?: boolean;
|
|
181
|
-
/**
|
|
182
|
-
* If true, removes comment tags from the DOM.
|
|
183
|
-
*/
|
|
184
|
-
comment?: boolean;
|
|
185
|
-
};
|
|
186
173
|
/**
|
|
187
174
|
* If true, applies a background color to blocked elements in the replay.
|
|
188
175
|
* This helps visualize which elements are blocked from being captured.
|
|
@@ -233,6 +220,8 @@ export interface SessionReplayLocalConfig extends IConfig {
|
|
|
233
220
|
* merges them into a single unified event stream.
|
|
234
221
|
*/
|
|
235
222
|
crossOriginIframes?: CrossOriginIframesConfig;
|
|
223
|
+
/** Interval in ms at which the SDK takes a full DOM snapshot. Disabled by default — periodic snapshots are expensive. Recommended value: 300000 (5 min). */
|
|
224
|
+
fullSnapshotIntervalMs?: number;
|
|
236
225
|
}
|
|
237
226
|
export interface SessionReplayJoinedConfig extends SessionReplayLocalConfig {
|
|
238
227
|
captureEnabled?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,iBAAiB;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,cAAc,C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,CAAC;IACF,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,iBAAiB,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,WAAW,CAAC,EAAE,4BAA4B,CAAC;CAC5C;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,QAAQ,GAAG,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":";;;AAuDa,QAAA,kBAAkB,GAAG,QAAQ,CAAC","sourcesContent":["import { IConfig, LogLevel, ILogger } from '@amplitude/analytics-core';\nimport { StoreType, ConsoleLogLevel } from '../typings/session-replay';\nimport { TargetingFlag } from '@amplitude/targeting';\n\nexport interface SamplingConfig {\n sample_rate: number;\n capture_enabled: boolean;\n}\n\nexport interface InteractionConfig {\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 LoggingConfig {\n console: {\n enabled: boolean;\n levels: ConsoleLogLevel[];\n };\n network?: {\n enabled: boolean;\n body?: {\n request?: boolean;\n response?: boolean;\n maxBodySizeBytes?: number;\n };\n };\n}\n\nexport type TargetingConfig = TargetingFlag;\n\nexport type SessionReplayRemoteConfig = {\n sr_sampling_config?: SamplingConfig;\n sr_privacy_config?: PrivacyConfig;\n sr_interaction_config?: InteractionConfig;\n sr_logging_config?: LoggingConfig;\n sr_targeting_config?: TargetingConfig;\n};\n\nexport interface SessionReplayRemoteConfigAPIResponse {\n configs: {\n sessionReplay: SessionReplayRemoteConfig;\n };\n}\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 const DEFAULT_MASK_LEVEL = 'medium';\n\n// err on the side of excluding more\nexport type PrivacyConfig = {\n blockSelector?: string | string[]; // exclude in the UI\n defaultMaskLevel?: MaskLevel;\n maskSelector?: string[];\n unmaskSelector?: string[];\n maskAttributes?: string[]; // HTML attribute names to mask (e.g. [\"placeholder\", \"aria-label\"])\n /**\n * Per-URL overrides for `defaultMaskLevel`. Each entry contains a glob pattern (`match`)\n * and a `maskLevel` to apply when the current page URL matches that pattern.\n * Rules are evaluated in order; the first match wins. Remote rules take precedence\n * over local rules (remote entries are prepended before local entries).\n *\n * @example\n * urlMaskLevels: [\n * { match: 'https://example.com/checkout/*', maskLevel: 'conservative' },\n * { match: 'https://example.com/public/*', maskLevel: 'light' },\n * ]\n */\n urlMaskLevels?: Array<{ match: string; maskLevel: MaskLevel }>;\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 CrossOriginIframesConfig {\n enabled: boolean;\n /**\n * When true (default), the parent SDK sends start/stop signals to child iframes via\n * postMessage, keeping their recording lifecycle in sync with the parent.\n *\n * **Privacy note:** The child page's rrweb instance performs its own DOM serialization,\n * so the parent's privacy config (mask levels, block selectors) does NOT automatically\n * apply inside the iframe. Privacy settings must be configured independently on the child page.\n *\n * **Third-party iframes:** Cannot capture iframes you don't control (e.g. Stripe, Google\n * Maps) — both parent and child pages must load the SDK with `crossOriginIframes.enabled: true`.\n *\n * Set to `false` to skip coordination and manage the child recording lifecycle yourself.\n * @defaultValue true\n */\n coordinateChildren?: boolean;\n}\n\nexport interface SessionReplayLocalConfig extends IConfig {\n apiKey: string;\n loggerProvider: ILogger;\n /**\n * LogLevel.None or LogLevel.Error or LogLevel.Warn or LogLevel.Verbose or LogLevel.Debug.\n * Sets the log level.\n *\n * @defaultValue LogLevel.Warn\n */\n logLevel: LogLevel;\n /**\n * The maximum number of retries allowed for sending replay events.\n * Once this limit is reached, failed events will no longer be sent.\n *\n * @defaultValue 2\n */\n flushMaxRetries: number;\n /**\n * Use this option to control how many sessions to select for replay collection.\n * The number should be a decimal between 0 and 1, for example 0.4, representing\n * the fraction of sessions to have randomly selected for replay collection.\n * Over a large number of sessions, 0.4 would select 40% of those sessions.\n * Sample rates as small as six decimal places (0.000001) are supported.\n *\n * @defaultValue 0\n */\n sampleRate: number;\n privacyConfig?: PrivacyConfig;\n /**\n * Adds additional debug event property to help debug instrumentation issues\n * (such as mismatching apps). Only recommended for debugging initial setup,\n * and not recommended for production.\n */\n debugMode?: boolean;\n /**\n * Specifies the endpoint URL to fetch remote configuration.\n * If provided, it overrides the default server zone configuration.\n */\n configServerUrl?: string;\n /**\n * Specifies the endpoint URL for sending session replay data.\n * If provided, it overrides the default server zone configuration.\n */\n trackServerUrl?: string;\n /**\n * If stylesheets are inlined, the contents of the stylesheet will be stored.\n * During replay, the stored stylesheet will be used instead of attempting to fetch it remotely.\n * This prevents replays from appearing broken due to missing stylesheets.\n * Note: Inlining stylesheets may not work in all cases.\n */\n shouldInlineStylesheet?: boolean;\n version?: SessionReplayVersion;\n /**\n * Performance configuration config. If enabled, we will defer compression\n * to be done during the browser's idle periods.\n */\n performanceConfig?: SessionReplayPerformanceConfig;\n /**\n * Specifies how replay events should be stored. `idb` uses IndexedDB to persist replay events\n * when all events cannot be sent during capture. `memory` stores replay events only in memory,\n * meaning events are lost when the page is closed. If IndexedDB is unavailable, the system falls back to `memory`.\n */\n storeType: StoreType;\n\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 userProperties?: { [key: string]: any };\n\n /**\n * Remove certain parts of the DOM from being captured. These are typically ignored when blocking by selectors.\n */\n omitElementTags?: {\n /**\n * If true, removes script tags from the DOM, but not noscript tags.\n */\n script?: boolean;\n /**\n * If true, removes comment tags from the DOM.\n */\n comment?: boolean;\n };\n\n /**\n * If true, applies a background color to blocked elements in the replay.\n * This helps visualize which elements are blocked from being captured.\n */\n applyBackgroundColorToBlockedElements?: boolean;\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 interactionConfig?: InteractionConfig;\n /**\n * When true (default), the CSS rules of any `adoptedStyleSheets` on shadow roots and\n * the document are serialized **inline** within the full snapshot. This makes the snapshot\n * self-contained so that shadow DOM styles are replayed correctly even if subsequent\n * incremental `AdoptedStyleSheet` events are dropped in transit.\n *\n * Set to `false` to revert to the legacy behavior where adopted stylesheet rules are\n * emitted as separate incremental events (which may be lost if delivery is unreliable).\n * Only consider opting out if snapshot payload size is a critical concern.\n *\n * @defaultValue true\n */\n captureAdoptedStyleSheets?: boolean;\n /**\n * Enables recording of cross-origin iframes. Both the parent page and each child iframe\n * page must load the Amplitude Session Replay SDK with this option enabled.\n *\n * When enabled, rrweb uses `postMessage` to relay child DOM events to the parent, which\n * merges them into a single unified event stream.\n */\n crossOriginIframes?: CrossOriginIframesConfig;\n}\n\nexport interface SessionReplayJoinedConfig extends SessionReplayLocalConfig {\n captureEnabled?: boolean;\n interactionConfig?: InteractionConfig;\n loggingConfig?: LoggingConfig;\n targetingConfig?: TargetingConfig;\n}\n\nexport interface SessionReplayConfigs {\n localConfig: SessionReplayLocalConfig;\n joinedConfig: SessionReplayJoinedConfig;\n remoteConfig: SessionReplayRemoteConfig | undefined;\n}\nexport interface SessionReplayJoinedConfigGenerator {\n generateJoinedConfig: () => Promise<SessionReplayConfigs>;\n}\n\nexport interface SessionReplayMetadata {\n remoteConfig: SessionReplayRemoteConfig | undefined;\n localConfig: SessionReplayLocalConfig;\n joinedConfig: SessionReplayJoinedConfig;\n framework?: {\n name: string;\n version: string;\n };\n sessionId: string | number | undefined;\n hashValue?: number;\n sampleRate: number;\n replaySDKType: string | null;\n replaySDKVersion: string | undefined;\n standaloneSDKType: string;\n standaloneSDKVersion: string | undefined;\n}\n\nexport interface SessionReplayVersion {\n version: string;\n type: SessionReplayType;\n}\n\n/**\n * Configuration options for session replay performance.\n */\nexport interface SessionReplayPerformanceConfig {\n /**\n * If enabled, event compression will be deferred to occur during the browser's idle periods.\n */\n enabled: boolean;\n /**\n * Optional timeout in milliseconds for the `requestIdleCallback` API.\n * If specified, this value will be used to set a maximum time for the browser to wait\n * before executing the deferred compression task, even if the browser is not idle.\n */\n timeout?: number;\n /**\n * If enabled, consecutive mutation events will be merged into a single event before\n * compression, reducing stored event count without changing replay semantics.\n * Defaults to false.\n */\n mergeMutations?: boolean;\n /**\n * Performance configuration for interaction tracking (clicks, scrolls).\n */\n interaction?: InteractionPerformanceConfig;\n}\n\n/**\n * Performance configuration for interaction tracking, specifically for CSS selector generation.\n */\nexport interface InteractionPerformanceConfig {\n /**\n * Maximum time in milliseconds allowed for CSS selector generation.\n * If selector generation takes longer than this, it will throw a timeout error.\n * Default: undefined (no timeout limit)\n */\n timeoutMs?: number;\n /**\n * Maximum number of attempts to optimize/simplify the CSS selector path.\n * Higher values may produce shorter selectors but take longer to compute.\n * Default: 10000\n */\n maxNumberOfTries?: number;\n /**\n * Maximum number of CSS selector combinations to test for uniqueness.\n * If more combinations would be generated, falls back to a simpler strategy.\n * Default: 1000\n */\n threshold?: number;\n}\n\nexport type SessionReplayType = 'standalone' | 'plugin' | 'segment';\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":";;;AAuDa,QAAA,kBAAkB,GAAG,QAAQ,CAAC","sourcesContent":["import { IConfig, LogLevel, ILogger } from '@amplitude/analytics-core';\nimport { StoreType, ConsoleLogLevel } from '../typings/session-replay';\nimport { TargetingFlag } from '@amplitude/targeting';\n\nexport interface SamplingConfig {\n sample_rate: number;\n capture_enabled: boolean;\n}\n\nexport interface InteractionConfig {\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 LoggingConfig {\n console: {\n enabled: boolean;\n levels: ConsoleLogLevel[];\n };\n network?: {\n enabled: boolean;\n body?: {\n request?: boolean;\n response?: boolean;\n maxBodySizeBytes?: number;\n };\n };\n}\n\nexport type TargetingConfig = TargetingFlag;\n\nexport type SessionReplayRemoteConfig = {\n sr_sampling_config?: SamplingConfig;\n sr_privacy_config?: PrivacyConfig;\n sr_interaction_config?: InteractionConfig;\n sr_logging_config?: LoggingConfig;\n sr_targeting_config?: TargetingConfig;\n};\n\nexport interface SessionReplayRemoteConfigAPIResponse {\n configs: {\n sessionReplay: SessionReplayRemoteConfig;\n };\n}\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 const DEFAULT_MASK_LEVEL = 'medium';\n\n// err on the side of excluding more\nexport type PrivacyConfig = {\n blockSelector?: string | string[]; // exclude in the UI\n defaultMaskLevel?: MaskLevel;\n maskSelector?: string[];\n unmaskSelector?: string[];\n maskAttributes?: string[]; // HTML attribute names to mask (e.g. [\"placeholder\", \"aria-label\"])\n /**\n * Per-URL overrides for `defaultMaskLevel`. Each entry contains a glob pattern (`match`)\n * and a `maskLevel` to apply when the current page URL matches that pattern.\n * Rules are evaluated in order; the first match wins. Remote rules take precedence\n * over local rules (remote entries are prepended before local entries).\n *\n * @example\n * urlMaskLevels: [\n * { match: 'https://example.com/checkout/*', maskLevel: 'conservative' },\n * { match: 'https://example.com/public/*', maskLevel: 'light' },\n * ]\n */\n urlMaskLevels?: Array<{ match: string; maskLevel: MaskLevel }>;\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 CrossOriginIframesConfig {\n enabled: boolean;\n /**\n * When true (default), the parent SDK sends start/stop signals to child iframes via\n * postMessage, keeping their recording lifecycle in sync with the parent.\n *\n * **Privacy note:** The child page's rrweb instance performs its own DOM serialization,\n * so the parent's privacy config (mask levels, block selectors) does NOT automatically\n * apply inside the iframe. Privacy settings must be configured independently on the child page.\n *\n * **Third-party iframes:** Cannot capture iframes you don't control (e.g. Stripe, Google\n * Maps) — both parent and child pages must load the SDK with `crossOriginIframes.enabled: true`.\n *\n * Set to `false` to skip coordination and manage the child recording lifecycle yourself.\n * @defaultValue true\n */\n coordinateChildren?: boolean;\n}\n\nexport interface SessionReplayLocalConfig extends IConfig {\n apiKey: string;\n loggerProvider: ILogger;\n /**\n * LogLevel.None or LogLevel.Error or LogLevel.Warn or LogLevel.Verbose or LogLevel.Debug.\n * Sets the log level.\n *\n * @defaultValue LogLevel.Warn\n */\n logLevel: LogLevel;\n /**\n * The maximum number of retries allowed for sending replay events.\n * Once this limit is reached, failed events will no longer be sent.\n *\n * @defaultValue 2\n */\n flushMaxRetries: number;\n /**\n * Use this option to control how many sessions to select for replay collection.\n * The number should be a decimal between 0 and 1, for example 0.4, representing\n * the fraction of sessions to have randomly selected for replay collection.\n * Over a large number of sessions, 0.4 would select 40% of those sessions.\n * Sample rates as small as six decimal places (0.000001) are supported.\n *\n * @defaultValue 0\n */\n sampleRate: number;\n privacyConfig?: PrivacyConfig;\n /**\n * Adds additional debug event property to help debug instrumentation issues\n * (such as mismatching apps). Only recommended for debugging initial setup,\n * and not recommended for production.\n */\n debugMode?: boolean;\n /**\n * Specifies the endpoint URL to fetch remote configuration.\n * If provided, it overrides the default server zone configuration.\n */\n configServerUrl?: string;\n /**\n * Specifies the endpoint URL for sending session replay data.\n * If provided, it overrides the default server zone configuration.\n */\n trackServerUrl?: string;\n /**\n * If stylesheets are inlined, the contents of the stylesheet will be stored.\n * During replay, the stored stylesheet will be used instead of attempting to fetch it remotely.\n * This prevents replays from appearing broken due to missing stylesheets.\n * Note: Inlining stylesheets may not work in all cases.\n */\n shouldInlineStylesheet?: boolean;\n version?: SessionReplayVersion;\n /**\n * Performance configuration config. If enabled, we will defer compression\n * to be done during the browser's idle periods.\n */\n performanceConfig?: SessionReplayPerformanceConfig;\n /**\n * Specifies how replay events should be stored. `idb` uses IndexedDB to persist replay events\n * when all events cannot be sent during capture. `memory` stores replay events only in memory,\n * meaning events are lost when the page is closed. If IndexedDB is unavailable, the system falls back to `memory`.\n */\n storeType: StoreType;\n\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 userProperties?: { [key: string]: any };\n\n /**\n * If true, applies a background color to blocked elements in the replay.\n * This helps visualize which elements are blocked from being captured.\n */\n applyBackgroundColorToBlockedElements?: boolean;\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 interactionConfig?: InteractionConfig;\n /**\n * When true (default), the CSS rules of any `adoptedStyleSheets` on shadow roots and\n * the document are serialized **inline** within the full snapshot. This makes the snapshot\n * self-contained so that shadow DOM styles are replayed correctly even if subsequent\n * incremental `AdoptedStyleSheet` events are dropped in transit.\n *\n * Set to `false` to revert to the legacy behavior where adopted stylesheet rules are\n * emitted as separate incremental events (which may be lost if delivery is unreliable).\n * Only consider opting out if snapshot payload size is a critical concern.\n *\n * @defaultValue true\n */\n captureAdoptedStyleSheets?: boolean;\n /**\n * Enables recording of cross-origin iframes. Both the parent page and each child iframe\n * page must load the Amplitude Session Replay SDK with this option enabled.\n *\n * When enabled, rrweb uses `postMessage` to relay child DOM events to the parent, which\n * merges them into a single unified event stream.\n */\n crossOriginIframes?: CrossOriginIframesConfig;\n /** Interval in ms at which the SDK takes a full DOM snapshot. Disabled by default — periodic snapshots are expensive. Recommended value: 300000 (5 min). */\n fullSnapshotIntervalMs?: number;\n}\n\nexport interface SessionReplayJoinedConfig extends SessionReplayLocalConfig {\n captureEnabled?: boolean;\n interactionConfig?: InteractionConfig;\n loggingConfig?: LoggingConfig;\n targetingConfig?: TargetingConfig;\n}\n\nexport interface SessionReplayConfigs {\n localConfig: SessionReplayLocalConfig;\n joinedConfig: SessionReplayJoinedConfig;\n remoteConfig: SessionReplayRemoteConfig | undefined;\n}\nexport interface SessionReplayJoinedConfigGenerator {\n generateJoinedConfig: () => Promise<SessionReplayConfigs>;\n}\n\nexport interface SessionReplayMetadata {\n remoteConfig: SessionReplayRemoteConfig | undefined;\n localConfig: SessionReplayLocalConfig;\n joinedConfig: SessionReplayJoinedConfig;\n framework?: {\n name: string;\n version: string;\n };\n sessionId: string | number | undefined;\n hashValue?: number;\n sampleRate: number;\n replaySDKType: string | null;\n replaySDKVersion: string | undefined;\n standaloneSDKType: string;\n standaloneSDKVersion: string | undefined;\n}\n\nexport interface SessionReplayVersion {\n version: string;\n type: SessionReplayType;\n}\n\n/**\n * Configuration options for session replay performance.\n */\nexport interface SessionReplayPerformanceConfig {\n /**\n * If enabled, event compression will be deferred to occur during the browser's idle periods.\n */\n enabled: boolean;\n /**\n * Optional timeout in milliseconds for the `requestIdleCallback` API.\n * If specified, this value will be used to set a maximum time for the browser to wait\n * before executing the deferred compression task, even if the browser is not idle.\n */\n timeout?: number;\n /**\n * If enabled, consecutive mutation events will be merged into a single event before\n * compression, reducing stored event count without changing replay semantics.\n * Defaults to false.\n */\n mergeMutations?: boolean;\n /**\n * Performance configuration for interaction tracking (clicks, scrolls).\n */\n interaction?: InteractionPerformanceConfig;\n}\n\n/**\n * Performance configuration for interaction tracking, specifically for CSS selector generation.\n */\nexport interface InteractionPerformanceConfig {\n /**\n * Maximum time in milliseconds allowed for CSS selector generation.\n * If selector generation takes longer than this, it will throw a timeout error.\n * Default: undefined (no timeout limit)\n */\n timeoutMs?: number;\n /**\n * Maximum number of attempts to optimize/simplify the CSS selector path.\n * Higher values may produce shorter selectors but take longer to compute.\n * Default: 10000\n */\n maxNumberOfTries?: number;\n /**\n * Maximum number of CSS selector combinations to test for uniqueness.\n * If more combinations would be generated, falls back to a simpler strategy.\n * Default: 1000\n */\n threshold?: number;\n}\n\nexport type SessionReplayType = 'standalone' | 'plugin' | 'segment';\n"]}
|
package/lib/cjs/constants.d.ts
CHANGED
|
@@ -17,7 +17,9 @@ export declare const SESSION_REPLAY_SERVER_URL = "https://api-sr.amplitude.com/s
|
|
|
17
17
|
export declare const SESSION_REPLAY_EU_URL = "https://api-sr.eu.amplitude.com/sessions/v2/track";
|
|
18
18
|
export declare const SESSION_REPLAY_STAGING_URL = "https://api-sr.stag2.amplitude.com/sessions/v2/track";
|
|
19
19
|
export declare const STORAGE_PREFIX: string;
|
|
20
|
-
export declare const MAX_EVENT_LIST_SIZE
|
|
20
|
+
export declare const MAX_EVENT_LIST_SIZE = 700000;
|
|
21
|
+
export declare const MAX_SINGLE_EVENT_SIZE: number;
|
|
22
|
+
export declare const WAF_PAYLOAD_TOO_LARGE_PATTERN: RegExp;
|
|
21
23
|
export declare const INTERACTION_MIN_INTERVAL = 30000;
|
|
22
24
|
export declare const INTERACTION_MAX_INTERVAL = 60000;
|
|
23
25
|
export declare const MIN_INTERVAL = 500;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEzE,eAAO,MAAM,6BAA6B,gBAAgB,CAAC;AAE3D,eAAO,MAAM,+BAA+B,QAAuD,CAAC;AACpG,eAAO,MAAM,2BAA2B,kBAAkB,CAAC;AAC3D,eAAO,MAAM,yBAAyB,gBAAgB,CAAC;AACvD,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,mBAAmB,gBAAgB,CAAC;AACjD,eAAO,MAAM,0BAA0B;;CAAoB,CAAC;AAC5D,eAAO,MAAM,mCAAmC,OAAO,CAAC;AAExD,eAAO,MAAM,6BAA6B,QAA0D,CAAC;AAErG,eAAO,MAAM,WAAW,cAAc,CAAC;AACvC,eAAO,MAAM,eAAe,aAAa,CA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Y,QAAY,CAAC;AACtC,eAAO,MAAM,sBAAsB,QAA0B,CAAC;AAC9D,eAAO,MAAM,OAAO,OAAO,CAAC;AAC5B,eAAO,MAAM,cAAc,OAAO,CAAC;AACnC,eAAO,MAAM,gBAAgB,OAAO,CAAC;AACrC,eAAO,MAAM,mBAAmB,QAAY,CAAC;AAE7C,eAAO,MAAM,gCAAgC,wBAAwB,CAAC;AAEtE,oBAAY,gBAAgB;IAC1B,YAAY,iBAAiB;IAC7B,UAAU,eAAe;IACzB,aAAa,kBAAkB;IAC/B,QAAQ,aAAa;IACrB,kBAAkB,uBAAuB;CAC1C"}
|
package/lib/cjs/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CustomRRwebEvent = exports.CROSS_ORIGIN_IFRAME_MESSAGE_TYPE = exports.MAX_KEEPALIVE_BYTES = exports.RETRY_TIMEOUT_MS = exports.MAX_URL_LENGTH = exports.KB_SIZE = exports.MAX_IDB_STORAGE_LENGTH = exports.MAX_INTERVAL = exports.MIN_INTERVAL = exports.INTERACTION_MAX_INTERVAL = exports.INTERACTION_MIN_INTERVAL = exports.MAX_EVENT_LIST_SIZE = exports.STORAGE_PREFIX = exports.SESSION_REPLAY_STAGING_URL = exports.SESSION_REPLAY_EU_URL = exports.SESSION_REPLAY_SERVER_URL = exports.UNMASK_TEXT_CLASS = exports.MASK_TEXT_CLASS = exports.BLOCK_CLASS = exports.SESSION_REPLAY_DEBUG_PROPERTY = exports.DEFAULT_URL_CHANGE_POLLING_INTERVAL = exports.DEFAULT_PERFORMANCE_CONFIG = exports.DEFAULT_SERVER_ZONE = exports.DEFAULT_SAMPLE_RATE = exports.DEFAULT_SESSION_END_EVENT = exports.DEFAULT_SESSION_START_EVENT = exports.DEFAULT_SESSION_REPLAY_PROPERTY = exports.DEFAULT_EVENT_PROPERTY_PREFIX = void 0;
|
|
3
|
+
exports.CustomRRwebEvent = exports.CROSS_ORIGIN_IFRAME_MESSAGE_TYPE = exports.MAX_KEEPALIVE_BYTES = exports.RETRY_TIMEOUT_MS = exports.MAX_URL_LENGTH = exports.KB_SIZE = exports.MAX_IDB_STORAGE_LENGTH = exports.MAX_INTERVAL = exports.MIN_INTERVAL = exports.INTERACTION_MAX_INTERVAL = exports.INTERACTION_MIN_INTERVAL = exports.WAF_PAYLOAD_TOO_LARGE_PATTERN = exports.MAX_SINGLE_EVENT_SIZE = exports.MAX_EVENT_LIST_SIZE = exports.STORAGE_PREFIX = exports.SESSION_REPLAY_STAGING_URL = exports.SESSION_REPLAY_EU_URL = exports.SESSION_REPLAY_SERVER_URL = exports.UNMASK_TEXT_CLASS = exports.MASK_TEXT_CLASS = exports.BLOCK_CLASS = exports.SESSION_REPLAY_DEBUG_PROPERTY = exports.DEFAULT_URL_CHANGE_POLLING_INTERVAL = exports.DEFAULT_PERFORMANCE_CONFIG = exports.DEFAULT_SERVER_ZONE = exports.DEFAULT_SAMPLE_RATE = exports.DEFAULT_SESSION_END_EVENT = exports.DEFAULT_SESSION_START_EVENT = exports.DEFAULT_SESSION_REPLAY_PROPERTY = exports.DEFAULT_EVENT_PROPERTY_PREFIX = void 0;
|
|
4
4
|
var analytics_core_1 = require("@amplitude/analytics-core");
|
|
5
5
|
exports.DEFAULT_EVENT_PROPERTY_PREFIX = '[Amplitude]';
|
|
6
6
|
exports.DEFAULT_SESSION_REPLAY_PROPERTY = "".concat(exports.DEFAULT_EVENT_PROPERTY_PREFIX, " Session Replay ID");
|
|
@@ -18,7 +18,18 @@ exports.SESSION_REPLAY_SERVER_URL = 'https://api-sr.amplitude.com/sessions/v2/tr
|
|
|
18
18
|
exports.SESSION_REPLAY_EU_URL = 'https://api-sr.eu.amplitude.com/sessions/v2/track';
|
|
19
19
|
exports.SESSION_REPLAY_STAGING_URL = 'https://api-sr.stag2.amplitude.com/sessions/v2/track';
|
|
20
20
|
exports.STORAGE_PREFIX = "".concat(analytics_core_1.AMPLITUDE_PREFIX, "_replay_unsent");
|
|
21
|
-
|
|
21
|
+
// Reduced from 1,000,000 to leave headroom for double-JSON-encoding overhead and the
|
|
22
|
+
// uncompressed fallback path. The HTTP body is ~10-30% larger than raw string length
|
|
23
|
+
// because events are re-serialized inside the { version, events } wrapper at send time.
|
|
24
|
+
exports.MAX_EVENT_LIST_SIZE = 700000;
|
|
25
|
+
// 9 MB UTF-8 bytes — just under the server's 10 MB per-event threshold. Compared against the
|
|
26
|
+
// UTF-8 byte length of the serialized event (via Blob/TextEncoder), not the JS string length,
|
|
27
|
+
// so multi-byte payloads (CJK, emoji) are gated correctly.
|
|
28
|
+
exports.MAX_SINGLE_EVENT_SIZE = 9 * 1000000;
|
|
29
|
+
// WAF rejects oversized compressed payloads with a body containing wording like
|
|
30
|
+
// "Payload exceeds the maximum allowed size of 10MB". Match loosely so vendor wording
|
|
31
|
+
// tweaks (rule updates, capitalization, etc.) don't silently disable bisect-retry.
|
|
32
|
+
exports.WAF_PAYLOAD_TOO_LARGE_PATTERN = /payload.*exceed/i;
|
|
22
33
|
exports.INTERACTION_MIN_INTERVAL = 30000; // 30 seconds
|
|
23
34
|
exports.INTERACTION_MAX_INTERVAL = 60000; // 1 minute
|
|
24
35
|
exports.MIN_INTERVAL = 500; // 500 ms
|
package/lib/cjs/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAA,4DAAyE;AAE5D,QAAA,6BAA6B,GAAG,aAAa,CAAC;AAE9C,QAAA,+BAA+B,GAAG,UAAG,qCAA6B,uBAAoB,CAAC;AACvF,QAAA,2BAA2B,GAAG,eAAe,CAAC;AAC9C,QAAA,yBAAyB,GAAG,aAAa,CAAC;AAC1C,QAAA,mBAAmB,GAAG,CAAC,CAAC;AACxB,QAAA,mBAAmB,GAAG,2BAAU,CAAC,EAAE,CAAC;AACpC,QAAA,0BAA0B,GAAG,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ClE,qFAAqF;AACrF,qFAAqF;AACrF,wFAAwF;AAC3E,QAAA,mBAAmB,GAAG,MAAO,CAAC;AAC3C,6FAA6F;AAC7F,8FAA8F;AAC9F,2DAA2D;AAC9C,QAAA,qBAAqB,GAAG,CAAC,GAAG,OAAO,CAAC;AACjD,gFAAgF;AAChF,sFAAsF;AACtF,mFAAmF;AACtE,QAAA,6BAA6B,GAAG,kBAAkB,CAAC;AACnD,QAAA,wBAAwB,GAAG,KAAM,CAAC,CAAC,aAAa;AAChD,QAAA,wBAAwB,GAAG,KAAM,CAAC,CAAC,WAAW;AAC9C,QAAA,YAAY,GAAG,GAAG,CAAC,CAAC,SAAS;AAC7B,QAAA,YAAY,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;AACvC,QAAA,sBAAsB,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,SAAS;AAC3D,QAAA,OAAO,GAAG,IAAI,CAAC;AACf,QAAA,cAAc,GAAG,IAAI,CAAC;AACtB,QAAA,gBAAgB,GAAG,IAAI,CAAC;AACxB,QAAA,mBAAmB,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,kDAAkD;AAEnF,QAAA,gCAAgC,GAAG,qBAAqB,CAAC;AAEtE,IAAY,gBAMX;AAND,WAAY,gBAAgB;IAC1B,iDAA6B,CAAA;IAC7B,6CAAyB,CAAA;IACzB,mDAA+B,CAAA;IAC/B,yCAAqB,CAAA;IACrB,6DAAyC,CAAA;AAC3C,CAAC,EANW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAM3B","sourcesContent":["import { AMPLITUDE_PREFIX, ServerZone } from '@amplitude/analytics-core';\n\nexport const DEFAULT_EVENT_PROPERTY_PREFIX = '[Amplitude]';\n\nexport const DEFAULT_SESSION_REPLAY_PROPERTY = `${DEFAULT_EVENT_PROPERTY_PREFIX} Session Replay ID`;\nexport const DEFAULT_SESSION_START_EVENT = 'session_start';\nexport const DEFAULT_SESSION_END_EVENT = 'session_end';\nexport const DEFAULT_SAMPLE_RATE = 0;\nexport const DEFAULT_SERVER_ZONE = ServerZone.US;\nexport const DEFAULT_PERFORMANCE_CONFIG = { enabled: true };\nexport const DEFAULT_URL_CHANGE_POLLING_INTERVAL = 1000;\n\nexport const SESSION_REPLAY_DEBUG_PROPERTY = `${DEFAULT_EVENT_PROPERTY_PREFIX} Session Replay Debug`;\n\nexport const BLOCK_CLASS = 'amp-block';\nexport const MASK_TEXT_CLASS = 'amp-mask';\nexport const UNMASK_TEXT_CLASS = 'amp-unmask';\nexport const SESSION_REPLAY_SERVER_URL = 'https://api-sr.amplitude.com/sessions/v2/track';\nexport const SESSION_REPLAY_EU_URL = 'https://api-sr.eu.amplitude.com/sessions/v2/track';\nexport const SESSION_REPLAY_STAGING_URL = 'https://api-sr.stag2.amplitude.com/sessions/v2/track';\nexport const STORAGE_PREFIX = `${AMPLITUDE_PREFIX}_replay_unsent`;\n// Reduced from 1,000,000 to leave headroom for double-JSON-encoding overhead and the\n// uncompressed fallback path. The HTTP body is ~10-30% larger than raw string length\n// because events are re-serialized inside the { version, events } wrapper at send time.\nexport const MAX_EVENT_LIST_SIZE = 700_000;\n// 9 MB UTF-8 bytes — just under the server's 10 MB per-event threshold. Compared against the\n// UTF-8 byte length of the serialized event (via Blob/TextEncoder), not the JS string length,\n// so multi-byte payloads (CJK, emoji) are gated correctly.\nexport const MAX_SINGLE_EVENT_SIZE = 9 * 1000000;\n// WAF rejects oversized compressed payloads with a body containing wording like\n// \"Payload exceeds the maximum allowed size of 10MB\". Match loosely so vendor wording\n// tweaks (rule updates, capitalization, etc.) don't silently disable bisect-retry.\nexport const WAF_PAYLOAD_TOO_LARGE_PATTERN = /payload.*exceed/i;\nexport const INTERACTION_MIN_INTERVAL = 30_000; // 30 seconds\nexport const INTERACTION_MAX_INTERVAL = 60_000; // 1 minute\nexport const MIN_INTERVAL = 500; // 500 ms\nexport const MAX_INTERVAL = 10 * 1000; // 10 seconds\nexport const MAX_IDB_STORAGE_LENGTH = 1000 * 60 * 60 * 24 * 3; // 3 days\nexport const KB_SIZE = 1024;\nexport const MAX_URL_LENGTH = 1000;\nexport const RETRY_TIMEOUT_MS = 1000;\nexport const MAX_KEEPALIVE_BYTES = 64 * 1024; // browser keepalive budget shared with sendBeacon\n\nexport const CROSS_ORIGIN_IFRAME_MESSAGE_TYPE = 'amplitude-sr-iframe';\n\nexport enum CustomRRwebEvent {\n GET_SR_PROPS = 'get-sr-props',\n DEBUG_INFO = 'debug-info',\n FETCH_REQUEST = 'fetch-request',\n METADATA = 'metadata',\n TARGETING_DECISION = 'targeting-decision',\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Events, EventsStore, SendingSequencesReturn } from '../typings/session-replay';
|
|
2
1
|
import { ILogger } from '@amplitude/analytics-core';
|
|
2
|
+
import { Events, EventsStore, SendingSequencesReturn } from '../typings/session-replay';
|
|
3
3
|
export type InstanceArgs = {
|
|
4
4
|
loggerProvider: ILogger;
|
|
5
5
|
minInterval?: number;
|
|
@@ -21,12 +21,12 @@ export declare abstract class BaseEventsStore<KeyType> implements EventsStore<Ke
|
|
|
21
21
|
abstract storeSendingEvents(sessionId: string | number, events: Events): Promise<KeyType | undefined>;
|
|
22
22
|
abstract cleanUpSessionEventsStore(sessionId: number, sequenceId: KeyType): Promise<void>;
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
24
|
+
* Returns the UTF-8 byte size of a string without buffer allocation, matching the
|
|
25
|
+
* actual wire byte count for non-ASCII content (Base64 image data, emoji, etc.).
|
|
26
26
|
*/
|
|
27
27
|
private getStringSize;
|
|
28
28
|
/**
|
|
29
|
-
* Calculates the total
|
|
29
|
+
* Calculates the total UTF-8 byte size of events array
|
|
30
30
|
* Accounts for JSON serialization overhead when sent to backend
|
|
31
31
|
*/
|
|
32
32
|
private getEventsArraySize;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-events-store.d.ts","sourceRoot":"","sources":["../../../src/events/base-events-store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base-events-store.d.ts","sourceRoot":"","sources":["../../../src/events/base-events-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAExF,MAAM,MAAM,YAAY,GAAG;IACzB,cAAc,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC,CAAC;AAEF,8BAAsB,eAAe,CAAC,OAAO,CAAE,YAAW,WAAW,CAAC,OAAO,CAAC;IAC5E,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IAC3C,OAAO,CAAC,WAAW,CAAgB;IACnC,OAAO,CAAC,WAAW,CAAgB;IACnC,OAAO,CAAC,sBAAsB,CAAuB;IACrD,OAAO,CAAC,QAAQ,CAAoB;IACpC,OAAO,CAAC,gBAAgB,CAAc;IAEtC,IAAW,eAAe,WAEzB;gBAEW,IAAI,EAAE,YAAY;IAO9B,QAAQ,CAAC,yBAAyB,CAChC,SAAS,EAAE,MAAM,GAAG,MAAM,EAC1B,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,sBAAsB,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;IACvD,QAAQ,CAAC,kBAAkB,IAAI,OAAO,CAAC,sBAAsB,CAAC,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC;IACrF,QAAQ,CAAC,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;IACtG,QAAQ,CAAC,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IACrG,QAAQ,CAAC,yBAAyB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAEzF;;;OAGG;IACH,OAAO,CAAC,aAAa;IA8BrB;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAkB1B;;;;;OAKG;IACH,qBAAqB,oCAAqC,MAAM,KAAG,OAAO,CAcxE;CACH"}
|
|
@@ -45,14 +45,45 @@ var BaseEventsStore = /** @class */ (function () {
|
|
|
45
45
|
configurable: true
|
|
46
46
|
});
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
48
|
+
* Returns the UTF-8 byte size of a string without buffer allocation, matching the
|
|
49
|
+
* actual wire byte count for non-ASCII content (Base64 image data, emoji, etc.).
|
|
50
50
|
*/
|
|
51
51
|
BaseEventsStore.prototype.getStringSize = function (str) {
|
|
52
|
-
|
|
52
|
+
var bytes = 0;
|
|
53
|
+
for (var i = 0; i < str.length; i++) {
|
|
54
|
+
var code = str.charCodeAt(i);
|
|
55
|
+
if (code <= 0x7f) {
|
|
56
|
+
bytes++;
|
|
57
|
+
}
|
|
58
|
+
else if (code <= 0x7ff) {
|
|
59
|
+
bytes += 2;
|
|
60
|
+
}
|
|
61
|
+
else if (code >= 0xd800 && code <= 0xdbff) {
|
|
62
|
+
// High surrogate — check for a valid low surrogate before consuming the pair.
|
|
63
|
+
var next = i + 1 < str.length ? str.charCodeAt(i + 1) : NaN;
|
|
64
|
+
if (next >= 0xdc00 && next <= 0xdfff) {
|
|
65
|
+
// Valid surrogate pair → encodes a code point above U+FFFF (4 UTF-8 bytes).
|
|
66
|
+
bytes += 4;
|
|
67
|
+
i++;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
// Orphaned high surrogate — treated as a replacement character (3 UTF-8 bytes).
|
|
71
|
+
bytes += 3;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else if (code >= 0xdc00 && code <= 0xdfff) {
|
|
75
|
+
// Orphaned low surrogate — treated as a replacement character (3 UTF-8 bytes).
|
|
76
|
+
bytes += 3;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
// Other BMP character (U+0800–U+FFFF, excluding surrogates): 3 UTF-8 bytes.
|
|
80
|
+
bytes += 3;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return bytes;
|
|
53
84
|
};
|
|
54
85
|
/**
|
|
55
|
-
* Calculates the total
|
|
86
|
+
* Calculates the total UTF-8 byte size of events array
|
|
56
87
|
* Accounts for JSON serialization overhead when sent to backend
|
|
57
88
|
*/
|
|
58
89
|
BaseEventsStore.prototype.getEventsArraySize = function (events) {
|
|
@@ -71,10 +102,13 @@ var BaseEventsStore = /** @class */ (function () {
|
|
|
71
102
|
}
|
|
72
103
|
finally { if (e_1) throw e_1.error; }
|
|
73
104
|
}
|
|
74
|
-
//
|
|
75
|
-
// - Array brackets: [] = 2
|
|
76
|
-
// - Commas between events: events.length - 1
|
|
77
|
-
// - Double quotes
|
|
105
|
+
// Approximate overhead from the array portion of the JSON payload:
|
|
106
|
+
// - Array brackets: [] = 2 bytes
|
|
107
|
+
// - Commas between events: events.length - 1 bytes
|
|
108
|
+
// - Double quotes wrapping each event string: events.length * 2 bytes
|
|
109
|
+
// Note: does not include the outer { version, events } wrapper (~22 bytes) or
|
|
110
|
+
// per-event JSON-escaping of " and \ characters; the reduced MAX_EVENT_LIST_SIZE
|
|
111
|
+
// cap (700 KB vs 1 MB) provides headroom for those.
|
|
78
112
|
var overhead = 2 + Math.max(0, events.length - 1) + events.length * 2;
|
|
79
113
|
return totalSize + overhead;
|
|
80
114
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-events-store.js","sourceRoot":"","sources":["../../../src/events/base-events-store.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"base-events-store.js","sourceRoot":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K,CAAC;IACf,CAAC;IAED;;;OAGG;IACK,4CAAkB,GAA1B,UAA2B,MAAc;;QACvC,IAAI,SAAS,GAAG,CAAC,CAAC;;YAClB,KAAoB,IAAA,WAAA,iBAAA,MAAM,CAAA,8BAAA,kDAAE;gBAAvB,IAAM,OAAK,mBAAA;gBACd,SAAS,IAAI,IAAI,CAAC,aAAa,CAAC,OAAK,CAAC,CAAC;aACxC;;;;;;;;;QAED,mEAAmE;QACnE,iCAAiC;QACjC,mDAAmD;QACnD,sEAAsE;QACtE,8EAA8E;QAC9E,iFAAiF;QACjF,oDAAoD;QACpD,IAAM,QAAQ,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QAExE,OAAO,SAAS,GAAG,QAAQ,CAAC;IAC9B,CAAC;IAuBH,sBAAC;AAAD,CAAC,AAzGD,IAyGC;AAzGqB,0CAAe","sourcesContent":["import { ILogger } from '@amplitude/analytics-core';\nimport { MAX_EVENT_LIST_SIZE, MAX_INTERVAL, MIN_INTERVAL } from '../constants';\nimport { Events, EventsStore, SendingSequencesReturn } from '../typings/session-replay';\n\nexport type InstanceArgs = {\n loggerProvider: ILogger;\n minInterval?: number;\n maxInterval?: number;\n maxPersistedEventsSize?: number;\n};\n\nexport abstract class BaseEventsStore<KeyType> implements EventsStore<KeyType> {\n protected readonly loggerProvider: ILogger;\n private minInterval = MIN_INTERVAL;\n private maxInterval = MAX_INTERVAL;\n private maxPersistedEventsSize = MAX_EVENT_LIST_SIZE;\n private interval = this.minInterval;\n private _timeAtLastSplit = Date.now(); // Initialize this so we have a point of comparison when events are recorded\n\n public get timeAtLastSplit() {\n return this._timeAtLastSplit;\n }\n\n constructor(args: InstanceArgs) {\n this.loggerProvider = args.loggerProvider;\n this.minInterval = args.minInterval ?? this.minInterval;\n this.maxInterval = args.maxInterval ?? this.maxInterval;\n this.maxPersistedEventsSize = args.maxPersistedEventsSize ?? this.maxPersistedEventsSize;\n }\n\n abstract addEventToCurrentSequence(\n sessionId: string | number,\n event: string,\n ): Promise<SendingSequencesReturn<KeyType> | undefined>;\n abstract getSequencesToSend(): Promise<SendingSequencesReturn<KeyType>[] | undefined>;\n abstract storeCurrentSequence(sessionId: number): Promise<SendingSequencesReturn<KeyType> | undefined>;\n abstract storeSendingEvents(sessionId: string | number, events: Events): Promise<KeyType | undefined>;\n abstract cleanUpSessionEventsStore(sessionId: number, sequenceId: KeyType): Promise<void>;\n\n /**\n * Returns the UTF-8 byte size of a string without buffer allocation, matching the\n * actual wire byte count for non-ASCII content (Base64 image data, emoji, etc.).\n */\n private getStringSize(str: string): number {\n let bytes = 0;\n for (let i = 0; i < str.length; i++) {\n const code = str.charCodeAt(i);\n if (code <= 0x7f) {\n bytes++;\n } else if (code <= 0x7ff) {\n bytes += 2;\n } else if (code >= 0xd800 && code <= 0xdbff) {\n // High surrogate — check for a valid low surrogate before consuming the pair.\n const next = i + 1 < str.length ? str.charCodeAt(i + 1) : NaN;\n if (next >= 0xdc00 && next <= 0xdfff) {\n // Valid surrogate pair → encodes a code point above U+FFFF (4 UTF-8 bytes).\n bytes += 4;\n i++;\n } else {\n // Orphaned high surrogate — treated as a replacement character (3 UTF-8 bytes).\n bytes += 3;\n }\n } else if (code >= 0xdc00 && code <= 0xdfff) {\n // Orphaned low surrogate — treated as a replacement character (3 UTF-8 bytes).\n bytes += 3;\n } else {\n // Other BMP character (U+0800–U+FFFF, excluding surrogates): 3 UTF-8 bytes.\n bytes += 3;\n }\n }\n return bytes;\n }\n\n /**\n * Calculates the total UTF-8 byte size of events array\n * Accounts for JSON serialization overhead when sent to backend\n */\n private getEventsArraySize(events: Events): number {\n let totalSize = 0;\n for (const event of events) {\n totalSize += this.getStringSize(event);\n }\n\n // Approximate overhead from the array portion of the JSON payload:\n // - Array brackets: [] = 2 bytes\n // - Commas between events: events.length - 1 bytes\n // - Double quotes wrapping each event string: events.length * 2 bytes\n // Note: does not include the outer { version, events } wrapper (~22 bytes) or\n // per-event JSON-escaping of \" and \\ characters; the reduced MAX_EVENT_LIST_SIZE\n // cap (700 KB vs 1 MB) provides headroom for those.\n const overhead = 2 + Math.max(0, events.length - 1) + events.length * 2;\n\n return totalSize + overhead;\n }\n\n /**\n * Determines whether to send the events list to the backend and start a new\n * empty events list, based on the size of the list as well as the last time sent\n * @param nextEventString\n * @returns boolean\n */\n shouldSplitEventsList = (events: Events, nextEventString: string): boolean => {\n const sizeOfNextEvent = this.getStringSize(nextEventString);\n const sizeOfEventsList = this.getEventsArraySize(events);\n\n // Check size constraint first (most likely to trigger)\n if (sizeOfEventsList + sizeOfNextEvent >= this.maxPersistedEventsSize) {\n return true;\n }\n if (Date.now() - this.timeAtLastSplit > this.interval && events.length) {\n this.interval = Math.min(this.maxInterval, this.interval + this.minInterval);\n this._timeAtLastSplit = Date.now();\n return true;\n }\n return false;\n };\n}\n"]}
|
|
@@ -23,6 +23,11 @@ export declare class EventCompressor {
|
|
|
23
23
|
compressEvent: (event: eventWithTime) => string;
|
|
24
24
|
private addCompressedEventToManager;
|
|
25
25
|
addCompressedEvent: (event: eventWithTime, sessionId: string | number) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Synchronously drain all queued events. Called during page unload to prevent
|
|
28
|
+
* data loss from events waiting in the requestIdleCallback queue.
|
|
29
|
+
*/
|
|
30
|
+
flushQueue: () => void;
|
|
26
31
|
private mergeMutationTasks;
|
|
27
32
|
terminate: () => void;
|
|
28
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-compressor.d.ts","sourceRoot":"","sources":["../../../src/events/event-compressor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"event-compressor.d.ts","sourceRoot":"","sources":["../../../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;IAEF;;;OAGG;IACI,UAAU,aAqBf;IAKF,OAAO,CAAC,kBAAkB;IA4BnB,SAAS,aAEd;CACH"}
|
|
@@ -4,6 +4,7 @@ exports.EventCompressor = void 0;
|
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var analytics_core_1 = require("@amplitude/analytics-core");
|
|
6
6
|
var rrweb_types_1 = require("@amplitude/rrweb-types");
|
|
7
|
+
var constants_1 = require("../constants");
|
|
7
8
|
var merge_mutation_events_1 = require("./merge-mutation-events");
|
|
8
9
|
var DEFAULT_TIMEOUT = 2000;
|
|
9
10
|
var EventCompressor = /** @class */ (function () {
|
|
@@ -24,6 +25,13 @@ var EventCompressor = /** @class */ (function () {
|
|
|
24
25
|
return delay != null ? JSON.stringify({ type: type, timestamp: timestamp, delay: delay, data: data }) : JSON.stringify({ type: type, timestamp: timestamp, data: data });
|
|
25
26
|
};
|
|
26
27
|
this.addCompressedEventToManager = function (compressedEvent, sessionId) {
|
|
28
|
+
// UTF-8 byte size, not JS char count: a 9 M-char string of CJK/emoji can be 18–27 MB
|
|
29
|
+
// on the wire and would otherwise slip past a char-count guard.
|
|
30
|
+
var eventSizeBytes = new Blob([compressedEvent]).size;
|
|
31
|
+
if (eventSizeBytes > constants_1.MAX_SINGLE_EVENT_SIZE) {
|
|
32
|
+
_this.config.loggerProvider.warn("Session replay event dropped: serialized size ".concat(Math.round(eventSizeBytes / 1024), " KB exceeds maximum allowed event size. If this recurs, please open a GitHub issue at https://github.com/amplitude/Amplitude-TypeScript/issues or contact Amplitude support."));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
27
35
|
if (_this.eventsManager && _this.deviceId) {
|
|
28
36
|
_this.eventsManager.addEvent({
|
|
29
37
|
event: { type: 'replay', data: compressedEvent },
|
|
@@ -54,6 +62,33 @@ var EventCompressor = /** @class */ (function () {
|
|
|
54
62
|
_this.addCompressedEventToManager(compressedEvent, sessionId);
|
|
55
63
|
}
|
|
56
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* Synchronously drain all queued events. Called during page unload to prevent
|
|
67
|
+
* data loss from events waiting in the requestIdleCallback queue.
|
|
68
|
+
*/
|
|
69
|
+
this.flushQueue = function () {
|
|
70
|
+
var _a;
|
|
71
|
+
// Merge any events still in pendingQueue into taskQueue first.
|
|
72
|
+
// Events land in pendingQueue when the idle callback hasn't fired yet;
|
|
73
|
+
// without this step they would be silently lost on page unload.
|
|
74
|
+
if (_this.pendingQueue.length > 0) {
|
|
75
|
+
(_a = _this.taskQueue).push.apply(_a, tslib_1.__spreadArray([], tslib_1.__read(_this.mergeMutationTasks(_this.pendingQueue.splice(0))), false));
|
|
76
|
+
}
|
|
77
|
+
while (_this.taskQueue.length > 0) {
|
|
78
|
+
var task = _this.taskQueue.shift();
|
|
79
|
+
if (task) {
|
|
80
|
+
var event_1 = task.event, sessionId = task.sessionId;
|
|
81
|
+
// Bypass the web worker: compress synchronously on the main thread and
|
|
82
|
+
// write directly to the manager. postMessage is async — during page
|
|
83
|
+
// unload the worker response would never arrive and events would be
|
|
84
|
+
// silently dropped. This mirrors the pattern used for full snapshots in
|
|
85
|
+
// enqueueEvent().
|
|
86
|
+
var compressed = _this.compressEvent(event_1);
|
|
87
|
+
_this.addCompressedEventToManager(compressed, sessionId);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
_this.isProcessing = false;
|
|
91
|
+
};
|
|
57
92
|
this.terminate = function () {
|
|
58
93
|
var _a;
|
|
59
94
|
(_a = _this.worker) === null || _a === void 0 ? void 0 : _a.terminate();
|
|
@@ -158,8 +193,8 @@ var EventCompressor = /** @class */ (function () {
|
|
|
158
193
|
while (this.taskQueue.length > 0 && (idleDeadline.timeRemaining() > 0 || idleDeadline.didTimeout)) {
|
|
159
194
|
var task = this.taskQueue.shift();
|
|
160
195
|
if (task) {
|
|
161
|
-
var
|
|
162
|
-
this.addCompressedEvent(
|
|
196
|
+
var event_2 = task.event, sessionId = task.sessionId;
|
|
197
|
+
this.addCompressedEvent(event_2, sessionId);
|
|
163
198
|
}
|
|
164
199
|
}
|
|
165
200
|
// If there are still tasks in the queue, schedule the next idle callback
|
|
@@ -195,8 +230,8 @@ var EventCompressor = /** @class */ (function () {
|
|
|
195
230
|
var merged = (0, merge_mutation_events_1.mergeMutationEvents)(tasks.slice(i, j).map(function (t) { return t.event; }));
|
|
196
231
|
try {
|
|
197
232
|
for (var merged_1 = (e_2 = void 0, tslib_1.__values(merged)), merged_1_1 = merged_1.next(); !merged_1_1.done; merged_1_1 = merged_1.next()) {
|
|
198
|
-
var
|
|
199
|
-
result.push({ event:
|
|
233
|
+
var event_3 = merged_1_1.value;
|
|
234
|
+
result.push({ event: event_3, sessionId: sessionId });
|
|
200
235
|
}
|
|
201
236
|
}
|
|
202
237
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|