@amplitude/session-replay-browser 1.22.5 → 1.22.7-prereleasenetworkcapture.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/config/joined-config.d.ts +2 -2
- package/lib/esm/config/joined-config.d.ts.map +1 -1
- package/lib/esm/config/joined-config.js +10 -2
- package/lib/esm/config/joined-config.js.map +1 -1
- package/lib/esm/config/types.d.ts +22 -1
- 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 +2 -1
- package/lib/esm/constants.d.ts.map +1 -1
- package/lib/esm/constants.js +1 -0
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/session-replay.d.ts +3 -1
- package/lib/esm/session-replay.d.ts.map +1 -1
- package/lib/esm/session-replay.js +50 -30
- package/lib/esm/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/amplitude-min.js +2 -0
- package/lib/scripts/amplitude-min.js.gz +0 -0
- package/lib/scripts/amplitude-min.js.map +1 -0
- package/lib/scripts/amplitude-min.umd.js +1 -0
- package/lib/scripts/amplitude-min.umd.js.gz +0 -0
- package/lib/scripts/beacon-transport.d.ts +28 -0
- package/lib/scripts/beacon-transport.d.ts.map +1 -0
- package/lib/scripts/config/joined-config.d.ts +13 -0
- package/lib/scripts/config/joined-config.d.ts.map +1 -0
- package/lib/scripts/config/local-config.d.ts +27 -0
- package/lib/scripts/config/local-config.d.ts.map +1 -0
- package/lib/scripts/config/types.d.ts +147 -0
- package/lib/scripts/config/types.d.ts.map +1 -0
- package/lib/scripts/console-plugin-min.js.gz +0 -0
- package/lib/scripts/constants.d.ts +29 -0
- package/lib/scripts/constants.d.ts.map +1 -0
- package/lib/scripts/events/base-events-store.d.ts +31 -0
- package/lib/scripts/events/base-events-store.d.ts.map +1 -0
- package/lib/scripts/events/event-compressor.d.ts +27 -0
- package/lib/scripts/events/event-compressor.d.ts.map +1 -0
- package/lib/scripts/events/events-idb-store.d.ts +52 -0
- package/lib/scripts/events/events-idb-store.d.ts.map +1 -0
- package/lib/scripts/events/events-manager.d.ts +13 -0
- package/lib/scripts/events/events-manager.d.ts.map +1 -0
- package/lib/scripts/events/events-memory-store.d.ts +15 -0
- package/lib/scripts/events/events-memory-store.d.ts.map +1 -0
- package/lib/scripts/events/legacy-idb-types.d.ts +26 -0
- package/lib/scripts/events/legacy-idb-types.d.ts.map +1 -0
- package/lib/scripts/events/multi-manager.d.ts +26 -0
- package/lib/scripts/events/multi-manager.d.ts.map +1 -0
- package/lib/scripts/helpers.d.ts +46 -0
- package/lib/scripts/helpers.d.ts.map +1 -0
- package/lib/scripts/hooks/click.d.ts +27 -0
- package/lib/scripts/hooks/click.d.ts.map +1 -0
- package/lib/scripts/hooks/scroll.d.ts +44 -0
- package/lib/scripts/hooks/scroll.d.ts.map +1 -0
- package/lib/scripts/identifiers.d.ts +11 -0
- package/lib/scripts/identifiers.d.ts.map +1 -0
- package/lib/scripts/index.d.ts +7 -0
- package/lib/scripts/index.d.ts.map +1 -0
- package/lib/scripts/libs/finder.d.ts +14 -0
- package/lib/scripts/libs/finder.d.ts.map +1 -0
- package/lib/scripts/logger.d.ts +13 -0
- package/lib/scripts/logger.d.ts.map +1 -0
- package/lib/scripts/messages.d.ts +7 -0
- package/lib/scripts/messages.d.ts.map +1 -0
- package/lib/scripts/observers.d.ts +24 -0
- package/lib/scripts/observers.d.ts.map +1 -0
- package/lib/scripts/session-replay-browser-esm.js.gz +0 -0
- package/lib/scripts/session-replay-browser-min.js.gz +0 -0
- package/lib/scripts/session-replay-factory.d.ts +7 -0
- package/lib/scripts/session-replay-factory.d.ts.map +1 -0
- package/lib/scripts/session-replay.d.ts +56 -0
- package/lib/scripts/session-replay.d.ts.map +1 -0
- package/lib/scripts/track-destination.d.ts +37 -0
- package/lib/scripts/track-destination.d.ts.map +1 -0
- package/lib/scripts/typings/session-replay.d.ts +129 -0
- package/lib/scripts/typings/session-replay.d.ts.map +1 -0
- package/lib/scripts/version.d.ts +2 -0
- package/lib/scripts/version.d.ts.map +1 -0
- package/lib/scripts/worker/compression.d.ts +2 -0
- package/lib/scripts/worker/compression.d.ts.map +1 -0
- package/package.json +3 -3
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { RemoteConfigFetch } from '@amplitude/analytics-remote-config';
|
|
2
2
|
import { ILogger } from '@amplitude/analytics-core';
|
|
3
3
|
import { SessionReplayOptions } from '../typings/session-replay';
|
|
4
|
-
import { SessionReplayLocalConfig as ISessionReplayLocalConfig, PrivacyConfig,
|
|
4
|
+
import { SessionReplayLocalConfig as ISessionReplayLocalConfig, PrivacyConfig, SessionReplayConfigs, SessionReplayRemoteConfig } from './types';
|
|
5
5
|
export declare const removeInvalidSelectorsFromPrivacyConfig: (privacyConfig: PrivacyConfig, loggerProvider: ILogger) => PrivacyConfig;
|
|
6
6
|
export declare class SessionReplayJoinedConfigGenerator {
|
|
7
7
|
private readonly localConfig;
|
|
8
8
|
private readonly remoteConfigFetch;
|
|
9
9
|
constructor(remoteConfigFetch: RemoteConfigFetch<SessionReplayRemoteConfig>, localConfig: ISessionReplayLocalConfig);
|
|
10
|
-
generateJoinedConfig(sessionId?: string | number): Promise<
|
|
10
|
+
generateJoinedConfig(sessionId?: string | number): Promise<SessionReplayConfigs>;
|
|
11
11
|
}
|
|
12
12
|
export declare const createSessionReplayJoinedConfigGenerator: (apiKey: string, options: SessionReplayOptions) => Promise<SessionReplayJoinedConfigGenerator>;
|
|
13
13
|
//# sourceMappingURL=joined-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"joined-config.d.ts","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA2B,MAAM,oCAAoC,CAAC;AAChG,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EACL,wBAAwB,IAAI,yBAAyB,EACrD,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"joined-config.d.ts","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA2B,MAAM,oCAAoC,CAAC;AAChG,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EACL,wBAAwB,IAAI,yBAAyB,EACrD,aAAa,EACb,oBAAoB,EAEpB,yBAAyB,EAC1B,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,uCAAuC,kBAAmB,aAAa,kBAAkB,OAAO,kBA0B5G,CAAC;AACF,qBAAa,kCAAkC;IAC7C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA4B;IACxD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA+C;gBAErE,iBAAiB,EAAE,iBAAiB,CAAC,yBAAyB,CAAC,EAAE,WAAW,EAAE,yBAAyB;IAK7G,oBAAoB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAwJvF;AAED,eAAO,MAAM,wCAAwC,WAAkB,MAAM,WAAW,oBAAoB,gDAQ3G,CAAC"}
|
|
@@ -88,7 +88,11 @@ var SessionReplayJoinedConfigGenerator = /** @class */ (function () {
|
|
|
88
88
|
return [3 /*break*/, 7];
|
|
89
89
|
case 7:
|
|
90
90
|
if (!remoteConfig) {
|
|
91
|
-
return [2 /*return*/,
|
|
91
|
+
return [2 /*return*/, {
|
|
92
|
+
localConfig: this.localConfig,
|
|
93
|
+
joinedConfig: config,
|
|
94
|
+
remoteConfig: remoteConfig,
|
|
95
|
+
}];
|
|
92
96
|
}
|
|
93
97
|
samplingConfig = remoteConfig.sr_sampling_config, remotePrivacyConfig = remoteConfig.sr_privacy_config;
|
|
94
98
|
if (samplingConfig && Object.keys(samplingConfig).length > 0) {
|
|
@@ -203,7 +207,11 @@ var SessionReplayJoinedConfigGenerator = /** @class */ (function () {
|
|
|
203
207
|
config.privacyConfig = removeInvalidSelectorsFromPrivacyConfig(joinedPrivacyConfig, this.localConfig.loggerProvider);
|
|
204
208
|
}
|
|
205
209
|
this.localConfig.loggerProvider.debug(JSON.stringify({ name: 'session replay joined config', config: getDebugConfig(config) }, null, 2));
|
|
206
|
-
return [2 /*return*/,
|
|
210
|
+
return [2 /*return*/, {
|
|
211
|
+
localConfig: this.localConfig,
|
|
212
|
+
joinedConfig: config,
|
|
213
|
+
remoteConfig: remoteConfig,
|
|
214
|
+
}];
|
|
207
215
|
}
|
|
208
216
|
});
|
|
209
217
|
});
|
|
@@ -1 +1 @@
|
|
|
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;AAQ1D,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,I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BAEF,sBAAO,MAAM,EAAC;;;;KACf;IACH,yCAAC;AAAD,CAAC,AAzJD,IAyJC;;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 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<SessionReplayJoinedConfig> {\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 samplingConfig = await this.remoteConfigFetch.getRemoteConfig(\n 'sessionReplay',\n 'sr_sampling_config',\n sessionId,\n );\n\n const privacyConfig = await this.remoteConfigFetch.getRemoteConfig(\n 'sessionReplay',\n 'sr_privacy_config',\n sessionId,\n );\n\n // This is intentionally forced to only be set through the remote config.\n config.interactionConfig = await this.remoteConfigFetch.getRemoteConfig(\n 'sessionReplay',\n 'sr_interaction_config',\n sessionId,\n );\n\n // This is intentionally forced to only be set through the remote config.\n config.loggingConfig = await this.remoteConfigFetch.getRemoteConfig(\n 'sessionReplay',\n 'sr_logging_config',\n sessionId,\n );\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 } 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 config;\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 config;\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,CAA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,IAAI,CAAC,WAAW,CAAC,cAAc,CAChC,CAAC;yBACH;wBAED,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,KAAK,CACnC,IAAI,CAAC,SAAS,CAAC,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,AAjKD,IAiKC;;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 samplingConfig = await this.remoteConfigFetch.getRemoteConfig(\n 'sessionReplay',\n 'sr_sampling_config',\n sessionId,\n );\n\n const privacyConfig = await this.remoteConfigFetch.getRemoteConfig(\n 'sessionReplay',\n 'sr_privacy_config',\n sessionId,\n );\n\n // This is intentionally forced to only be set through the remote config.\n config.interactionConfig = await this.remoteConfigFetch.getRemoteConfig(\n 'sessionReplay',\n 'sr_interaction_config',\n sessionId,\n );\n\n // This is intentionally forced to only be set through the remote config.\n config.loggingConfig = await this.remoteConfigFetch.getRemoteConfig(\n 'sessionReplay',\n 'sr_logging_config',\n sessionId,\n );\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 } 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"]}
|
|
@@ -121,8 +121,29 @@ export interface SessionReplayRemoteConfigFetch {
|
|
|
121
121
|
fetchRemoteConfig: (sessionId?: number) => Promise<SessionReplayRemoteConfig | void>;
|
|
122
122
|
getRemoteConfig: (sessionId?: number) => Promise<SessionReplayRemoteConfig | void>;
|
|
123
123
|
}
|
|
124
|
+
export interface SessionReplayConfigs {
|
|
125
|
+
localConfig: SessionReplayLocalConfig;
|
|
126
|
+
joinedConfig: SessionReplayJoinedConfig;
|
|
127
|
+
remoteConfig: SessionReplayRemoteConfig | undefined;
|
|
128
|
+
}
|
|
124
129
|
export interface SessionReplayJoinedConfigGenerator {
|
|
125
|
-
generateJoinedConfig: (sessionId?: string | number) => Promise<
|
|
130
|
+
generateJoinedConfig: (sessionId?: string | number) => Promise<SessionReplayConfigs>;
|
|
131
|
+
}
|
|
132
|
+
export interface SessionReplayMetadata {
|
|
133
|
+
remoteConfig: SessionReplayRemoteConfig | undefined;
|
|
134
|
+
localConfig: SessionReplayLocalConfig;
|
|
135
|
+
joinedConfig: SessionReplayJoinedConfig;
|
|
136
|
+
framework?: {
|
|
137
|
+
name: string;
|
|
138
|
+
version: string;
|
|
139
|
+
};
|
|
140
|
+
sessionId: string | number | undefined;
|
|
141
|
+
hashValue?: number;
|
|
142
|
+
sampleRate: number;
|
|
143
|
+
replaySDKType: string;
|
|
144
|
+
replaySDKVersion: string | undefined;
|
|
145
|
+
standaloneSDKType: string;
|
|
146
|
+
standaloneSDKVersion: string | undefined;
|
|
126
147
|
}
|
|
127
148
|
export interface SessionReplayVersion {
|
|
128
149
|
version: string;
|
|
@@ -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;AAEvE,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,iBAAiB;IAChC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AAyB,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,CAAC;IACtB,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":"AA0CA,MAAM,CAAC,IAAM,kBAAkB,GAAG,QAAQ,CAAC","sourcesContent":["import { IConfig, LogLevel, ILogger } from '@amplitude/analytics-core';\nimport { StoreType, ConsoleLogLevel } from '../typings/session-replay';\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\nexport interface LoggingConfig {\n console: {\n enabled: boolean;\n levels: ConsoleLogLevel[];\n };\n network?: {\n enabled: boolean;\n };\n}\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};\n\nexport interface SessionReplayRemoteConfigAPIResponse {\n configs: {\n sessionReplay: SessionReplayRemoteConfig;\n };\n}\n\nexport type MaskLevel =\n | 'light' // only mask a subset of inputs that
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":"AA0CA,MAAM,CAAC,IAAM,kBAAkB,GAAG,QAAQ,CAAC","sourcesContent":["import { IConfig, LogLevel, ILogger } from '@amplitude/analytics-core';\nimport { StoreType, ConsoleLogLevel } from '../typings/session-replay';\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\nexport interface LoggingConfig {\n console: {\n enabled: boolean;\n levels: ConsoleLogLevel[];\n };\n network?: {\n enabled: boolean;\n };\n}\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};\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\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}\n\nexport interface SessionReplayJoinedConfig extends SessionReplayLocalConfig {\n captureEnabled?: boolean;\n interactionConfig?: InteractionConfig;\n loggingConfig?: LoggingConfig;\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;\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
|
@@ -24,6 +24,7 @@ export declare const MAX_URL_LENGTH = 1000;
|
|
|
24
24
|
export declare enum CustomRRwebEvent {
|
|
25
25
|
GET_SR_PROPS = "get-sr-props",
|
|
26
26
|
DEBUG_INFO = "debug-info",
|
|
27
|
-
FETCH_REQUEST = "fetch-request"
|
|
27
|
+
FETCH_REQUEST = "fetch-request",
|
|
28
|
+
METADATA = "metadata"
|
|
28
29
|
}
|
|
29
30
|
//# 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,+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;AAEjD,eAAO,MAAM,6BAA6B,QAA0D,CAAC;AAErG,eAAO,MAAM,WAAW,cAAc,CAAC;AACvC,eAAO,MAAM,eAAe,aAAa,CAAC;AAC1C,eAAO,MAAM,iBAAiB,eAAe,CAAC;AAC9C,eAAO,MAAM,yBAAyB,mDAAmD,CAAC;AAC1F,eAAO,MAAM,qBAAqB,sDAAsD,CAAC;AACzF,eAAO,MAAM,0BAA0B,yDAAyD,CAAC;AACjG,eAAO,MAAM,cAAc,QAAsC,CAAC;AAClE,eAAO,MAAM,4BAA4B,QAAc,CAAC;AACxD,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAC/C,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAC/C,eAAO,MAAM,YAAY,MAAM,CAAC;AAChC,eAAO,MAAM,YAAY,QAAY,CAAC;AACtC,eAAO,MAAM,sBAAsB,QAA0B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Aa,kBAAkB;IAC/B,QAAQ,aAAa;CACtB"}
|
package/lib/esm/constants.js
CHANGED
|
@@ -26,5 +26,6 @@ export var CustomRRwebEvent;
|
|
|
26
26
|
CustomRRwebEvent["GET_SR_PROPS"] = "get-sr-props";
|
|
27
27
|
CustomRRwebEvent["DEBUG_INFO"] = "debug-info";
|
|
28
28
|
CustomRRwebEvent["FETCH_REQUEST"] = "fetch-request";
|
|
29
|
+
CustomRRwebEvent["METADATA"] = "metadata";
|
|
29
30
|
})(CustomRRwebEvent || (CustomRRwebEvent = {}));
|
|
30
31
|
//# 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,GAAG,UAAG,6BAA6B,uBAAoB,CAAC;AACpG,MAAM,CAAC,IAAM,2BAA2B,GAAG,eAAe,CAAC;AAC3D,MAAM,CAAC,IAAM,yBAAyB,GAAG,aAAa,CAAC;AACvD,MAAM,CAAC,IAAM,mBAAmB,GAAG,CAAC,CAAC;AACrC,MAAM,CAAC,IAAM,mBAAmB,GAAG,UAAU,CAAC,EAAE,CAAC;AAEjD,MAAM,CAAC,IAAM,6BAA6B,GAAG,UAAG,6BAA6B,0BAAuB,CAAC;AAErG,MAAM,CAAC,IAAM,WAAW,GAAG,WAAW,CAAC;AACvC,MAAM,CAAC,IAAM,eAAe,GAAG,UAAU,CAAC;AAC1C,MAAM,CAAC,IAAM,iBAAiB,GAAG,YAAY,CAAC;AAC9C,MAAM,CAAC,IAAM,yBAAyB,GAAG,gDAAgD,CAAC;AAC1F,MAAM,CAAC,IAAM,qBAAqB,GAAG,mDAAmD,CAAC;AACzF,MA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Y = `${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;\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_IN_BYTES = 1 * 1000000; // 1 MB\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}\n"]}
|
|
@@ -18,6 +18,7 @@ export declare class SessionReplay implements AmplitudeSessionReplay {
|
|
|
18
18
|
pageLeaveFns: PageLeaveFn[];
|
|
19
19
|
private scrollHook?;
|
|
20
20
|
private networkObservers?;
|
|
21
|
+
private metadata;
|
|
21
22
|
constructor();
|
|
22
23
|
init(apiKey: string, options: SessionReplayOptions): import("@amplitude/analytics-core").AmplitudeReturn<void>;
|
|
23
24
|
private teardownEventListeners;
|
|
@@ -42,7 +43,7 @@ export declare class SessionReplay implements AmplitudeSessionReplay {
|
|
|
42
43
|
getBlockSelectors(): string | string[] | undefined;
|
|
43
44
|
getMaskTextSelectors(): string | undefined;
|
|
44
45
|
getRecordingPlugins(loggingConfig: LoggingConfig | undefined): Promise<import("@amplitude/rrweb-types").RecordPlugin<unknown>[] | undefined>;
|
|
45
|
-
recordEvents(): Promise<void>;
|
|
46
|
+
recordEvents(shouldLogMetadata?: boolean): Promise<void>;
|
|
46
47
|
addCustomRRWebEvent: (eventName: CustomRRwebEvent, eventData?: {
|
|
47
48
|
[key: string]: any;
|
|
48
49
|
}, addStorageInfo?: boolean) => Promise<void>;
|
|
@@ -51,6 +52,7 @@ export declare class SessionReplay implements AmplitudeSessionReplay {
|
|
|
51
52
|
getSessionId(): string | number | undefined;
|
|
52
53
|
flush(useRetry?: boolean): Promise<void | undefined>;
|
|
53
54
|
shutdown(): void;
|
|
55
|
+
private setMetadata;
|
|
54
56
|
}
|
|
55
57
|
export {};
|
|
56
58
|
//# sourceMappingURL=session-replay.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,OAAO,EAER,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C,OAAO,
|
|
1
|
+
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,OAAO,EAER,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C,OAAO,EACL,aAAa,EACb,yBAAyB,EACzB,kCAAkC,EAInC,MAAM,gBAAgB,CAAC;AACxB,OAAO,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AsC1B,YAAY,aAEV;IAEF,aAAa,aAIX;IAEF;;;;OAIG;IACH,OAAO,CAAC,iBAAiB,CAIvB;IAEF,UAAU,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM;IAShC,UAAU,CAAC,sBAAsB,UAAQ;IAgB/C,YAAY;IAUZ,eAAe;IAwBf,iBAAiB,IAAI,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS;IAWlD,oBAAoB,IAAI,MAAM,GAAG,SAAS;IAapC,mBAAmB,CAAC,aAAa,EAAE,aAAa,GAAG,SAAS;IA0B5D,YAAY,CAAC,iBAAiB,UAAO;IAsF3C,mBAAmB,cACN,gBAAgB;;kDAmC3B;IAEF,mBAAmB,aAUjB;IAEF,WAAW;IAIX,YAAY;IAIN,KAAK,CAAC,QAAQ,UAAQ;IAI5B,QAAQ;IAMR,OAAO,CAAC,WAAW;CAuBpB"}
|
|
@@ -48,7 +48,7 @@ var SessionReplay = /** @class */ (function () {
|
|
|
48
48
|
this.focusListener = function () {
|
|
49
49
|
// Restart recording on focus to ensure that when user
|
|
50
50
|
// switches tabs, we take a full snapshot
|
|
51
|
-
void _this.recordEvents();
|
|
51
|
+
void _this.recordEvents(false);
|
|
52
52
|
};
|
|
53
53
|
/**
|
|
54
54
|
* This is an instance member so that if init is called multiple times
|
|
@@ -71,7 +71,7 @@ var SessionReplay = /** @class */ (function () {
|
|
|
71
71
|
_a.trys.push([0, 3, , 4]);
|
|
72
72
|
debugInfo = undefined;
|
|
73
73
|
config = this.config;
|
|
74
|
-
if (!config) return [3 /*break*/, 2];
|
|
74
|
+
if (!(config && eventName !== CustomRRwebEvent.METADATA)) return [3 /*break*/, 2];
|
|
75
75
|
debugInfo = {
|
|
76
76
|
config: getDebugConfig(config),
|
|
77
77
|
version: VERSION,
|
|
@@ -119,25 +119,26 @@ var SessionReplay = /** @class */ (function () {
|
|
|
119
119
|
return returnWrapper(this._init(apiKey, options));
|
|
120
120
|
};
|
|
121
121
|
SessionReplay.prototype._init = function (apiKey, options) {
|
|
122
|
-
var _a, _b, _c, _d, _e, _f;
|
|
122
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
123
123
|
return __awaiter(this, void 0, void 0, function () {
|
|
124
|
-
var
|
|
125
|
-
return __generator(this, function (
|
|
126
|
-
switch (
|
|
124
|
+
var _h, _j, joinedConfig, localConfig, remoteConfig, scrollWatcher, managers, storeType, rrwebEventManager, error_1, typedError, payloadBatcher, interactionEventManager, error_2, typedError;
|
|
125
|
+
return __generator(this, function (_k) {
|
|
126
|
+
switch (_k.label) {
|
|
127
127
|
case 0:
|
|
128
128
|
this.loggerProvider = new SafeLoggerProvider(options.loggerProvider || new Logger());
|
|
129
129
|
Object.prototype.hasOwnProperty.call(options, 'logLevel') &&
|
|
130
130
|
this.loggerProvider.enable(options.logLevel);
|
|
131
131
|
this.identifiers = new SessionIdentifiers({ sessionId: options.sessionId, deviceId: options.deviceId });
|
|
132
|
-
|
|
132
|
+
_h = this;
|
|
133
133
|
return [4 /*yield*/, createSessionReplayJoinedConfigGenerator(apiKey, options)];
|
|
134
134
|
case 1:
|
|
135
|
-
|
|
136
|
-
_h = this;
|
|
135
|
+
_h.joinedConfigGenerator = _k.sent();
|
|
137
136
|
return [4 /*yield*/, this.joinedConfigGenerator.generateJoinedConfig(this.identifiers.sessionId)];
|
|
138
137
|
case 2:
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
_j = _k.sent(), joinedConfig = _j.joinedConfig, localConfig = _j.localConfig, remoteConfig = _j.remoteConfig;
|
|
139
|
+
this.config = joinedConfig;
|
|
140
|
+
this.setMetadata(options.sessionId, joinedConfig, localConfig, remoteConfig, (_a = options.version) === null || _a === void 0 ? void 0 : _a.version, VERSION);
|
|
141
|
+
if (options.sessionId && ((_b = this.config.interactionConfig) === null || _b === void 0 ? void 0 : _b.enabled)) {
|
|
141
142
|
scrollWatcher = ScrollWatcher.default({
|
|
142
143
|
sessionId: options.sessionId,
|
|
143
144
|
type: 'interaction',
|
|
@@ -147,14 +148,14 @@ var SessionReplay = /** @class */ (function () {
|
|
|
147
148
|
}
|
|
148
149
|
managers = [];
|
|
149
150
|
storeType = this.config.storeType;
|
|
150
|
-
if (storeType === 'idb' && !((
|
|
151
|
+
if (storeType === 'idb' && !((_c = getGlobalScope()) === null || _c === void 0 ? void 0 : _c.indexedDB)) {
|
|
151
152
|
storeType = 'memory';
|
|
152
153
|
this.loggerProvider.warn('Could not use preferred indexedDB storage, reverting to in memory option.');
|
|
153
154
|
}
|
|
154
155
|
this.loggerProvider.log("Using ".concat(storeType, " for event storage."));
|
|
155
|
-
|
|
156
|
+
_k.label = 3;
|
|
156
157
|
case 3:
|
|
157
|
-
|
|
158
|
+
_k.trys.push([3, 5, , 6]);
|
|
158
159
|
return [4 /*yield*/, createEventsManager({
|
|
159
160
|
config: this.config,
|
|
160
161
|
sessionId: this.identifiers.sessionId,
|
|
@@ -162,35 +163,35 @@ var SessionReplay = /** @class */ (function () {
|
|
|
162
163
|
storeType: storeType,
|
|
163
164
|
})];
|
|
164
165
|
case 4:
|
|
165
|
-
rrwebEventManager =
|
|
166
|
+
rrwebEventManager = _k.sent();
|
|
166
167
|
managers.push({ name: 'replay', manager: rrwebEventManager });
|
|
167
168
|
return [3 /*break*/, 6];
|
|
168
169
|
case 5:
|
|
169
|
-
error_1 =
|
|
170
|
+
error_1 = _k.sent();
|
|
170
171
|
typedError = error_1;
|
|
171
172
|
this.loggerProvider.warn("Error occurred while creating replay events manager: ".concat(typedError.toString()));
|
|
172
173
|
return [3 /*break*/, 6];
|
|
173
174
|
case 6:
|
|
174
|
-
if (!((
|
|
175
|
+
if (!((_d = this.config.interactionConfig) === null || _d === void 0 ? void 0 : _d.enabled)) return [3 /*break*/, 10];
|
|
175
176
|
payloadBatcher = this.config.interactionConfig.batch ? clickBatcher : clickNonBatcher;
|
|
176
|
-
|
|
177
|
+
_k.label = 7;
|
|
177
178
|
case 7:
|
|
178
|
-
|
|
179
|
+
_k.trys.push([7, 9, , 10]);
|
|
179
180
|
return [4 /*yield*/, createEventsManager({
|
|
180
181
|
config: this.config,
|
|
181
182
|
sessionId: this.identifiers.sessionId,
|
|
182
183
|
type: 'interaction',
|
|
183
|
-
minInterval: (
|
|
184
|
+
minInterval: (_e = this.config.interactionConfig.trackEveryNms) !== null && _e !== void 0 ? _e : INTERACTION_MIN_INTERVAL,
|
|
184
185
|
maxInterval: INTERACTION_MAX_INTERVAL,
|
|
185
186
|
payloadBatcher: payloadBatcher,
|
|
186
187
|
storeType: storeType,
|
|
187
188
|
})];
|
|
188
189
|
case 8:
|
|
189
|
-
interactionEventManager =
|
|
190
|
+
interactionEventManager = _k.sent();
|
|
190
191
|
managers.push({ name: 'interaction', manager: interactionEventManager });
|
|
191
192
|
return [3 /*break*/, 10];
|
|
192
193
|
case 9:
|
|
193
|
-
error_2 =
|
|
194
|
+
error_2 = _k.sent();
|
|
194
195
|
typedError = error_2;
|
|
195
196
|
this.loggerProvider.warn("Error occurred while creating interaction events manager: ".concat(typedError.toString()));
|
|
196
197
|
return [3 /*break*/, 10];
|
|
@@ -202,7 +203,7 @@ var SessionReplay = /** @class */ (function () {
|
|
|
202
203
|
}
|
|
203
204
|
this.eventCompressor = new EventCompressor(this.eventsManager, this.config, this.getDeviceId());
|
|
204
205
|
// Initialize network observers if logging is enabled
|
|
205
|
-
if ((
|
|
206
|
+
if ((_g = (_f = this.config.loggingConfig) === null || _f === void 0 ? void 0 : _f.network) === null || _g === void 0 ? void 0 : _g.enabled) {
|
|
206
207
|
this.networkObservers = new NetworkObservers();
|
|
207
208
|
}
|
|
208
209
|
this.loggerProvider.log('Installing @amplitude/session-replay-browser.');
|
|
@@ -218,9 +219,9 @@ var SessionReplay = /** @class */ (function () {
|
|
|
218
219
|
};
|
|
219
220
|
SessionReplay.prototype.asyncSetSessionId = function (sessionId, deviceId) {
|
|
220
221
|
return __awaiter(this, void 0, void 0, function () {
|
|
221
|
-
var previousSessionId, deviceIdForReplayId,
|
|
222
|
-
return __generator(this, function (
|
|
223
|
-
switch (
|
|
222
|
+
var previousSessionId, deviceIdForReplayId, joinedConfig;
|
|
223
|
+
return __generator(this, function (_a) {
|
|
224
|
+
switch (_a.label) {
|
|
224
225
|
case 0:
|
|
225
226
|
previousSessionId = this.identifiers && this.identifiers.sessionId;
|
|
226
227
|
if (previousSessionId) {
|
|
@@ -232,11 +233,11 @@ var SessionReplay = /** @class */ (function () {
|
|
|
232
233
|
deviceId: deviceIdForReplayId,
|
|
233
234
|
});
|
|
234
235
|
if (!(this.joinedConfigGenerator && previousSessionId)) return [3 /*break*/, 2];
|
|
235
|
-
_a = this;
|
|
236
236
|
return [4 /*yield*/, this.joinedConfigGenerator.generateJoinedConfig(this.identifiers.sessionId)];
|
|
237
237
|
case 1:
|
|
238
|
-
|
|
239
|
-
|
|
238
|
+
joinedConfig = (_a.sent()).joinedConfig;
|
|
239
|
+
this.config = joinedConfig;
|
|
240
|
+
_a.label = 2;
|
|
240
241
|
case 2:
|
|
241
242
|
void this.recordEvents();
|
|
242
243
|
return [2 /*return*/];
|
|
@@ -379,8 +380,9 @@ var SessionReplay = /** @class */ (function () {
|
|
|
379
380
|
});
|
|
380
381
|
});
|
|
381
382
|
};
|
|
382
|
-
SessionReplay.prototype.recordEvents = function () {
|
|
383
|
+
SessionReplay.prototype.recordEvents = function (shouldLogMetadata) {
|
|
383
384
|
var _a, _b;
|
|
385
|
+
if (shouldLogMetadata === void 0) { shouldLogMetadata = true; }
|
|
384
386
|
return __awaiter(this, void 0, void 0, function () {
|
|
385
387
|
var config, shouldRecord, sessionId, privacyConfig, interactionConfig, loggingConfig, hooks, _c, _d, error_4;
|
|
386
388
|
var _e;
|
|
@@ -463,6 +465,9 @@ var SessionReplay = /** @class */ (function () {
|
|
|
463
465
|
_c.recordCancelCallback = _d.apply(void 0, [(_e.plugins = _f.sent(),
|
|
464
466
|
_e)]);
|
|
465
467
|
void this.addCustomRRWebEvent(CustomRRwebEvent.DEBUG_INFO);
|
|
468
|
+
if (shouldLogMetadata) {
|
|
469
|
+
void this.addCustomRRWebEvent(CustomRRwebEvent.METADATA, this.metadata);
|
|
470
|
+
}
|
|
466
471
|
return [3 /*break*/, 4];
|
|
467
472
|
case 3:
|
|
468
473
|
error_4 = _f.sent();
|
|
@@ -495,6 +500,21 @@ var SessionReplay = /** @class */ (function () {
|
|
|
495
500
|
this.stopRecordingEvents();
|
|
496
501
|
this.sendEvents();
|
|
497
502
|
};
|
|
503
|
+
SessionReplay.prototype.setMetadata = function (sessionId, joinedConfig, localConfig, remoteConfig, replaySDKVersion, standaloneSDKVersion) {
|
|
504
|
+
var hashValue = (sessionId === null || sessionId === void 0 ? void 0 : sessionId.toString()) ? generateHashCode(sessionId.toString()) : undefined;
|
|
505
|
+
this.metadata = {
|
|
506
|
+
joinedConfig: joinedConfig,
|
|
507
|
+
localConfig: localConfig,
|
|
508
|
+
remoteConfig: remoteConfig,
|
|
509
|
+
sessionId: sessionId,
|
|
510
|
+
hashValue: hashValue,
|
|
511
|
+
sampleRate: joinedConfig.sampleRate,
|
|
512
|
+
replaySDKType: '@amplitude/plugin-session-replay-browser',
|
|
513
|
+
replaySDKVersion: replaySDKVersion,
|
|
514
|
+
standaloneSDKType: '@amplitude/session-replay-browser',
|
|
515
|
+
standaloneSDKVersion: standaloneSDKVersion,
|
|
516
|
+
};
|
|
517
|
+
};
|
|
498
518
|
return SessionReplay;
|
|
499
519
|
}());
|
|
500
520
|
export { SessionReplay };
|