@amplitude/session-replay-browser 1.26.2 → 1.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -3
- package/lib/cjs/config/joined-config.d.ts.map +1 -1
- package/lib/cjs/config/joined-config.js +10 -3
- package/lib/cjs/config/joined-config.js.map +1 -1
- package/lib/cjs/config/local-config.d.ts +3 -0
- package/lib/cjs/config/local-config.d.ts.map +1 -1
- package/lib/cjs/config/local-config.js +4 -1
- package/lib/cjs/config/local-config.js.map +1 -1
- package/lib/cjs/config/types.d.ts +30 -0
- 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 +3 -1
- package/lib/cjs/constants.js.map +1 -1
- package/lib/cjs/helpers.d.ts +7 -0
- package/lib/cjs/helpers.d.ts.map +1 -1
- package/lib/cjs/index.d.ts +1 -1
- package/lib/cjs/index.d.ts.map +1 -1
- package/lib/cjs/index.js +2 -2
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/plugins/index.d.ts +2 -0
- package/lib/cjs/plugins/index.d.ts.map +1 -0
- package/lib/cjs/plugins/index.js +5 -0
- package/lib/cjs/plugins/index.js.map +1 -0
- package/lib/cjs/plugins/url-tracking-plugin.d.ts +56 -0
- package/lib/cjs/plugins/url-tracking-plugin.d.ts.map +1 -0
- package/lib/cjs/plugins/url-tracking-plugin.js +187 -0
- package/lib/cjs/plugins/url-tracking-plugin.js.map +1 -0
- package/lib/cjs/session-replay-factory.d.ts.map +1 -1
- package/lib/cjs/session-replay-factory.js +1 -0
- package/lib/cjs/session-replay-factory.js.map +1 -1
- package/lib/cjs/session-replay.d.ts +12 -3
- package/lib/cjs/session-replay.d.ts.map +1 -1
- package/lib/cjs/session-replay.js +132 -19
- package/lib/cjs/session-replay.js.map +1 -1
- package/lib/cjs/targeting/targeting-idb-store.d.ts +38 -0
- package/lib/cjs/targeting/targeting-idb-store.d.ts.map +1 -0
- package/lib/cjs/targeting/targeting-idb-store.js +146 -0
- package/lib/cjs/targeting/targeting-idb-store.js.map +1 -0
- package/lib/cjs/targeting/targeting-manager.d.ts +11 -0
- package/lib/cjs/targeting/targeting-manager.d.ts.map +1 -0
- package/lib/cjs/targeting/targeting-manager.js +60 -0
- package/lib/cjs/targeting/targeting-manager.js.map +1 -0
- package/lib/cjs/typings/session-replay.d.ts +2 -0
- 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.js +1 -1
- package/lib/cjs/version.js.map +1 -1
- package/lib/esm/config/joined-config.d.ts.map +1 -1
- package/lib/esm/config/joined-config.js +10 -3
- package/lib/esm/config/joined-config.js.map +1 -1
- package/lib/esm/config/local-config.d.ts +3 -0
- package/lib/esm/config/local-config.d.ts.map +1 -1
- package/lib/esm/config/local-config.js +5 -2
- package/lib/esm/config/local-config.js.map +1 -1
- package/lib/esm/config/types.d.ts +30 -0
- 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 +2 -0
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/helpers.d.ts +7 -0
- package/lib/esm/helpers.d.ts.map +1 -1
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.d.ts.map +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/plugins/index.d.ts +2 -0
- package/lib/esm/plugins/index.d.ts.map +1 -0
- package/lib/esm/plugins/index.js +2 -0
- package/lib/esm/plugins/index.js.map +1 -0
- package/lib/esm/plugins/url-tracking-plugin.d.ts +56 -0
- package/lib/esm/plugins/url-tracking-plugin.d.ts.map +1 -0
- package/lib/esm/plugins/url-tracking-plugin.js +183 -0
- package/lib/esm/plugins/url-tracking-plugin.js.map +1 -0
- package/lib/esm/session-replay-factory.d.ts.map +1 -1
- package/lib/esm/session-replay-factory.js +1 -0
- package/lib/esm/session-replay-factory.js.map +1 -1
- package/lib/esm/session-replay.d.ts +12 -3
- package/lib/esm/session-replay.d.ts.map +1 -1
- package/lib/esm/session-replay.js +133 -20
- package/lib/esm/session-replay.js.map +1 -1
- package/lib/esm/targeting/targeting-idb-store.d.ts +38 -0
- package/lib/esm/targeting/targeting-idb-store.d.ts.map +1 -0
- package/lib/esm/targeting/targeting-idb-store.js +143 -0
- package/lib/esm/targeting/targeting-idb-store.js.map +1 -0
- package/lib/esm/targeting/targeting-manager.d.ts +11 -0
- package/lib/esm/targeting/targeting-manager.d.ts.map +1 -0
- package/lib/esm/targeting/targeting-manager.js +56 -0
- package/lib/esm/targeting/targeting-manager.js.map +1 -0
- package/lib/esm/typings/session-replay.d.ts +2 -0
- 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.js +1 -1
- package/lib/esm/version.js.map +1 -1
- package/lib/scripts/observers-min.js +1 -1
- package/lib/scripts/observers-min.js.gz +0 -0
- package/lib/scripts/observers-min.js.map +1 -1
- package/lib/scripts/session-replay-browser-esm.js +1 -1
- package/lib/scripts/session-replay-browser-esm.js.gz +0 -0
- 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/session-replay-min.js +1 -1
- package/lib/scripts/session-replay-min.js.gz +0 -0
- package/lib/scripts/session-replay-min.js.map +1 -1
- package/lib/scripts/targeting-min.js +2 -0
- package/lib/scripts/targeting-min.js.gz +0 -0
- package/lib/scripts/targeting-min.js.map +1 -0
- package/package.json +6 -3
|
@@ -38,7 +38,7 @@ var SessionReplayJoinedConfigGenerator = /** @class */ (function () {
|
|
|
38
38
|
SessionReplayJoinedConfigGenerator.prototype.generateJoinedConfig = function (sessionId) {
|
|
39
39
|
var _a, _b, _c, _d;
|
|
40
40
|
return __awaiter(this, void 0, void 0, function () {
|
|
41
|
-
var config, remoteConfig, namespaceConfig, samplingConfig_1, privacyConfig, ugcFilterRules, err_1, knownError, samplingConfig, remotePrivacyConfig, localPrivacyConfig, joinedPrivacyConfig, privacyConfigSelectorMap, selectorMap, _e, _f, _g, selector, selectorType;
|
|
41
|
+
var config, remoteConfig, namespaceConfig, samplingConfig_1, privacyConfig, targetingConfig_1, ugcFilterRules, err_1, knownError, samplingConfig, remotePrivacyConfig, targetingConfig, localPrivacyConfig, joinedPrivacyConfig, privacyConfigSelectorMap, selectorMap, _e, _f, _g, selector, selectorType;
|
|
42
42
|
var e_1, _h;
|
|
43
43
|
return __generator(this, function (_j) {
|
|
44
44
|
switch (_j.label) {
|
|
@@ -58,6 +58,7 @@ var SessionReplayJoinedConfigGenerator = /** @class */ (function () {
|
|
|
58
58
|
if (namespaceConfig) {
|
|
59
59
|
samplingConfig_1 = namespaceConfig.sr_sampling_config;
|
|
60
60
|
privacyConfig = namespaceConfig.sr_privacy_config;
|
|
61
|
+
targetingConfig_1 = namespaceConfig.sr_targeting_config;
|
|
61
62
|
ugcFilterRules = (_a = config.interactionConfig) === null || _a === void 0 ? void 0 : _a.ugcFilterRules;
|
|
62
63
|
// This is intentionally forced to only be set through the remote config.
|
|
63
64
|
config.interactionConfig = namespaceConfig.sr_interaction_config;
|
|
@@ -66,7 +67,7 @@ var SessionReplayJoinedConfigGenerator = /** @class */ (function () {
|
|
|
66
67
|
}
|
|
67
68
|
// This is intentionally forced to only be set through the remote config.
|
|
68
69
|
config.loggingConfig = namespaceConfig.sr_logging_config;
|
|
69
|
-
if (samplingConfig_1 || privacyConfig) {
|
|
70
|
+
if (samplingConfig_1 || privacyConfig || targetingConfig_1) {
|
|
70
71
|
remoteConfig = {};
|
|
71
72
|
if (samplingConfig_1) {
|
|
72
73
|
remoteConfig.sr_sampling_config = samplingConfig_1;
|
|
@@ -74,6 +75,9 @@ var SessionReplayJoinedConfigGenerator = /** @class */ (function () {
|
|
|
74
75
|
if (privacyConfig) {
|
|
75
76
|
remoteConfig.sr_privacy_config = privacyConfig;
|
|
76
77
|
}
|
|
78
|
+
if (targetingConfig_1) {
|
|
79
|
+
remoteConfig.sr_targeting_config = targetingConfig_1;
|
|
80
|
+
}
|
|
77
81
|
}
|
|
78
82
|
}
|
|
79
83
|
return [3 /*break*/, 4];
|
|
@@ -91,7 +95,7 @@ var SessionReplayJoinedConfigGenerator = /** @class */ (function () {
|
|
|
91
95
|
remoteConfig: remoteConfig,
|
|
92
96
|
}];
|
|
93
97
|
}
|
|
94
|
-
samplingConfig = remoteConfig.sr_sampling_config, remotePrivacyConfig = remoteConfig.sr_privacy_config;
|
|
98
|
+
samplingConfig = remoteConfig.sr_sampling_config, remotePrivacyConfig = remoteConfig.sr_privacy_config, targetingConfig = remoteConfig.sr_targeting_config;
|
|
95
99
|
if (samplingConfig && Object.keys(samplingConfig).length > 0) {
|
|
96
100
|
if (Object.prototype.hasOwnProperty.call(samplingConfig, 'capture_enabled')) {
|
|
97
101
|
config.captureEnabled = samplingConfig.capture_enabled;
|
|
@@ -203,6 +207,9 @@ var SessionReplayJoinedConfigGenerator = /** @class */ (function () {
|
|
|
203
207
|
}
|
|
204
208
|
config.privacyConfig = removeInvalidSelectorsFromPrivacyConfig(joinedPrivacyConfig, this.localConfig.loggerProvider);
|
|
205
209
|
}
|
|
210
|
+
if (targetingConfig && Object.keys(targetingConfig).length > 0) {
|
|
211
|
+
config.targetingConfig = targetingConfig;
|
|
212
|
+
}
|
|
206
213
|
this.localConfig.loggerProvider.debug(JSON.stringify({ name: 'session replay joined config', config: getDebugConfig(config) }, null, 2));
|
|
207
214
|
return [2 /*return*/, {
|
|
208
215
|
localConfig: this.localConfig,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"joined-config.js","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etch } from '@amplitude/analytics-remote-config';\nimport { ILogger } from '@amplitude/analytics-core';\nimport { getDebugConfig } from '../helpers';\nimport { SessionReplayOptions } from '../typings/session-replay';\nimport { SessionReplayLocalConfig } from './local-config';\nimport {\n SessionReplayLocalConfig as ISessionReplayLocalConfig,\n PrivacyConfig,\n SessionReplayConfigs,\n SessionReplayJoinedConfig,\n SessionReplayRemoteConfig,\n} from './types';\n\nexport const removeInvalidSelectorsFromPrivacyConfig = (privacyConfig: PrivacyConfig, loggerProvider: ILogger) => {\n // This allows us to not search the DOM.\n const fragment = document.createDocumentFragment();\n\n const dropInvalidSelectors = (selectors: string[] | string = []): string[] | undefined => {\n if (typeof selectors === 'string') {\n selectors = [selectors];\n }\n selectors = selectors.filter((selector: string) => {\n try {\n fragment.querySelector(selector);\n } catch {\n loggerProvider.warn(`[session-replay-browser] omitting selector \"${selector}\" because it is invalid`);\n return false;\n }\n return true;\n });\n if (selectors.length === 0) {\n return undefined;\n }\n return selectors;\n };\n privacyConfig.blockSelector = dropInvalidSelectors(privacyConfig.blockSelector);\n privacyConfig.maskSelector = dropInvalidSelectors(privacyConfig.maskSelector);\n privacyConfig.unmaskSelector = dropInvalidSelectors(privacyConfig.unmaskSelector);\n return privacyConfig;\n};\nexport class SessionReplayJoinedConfigGenerator {\n private readonly localConfig: ISessionReplayLocalConfig;\n private readonly remoteConfigFetch: RemoteConfigFetch<SessionReplayRemoteConfig>;\n\n constructor(remoteConfigFetch: RemoteConfigFetch<SessionReplayRemoteConfig>, localConfig: ISessionReplayLocalConfig) {\n this.localConfig = localConfig;\n this.remoteConfigFetch = remoteConfigFetch;\n }\n\n async generateJoinedConfig(sessionId?: string | number): Promise<SessionReplayConfigs> {\n const config: SessionReplayJoinedConfig = { ...this.localConfig };\n // Special case here as optOut is implemented via getter/setter\n config.optOut = this.localConfig.optOut;\n // We always want captureEnabled to be true, unless there's an override\n // in the remote config.\n config.captureEnabled = true;\n let remoteConfig: SessionReplayRemoteConfig | undefined;\n try {\n const namespaceConfig = await this.remoteConfigFetch.getRemoteNamespaceConfig('sessionReplay', sessionId);\n if (namespaceConfig) {\n const samplingConfig = namespaceConfig.sr_sampling_config;\n const privacyConfig = namespaceConfig.sr_privacy_config;\n\n const ugcFilterRules = config.interactionConfig?.ugcFilterRules;\n // This is intentionally forced to only be set through the remote config.\n config.interactionConfig = namespaceConfig.sr_interaction_config;\n if (config.interactionConfig && ugcFilterRules) {\n config.interactionConfig.ugcFilterRules = ugcFilterRules;\n }\n\n // This is intentionally forced to only be set through the remote config.\n config.loggingConfig = namespaceConfig.sr_logging_config;\n\n if (samplingConfig || privacyConfig) {\n remoteConfig = {};\n if (samplingConfig) {\n remoteConfig.sr_sampling_config = samplingConfig;\n }\n if (privacyConfig) {\n remoteConfig.sr_privacy_config = privacyConfig;\n }\n }\n }\n } catch (err: unknown) {\n const knownError = err as Error;\n this.localConfig.loggerProvider.warn(knownError.message);\n config.captureEnabled = false;\n }\n\n if (!remoteConfig) {\n return {\n localConfig: this.localConfig,\n joinedConfig: config,\n remoteConfig,\n };\n }\n\n const { sr_sampling_config: samplingConfig, sr_privacy_config: remotePrivacyConfig } = remoteConfig;\n if (samplingConfig && Object.keys(samplingConfig).length > 0) {\n if (Object.prototype.hasOwnProperty.call(samplingConfig, 'capture_enabled')) {\n config.captureEnabled = samplingConfig.capture_enabled;\n } else {\n config.captureEnabled = false;\n }\n\n if (Object.prototype.hasOwnProperty.call(samplingConfig, 'sample_rate')) {\n config.sampleRate = samplingConfig.sample_rate;\n }\n } else {\n // If config API response was valid (ie 200), but no config returned, assume that\n // customer has not yet set up config, and use sample rate from SDK options,\n // allowing for immediate replay capture\n config.captureEnabled = true;\n this.localConfig.loggerProvider.debug(\n 'Remote config successfully fetched, but no values set for project, Session Replay capture enabled.',\n );\n }\n\n // Remote config join acts somewhat like a left join between the remote and the local\n // config. That is, remote config has precedence over local values as with sampling.\n // However, non conflicting values will be added to the lists.\n // Here's an example to illustrate:\n //\n // Remote config: {'.selector1': 'MASK', '.selector2': 'UNMASK'}\n // Local config: {'.selector1': 'UNMASK', '.selector3': 'MASK'}\n //\n // Resolved config: {'.selector1': 'MASK', '.selector2': 'UNMASK', '.selector3': 'MASK'}\n // config.privacyConfig = {\n // ...(config.privacyConfig ?? {}),\n // ...remotePrivacyConfig,\n // };\n\n if (remotePrivacyConfig) {\n const localPrivacyConfig: PrivacyConfig = config.privacyConfig ?? {};\n\n const joinedPrivacyConfig: Required<PrivacyConfig> & { blockSelector: string[] } = {\n defaultMaskLevel: remotePrivacyConfig.defaultMaskLevel ?? localPrivacyConfig.defaultMaskLevel ?? 'medium',\n blockSelector: [],\n maskSelector: [],\n unmaskSelector: [],\n };\n\n const privacyConfigSelectorMap = (privacyConfig: PrivacyConfig): Record<string, 'mask' | 'unmask' | 'block'> => {\n const selectorMap: Record<string, 'mask' | 'unmask' | 'block'> = {};\n if (typeof privacyConfig.blockSelector === 'string') {\n privacyConfig.blockSelector = [privacyConfig.blockSelector];\n }\n\n for (const selector of privacyConfig.blockSelector ?? []) {\n selectorMap[selector] = 'block';\n }\n for (const selector of privacyConfig.maskSelector ?? []) {\n selectorMap[selector] = 'mask';\n }\n for (const selector of privacyConfig.unmaskSelector ?? []) {\n selectorMap[selector] = 'unmask';\n }\n return selectorMap;\n };\n\n const selectorMap: Record<string, 'mask' | 'unmask' | 'block'> = {\n ...privacyConfigSelectorMap(localPrivacyConfig),\n ...privacyConfigSelectorMap(remotePrivacyConfig),\n };\n\n for (const [selector, selectorType] of Object.entries(selectorMap)) {\n if (selectorType === 'mask') {\n joinedPrivacyConfig.maskSelector.push(selector);\n } else if (selectorType === 'block') {\n joinedPrivacyConfig.blockSelector.push(selector);\n } else if (selectorType === 'unmask') {\n joinedPrivacyConfig.unmaskSelector.push(selector);\n }\n }\n\n config.privacyConfig = removeInvalidSelectorsFromPrivacyConfig(\n joinedPrivacyConfig,\n this.localConfig.loggerProvider,\n );\n }\n\n this.localConfig.loggerProvider.debug(\n JSON.stringify({ name: 'session replay joined config', config: getDebugConfig(config) }, null, 2),\n );\n\n return {\n localConfig: this.localConfig,\n joinedConfig: config,\n remoteConfig,\n };\n }\n}\n\nexport const createSessionReplayJoinedConfigGenerator = async (apiKey: string, options: SessionReplayOptions) => {\n const localConfig = new SessionReplayLocalConfig(apiKey, options);\n const remoteConfigFetch = await createRemoteConfigFetch<SessionReplayRemoteConfig>({\n localConfig,\n configKeys: ['sessionReplay'],\n });\n\n return new SessionReplayJoinedConfigGenerator(remoteConfigFetch, localConfig);\n};\n"]}
|
|
1
|
+
{"version":3,"file":"joined-config.js","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":";AAAA,OAAO,EAAqB,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAEhG,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAS1D,MAAM,CAAC,IAAM,uCAAuC,GAAG,UAAC,aAA4B,EAAE,cAAuB;IAC3G,wCAAwC;IACxC,IAAM,QAAQ,GAAG,QAAQ,CAAC,sBAAsB,EAAE,CAAC;IAEnD,IAAM,oBAAoB,GAAG,UAAC,SAAiC;QAAjC,0BAAA,EAAA,cAAiC;QAC7D,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;YACjC,SAAS,GAAG,CAAC,SAAS,CAAC,CAAC;SACzB;QACD,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,UAAC,QAAgB;YAC5C,IAAI;gBACF,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;aAClC;YAAC,WAAM;gBACN,cAAc,CAAC,IAAI,CAAC,uDAA+C,QAAQ,6BAAyB,CAAC,CAAC;gBACtG,OAAO,KAAK,CAAC;aACd;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;QACH,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;YAC1B,OAAO,SAAS,CAAC;SAClB;QACD,OAAO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,EAAE,IAAI,EAAE,8BAA8B,EAAE,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAClG,CAAC;wBAEF,sBAAO;gCACL,WAAW,EAAE,IAAI,CAAC,WAAW;gCAC7B,YAAY,EAAE,MAAM;gCACpB,YAAY,cAAA;6BACb,EAAC;;;;KACH;IACH,yCAAC;AAAD,CAAC,AAnKD,IAmKC;;AAED,MAAM,CAAC,IAAM,wCAAwC,GAAG,UAAO,MAAc,EAAE,OAA6B;;;;;gBACpG,WAAW,GAAG,IAAI,wBAAwB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBACxC,qBAAM,uBAAuB,CAA4B;wBACjF,WAAW,aAAA;wBACX,UAAU,EAAE,CAAC,eAAe,CAAC;qBAC9B,CAAC,EAAA;;gBAHI,iBAAiB,GAAG,SAGxB;gBAEF,sBAAO,IAAI,kCAAkC,CAAC,iBAAiB,EAAE,WAAW,CAAC,EAAC;;;KAC/E,CAAC","sourcesContent":["import { RemoteConfigFetch, createRemoteConfigFetch } from '@amplitude/analytics-remote-config';\nimport { ILogger } from '@amplitude/analytics-core';\nimport { getDebugConfig } from '../helpers';\nimport { SessionReplayOptions } from '../typings/session-replay';\nimport { SessionReplayLocalConfig } from './local-config';\nimport {\n SessionReplayLocalConfig as ISessionReplayLocalConfig,\n PrivacyConfig,\n SessionReplayConfigs,\n SessionReplayJoinedConfig,\n SessionReplayRemoteConfig,\n} from './types';\n\nexport const removeInvalidSelectorsFromPrivacyConfig = (privacyConfig: PrivacyConfig, loggerProvider: ILogger) => {\n // This allows us to not search the DOM.\n const fragment = document.createDocumentFragment();\n\n const dropInvalidSelectors = (selectors: string[] | string = []): string[] | undefined => {\n if (typeof selectors === 'string') {\n selectors = [selectors];\n }\n selectors = selectors.filter((selector: string) => {\n try {\n fragment.querySelector(selector);\n } catch {\n loggerProvider.warn(`[session-replay-browser] omitting selector \"${selector}\" because it is invalid`);\n return false;\n }\n return true;\n });\n if (selectors.length === 0) {\n return undefined;\n }\n return selectors;\n };\n privacyConfig.blockSelector = dropInvalidSelectors(privacyConfig.blockSelector);\n privacyConfig.maskSelector = dropInvalidSelectors(privacyConfig.maskSelector);\n privacyConfig.unmaskSelector = dropInvalidSelectors(privacyConfig.unmaskSelector);\n return privacyConfig;\n};\nexport class SessionReplayJoinedConfigGenerator {\n private readonly localConfig: ISessionReplayLocalConfig;\n private readonly remoteConfigFetch: RemoteConfigFetch<SessionReplayRemoteConfig>;\n\n constructor(remoteConfigFetch: RemoteConfigFetch<SessionReplayRemoteConfig>, localConfig: ISessionReplayLocalConfig) {\n this.localConfig = localConfig;\n this.remoteConfigFetch = remoteConfigFetch;\n }\n\n async generateJoinedConfig(sessionId?: string | number): Promise<SessionReplayConfigs> {\n const config: SessionReplayJoinedConfig = { ...this.localConfig };\n // Special case here as optOut is implemented via getter/setter\n config.optOut = this.localConfig.optOut;\n // We always want captureEnabled to be true, unless there's an override\n // in the remote config.\n config.captureEnabled = true;\n let remoteConfig: SessionReplayRemoteConfig | undefined;\n try {\n const namespaceConfig = await this.remoteConfigFetch.getRemoteNamespaceConfig('sessionReplay', sessionId);\n if (namespaceConfig) {\n const samplingConfig = namespaceConfig.sr_sampling_config;\n const privacyConfig = namespaceConfig.sr_privacy_config;\n const targetingConfig = namespaceConfig.sr_targeting_config;\n\n const ugcFilterRules = config.interactionConfig?.ugcFilterRules;\n // This is intentionally forced to only be set through the remote config.\n config.interactionConfig = namespaceConfig.sr_interaction_config;\n if (config.interactionConfig && ugcFilterRules) {\n config.interactionConfig.ugcFilterRules = ugcFilterRules;\n }\n\n // This is intentionally forced to only be set through the remote config.\n config.loggingConfig = namespaceConfig.sr_logging_config;\n\n if (samplingConfig || privacyConfig || targetingConfig) {\n remoteConfig = {};\n if (samplingConfig) {\n remoteConfig.sr_sampling_config = samplingConfig;\n }\n if (privacyConfig) {\n remoteConfig.sr_privacy_config = privacyConfig;\n }\n if (targetingConfig) {\n remoteConfig.sr_targeting_config = targetingConfig;\n }\n }\n }\n } catch (err: unknown) {\n const knownError = err as Error;\n this.localConfig.loggerProvider.warn(knownError.message);\n config.captureEnabled = false;\n }\n\n if (!remoteConfig) {\n return {\n localConfig: this.localConfig,\n joinedConfig: config,\n remoteConfig,\n };\n }\n\n const {\n sr_sampling_config: samplingConfig,\n sr_privacy_config: remotePrivacyConfig,\n sr_targeting_config: targetingConfig,\n } = remoteConfig;\n if (samplingConfig && Object.keys(samplingConfig).length > 0) {\n if (Object.prototype.hasOwnProperty.call(samplingConfig, 'capture_enabled')) {\n config.captureEnabled = samplingConfig.capture_enabled;\n } else {\n config.captureEnabled = false;\n }\n\n if (Object.prototype.hasOwnProperty.call(samplingConfig, 'sample_rate')) {\n config.sampleRate = samplingConfig.sample_rate;\n }\n } else {\n // If config API response was valid (ie 200), but no config returned, assume that\n // customer has not yet set up config, and use sample rate from SDK options,\n // allowing for immediate replay capture\n config.captureEnabled = true;\n this.localConfig.loggerProvider.debug(\n 'Remote config successfully fetched, but no values set for project, Session Replay capture enabled.',\n );\n }\n\n // Remote config join acts somewhat like a left join between the remote and the local\n // config. That is, remote config has precedence over local values as with sampling.\n // However, non conflicting values will be added to the lists.\n // Here's an example to illustrate:\n //\n // Remote config: {'.selector1': 'MASK', '.selector2': 'UNMASK'}\n // Local config: {'.selector1': 'UNMASK', '.selector3': 'MASK'}\n //\n // Resolved config: {'.selector1': 'MASK', '.selector2': 'UNMASK', '.selector3': 'MASK'}\n // config.privacyConfig = {\n // ...(config.privacyConfig ?? {}),\n // ...remotePrivacyConfig,\n // };\n\n if (remotePrivacyConfig) {\n const localPrivacyConfig: PrivacyConfig = config.privacyConfig ?? {};\n\n const joinedPrivacyConfig: Required<PrivacyConfig> & { blockSelector: string[] } = {\n defaultMaskLevel: remotePrivacyConfig.defaultMaskLevel ?? localPrivacyConfig.defaultMaskLevel ?? 'medium',\n blockSelector: [],\n maskSelector: [],\n unmaskSelector: [],\n };\n\n const privacyConfigSelectorMap = (privacyConfig: PrivacyConfig): Record<string, 'mask' | 'unmask' | 'block'> => {\n const selectorMap: Record<string, 'mask' | 'unmask' | 'block'> = {};\n if (typeof privacyConfig.blockSelector === 'string') {\n privacyConfig.blockSelector = [privacyConfig.blockSelector];\n }\n\n for (const selector of privacyConfig.blockSelector ?? []) {\n selectorMap[selector] = 'block';\n }\n for (const selector of privacyConfig.maskSelector ?? []) {\n selectorMap[selector] = 'mask';\n }\n for (const selector of privacyConfig.unmaskSelector ?? []) {\n selectorMap[selector] = 'unmask';\n }\n return selectorMap;\n };\n\n const selectorMap: Record<string, 'mask' | 'unmask' | 'block'> = {\n ...privacyConfigSelectorMap(localPrivacyConfig),\n ...privacyConfigSelectorMap(remotePrivacyConfig),\n };\n\n for (const [selector, selectorType] of Object.entries(selectorMap)) {\n if (selectorType === 'mask') {\n joinedPrivacyConfig.maskSelector.push(selector);\n } else if (selectorType === 'block') {\n joinedPrivacyConfig.blockSelector.push(selector);\n } else if (selectorType === 'unmask') {\n joinedPrivacyConfig.unmaskSelector.push(selector);\n }\n }\n\n config.privacyConfig = removeInvalidSelectorsFromPrivacyConfig(\n joinedPrivacyConfig,\n this.localConfig.loggerProvider,\n );\n }\n\n if (targetingConfig && Object.keys(targetingConfig).length > 0) {\n config.targetingConfig = targetingConfig;\n }\n\n this.localConfig.loggerProvider.debug(\n JSON.stringify({ name: 'session replay joined config', config: getDebugConfig(config) }, null, 2),\n );\n\n return {\n localConfig: this.localConfig,\n joinedConfig: config,\n remoteConfig,\n };\n }\n}\n\nexport const createSessionReplayJoinedConfigGenerator = async (apiKey: string, options: SessionReplayOptions) => {\n const localConfig = new SessionReplayLocalConfig(apiKey, options);\n const remoteConfigFetch = await createRemoteConfigFetch<SessionReplayRemoteConfig>({\n localConfig,\n configKeys: ['sessionReplay'],\n });\n\n return new SessionReplayJoinedConfigGenerator(remoteConfigFetch, localConfig);\n};\n"]}
|
|
@@ -27,6 +27,9 @@ export declare class SessionReplayLocalConfig extends Config implements ISession
|
|
|
27
27
|
script?: boolean;
|
|
28
28
|
comment?: boolean;
|
|
29
29
|
};
|
|
30
|
+
enableUrlChangePolling?: boolean;
|
|
31
|
+
urlChangePollingInterval?: number;
|
|
32
|
+
captureDocumentTitle?: boolean;
|
|
30
33
|
constructor(apiKey: string, options: SessionReplayOptions);
|
|
31
34
|
}
|
|
32
35
|
//# 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;AAOrF,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EACL,wBAAwB,IAAI,yBAAyB,EACrD,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;QAAE,YAAY,EAAE,OAAO,CAAA;KAAE,CAAC;IACzC,qCAAqC,CAAC,EAAE,OAAO,CAAC;IAChD,eAAe,CAAC,EAAE;QAChB,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;IACF,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,oBAAoB,CAAC,EAAE,OAAO,CAAC;gBAEnB,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB;CAgD1D"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __assign, __extends } from "tslib";
|
|
2
2
|
import { Config, Logger, FetchTransport, LogLevel } from '@amplitude/analytics-core';
|
|
3
|
-
import { DEFAULT_PERFORMANCE_CONFIG, DEFAULT_SAMPLE_RATE, DEFAULT_SERVER_ZONE } from '../constants';
|
|
3
|
+
import { DEFAULT_PERFORMANCE_CONFIG, DEFAULT_SAMPLE_RATE, DEFAULT_SERVER_ZONE, DEFAULT_URL_CHANGE_POLLING_INTERVAL, } from '../constants';
|
|
4
4
|
import { SafeLoggerProvider } from '../logger';
|
|
5
5
|
import { validateUGCFilterRules } from '../helpers';
|
|
6
6
|
export var getDefaultConfig = function () { return ({
|
|
@@ -13,7 +13,7 @@ var SessionReplayLocalConfig = /** @class */ (function (_super) {
|
|
|
13
13
|
__extends(SessionReplayLocalConfig, _super);
|
|
14
14
|
function SessionReplayLocalConfig(apiKey, options) {
|
|
15
15
|
var _this = this;
|
|
16
|
-
var _a, _b;
|
|
16
|
+
var _a, _b, _c, _d, _e;
|
|
17
17
|
var defaultConfig = getDefaultConfig();
|
|
18
18
|
_this = _super.call(this, __assign(__assign({ transportProvider: defaultConfig.transportProvider, loggerProvider: new SafeLoggerProvider(options.loggerProvider || defaultConfig.loggerProvider) }, options), { apiKey: apiKey })) || this;
|
|
19
19
|
_this.flushMaxRetries =
|
|
@@ -30,6 +30,9 @@ var SessionReplayLocalConfig = /** @class */ (function (_super) {
|
|
|
30
30
|
_this.performanceConfig = options.performanceConfig || DEFAULT_PERFORMANCE_CONFIG;
|
|
31
31
|
_this.storeType = (_a = options.storeType) !== null && _a !== void 0 ? _a : 'idb';
|
|
32
32
|
_this.applyBackgroundColorToBlockedElements = (_b = options.applyBackgroundColorToBlockedElements) !== null && _b !== void 0 ? _b : false;
|
|
33
|
+
_this.enableUrlChangePolling = (_c = options.enableUrlChangePolling) !== null && _c !== void 0 ? _c : false;
|
|
34
|
+
_this.urlChangePollingInterval = (_d = options.urlChangePollingInterval) !== null && _d !== void 0 ? _d : DEFAULT_URL_CHANGE_POLLING_INTERVAL;
|
|
35
|
+
_this.captureDocumentTitle = (_e = options.captureDocumentTitle) !== null && _e !== void 0 ? _e : false;
|
|
33
36
|
if (options.privacyConfig) {
|
|
34
37
|
_this.privacyConfig = options.privacyConfig;
|
|
35
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-config.js","sourceRoot":"","sources":["../../../src/config/local-config.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrF,OAAO,
|
|
1
|
+
{"version":3,"file":"local-config.js","sourceRoot":"","sources":["../../../src/config/local-config.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrF,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,EACnB,mBAAmB,EACnB,mCAAmC,GACpC,MAAM,cAAc,CAAC;AAStB,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM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AI,KAAK,CAAC;QAC5C,KAAI,CAAC,qCAAqC,GAAG,MAAA,OAAO,CAAC,qCAAqC,mCAAI,KAAK,CAAC;QACpG,KAAI,CAAC,sBAAsB,GAAG,MAAA,OAAO,CAAC,sBAAsB,mCAAI,KAAK,CAAC;QACtE,KAAI,CAAC,wBAAwB,GAAG,MAAA,OAAO,CAAC,wBAAwB,mCAAI,mCAAmC,CAAC;QACxG,KAAI,CAAC,oBAAoB,GAAG,MAAA,OAAO,CAAC,oBAAoB,mCAAI,KAAK,CAAC;QAElE,IAAI,OAAO,CAAC,aAAa,EAAE;YACzB,KAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;SAC5C;QACD,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,sBAAsB,CAAC,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,IAAI,OAAO,CAAC,YAAY,EAAE;YACxB,KAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;SAC1C;QACD,IAAI,OAAO,CAAC,eAAe,EAAE;YAC3B,KAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;SAChD;;IACH,CAAC;IACH,+BAAC;AAAD,CAAC,AAtED,CAA8C,MAAM,GAsEnD","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} from '../constants';\nimport { SessionReplayOptions, StoreType } from '../typings/session-replay';\nimport {\n SessionReplayLocalConfig as ISessionReplayLocalConfig,\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 experimental?: { useWebWorker: boolean };\n applyBackgroundColorToBlockedElements?: boolean;\n omitElementTags?: {\n script?: boolean;\n comment?: boolean;\n };\n enableUrlChangePolling?: boolean;\n urlChangePollingInterval?: number;\n captureDocumentTitle?: boolean;\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 ?? 'idb';\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\n if (options.privacyConfig) {\n this.privacyConfig = options.privacyConfig;\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 if (options.experimental) {\n this.experimental = options.experimental;\n }\n if (options.omitElementTags) {\n this.omitElementTags = options.omitElementTags;\n }\n }\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IConfig, LogLevel, ILogger } from '@amplitude/analytics-core';
|
|
2
2
|
import { StoreType, ConsoleLogLevel } from '../typings/session-replay';
|
|
3
|
+
import { TargetingFlag } from '@amplitude/targeting';
|
|
3
4
|
export interface SamplingConfig {
|
|
4
5
|
sample_rate: number;
|
|
5
6
|
capture_enabled: boolean;
|
|
@@ -22,11 +23,13 @@ export interface LoggingConfig {
|
|
|
22
23
|
enabled: boolean;
|
|
23
24
|
};
|
|
24
25
|
}
|
|
26
|
+
export type TargetingConfig = TargetingFlag;
|
|
25
27
|
export type SessionReplayRemoteConfig = {
|
|
26
28
|
sr_sampling_config?: SamplingConfig;
|
|
27
29
|
sr_privacy_config?: PrivacyConfig;
|
|
28
30
|
sr_interaction_config?: InteractionConfig;
|
|
29
31
|
sr_logging_config?: LoggingConfig;
|
|
32
|
+
sr_targeting_config?: TargetingConfig;
|
|
30
33
|
};
|
|
31
34
|
export interface SessionReplayRemoteConfigAPIResponse {
|
|
32
35
|
configs: {
|
|
@@ -126,6 +129,9 @@ export interface SessionReplayLocalConfig extends IConfig {
|
|
|
126
129
|
*/
|
|
127
130
|
useWebWorker: boolean;
|
|
128
131
|
};
|
|
132
|
+
userProperties?: {
|
|
133
|
+
[key: string]: any;
|
|
134
|
+
};
|
|
129
135
|
/**
|
|
130
136
|
* Remove certain parts of the DOM from being captured. These are typically ignored when blocking by selectors.
|
|
131
137
|
*/
|
|
@@ -144,12 +150,36 @@ export interface SessionReplayLocalConfig extends IConfig {
|
|
|
144
150
|
* This helps visualize which elements are blocked from being captured.
|
|
145
151
|
*/
|
|
146
152
|
applyBackgroundColorToBlockedElements?: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Enables URL change polling as a fallback for SPA route tracking.
|
|
155
|
+
* When enabled, the SDK will periodically check for URL changes every second
|
|
156
|
+
* in addition to patching the History API. This is useful for edge cases where
|
|
157
|
+
* route changes might bypass the standard History API methods.
|
|
158
|
+
*
|
|
159
|
+
* @defaultValue false
|
|
160
|
+
*/
|
|
161
|
+
enableUrlChangePolling?: boolean;
|
|
162
|
+
/**
|
|
163
|
+
* Specifies the interval in milliseconds for URL change polling when enableUrlChangePolling is true.
|
|
164
|
+
* The SDK will check for URL changes at this interval as a fallback for SPA route tracking.
|
|
165
|
+
*
|
|
166
|
+
* @defaultValue 1000
|
|
167
|
+
*/
|
|
168
|
+
urlChangePollingInterval?: number;
|
|
169
|
+
/**
|
|
170
|
+
* Whether to capture document title in URL change events.
|
|
171
|
+
* When disabled, the title field will be empty in URL change events.
|
|
172
|
+
*
|
|
173
|
+
* @defaultValue false
|
|
174
|
+
*/
|
|
175
|
+
captureDocumentTitle?: boolean;
|
|
147
176
|
interactionConfig?: InteractionConfig;
|
|
148
177
|
}
|
|
149
178
|
export interface SessionReplayJoinedConfig extends SessionReplayLocalConfig {
|
|
150
179
|
captureEnabled?: boolean;
|
|
151
180
|
interactionConfig?: InteractionConfig;
|
|
152
181
|
loggingConfig?: LoggingConfig;
|
|
182
|
+
targetingConfig?: TargetingConfig;
|
|
153
183
|
}
|
|
154
184
|
export interface SessionReplayRemoteConfigFetch {
|
|
155
185
|
getServerUrl: () => void;
|
|
@@ -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;
|
|
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,CAAC,EAAE,aAAa,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE;QACP,OAAO,EAAE,OAAO,CAAC;QACjB,MAAM,EAAE,eAAe,EAAE,CAAC;KAC3B,CAAC;IACF,OAAO,CAAC,EAAE;QACR,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;CACH;AAED,MAAM,MAAM,eAAe,GAAG,aAAa,CAAC;AAE5C,MAAM,MAAM,yBAAyB,GAAG;IACtC,kBAAkB,CAAC,EAAE,cAAc,CAAC;IACpC,iBAAiB,CAAC,EAAE,aAAa,CAAC;IAClC,qBAAqB,CAAC,EAAE,iBAAiB,CAAC;IAC1C,iBAAiB,CAAC,EAAE,aAAa,CAAC;IAClC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AY,EAAE,yBAAyB,CAAC;IACxC,YAAY,EAAE,yBAAyB,GAAG,SAAS,CAAC;CACrD;AACD,MAAM,WAAW,kCAAkC;IACjD,oBAAoB,EAAE,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACtF;AAED,MAAM,WAAW,qBAAqB;IACpC,YAAY,EAAE,yBAAyB,GAAG,SAAS,CAAC;IACpD,WAAW,EAAE,wBAAwB,CAAC;IACtC,YAAY,EAAE,yBAAyB,CAAC;IACxC,SAAS,CAAC,EAAE;QACV,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,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;CAClB;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":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":"AAkDA,MAAM,CAAC,IAAM,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 };\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};\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 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 * Experimental features.\n */\n experimental?: {\n /**\n * If the SDK should compress the replay events using a webworker.\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\nexport interface SessionReplayJoinedConfig extends SessionReplayLocalConfig {\n captureEnabled?: boolean;\n interactionConfig?: InteractionConfig;\n loggingConfig?: LoggingConfig;\n targetingConfig?: TargetingConfig;\n}\n\nexport interface SessionReplayRemoteConfigFetch {\n getServerUrl: () => void;\n getSamplingConfig: (sessionId?: number) => Promise<SessionReplayRemoteConfig['sr_sampling_config'] | void>;\n fetchRemoteConfig: (sessionId?: number) => Promise<SessionReplayRemoteConfig | void>;\n getRemoteConfig: (sessionId?: number) => Promise<SessionReplayRemoteConfig | void>;\n}\n\nexport interface SessionReplayConfigs {\n localConfig: SessionReplayLocalConfig;\n joinedConfig: SessionReplayJoinedConfig;\n remoteConfig: SessionReplayRemoteConfig | undefined;\n}\nexport interface SessionReplayJoinedConfigGenerator {\n generateJoinedConfig: (sessionId?: string | number) => 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\nexport type SessionReplayType = 'standalone' | 'plugin' | 'segment';\n"]}
|
package/lib/esm/constants.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export declare const DEFAULT_SERVER_ZONE = ServerZone.US;
|
|
|
8
8
|
export declare const DEFAULT_PERFORMANCE_CONFIG: {
|
|
9
9
|
enabled: boolean;
|
|
10
10
|
};
|
|
11
|
+
export declare const DEFAULT_URL_CHANGE_POLLING_INTERVAL = 1000;
|
|
11
12
|
export declare const SESSION_REPLAY_DEBUG_PROPERTY: string;
|
|
12
13
|
export declare const BLOCK_CLASS = "amp-block";
|
|
13
14
|
export declare const MASK_TEXT_CLASS = "amp-mask";
|
|
@@ -28,6 +29,7 @@ export declare enum CustomRRwebEvent {
|
|
|
28
29
|
GET_SR_PROPS = "get-sr-props",
|
|
29
30
|
DEBUG_INFO = "debug-info",
|
|
30
31
|
FETCH_REQUEST = "fetch-request",
|
|
31
|
-
METADATA = "metadata"
|
|
32
|
+
METADATA = "metadata",
|
|
33
|
+
TARGETING_DECISION = "targeting-decision"
|
|
32
34
|
}
|
|
33
35
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -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,+B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AO,MAAM,OAAO,OAAO,CAAC;AAC5B,eAAO,MAAM,cAAc,OAAO,CAAC;AAEnC,oBAAY,gBAAgB;IAC1B,YAAY,iBAAiB;IAC7B,UAAU,eAAe;IACzB,aAAa,kBAAkB;IAC/B,QAAQ,aAAa;IACrB,kBAAkB,uBAAuB;CAC1C"}
|
package/lib/esm/constants.js
CHANGED
|
@@ -6,6 +6,7 @@ export var DEFAULT_SESSION_END_EVENT = 'session_end';
|
|
|
6
6
|
export var DEFAULT_SAMPLE_RATE = 0;
|
|
7
7
|
export var DEFAULT_SERVER_ZONE = ServerZone.US;
|
|
8
8
|
export var DEFAULT_PERFORMANCE_CONFIG = { enabled: true };
|
|
9
|
+
export var DEFAULT_URL_CHANGE_POLLING_INTERVAL = 1000;
|
|
9
10
|
export var SESSION_REPLAY_DEBUG_PROPERTY = "".concat(DEFAULT_EVENT_PROPERTY_PREFIX, " Session Replay Debug");
|
|
10
11
|
export var BLOCK_CLASS = 'amp-block';
|
|
11
12
|
export var MASK_TEXT_CLASS = 'amp-mask';
|
|
@@ -28,5 +29,6 @@ export var CustomRRwebEvent;
|
|
|
28
29
|
CustomRRwebEvent["DEBUG_INFO"] = "debug-info";
|
|
29
30
|
CustomRRwebEvent["FETCH_REQUEST"] = "fetch-request";
|
|
30
31
|
CustomRRwebEvent["METADATA"] = "metadata";
|
|
32
|
+
CustomRRwebEvent["TARGETING_DECISION"] = "targeting-decision";
|
|
31
33
|
})(CustomRRwebEvent || (CustomRRwebEvent = {}));
|
|
32
34
|
//# sourceMappingURL=constants.js.map
|
package/lib/esm/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEzE,MAAM,CAAC,IAAM,6BAA6B,GAAG,aAAa,CAAC;AAE3D,MAAM,CAAC,IAAM,+BAA+B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AG,mDAAmD,CAAC;AACzF,MAAM,CAAC,IAAM,0BAA0B,GAAG,sDAAsD,CAAC;AACjG,MAAM,CAAC,IAAM,cAAc,GAAG,UAAG,gBAAgB,mBAAgB,CAAC;AAClE,MAAM,CAAC,IAAM,mBAAmB,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,iDAAiD;AACjG,MAAM,CAAC,IAAM,wBAAwB,GAAG,KAAM,CAAC,CAAC,aAAa;AAC7D,MAAM,CAAC,IAAM,wBAAwB,GAAG,KAAM,CAAC,CAAC,WAAW;AAC3D,MAAM,CAAC,IAAM,YAAY,GAAG,GAAG,CAAC,CAAC,SAAS;AAC1C,MAAM,CAAC,IAAM,YAAY,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;AACpD,MAAM,CAAC,IAAM,sBAAsB,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,SAAS;AACxE,MAAM,CAAC,IAAM,OAAO,GAAG,IAAI,CAAC;AAC5B,MAAM,CAAC,IAAM,cAAc,GAAG,IAAI,CAAC;AAEnC,MAAM,CAAN,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,KAAhB,gBAAgB,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`;\nexport const MAX_EVENT_LIST_SIZE = 1 * 1000000; // ~1 MB limit for JSON serialized events payload\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;\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"]}
|
package/lib/esm/helpers.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare const getDebugConfig: (config: SessionReplayJoinedConfig) => {
|
|
|
14
14
|
captureEnabled?: boolean | undefined;
|
|
15
15
|
interactionConfig?: import("./config/types").InteractionConfig | undefined;
|
|
16
16
|
loggingConfig?: import("./config/types").LoggingConfig | undefined;
|
|
17
|
+
targetingConfig?: import("@amplitude/experiment-core").EvaluationFlag | undefined;
|
|
17
18
|
apiKey: string;
|
|
18
19
|
loggerProvider: import("@amplitude/analytics-core").ILogger;
|
|
19
20
|
logLevel: import("@amplitude/analytics-core").LogLevel;
|
|
@@ -30,11 +31,17 @@ export declare const getDebugConfig: (config: SessionReplayJoinedConfig) => {
|
|
|
30
31
|
experimental?: {
|
|
31
32
|
useWebWorker: boolean;
|
|
32
33
|
} | undefined;
|
|
34
|
+
userProperties?: {
|
|
35
|
+
[key: string]: any;
|
|
36
|
+
} | undefined;
|
|
33
37
|
omitElementTags?: {
|
|
34
38
|
script?: boolean | undefined;
|
|
35
39
|
comment?: boolean | undefined;
|
|
36
40
|
} | undefined;
|
|
37
41
|
applyBackgroundColorToBlockedElements?: boolean | undefined;
|
|
42
|
+
enableUrlChangePolling?: boolean | undefined;
|
|
43
|
+
urlChangePollingInterval?: number | undefined;
|
|
44
|
+
captureDocumentTitle?: boolean | undefined;
|
|
38
45
|
flushIntervalMillis: number;
|
|
39
46
|
flushQueueSize: number;
|
|
40
47
|
instanceName?: string | undefined;
|
package/lib/esm/helpers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAiC,aAAa,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AASxH,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAqFvD,eAAO,MAAM,MAAM,gBACH,MAAM,GAAG,OAAO,WAAW,aAAa,YAC/C,MAAM,WAAW,WAAW,GAAG,IAAI,KAAG,MAE5C,CAAC;AAEJ,eAAO,MAAM,gBAAgB,QAAkB,MAAM,WASpD,CAAC;AAEF,eAAO,MAAM,iBAAiB,cAAwB,MAAM,GAAG,MAAM,cAAc,MAAM,YAMxF,CAAC;AAEF,eAAO,MAAM,aAAa,cAGzB,CAAC;AAEF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O,MAAM,cAAc,QAAa,QAAQ,WAAW,CAa1D,CAAC;AAEF,eAAO,MAAM,cAAc,WAAY,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAO/D,CAAC"}
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const init: (apiKey: string, options: import("./typings/session-replay").SessionReplayOptions) => import("@amplitude/analytics-core").AmplitudeReturn<void>, setSessionId: (sessionId: string | number, deviceId?: string | undefined) => import("@amplitude/analytics-core").AmplitudeReturn<void>, getSessionId: () => string | number | undefined, getSessionReplayProperties: () => {
|
|
2
2
|
[key: string]: string | boolean | null;
|
|
3
|
-
}, flush: (useRetry: boolean) => Promise<void>, shutdown: () => void
|
|
3
|
+
}, flush: (useRetry: boolean) => Promise<void>, shutdown: () => void, evaluateTargetingAndCapture: (targetingParams: Pick<import("@amplitude/targeting").TargetingParameters, "event" | "userProperties">, isInit?: boolean | undefined) => Promise<void>;
|
|
4
4
|
export { SessionReplayOptions, StoreType } from './typings/session-replay';
|
|
5
5
|
export { SafeLoggerProvider } from './logger';
|
|
6
6
|
export { AmplitudeSessionReplay } from './typings/session-replay';
|
package/lib/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,eAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,eAAO,MACL,IAAI,mJACJ,YAAY,4HACZ,YAAY,qCACZ,0BAA0B;;GAC1B,KAAK,wCACL,QAAQ,cACR,2BAA2B,wJACZ,CAAC;AAClB,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC"}
|
package/lib/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import sessionReplay from './session-replay-factory';
|
|
2
|
-
export var init = sessionReplay.init, setSessionId = sessionReplay.setSessionId, getSessionId = sessionReplay.getSessionId, getSessionReplayProperties = sessionReplay.getSessionReplayProperties, flush = sessionReplay.flush, shutdown = sessionReplay.shutdown;
|
|
2
|
+
export var init = sessionReplay.init, setSessionId = sessionReplay.setSessionId, getSessionId = sessionReplay.getSessionId, getSessionReplayProperties = sessionReplay.getSessionReplayProperties, flush = sessionReplay.flush, shutdown = sessionReplay.shutdown, evaluateTargetingAndCapture = sessionReplay.evaluateTargetingAndCapture;
|
|
3
3
|
export { SafeLoggerProvider } from './logger';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,0BAA0B,CAAC;AACrD,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,0BAA0B,CAAC;AACrD,MAAM,CACJ,IAAA,IAAI,GAOF,aAAa,KAPX,EACJ,YAAY,GAMV,aAAa,aANH,EACZ,YAAY,GAKV,aAAa,aALH,EACZ,0BAA0B,GAIxB,aAAa,2BAJW,EAC1B,KAAK,GAGH,aAAa,MAHV,EACL,QAAQ,GAEN,aAAa,SAFP,EACR,2BAA2B,GACzB,aAAa,4BADY,CACX;AAElB,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC","sourcesContent":["import sessionReplay from './session-replay-factory';\nexport const {\n init,\n setSessionId,\n getSessionId,\n getSessionReplayProperties,\n flush,\n shutdown,\n evaluateTargetingAndCapture,\n} = sessionReplay;\nexport { SessionReplayOptions, StoreType } from './typings/session-replay';\nexport { SafeLoggerProvider } from './logger';\nexport { AmplitudeSessionReplay } from './typings/session-replay';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC","sourcesContent":["export * from './url-tracking-plugin';\n"]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { UGCFilterRule } from '../config/types';
|
|
2
|
+
import { RecordPlugin } from '@amplitude/rrweb-types';
|
|
3
|
+
/**
|
|
4
|
+
* Event emitted when URL changes are detected by the plugin
|
|
5
|
+
* Contains the current page URL, title, and viewport dimensions
|
|
6
|
+
*/
|
|
7
|
+
export interface URLChangeEvent {
|
|
8
|
+
/** The current page URL (may be filtered if UGC rules are applied) */
|
|
9
|
+
href: string;
|
|
10
|
+
/** The current page title */
|
|
11
|
+
title: string;
|
|
12
|
+
/** Viewport height in pixels */
|
|
13
|
+
viewportHeight: number;
|
|
14
|
+
/** Viewport width in pixels */
|
|
15
|
+
viewportWidth: number;
|
|
16
|
+
/** The type of URL change event */
|
|
17
|
+
type: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Configuration options for the URL tracking plugin
|
|
21
|
+
*/
|
|
22
|
+
export interface URLTrackingPluginOptions {
|
|
23
|
+
/** Rules for filtering sensitive URLs (User Generated Content) */
|
|
24
|
+
ugcFilterRules?: UGCFilterRule[];
|
|
25
|
+
/** Whether to use polling instead of history API events for URL detection */
|
|
26
|
+
enablePolling?: boolean;
|
|
27
|
+
/** Interval in milliseconds for polling URL changes (default: 1000ms) */
|
|
28
|
+
pollingInterval?: number;
|
|
29
|
+
/** Whether to capture document title in URL change events (default: false) */
|
|
30
|
+
captureDocumentTitle?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Creates a URL tracking plugin for rrweb record function
|
|
34
|
+
*
|
|
35
|
+
* This plugin monitors URL changes in the browser and emits events when the URL changes.
|
|
36
|
+
* It supports three tracking modes:
|
|
37
|
+
* 1. Polling (if explicitly enabled) - periodically checks for URL changes
|
|
38
|
+
* 2. History API + Hash routing (default) - patches pushState/replaceState, listens to popstate and hashchange
|
|
39
|
+
* 3. Hash routing only (fallback) - listens to hashchange events when History API is unavailable
|
|
40
|
+
*
|
|
41
|
+
* The plugin handles edge cases gracefully:
|
|
42
|
+
* - Missing or null location objects
|
|
43
|
+
* - Undefined, null, or empty location.href values
|
|
44
|
+
* - Temporal dead zone issues with variable declarations
|
|
45
|
+
* - Consistent URL normalization across all code paths
|
|
46
|
+
*
|
|
47
|
+
* @param options Configuration options for URL tracking
|
|
48
|
+
* @returns RecordPlugin instance that can be used with rrweb
|
|
49
|
+
*/
|
|
50
|
+
export declare function createUrlTrackingPlugin(options?: URLTrackingPluginOptions): RecordPlugin<URLTrackingPluginOptions>;
|
|
51
|
+
/**
|
|
52
|
+
* Default URL tracking plugin instance with default options
|
|
53
|
+
* Can be used directly without custom configuration
|
|
54
|
+
*/
|
|
55
|
+
export declare const urlTrackingPlugin: RecordPlugin<URLTrackingPluginOptions>;
|
|
56
|
+
//# sourceMappingURL=url-tracking-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-tracking-plugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/url-tracking-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAC;IACb,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,gCAAgC;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,+BAA+B;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,kEAAkE;IAClE,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;IACjC,6EAA6E;IAC7E,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,yEAAyE;IACzE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,8EAA8E;IAC9E,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,GAAE,wBAA6B,GACrC,YAAY,CAAC,wBAAwB,CAAC,CA4KxC;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,wCAA4B,CAAC"}
|