@amplitude/plugin-session-replay-browser 1.37.0-codexsemantic-review-integration.0 → 1.37.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import type { BrowserConfig } from '@amplitude/analytics-core';
2
- /** Mirrors analytics-browser's boolean defaults and frustration-plugin's detector defaults. */
3
- export declare function semanticAutocaptureFamilies(autocapture: BrowserConfig['autocapture']): string[];
1
+ import { type BrowserConfig } from '@amplitude/analytics-core';
2
+ /** Reports the analytics SDK features active alongside semantic capture. */
3
+ export declare function semanticAutocaptureFamilies(autocapture: BrowserConfig['autocapture'], defaultTracking?: BrowserConfig['defaultTracking']): string[];
4
4
  //# sourceMappingURL=semantic-context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"semantic-context.d.ts","sourceRoot":"","sources":["../../src/semantic-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,+FAA+F;AAC/F,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,aAAa,CAAC,aAAa,CAAC,GAAG,MAAM,EAAE,CAuB/F"}
1
+ {"version":3,"file":"semantic-context.d.ts","sourceRoot":"","sources":["../../src/semantic-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAmBlF,4EAA4E;AAC5E,wBAAgB,2BAA2B,CACzC,WAAW,EAAE,aAAa,CAAC,aAAa,CAAC,EACzC,eAAe,GAAE,aAAa,CAAC,iBAAiB,CAAe,GAC9D,MAAM,EAAE,CAkCV"}
@@ -1,34 +1,70 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.semanticAutocaptureFamilies = void 0;
4
- /** Mirrors analytics-browser's boolean defaults and frustration-plugin's detector defaults. */
5
- function semanticAutocaptureFamilies(autocapture) {
4
+ var tslib_1 = require("tslib");
5
+ var analytics_core_1 = require("@amplitude/analytics-core");
6
+ /** Mirrors analytics-browser's default-on tracking rules without importing the browser package. */
7
+ function isDefaultFamilyEnabled(config, key) {
8
+ if (typeof config === 'boolean')
9
+ return config;
10
+ var value = config && typeof config === 'object' ? config[key] : undefined;
11
+ if (value === false)
12
+ return false;
13
+ return (0, analytics_core_1.isChromeExtension)() ? Boolean(value) : true;
14
+ }
15
+ function isExplicitlyEnabled(value) {
16
+ return value === true || (typeof value === 'object' && value !== null);
17
+ }
18
+ /** Reports the analytics SDK features active alongside semantic capture. */
19
+ function semanticAutocaptureFamilies(autocapture, defaultTracking) {
20
+ var e_1, _a;
21
+ if (defaultTracking === void 0) { defaultTracking = autocapture; }
22
+ var families = [];
23
+ var defaultFamilies = [
24
+ 'attribution',
25
+ 'fileDownloads',
26
+ 'formInteractions',
27
+ 'pageViews',
28
+ 'sessions',
29
+ ];
30
+ try {
31
+ for (var defaultFamilies_1 = tslib_1.__values(defaultFamilies), defaultFamilies_1_1 = defaultFamilies_1.next(); !defaultFamilies_1_1.done; defaultFamilies_1_1 = defaultFamilies_1.next()) {
32
+ var key = defaultFamilies_1_1.value;
33
+ if (isDefaultFamilyEnabled(defaultTracking, key))
34
+ families.push(key);
35
+ }
36
+ }
37
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
38
+ finally {
39
+ try {
40
+ if (defaultFamilies_1_1 && !defaultFamilies_1_1.done && (_a = defaultFamilies_1.return)) _a.call(defaultFamilies_1);
41
+ }
42
+ finally { if (e_1) throw e_1.error; }
43
+ }
44
+ if (isDefaultFamilyEnabled(autocapture, 'pageUrlEnrichment'))
45
+ families.push('pageUrlEnrichment');
6
46
  if (autocapture === true) {
7
- return [
8
- 'attribution',
9
- 'fileDownloads',
10
- 'formInteractions',
11
- 'pageViews',
12
- 'sessions',
13
- 'elementInteractions',
14
- 'webVitals',
15
- 'frustrationInteractions',
16
- ];
47
+ families.push('networkTracking', 'elementInteractions', 'webVitals', 'frustrationInteractions');
17
48
  }
18
- if (!autocapture || typeof autocapture !== 'object')
19
- return [];
20
- return Object.keys(autocapture).filter(function (key) {
21
- var value = autocapture[key];
22
- if (key !== 'frustrationInteractions')
23
- return Boolean(value);
49
+ else if (autocapture && typeof autocapture === 'object') {
50
+ if (isExplicitlyEnabled(autocapture.networkTracking))
51
+ families.push('networkTracking');
52
+ if (isExplicitlyEnabled(autocapture.elementInteractions))
53
+ families.push('elementInteractions');
54
+ if (isExplicitlyEnabled(autocapture.webVitals))
55
+ families.push('webVitals');
56
+ if (isExplicitlyEnabled(autocapture.performanceTracking))
57
+ families.push('performanceTracking');
24
58
  var frustration = autocapture.frustrationInteractions;
25
- if (frustration === true)
26
- return true;
27
- if (!frustration || typeof frustration !== 'object')
28
- return false;
29
- // Dead clicks default on. Error clicks are currently opt-in in frustration-plugin.
30
- return (frustration.deadClicks !== false && frustration.deadClicks !== null) || Boolean(frustration.errorClicks);
31
- });
59
+ if (frustration === true ||
60
+ (frustration &&
61
+ typeof frustration === 'object' &&
62
+ // Dead clicks default on. Error clicks are currently opt-in in frustration-plugin.
63
+ ((frustration.deadClicks !== false && frustration.deadClicks !== null) || Boolean(frustration.errorClicks)))) {
64
+ families.push('frustrationInteractions');
65
+ }
66
+ }
67
+ return families;
32
68
  }
33
69
  exports.semanticAutocaptureFamilies = semanticAutocaptureFamilies;
34
70
  //# sourceMappingURL=semantic-context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"semantic-context.js","sourceRoot":"","sources":["../../src/semantic-context.ts"],"names":[],"mappings":";;;AAEA,+FAA+F;AAC/F,SAAgB,2BAA2B,CAAC,WAAyC;IACnF,IAAI,WAAW,KAAK,IAAI,EAAE;QACxB,OAAO;YACL,aAAa;YACb,eAAe;YACf,kBAAkB;YAClB,WAAW;YACX,UAAU;YACV,qBAAqB;YACrB,WAAW;YACX,yBAAyB;SAC1B,CAAC;KACH;IACD,IAAI,CAAC,WAAW,IAAI,OAAO,WAAW,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IAC/D,OAAO,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,UAAC,GAAG;QACzC,IAAM,KAAK,GAAG,WAAW,CAAC,GAA+B,CAAC,CAAC;QAC3D,IAAI,GAAG,KAAK,yBAAyB;YAAE,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;QAC7D,IAAM,WAAW,GAAG,WAAW,CAAC,uBAAuB,CAAC;QACxD,IAAI,WAAW,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QACtC,IAAI,CAAC,WAAW,IAAI,OAAO,WAAW,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QAClE,mFAAmF;QACnF,OAAO,CAAC,WAAW,CAAC,UAAU,KAAK,KAAK,IAAI,WAAW,CAAC,UAAU,KAAK,IAAI,CAAC,IAAI,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IACnH,CAAC,CAAC,CAAC;AACL,CAAC;AAvBD,kEAuBC","sourcesContent":["import type { BrowserConfig } from '@amplitude/analytics-core';\n\n/** Mirrors analytics-browser's boolean defaults and frustration-plugin's detector defaults. */\nexport function semanticAutocaptureFamilies(autocapture: BrowserConfig['autocapture']): string[] {\n if (autocapture === true) {\n return [\n 'attribution',\n 'fileDownloads',\n 'formInteractions',\n 'pageViews',\n 'sessions',\n 'elementInteractions',\n 'webVitals',\n 'frustrationInteractions',\n ];\n }\n if (!autocapture || typeof autocapture !== 'object') return [];\n return Object.keys(autocapture).filter((key) => {\n const value = autocapture[key as keyof typeof autocapture];\n if (key !== 'frustrationInteractions') return Boolean(value);\n const frustration = autocapture.frustrationInteractions;\n if (frustration === true) return true;\n if (!frustration || typeof frustration !== 'object') return false;\n // Dead clicks default on. Error clicks are currently opt-in in frustration-plugin.\n return (frustration.deadClicks !== false && frustration.deadClicks !== null) || Boolean(frustration.errorClicks);\n });\n}\n"]}
1
+ {"version":3,"file":"semantic-context.js","sourceRoot":"","sources":["../../src/semantic-context.ts"],"names":[],"mappings":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AW,EAAE,yBAAyB,CAAC,CAAC;KACjG;SAAM,IAAI,WAAW,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;QACzD,IAAI,mBAAmB,CAAC,WAAW,CAAC,eAAe,CAAC;YAAE,QAAQ,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACvF,IAAI,mBAAmB,CAAC,WAAW,CAAC,mBAAmB,CAAC;YAAE,QAAQ,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAC/F,IAAI,mBAAmB,CAAC,WAAW,CAAC,SAAS,CAAC;YAAE,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC3E,IAAI,mBAAmB,CAAC,WAAW,CAAC,mBAAmB,CAAC;YAAE,QAAQ,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAE/F,IAAM,WAAW,GAAG,WAAW,CAAC,uBAAuB,CAAC;QACxD,IACE,WAAW,KAAK,IAAI;YACpB,CAAC,WAAW;gBACV,OAAO,WAAW,KAAK,QAAQ;gBAC/B,mFAAmF;gBACnF,CAAC,CAAC,WAAW,CAAC,UAAU,KAAK,KAAK,IAAI,WAAW,CAAC,UAAU,KAAK,IAAI,CAAC,IAAI,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,EAC9G;YACA,QAAQ,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;SAC1C;KACF;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AArCD,kEAqCC","sourcesContent":["import { isChromeExtension, type BrowserConfig } from '@amplitude/analytics-core';\n\ntype DefaultFamily = 'attribution' | 'fileDownloads' | 'formInteractions' | 'pageViews' | 'sessions';\n\n/** Mirrors analytics-browser's default-on tracking rules without importing the browser package. */\nfunction isDefaultFamilyEnabled(\n config: BrowserConfig['autocapture'] | BrowserConfig['defaultTracking'],\n key: DefaultFamily | 'pageUrlEnrichment',\n): boolean {\n if (typeof config === 'boolean') return config;\n const value = config && typeof config === 'object' ? (config as Record<string, unknown>)[key] : undefined;\n if (value === false) return false;\n return isChromeExtension() ? Boolean(value) : true;\n}\n\nfunction isExplicitlyEnabled(value: unknown): boolean {\n return value === true || (typeof value === 'object' && value !== null);\n}\n\n/** Reports the analytics SDK features active alongside semantic capture. */\nexport function semanticAutocaptureFamilies(\n autocapture: BrowserConfig['autocapture'],\n defaultTracking: BrowserConfig['defaultTracking'] = autocapture,\n): string[] {\n const families: string[] = [];\n const defaultFamilies: DefaultFamily[] = [\n 'attribution',\n 'fileDownloads',\n 'formInteractions',\n 'pageViews',\n 'sessions',\n ];\n for (const key of defaultFamilies) {\n if (isDefaultFamilyEnabled(defaultTracking, key)) families.push(key);\n }\n if (isDefaultFamilyEnabled(autocapture, 'pageUrlEnrichment')) families.push('pageUrlEnrichment');\n\n if (autocapture === true) {\n families.push('networkTracking', 'elementInteractions', 'webVitals', 'frustrationInteractions');\n } else if (autocapture && typeof autocapture === 'object') {\n if (isExplicitlyEnabled(autocapture.networkTracking)) families.push('networkTracking');\n if (isExplicitlyEnabled(autocapture.elementInteractions)) families.push('elementInteractions');\n if (isExplicitlyEnabled(autocapture.webVitals)) families.push('webVitals');\n if (isExplicitlyEnabled(autocapture.performanceTracking)) families.push('performanceTracking');\n\n const frustration = autocapture.frustrationInteractions;\n if (\n frustration === true ||\n (frustration &&\n typeof frustration === 'object' &&\n // Dead clicks default on. Error clicks are currently opt-in in frustration-plugin.\n ((frustration.deadClicks !== false && frustration.deadClicks !== null) || Boolean(frustration.errorClicks)))\n ) {\n families.push('frustrationInteractions');\n }\n }\n return families;\n}\n"]}
@@ -74,7 +74,7 @@ var SessionReplayPlugin = /** @class */ (function () {
74
74
  semanticCapture: this.options.semanticCapture,
75
75
  semanticAnalyticsContext: {
76
76
  present: true,
77
- autocapture: (0, semantic_context_1.semanticAutocaptureFamilies)(this.config.autocapture),
77
+ autocapture: (0, semantic_context_1.semanticAutocaptureFamilies)(this.config.autocapture, this.config.defaultTracking),
78
78
  },
79
79
  privacyConfig: {
80
80
  blockSelector: (_c = this.options.privacyConfig) === null || _c === void 0 ? void 0 : _c.blockSelector,
@@ -1 +1 @@
1
- {"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":";;;;AAAA,4DAQmC;AACnC,4EAY2C;AAC3C,qCAAgD;AAChD,uDAAiE;AAEjE,qCAAoC;AAEvB,QAAA,6BAA6B,GAAG,aAAa,CAAC;AAC9C,QAAA,+BAA+B,GAAG,UAAG,qCAA6B,uBAAoB,CAAC;AACpG;IAsBE,6BAAY,OAA8B;QApB1C,SAAI,GAAG,mBAAmB,CAAC,UAAU,CAAC;QACtC,SAAI,GAAG,YAAqB,CAAC;QAC7B,sEAAsE;QACtE,6DAA6D;QAC7D,aAAa;QACb,WAAM,GAAyB,IAAI,CAAC;QAGpC,kBAAa,GAA2B;YACtC,KAAK,EAAE,8BAAK;YACZ,YAAY,EAAE,qCAAY;YAC1B,0BAA0B,EAAE,mDAA0B;YACtD,IAAI,EAAE,6BAAI;YACV,YAAY,EAAE,qCAAY;YAC1B,KAAK,EAAE,8BAAK;YACZ,IAAI,EAAE,6BAAI;YACV,QAAQ,EAAE,iCAAQ;YAClB,2BAA2B,EAAE,oDAA2B;SACzD,CAAC;QAGA,IAAI,CAAC,OAAO,sBAAK,oBAAoB,EAAE,KAAK,IAAK,OAAO,CAAE,CAAC;QAC3D,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC;IACpC,CAAC;IAEK,mCAAK,GAAX,UAAY,MAAqB,EAAE,OAAsB;;;;;;;;wBAErD,0BAA0B;wBAC1B,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,cAAc,CAAC,GAAG,CAAC,+DAAwD,iBAAO,MAAG,CAAC,CAAC;wBAE/F,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;wBAErB,IAAI,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE;4BACrC,IAAI,OAAO,MAAM,CAAC,eAAe,KAAK,SAAS,EAA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wBAC/G,sBAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAC;;;;;KAEjC;IAEK,sCAAQ,GAAd;;;;gBACE,IAAI;oBACF,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;oBAC9B,6EAA6E;oBAC7E,qDAAqD;oBACrD,6DAA6D;oBAC7D,aAAa;oBACb,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;iBACpB;gBAAC,OAAO,KAAK,EAAE;oBACd,0BAA0B;oBAC1B,MAAA,IAAI,CAAC,MAAM,0CAAE,cAAc,CAAC,KAAK,CAAC,iDAA2C,KAAe,CAAC,OAAO,CAAE,CAAC,CAAC;iBACzG;;;;KACF;IAED,wDAA0B,GAA1B;QACE,OAAO,IAAI,CAAC,aAAa,CAAC,0BAA0B,EAAE,CAAC;IACzD,CAAC;IAED;;;OAGG;IACG,mCAAK,GAAX;;;;4BACE,qBAAM,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC,OAAO,EAAA;;wBAAxC,SAAwC,CAAC;;;;;KAC1C;IAED;;;OAGG;IACH,kCAAI,GAAJ;QACE,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;IAC5B,CAAC;IA9NM,8BAAU,GAAG,0CAA0C,CAAC;IA+NjE,0BAAC;CAAA,AAhOD,IAgOC;AAhOY,kDAAmB;AAkOzB,IAAM,mBAAmB,GAA4D,UAC1F,OAA8B;IAE9B,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC,CAAC;AAJW,QAAA,mBAAmB,uBAI9B","sourcesContent":["import {\n BrowserClient,\n BrowserConfig,\n EnrichmentPlugin,\n Event,\n SpecialEventType,\n getGlobalScope,\n getAnalyticsConnector,\n} from '@amplitude/analytics-core';\nimport {\n init,\n setSessionId,\n getSessionId,\n getSessionReplayProperties,\n flush,\n start,\n stop,\n shutdown,\n evaluateTargetingAndCapture,\n AmplitudeSessionReplay,\n SessionReplayOptions as SessionReplayBrowserOptions,\n} from '@amplitude/session-replay-browser';\nimport { parseUserProperties } from './helpers';\nimport { semanticAutocaptureFamilies } from './semantic-context';\nimport { SessionReplayOptions } from './typings/session-replay';\nimport { VERSION } from './version';\n\nexport const DEFAULT_EVENT_PROPERTY_PREFIX = '[Amplitude]';\nexport const DEFAULT_SESSION_REPLAY_PROPERTY = `${DEFAULT_EVENT_PROPERTY_PREFIX} Session Replay ID`;\nexport class SessionReplayPlugin implements EnrichmentPlugin<BrowserClient, BrowserConfig> {\n static pluginName = '@amplitude/plugin-session-replay-browser';\n name = SessionReplayPlugin.pluginName;\n type = 'enrichment' as const;\n // this.config is defined in setup() which will always be called first\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: BrowserConfig | null = null;\n options: SessionReplayOptions;\n srInitOptions: SessionReplayBrowserOptions;\n sessionReplay: AmplitudeSessionReplay = {\n flush: flush,\n getSessionId: getSessionId,\n getSessionReplayProperties: getSessionReplayProperties,\n init: init,\n setSessionId: setSessionId,\n start: start,\n stop: stop,\n shutdown: shutdown,\n evaluateTargetingAndCapture: evaluateTargetingAndCapture,\n };\n\n constructor(options?: SessionReplayOptions) {\n this.options = { forceSessionTracking: false, ...options };\n this.srInitOptions = this.options;\n }\n\n async setup(config: BrowserConfig, _client: BrowserClient) {\n try {\n /* istanbul ignore next */\n config?.loggerProvider.log(`Installing @amplitude/plugin-session-replay, version ${VERSION}.`);\n\n this.config = config;\n\n if (this.options.forceSessionTracking) {\n if (typeof config.defaultTracking === 'boolean') {\n if (config.defaultTracking === false) {\n config.defaultTracking = {\n pageViews: false,\n formInteractions: false,\n fileDownloads: false,\n sessions: true,\n };\n }\n } else {\n config.defaultTracking = {\n ...config.defaultTracking,\n sessions: true,\n };\n }\n }\n const identityStore = getAnalyticsConnector(this.config.instanceName).identityStore;\n const userProperties = identityStore.getIdentity().userProperties;\n\n this.srInitOptions = {\n instanceName: this.config.instanceName,\n deviceId: this.options.deviceId ?? this.config.deviceId,\n optOut: this.config.optOut,\n sessionId: this.options.customSessionId ? undefined : this.config.sessionId,\n loggerProvider: this.config.loggerProvider,\n logLevel: this.config.logLevel,\n flushMaxRetries: this.config.flushMaxRetries,\n serverZone: this.config.serverZone,\n configServerUrl: this.options.configServerUrl || this.config.remoteConfig?.serverUrl,\n trackServerUrl: this.options.trackServerUrl,\n sampleRate: this.options.sampleRate,\n semanticCapture: this.options.semanticCapture,\n semanticAnalyticsContext: {\n present: true,\n autocapture: semanticAutocaptureFamilies(this.config.autocapture),\n },\n privacyConfig: {\n blockSelector: this.options.privacyConfig?.blockSelector,\n maskAttributes: this.options.privacyConfig?.maskAttributes,\n maskSelector: this.options.privacyConfig?.maskSelector,\n unmaskSelector: this.options.privacyConfig?.unmaskSelector,\n defaultMaskLevel: this.options.privacyConfig?.defaultMaskLevel,\n },\n debugMode: this.options.debugMode,\n shouldInlineStylesheet: this.options.shouldInlineStylesheet,\n inlineImages: this.options.inlineImages,\n version: { type: 'plugin', version: VERSION },\n performanceConfig: this.options.performanceConfig,\n storeType: this.options.storeType,\n useWebWorker: this.options.useWebWorker ?? this.options.experimental?.useWebWorker,\n userProperties: userProperties,\n applyBackgroundColorToBlockedElements: this.options.applyBackgroundColorToBlockedElements,\n interactionConfig: this.options.interactionConfig,\n captureDocumentTitle: this.options.captureDocumentTitle,\n enableUrlChangePolling: this.options.enableUrlChangePolling,\n urlChangePollingInterval: this.options.urlChangePollingInterval,\n captureAdoptedStyleSheets: this.options.captureAdoptedStyleSheets,\n crossOriginIframes: this.options.crossOriginIframes,\n flushIntervalConfig: this.options.flushIntervalConfig,\n eagerFullSnapshotSend: this.options.eagerFullSnapshotSend,\n captureFullSnapshotOnFocus: this.options.captureFullSnapshotOnFocus,\n maxPersistedEventsSizeBytes: this.options.maxPersistedEventsSizeBytes,\n maxSingleEventSizeBytes: this.options.maxSingleEventSizeBytes,\n sendTimeoutMs: this.options.sendTimeoutMs,\n handleSendEvents: this.options.handleSendEvents,\n handleFetchConfig: this.options.handleFetchConfig,\n };\n\n await this.sessionReplay.init(config.apiKey, this.srInitOptions).promise;\n } catch (error) {\n /* istanbul ignore next */\n config?.loggerProvider.error(`Session Replay: Failed to initialize due to ${(error as Error).message}`);\n }\n }\n\n async onSessionIdChanged(sessionId: number): Promise<void> {\n this.config?.loggerProvider.debug(\n `Analytics session id is changed to ${sessionId}, SR session id is ${String(this.sessionReplay.getSessionId())}.`,\n );\n await this.sessionReplay.setSessionId(sessionId).promise;\n }\n\n async onOptOutChanged(optOut: boolean): Promise<void> {\n this.config?.loggerProvider.debug(\n `optOut is changed to ${String(optOut)}, calling ${\n optOut ? 'sessionReplay.shutdown()' : 'sessionReplay.init()'\n }.`,\n );\n // TODO: compare optOut with this.sessionReplay.getOptOut().\n // Need to add getOptOut() to the interface AmplitudeSessionReplay first.\n if (optOut) {\n this.sessionReplay.shutdown();\n } else {\n this.config != null && (await this.sessionReplay.init(this.config.apiKey, this.srInitOptions).promise);\n }\n }\n\n async execute(event: Event) {\n try {\n if (this.options.customSessionId) {\n const sessionId = this.options.customSessionId(event);\n if (sessionId) {\n // On event, synchronize the session id to the custom session id from the event. This may\n // suffer from offline/delayed events messing up the state stored\n if (sessionId !== this.sessionReplay.getSessionId()) {\n await this.sessionReplay.setSessionId(sessionId).promise;\n }\n\n const sessionRecordingProperties = this.sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n } else {\n // On event, synchronize the session id to the what's on the browserConfig (source of truth)\n // Choosing not to read from event object here, concerned about offline/delayed events messing up the state stored\n // in SR.\n const sessionId: string | number | undefined = this.config?.sessionId;\n if (sessionId && sessionId !== this.sessionReplay.getSessionId()) {\n await this.sessionReplay.setSessionId(sessionId).promise;\n }\n\n // Treating config.sessionId as source of truth, if the event's session id doesn't match, the\n // event is not of the current session (offline/late events). In that case, don't tag the events\n if (sessionId && sessionId === event.session_id) {\n let userProperties;\n if (event.event_type === SpecialEventType.IDENTIFY) {\n userProperties = parseUserProperties(event);\n }\n const globalScope = getGlobalScope();\n await this.sessionReplay.evaluateTargetingAndCapture({\n event,\n userProperties,\n page: globalScope?.location?.href != null ? { url: globalScope.location.href } : undefined,\n });\n const sessionRecordingProperties = this.sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n }\n\n if (event.event_type === SpecialEventType.IDENTIFY && event.event_properties) {\n delete event.event_properties[DEFAULT_SESSION_REPLAY_PROPERTY];\n }\n\n return Promise.resolve(event);\n } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: Failed to enrich event due to ${(error as Error).message}`);\n return Promise.resolve(event);\n }\n }\n\n async teardown(): Promise<void> {\n try {\n this.sessionReplay.shutdown();\n // the following are initialized in setup() which will always be called first\n // here we reset them to null to prevent memory leaks\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.config = null;\n } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: teardown failed due to ${(error as Error).message}`);\n }\n }\n\n getSessionReplayProperties() {\n return this.sessionReplay.getSessionReplayProperties();\n }\n\n /**\n * Start or resume session replay recording.\n * Recording still respects sample rate, targeting, opt-out, and remote capture flags.\n */\n async start() {\n await this.sessionReplay.start().promise;\n }\n\n /**\n * Stop session replay recording without removing the plugin.\n * Call {@link SessionReplayPlugin.start} to resume. Plugin teardown still uses shutdown.\n */\n stop() {\n this.sessionReplay.stop();\n }\n}\n\nexport const sessionReplayPlugin: (options?: SessionReplayOptions) => SessionReplayPlugin = (\n options?: SessionReplayOptions,\n) => {\n return new SessionReplayPlugin(options);\n};\n"]}
1
+ {"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":";;;;AAAA,4DAQmC;AACnC,4EAY2C;AAC3C,qCAAgD;AAChD,uDAAiE;AAEjE,qCAAoC;AAEvB,QAAA,6BAA6B,GAAG,aAAa,CAAC;AAC9C,QAAA,+B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AM,GAAG,IAAI,CAAC;iBACpB;gBAAC,OAAO,KAAK,EAAE;oBACd,0BAA0B;oBAC1B,MAAA,IAAI,CAAC,MAAM,0CAAE,cAAc,CAAC,KAAK,CAAC,iDAA2C,KAAe,CAAC,OAAO,CAAE,CAAC,CAAC;iBACzG;;;;KACF;IAED,wDAA0B,GAA1B;QACE,OAAO,IAAI,CAAC,aAAa,CAAC,0BAA0B,EAAE,CAAC;IACzD,CAAC;IAED;;;OAGG;IACG,mCAAK,GAAX;;;;4BACE,qBAAM,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC,OAAO,EAAA;;wBAAxC,SAAwC,CAAC;;;;;KAC1C;IAED;;;OAGG;IACH,kCAAI,GAAJ;QACE,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;IAC5B,CAAC;IA9NM,8BAAU,GAAG,0CAA0C,CAAC;IA+NjE,0BAAC;CAAA,AAhOD,IAgOC;AAhOY,kDAAmB;AAkOzB,IAAM,mBAAmB,GAA4D,UAC1F,OAA8B;IAE9B,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC,CAAC;AAJW,QAAA,mBAAmB,uBAI9B","sourcesContent":["import {\n BrowserClient,\n BrowserConfig,\n EnrichmentPlugin,\n Event,\n SpecialEventType,\n getGlobalScope,\n getAnalyticsConnector,\n} from '@amplitude/analytics-core';\nimport {\n init,\n setSessionId,\n getSessionId,\n getSessionReplayProperties,\n flush,\n start,\n stop,\n shutdown,\n evaluateTargetingAndCapture,\n AmplitudeSessionReplay,\n SessionReplayOptions as SessionReplayBrowserOptions,\n} from '@amplitude/session-replay-browser';\nimport { parseUserProperties } from './helpers';\nimport { semanticAutocaptureFamilies } from './semantic-context';\nimport { SessionReplayOptions } from './typings/session-replay';\nimport { VERSION } from './version';\n\nexport const DEFAULT_EVENT_PROPERTY_PREFIX = '[Amplitude]';\nexport const DEFAULT_SESSION_REPLAY_PROPERTY = `${DEFAULT_EVENT_PROPERTY_PREFIX} Session Replay ID`;\nexport class SessionReplayPlugin implements EnrichmentPlugin<BrowserClient, BrowserConfig> {\n static pluginName = '@amplitude/plugin-session-replay-browser';\n name = SessionReplayPlugin.pluginName;\n type = 'enrichment' as const;\n // this.config is defined in setup() which will always be called first\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: BrowserConfig | null = null;\n options: SessionReplayOptions;\n srInitOptions: SessionReplayBrowserOptions;\n sessionReplay: AmplitudeSessionReplay = {\n flush: flush,\n getSessionId: getSessionId,\n getSessionReplayProperties: getSessionReplayProperties,\n init: init,\n setSessionId: setSessionId,\n start: start,\n stop: stop,\n shutdown: shutdown,\n evaluateTargetingAndCapture: evaluateTargetingAndCapture,\n };\n\n constructor(options?: SessionReplayOptions) {\n this.options = { forceSessionTracking: false, ...options };\n this.srInitOptions = this.options;\n }\n\n async setup(config: BrowserConfig, _client: BrowserClient) {\n try {\n /* istanbul ignore next */\n config?.loggerProvider.log(`Installing @amplitude/plugin-session-replay, version ${VERSION}.`);\n\n this.config = config;\n\n if (this.options.forceSessionTracking) {\n if (typeof config.defaultTracking === 'boolean') {\n if (config.defaultTracking === false) {\n config.defaultTracking = {\n pageViews: false,\n formInteractions: false,\n fileDownloads: false,\n sessions: true,\n };\n }\n } else {\n config.defaultTracking = {\n ...config.defaultTracking,\n sessions: true,\n };\n }\n }\n const identityStore = getAnalyticsConnector(this.config.instanceName).identityStore;\n const userProperties = identityStore.getIdentity().userProperties;\n\n this.srInitOptions = {\n instanceName: this.config.instanceName,\n deviceId: this.options.deviceId ?? this.config.deviceId,\n optOut: this.config.optOut,\n sessionId: this.options.customSessionId ? undefined : this.config.sessionId,\n loggerProvider: this.config.loggerProvider,\n logLevel: this.config.logLevel,\n flushMaxRetries: this.config.flushMaxRetries,\n serverZone: this.config.serverZone,\n configServerUrl: this.options.configServerUrl || this.config.remoteConfig?.serverUrl,\n trackServerUrl: this.options.trackServerUrl,\n sampleRate: this.options.sampleRate,\n semanticCapture: this.options.semanticCapture,\n semanticAnalyticsContext: {\n present: true,\n autocapture: semanticAutocaptureFamilies(this.config.autocapture, this.config.defaultTracking),\n },\n privacyConfig: {\n blockSelector: this.options.privacyConfig?.blockSelector,\n maskAttributes: this.options.privacyConfig?.maskAttributes,\n maskSelector: this.options.privacyConfig?.maskSelector,\n unmaskSelector: this.options.privacyConfig?.unmaskSelector,\n defaultMaskLevel: this.options.privacyConfig?.defaultMaskLevel,\n },\n debugMode: this.options.debugMode,\n shouldInlineStylesheet: this.options.shouldInlineStylesheet,\n inlineImages: this.options.inlineImages,\n version: { type: 'plugin', version: VERSION },\n performanceConfig: this.options.performanceConfig,\n storeType: this.options.storeType,\n useWebWorker: this.options.useWebWorker ?? this.options.experimental?.useWebWorker,\n userProperties: userProperties,\n applyBackgroundColorToBlockedElements: this.options.applyBackgroundColorToBlockedElements,\n interactionConfig: this.options.interactionConfig,\n captureDocumentTitle: this.options.captureDocumentTitle,\n enableUrlChangePolling: this.options.enableUrlChangePolling,\n urlChangePollingInterval: this.options.urlChangePollingInterval,\n captureAdoptedStyleSheets: this.options.captureAdoptedStyleSheets,\n crossOriginIframes: this.options.crossOriginIframes,\n flushIntervalConfig: this.options.flushIntervalConfig,\n eagerFullSnapshotSend: this.options.eagerFullSnapshotSend,\n captureFullSnapshotOnFocus: this.options.captureFullSnapshotOnFocus,\n maxPersistedEventsSizeBytes: this.options.maxPersistedEventsSizeBytes,\n maxSingleEventSizeBytes: this.options.maxSingleEventSizeBytes,\n sendTimeoutMs: this.options.sendTimeoutMs,\n handleSendEvents: this.options.handleSendEvents,\n handleFetchConfig: this.options.handleFetchConfig,\n };\n\n await this.sessionReplay.init(config.apiKey, this.srInitOptions).promise;\n } catch (error) {\n /* istanbul ignore next */\n config?.loggerProvider.error(`Session Replay: Failed to initialize due to ${(error as Error).message}`);\n }\n }\n\n async onSessionIdChanged(sessionId: number): Promise<void> {\n this.config?.loggerProvider.debug(\n `Analytics session id is changed to ${sessionId}, SR session id is ${String(this.sessionReplay.getSessionId())}.`,\n );\n await this.sessionReplay.setSessionId(sessionId).promise;\n }\n\n async onOptOutChanged(optOut: boolean): Promise<void> {\n this.config?.loggerProvider.debug(\n `optOut is changed to ${String(optOut)}, calling ${\n optOut ? 'sessionReplay.shutdown()' : 'sessionReplay.init()'\n }.`,\n );\n // TODO: compare optOut with this.sessionReplay.getOptOut().\n // Need to add getOptOut() to the interface AmplitudeSessionReplay first.\n if (optOut) {\n this.sessionReplay.shutdown();\n } else {\n this.config != null && (await this.sessionReplay.init(this.config.apiKey, this.srInitOptions).promise);\n }\n }\n\n async execute(event: Event) {\n try {\n if (this.options.customSessionId) {\n const sessionId = this.options.customSessionId(event);\n if (sessionId) {\n // On event, synchronize the session id to the custom session id from the event. This may\n // suffer from offline/delayed events messing up the state stored\n if (sessionId !== this.sessionReplay.getSessionId()) {\n await this.sessionReplay.setSessionId(sessionId).promise;\n }\n\n const sessionRecordingProperties = this.sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n } else {\n // On event, synchronize the session id to the what's on the browserConfig (source of truth)\n // Choosing not to read from event object here, concerned about offline/delayed events messing up the state stored\n // in SR.\n const sessionId: string | number | undefined = this.config?.sessionId;\n if (sessionId && sessionId !== this.sessionReplay.getSessionId()) {\n await this.sessionReplay.setSessionId(sessionId).promise;\n }\n\n // Treating config.sessionId as source of truth, if the event's session id doesn't match, the\n // event is not of the current session (offline/late events). In that case, don't tag the events\n if (sessionId && sessionId === event.session_id) {\n let userProperties;\n if (event.event_type === SpecialEventType.IDENTIFY) {\n userProperties = parseUserProperties(event);\n }\n const globalScope = getGlobalScope();\n await this.sessionReplay.evaluateTargetingAndCapture({\n event,\n userProperties,\n page: globalScope?.location?.href != null ? { url: globalScope.location.href } : undefined,\n });\n const sessionRecordingProperties = this.sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n }\n\n if (event.event_type === SpecialEventType.IDENTIFY && event.event_properties) {\n delete event.event_properties[DEFAULT_SESSION_REPLAY_PROPERTY];\n }\n\n return Promise.resolve(event);\n } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: Failed to enrich event due to ${(error as Error).message}`);\n return Promise.resolve(event);\n }\n }\n\n async teardown(): Promise<void> {\n try {\n this.sessionReplay.shutdown();\n // the following are initialized in setup() which will always be called first\n // here we reset them to null to prevent memory leaks\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.config = null;\n } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: teardown failed due to ${(error as Error).message}`);\n }\n }\n\n getSessionReplayProperties() {\n return this.sessionReplay.getSessionReplayProperties();\n }\n\n /**\n * Start or resume session replay recording.\n * Recording still respects sample rate, targeting, opt-out, and remote capture flags.\n */\n async start() {\n await this.sessionReplay.start().promise;\n }\n\n /**\n * Stop session replay recording without removing the plugin.\n * Call {@link SessionReplayPlugin.start} to resume. Plugin teardown still uses shutdown.\n */\n stop() {\n this.sessionReplay.stop();\n }\n}\n\nexport const sessionReplayPlugin: (options?: SessionReplayOptions) => SessionReplayPlugin = (\n options?: SessionReplayOptions,\n) => {\n return new SessionReplayPlugin(options);\n};\n"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.37.0-codexsemantic-review-integration.0";
1
+ export declare const VERSION = "1.37.1";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,8CAA8C,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,WAAW,CAAC"}
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // Autogenerated by `pnpm version-file`. DO NOT EDIT
5
- exports.VERSION = '1.37.0-codexsemantic-review-integration.0';
5
+ exports.VERSION = '1.37.1';
6
6
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAA,oDAAoD;AACvC,QAAA,OAAO,GAAG,2CAA2C,CAAC","sourcesContent":["// Autogenerated by `pnpm version-file`. DO NOT EDIT\nexport const VERSION = '1.37.0-codexsemantic-review-integration.0';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAA,oDAAoD;AACvC,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// Autogenerated by `pnpm version-file`. DO NOT EDIT\nexport const VERSION = '1.37.1';\n"]}
@@ -1,4 +1,4 @@
1
- import type { BrowserConfig } from '@amplitude/analytics-core';
2
- /** Mirrors analytics-browser's boolean defaults and frustration-plugin's detector defaults. */
3
- export declare function semanticAutocaptureFamilies(autocapture: BrowserConfig['autocapture']): string[];
1
+ import { type BrowserConfig } from '@amplitude/analytics-core';
2
+ /** Reports the analytics SDK features active alongside semantic capture. */
3
+ export declare function semanticAutocaptureFamilies(autocapture: BrowserConfig['autocapture'], defaultTracking?: BrowserConfig['defaultTracking']): string[];
4
4
  //# sourceMappingURL=semantic-context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"semantic-context.d.ts","sourceRoot":"","sources":["../../src/semantic-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,+FAA+F;AAC/F,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,aAAa,CAAC,aAAa,CAAC,GAAG,MAAM,EAAE,CAuB/F"}
1
+ {"version":3,"file":"semantic-context.d.ts","sourceRoot":"","sources":["../../src/semantic-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAmBlF,4EAA4E;AAC5E,wBAAgB,2BAA2B,CACzC,WAAW,EAAE,aAAa,CAAC,aAAa,CAAC,EACzC,eAAe,GAAE,aAAa,CAAC,iBAAiB,CAAe,GAC9D,MAAM,EAAE,CAkCV"}
@@ -1,30 +1,66 @@
1
- /** Mirrors analytics-browser's boolean defaults and frustration-plugin's detector defaults. */
2
- export function semanticAutocaptureFamilies(autocapture) {
1
+ import { __values } from "tslib";
2
+ import { isChromeExtension } from '@amplitude/analytics-core';
3
+ /** Mirrors analytics-browser's default-on tracking rules without importing the browser package. */
4
+ function isDefaultFamilyEnabled(config, key) {
5
+ if (typeof config === 'boolean')
6
+ return config;
7
+ var value = config && typeof config === 'object' ? config[key] : undefined;
8
+ if (value === false)
9
+ return false;
10
+ return isChromeExtension() ? Boolean(value) : true;
11
+ }
12
+ function isExplicitlyEnabled(value) {
13
+ return value === true || (typeof value === 'object' && value !== null);
14
+ }
15
+ /** Reports the analytics SDK features active alongside semantic capture. */
16
+ export function semanticAutocaptureFamilies(autocapture, defaultTracking) {
17
+ var e_1, _a;
18
+ if (defaultTracking === void 0) { defaultTracking = autocapture; }
19
+ var families = [];
20
+ var defaultFamilies = [
21
+ 'attribution',
22
+ 'fileDownloads',
23
+ 'formInteractions',
24
+ 'pageViews',
25
+ 'sessions',
26
+ ];
27
+ try {
28
+ for (var defaultFamilies_1 = __values(defaultFamilies), defaultFamilies_1_1 = defaultFamilies_1.next(); !defaultFamilies_1_1.done; defaultFamilies_1_1 = defaultFamilies_1.next()) {
29
+ var key = defaultFamilies_1_1.value;
30
+ if (isDefaultFamilyEnabled(defaultTracking, key))
31
+ families.push(key);
32
+ }
33
+ }
34
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
35
+ finally {
36
+ try {
37
+ if (defaultFamilies_1_1 && !defaultFamilies_1_1.done && (_a = defaultFamilies_1.return)) _a.call(defaultFamilies_1);
38
+ }
39
+ finally { if (e_1) throw e_1.error; }
40
+ }
41
+ if (isDefaultFamilyEnabled(autocapture, 'pageUrlEnrichment'))
42
+ families.push('pageUrlEnrichment');
3
43
  if (autocapture === true) {
4
- return [
5
- 'attribution',
6
- 'fileDownloads',
7
- 'formInteractions',
8
- 'pageViews',
9
- 'sessions',
10
- 'elementInteractions',
11
- 'webVitals',
12
- 'frustrationInteractions',
13
- ];
44
+ families.push('networkTracking', 'elementInteractions', 'webVitals', 'frustrationInteractions');
14
45
  }
15
- if (!autocapture || typeof autocapture !== 'object')
16
- return [];
17
- return Object.keys(autocapture).filter(function (key) {
18
- var value = autocapture[key];
19
- if (key !== 'frustrationInteractions')
20
- return Boolean(value);
46
+ else if (autocapture && typeof autocapture === 'object') {
47
+ if (isExplicitlyEnabled(autocapture.networkTracking))
48
+ families.push('networkTracking');
49
+ if (isExplicitlyEnabled(autocapture.elementInteractions))
50
+ families.push('elementInteractions');
51
+ if (isExplicitlyEnabled(autocapture.webVitals))
52
+ families.push('webVitals');
53
+ if (isExplicitlyEnabled(autocapture.performanceTracking))
54
+ families.push('performanceTracking');
21
55
  var frustration = autocapture.frustrationInteractions;
22
- if (frustration === true)
23
- return true;
24
- if (!frustration || typeof frustration !== 'object')
25
- return false;
26
- // Dead clicks default on. Error clicks are currently opt-in in frustration-plugin.
27
- return (frustration.deadClicks !== false && frustration.deadClicks !== null) || Boolean(frustration.errorClicks);
28
- });
56
+ if (frustration === true ||
57
+ (frustration &&
58
+ typeof frustration === 'object' &&
59
+ // Dead clicks default on. Error clicks are currently opt-in in frustration-plugin.
60
+ ((frustration.deadClicks !== false && frustration.deadClicks !== null) || Boolean(frustration.errorClicks)))) {
61
+ families.push('frustrationInteractions');
62
+ }
63
+ }
64
+ return families;
29
65
  }
30
66
  //# sourceMappingURL=semantic-context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"semantic-context.js","sourceRoot":"","sources":["../../src/semantic-context.ts"],"names":[],"mappings":"AAEA,+FAA+F;AAC/F,MAAM,UAAU,2BAA2B,CAAC,WAAyC;IACnF,IAAI,WAAW,KAAK,IAAI,EAAE;QACxB,OAAO;YACL,aAAa;YACb,eAAe;YACf,kBAAkB;YAClB,WAAW;YACX,UAAU;YACV,qBAAqB;YACrB,WAAW;YACX,yBAAyB;SAC1B,CAAC;KACH;IACD,IAAI,CAAC,WAAW,IAAI,OAAO,WAAW,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IAC/D,OAAO,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,UAAC,GAAG;QACzC,IAAM,KAAK,GAAG,WAAW,CAAC,GAA+B,CAAC,CAAC;QAC3D,IAAI,GAAG,KAAK,yBAAyB;YAAE,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;QAC7D,IAAM,WAAW,GAAG,WAAW,CAAC,uBAAuB,CAAC;QACxD,IAAI,WAAW,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QACtC,IAAI,CAAC,WAAW,IAAI,OAAO,WAAW,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QAClE,mFAAmF;QACnF,OAAO,CAAC,WAAW,CAAC,UAAU,KAAK,KAAK,IAAI,WAAW,CAAC,UAAU,KAAK,IAAI,CAAC,IAAI,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IACnH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { BrowserConfig } from '@amplitude/analytics-core';\n\n/** Mirrors analytics-browser's boolean defaults and frustration-plugin's detector defaults. */\nexport function semanticAutocaptureFamilies(autocapture: BrowserConfig['autocapture']): string[] {\n if (autocapture === true) {\n return [\n 'attribution',\n 'fileDownloads',\n 'formInteractions',\n 'pageViews',\n 'sessions',\n 'elementInteractions',\n 'webVitals',\n 'frustrationInteractions',\n ];\n }\n if (!autocapture || typeof autocapture !== 'object') return [];\n return Object.keys(autocapture).filter((key) => {\n const value = autocapture[key as keyof typeof autocapture];\n if (key !== 'frustrationInteractions') return Boolean(value);\n const frustration = autocapture.frustrationInteractions;\n if (frustration === true) return true;\n if (!frustration || typeof frustration !== 'object') return false;\n // Dead clicks default on. Error clicks are currently opt-in in frustration-plugin.\n return (frustration.deadClicks !== false && frustration.deadClicks !== null) || Boolean(frustration.errorClicks);\n });\n}\n"]}
1
+ {"version":3,"file":"semantic-context.js","sourceRoot":"","sources":["../../src/semantic-context.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAsB,MAAM,2BAA2B,CAAC;AAIlF,mGAAmG;AACnG,SAAS,sBAAsB,CAC7B,MAAuE,EACvE,GAAwC;IAExC,IAAI,OAAO,MAAM,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC;IAC/C,IAAM,KAAK,GAAG,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAE,MAAkC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1G,IAAI,KAAK,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC;IAClC,OAAO,iBAAiB,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACrD,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAc;IACzC,OAAO,KAAK,KAAK,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC;AACzE,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,2BAA2B,CACzC,WAAyC,EACzC,eAA+D;;IAA/D,gCAAA,EAAA,6BAA+D;IAE/D,IAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,IAAM,eAAe,GAAoB;QACvC,aAAa;QACb,eAAe;QACf,kBAAkB;QAClB,WAAW;QACX,UAAU;KACX,CAAC;;QACF,KAAkB,IAAA,oBAAA,SAAA,eAAe,CAAA,gDAAA,6EAAE;YAA9B,IAAM,GAAG,4BAAA;YACZ,IAAI,sBAAsB,CAAC,eAAe,EAAE,GAAG,CAAC;gBAAE,QAAQ,CA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'fileDownloads' | 'formInteractions' | 'pageViews' | 'sessions';\n\n/** Mirrors analytics-browser's default-on tracking rules without importing the browser package. */\nfunction isDefaultFamilyEnabled(\n config: BrowserConfig['autocapture'] | BrowserConfig['defaultTracking'],\n key: DefaultFamily | 'pageUrlEnrichment',\n): boolean {\n if (typeof config === 'boolean') return config;\n const value = config && typeof config === 'object' ? (config as Record<string, unknown>)[key] : undefined;\n if (value === false) return false;\n return isChromeExtension() ? Boolean(value) : true;\n}\n\nfunction isExplicitlyEnabled(value: unknown): boolean {\n return value === true || (typeof value === 'object' && value !== null);\n}\n\n/** Reports the analytics SDK features active alongside semantic capture. */\nexport function semanticAutocaptureFamilies(\n autocapture: BrowserConfig['autocapture'],\n defaultTracking: BrowserConfig['defaultTracking'] = autocapture,\n): string[] {\n const families: string[] = [];\n const defaultFamilies: DefaultFamily[] = [\n 'attribution',\n 'fileDownloads',\n 'formInteractions',\n 'pageViews',\n 'sessions',\n ];\n for (const key of defaultFamilies) {\n if (isDefaultFamilyEnabled(defaultTracking, key)) families.push(key);\n }\n if (isDefaultFamilyEnabled(autocapture, 'pageUrlEnrichment')) families.push('pageUrlEnrichment');\n\n if (autocapture === true) {\n families.push('networkTracking', 'elementInteractions', 'webVitals', 'frustrationInteractions');\n } else if (autocapture && typeof autocapture === 'object') {\n if (isExplicitlyEnabled(autocapture.networkTracking)) families.push('networkTracking');\n if (isExplicitlyEnabled(autocapture.elementInteractions)) families.push('elementInteractions');\n if (isExplicitlyEnabled(autocapture.webVitals)) families.push('webVitals');\n if (isExplicitlyEnabled(autocapture.performanceTracking)) families.push('performanceTracking');\n\n const frustration = autocapture.frustrationInteractions;\n if (\n frustration === true ||\n (frustration &&\n typeof frustration === 'object' &&\n // Dead clicks default on. Error clicks are currently opt-in in frustration-plugin.\n ((frustration.deadClicks !== false && frustration.deadClicks !== null) || Boolean(frustration.errorClicks)))\n ) {\n families.push('frustrationInteractions');\n }\n }\n return families;\n}\n"]}
@@ -71,7 +71,7 @@ var SessionReplayPlugin = /** @class */ (function () {
71
71
  semanticCapture: this.options.semanticCapture,
72
72
  semanticAnalyticsContext: {
73
73
  present: true,
74
- autocapture: semanticAutocaptureFamilies(this.config.autocapture),
74
+ autocapture: semanticAutocaptureFamilies(this.config.autocapture, this.config.defaultTracking),
75
75
  },
76
76
  privacyConfig: {
77
77
  blockSelector: (_c = this.options.privacyConfig) === null || _c === void 0 ? void 0 : _c.blockSelector,
@@ -1 +1 @@
1
- {"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":";AAAA,OAAO,EAKL,gBAAgB,EAChB,cAAc,EACd,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,YAAY,EACZ,0BAA0B,EAC1B,KAAK,EACL,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,2BAA2B,GAG5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,CAAC,IAAM,6BAA6B,GAAG,aAAa,CAAC;AAC3D,MAAM,CAAC,IAAM,+BAA+B,GAAG,UAAG,6BAA6B,uBAAoB,CAAC;AACpG;IAsBE,6BAAY,OAA8B;QApB1C,SAAI,GAAG,mBAAmB,CAAC,UAAU,CAAC;QACtC,SAAI,GAAG,YAAqB,CAAC;QAC7B,sEAAsE;QACtE,6DAA6D;QAC7D,aAAa;QACb,WAAM,GAAyB,IAAI,CAAC;QAGpC,kBAAa,GAA2B;YACtC,KAAK,EAAE,KAAK;YACZ,YAAY,EAAE,YAAY;YAC1B,0BAA0B,EAAE,0BAA0B;YACtD,IAAI,EAAE,IAAI;YACV,YAAY,EAAE,YAAY;YAC1B,KAAK,EAAE,KAAK;YACZ,IAAI,EAAE,IAAI;YAC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AAC;IAC5B,CAAC;IA9NM,8BAAU,GAAG,0CAA0C,CAAC;IA+NjE,0BAAC;CAAA,AAhOD,IAgOC;SAhOY,mBAAmB;AAkOhC,MAAM,CAAC,IAAM,mBAAmB,GAA4D,UAC1F,OAA8B;IAE9B,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC,CAAC","sourcesContent":["import {\n BrowserClient,\n BrowserConfig,\n EnrichmentPlugin,\n Event,\n SpecialEventType,\n getGlobalScope,\n getAnalyticsConnector,\n} from '@amplitude/analytics-core';\nimport {\n init,\n setSessionId,\n getSessionId,\n getSessionReplayProperties,\n flush,\n start,\n stop,\n shutdown,\n evaluateTargetingAndCapture,\n AmplitudeSessionReplay,\n SessionReplayOptions as SessionReplayBrowserOptions,\n} from '@amplitude/session-replay-browser';\nimport { parseUserProperties } from './helpers';\nimport { semanticAutocaptureFamilies } from './semantic-context';\nimport { SessionReplayOptions } from './typings/session-replay';\nimport { VERSION } from './version';\n\nexport const DEFAULT_EVENT_PROPERTY_PREFIX = '[Amplitude]';\nexport const DEFAULT_SESSION_REPLAY_PROPERTY = `${DEFAULT_EVENT_PROPERTY_PREFIX} Session Replay ID`;\nexport class SessionReplayPlugin implements EnrichmentPlugin<BrowserClient, BrowserConfig> {\n static pluginName = '@amplitude/plugin-session-replay-browser';\n name = SessionReplayPlugin.pluginName;\n type = 'enrichment' as const;\n // this.config is defined in setup() which will always be called first\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: BrowserConfig | null = null;\n options: SessionReplayOptions;\n srInitOptions: SessionReplayBrowserOptions;\n sessionReplay: AmplitudeSessionReplay = {\n flush: flush,\n getSessionId: getSessionId,\n getSessionReplayProperties: getSessionReplayProperties,\n init: init,\n setSessionId: setSessionId,\n start: start,\n stop: stop,\n shutdown: shutdown,\n evaluateTargetingAndCapture: evaluateTargetingAndCapture,\n };\n\n constructor(options?: SessionReplayOptions) {\n this.options = { forceSessionTracking: false, ...options };\n this.srInitOptions = this.options;\n }\n\n async setup(config: BrowserConfig, _client: BrowserClient) {\n try {\n /* istanbul ignore next */\n config?.loggerProvider.log(`Installing @amplitude/plugin-session-replay, version ${VERSION}.`);\n\n this.config = config;\n\n if (this.options.forceSessionTracking) {\n if (typeof config.defaultTracking === 'boolean') {\n if (config.defaultTracking === false) {\n config.defaultTracking = {\n pageViews: false,\n formInteractions: false,\n fileDownloads: false,\n sessions: true,\n };\n }\n } else {\n config.defaultTracking = {\n ...config.defaultTracking,\n sessions: true,\n };\n }\n }\n const identityStore = getAnalyticsConnector(this.config.instanceName).identityStore;\n const userProperties = identityStore.getIdentity().userProperties;\n\n this.srInitOptions = {\n instanceName: this.config.instanceName,\n deviceId: this.options.deviceId ?? this.config.deviceId,\n optOut: this.config.optOut,\n sessionId: this.options.customSessionId ? undefined : this.config.sessionId,\n loggerProvider: this.config.loggerProvider,\n logLevel: this.config.logLevel,\n flushMaxRetries: this.config.flushMaxRetries,\n serverZone: this.config.serverZone,\n configServerUrl: this.options.configServerUrl || this.config.remoteConfig?.serverUrl,\n trackServerUrl: this.options.trackServerUrl,\n sampleRate: this.options.sampleRate,\n semanticCapture: this.options.semanticCapture,\n semanticAnalyticsContext: {\n present: true,\n autocapture: semanticAutocaptureFamilies(this.config.autocapture),\n },\n privacyConfig: {\n blockSelector: this.options.privacyConfig?.blockSelector,\n maskAttributes: this.options.privacyConfig?.maskAttributes,\n maskSelector: this.options.privacyConfig?.maskSelector,\n unmaskSelector: this.options.privacyConfig?.unmaskSelector,\n defaultMaskLevel: this.options.privacyConfig?.defaultMaskLevel,\n },\n debugMode: this.options.debugMode,\n shouldInlineStylesheet: this.options.shouldInlineStylesheet,\n inlineImages: this.options.inlineImages,\n version: { type: 'plugin', version: VERSION },\n performanceConfig: this.options.performanceConfig,\n storeType: this.options.storeType,\n useWebWorker: this.options.useWebWorker ?? this.options.experimental?.useWebWorker,\n userProperties: userProperties,\n applyBackgroundColorToBlockedElements: this.options.applyBackgroundColorToBlockedElements,\n interactionConfig: this.options.interactionConfig,\n captureDocumentTitle: this.options.captureDocumentTitle,\n enableUrlChangePolling: this.options.enableUrlChangePolling,\n urlChangePollingInterval: this.options.urlChangePollingInterval,\n captureAdoptedStyleSheets: this.options.captureAdoptedStyleSheets,\n crossOriginIframes: this.options.crossOriginIframes,\n flushIntervalConfig: this.options.flushIntervalConfig,\n eagerFullSnapshotSend: this.options.eagerFullSnapshotSend,\n captureFullSnapshotOnFocus: this.options.captureFullSnapshotOnFocus,\n maxPersistedEventsSizeBytes: this.options.maxPersistedEventsSizeBytes,\n maxSingleEventSizeBytes: this.options.maxSingleEventSizeBytes,\n sendTimeoutMs: this.options.sendTimeoutMs,\n handleSendEvents: this.options.handleSendEvents,\n handleFetchConfig: this.options.handleFetchConfig,\n };\n\n await this.sessionReplay.init(config.apiKey, this.srInitOptions).promise;\n } catch (error) {\n /* istanbul ignore next */\n config?.loggerProvider.error(`Session Replay: Failed to initialize due to ${(error as Error).message}`);\n }\n }\n\n async onSessionIdChanged(sessionId: number): Promise<void> {\n this.config?.loggerProvider.debug(\n `Analytics session id is changed to ${sessionId}, SR session id is ${String(this.sessionReplay.getSessionId())}.`,\n );\n await this.sessionReplay.setSessionId(sessionId).promise;\n }\n\n async onOptOutChanged(optOut: boolean): Promise<void> {\n this.config?.loggerProvider.debug(\n `optOut is changed to ${String(optOut)}, calling ${\n optOut ? 'sessionReplay.shutdown()' : 'sessionReplay.init()'\n }.`,\n );\n // TODO: compare optOut with this.sessionReplay.getOptOut().\n // Need to add getOptOut() to the interface AmplitudeSessionReplay first.\n if (optOut) {\n this.sessionReplay.shutdown();\n } else {\n this.config != null && (await this.sessionReplay.init(this.config.apiKey, this.srInitOptions).promise);\n }\n }\n\n async execute(event: Event) {\n try {\n if (this.options.customSessionId) {\n const sessionId = this.options.customSessionId(event);\n if (sessionId) {\n // On event, synchronize the session id to the custom session id from the event. This may\n // suffer from offline/delayed events messing up the state stored\n if (sessionId !== this.sessionReplay.getSessionId()) {\n await this.sessionReplay.setSessionId(sessionId).promise;\n }\n\n const sessionRecordingProperties = this.sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n } else {\n // On event, synchronize the session id to the what's on the browserConfig (source of truth)\n // Choosing not to read from event object here, concerned about offline/delayed events messing up the state stored\n // in SR.\n const sessionId: string | number | undefined = this.config?.sessionId;\n if (sessionId && sessionId !== this.sessionReplay.getSessionId()) {\n await this.sessionReplay.setSessionId(sessionId).promise;\n }\n\n // Treating config.sessionId as source of truth, if the event's session id doesn't match, the\n // event is not of the current session (offline/late events). In that case, don't tag the events\n if (sessionId && sessionId === event.session_id) {\n let userProperties;\n if (event.event_type === SpecialEventType.IDENTIFY) {\n userProperties = parseUserProperties(event);\n }\n const globalScope = getGlobalScope();\n await this.sessionReplay.evaluateTargetingAndCapture({\n event,\n userProperties,\n page: globalScope?.location?.href != null ? { url: globalScope.location.href } : undefined,\n });\n const sessionRecordingProperties = this.sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n }\n\n if (event.event_type === SpecialEventType.IDENTIFY && event.event_properties) {\n delete event.event_properties[DEFAULT_SESSION_REPLAY_PROPERTY];\n }\n\n return Promise.resolve(event);\n } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: Failed to enrich event due to ${(error as Error).message}`);\n return Promise.resolve(event);\n }\n }\n\n async teardown(): Promise<void> {\n try {\n this.sessionReplay.shutdown();\n // the following are initialized in setup() which will always be called first\n // here we reset them to null to prevent memory leaks\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.config = null;\n } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: teardown failed due to ${(error as Error).message}`);\n }\n }\n\n getSessionReplayProperties() {\n return this.sessionReplay.getSessionReplayProperties();\n }\n\n /**\n * Start or resume session replay recording.\n * Recording still respects sample rate, targeting, opt-out, and remote capture flags.\n */\n async start() {\n await this.sessionReplay.start().promise;\n }\n\n /**\n * Stop session replay recording without removing the plugin.\n * Call {@link SessionReplayPlugin.start} to resume. Plugin teardown still uses shutdown.\n */\n stop() {\n this.sessionReplay.stop();\n }\n}\n\nexport const sessionReplayPlugin: (options?: SessionReplayOptions) => SessionReplayPlugin = (\n options?: SessionReplayOptions,\n) => {\n return new SessionReplayPlugin(options);\n};\n"]}
1
+ {"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":";AAAA,OAAO,EAKL,gBAAgB,EAChB,cAAc,EACd,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,YAAY,EACZ,0BAA0B,EAC1B,KAAK,EACL,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,2BAA2B,GAG5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,CAAC,IAAM,6BAA6B,GAAG,aAAa,CAAC;AAC3D,MAAM,CAAC,IAAM,+BAA+B,GAAG,UAAG,6BAA6B,uBAAoB,CAAC;AACpG;IAsBE,6BAAY,OAA8B;QApB1C,SAAI,GAAG,mBAAmB,CAAC,UAAU,CAAC;QACtC,SAAI,GAAG,YAAqB,CAAC;QAC7B,sEAAsE;QACtE,6DAA6D;QAC7D,aAAa;QACb,WAAM,GAAyB,IAAI,CAAC;QAGpC,kBAAa,GAA2B;YACtC,KAAK,EAAE,KAAK;YACZ,YAAY,EAAE,YAAY;YAC1B,0BAA0B,EAAE,0BAA0B;YACtD,IAAI,EAAE,IAAI;YACV,YAAY,EAAE,YAAY;YAC1B,KAAK,EAAE,KAAK;YACZ,IAAI,EAAE,IAAI;YACV,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AI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;IAC5B,CAAC;IA9NM,8BAAU,GAAG,0CAA0C,CAAC;IA+NjE,0BAAC;CAAA,AAhOD,IAgOC;SAhOY,mBAAmB;AAkOhC,MAAM,CAAC,IAAM,mBAAmB,GAA4D,UAC1F,OAA8B;IAE9B,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC,CAAC","sourcesContent":["import {\n BrowserClient,\n BrowserConfig,\n EnrichmentPlugin,\n Event,\n SpecialEventType,\n getGlobalScope,\n getAnalyticsConnector,\n} from '@amplitude/analytics-core';\nimport {\n init,\n setSessionId,\n getSessionId,\n getSessionReplayProperties,\n flush,\n start,\n stop,\n shutdown,\n evaluateTargetingAndCapture,\n AmplitudeSessionReplay,\n SessionReplayOptions as SessionReplayBrowserOptions,\n} from '@amplitude/session-replay-browser';\nimport { parseUserProperties } from './helpers';\nimport { semanticAutocaptureFamilies } from './semantic-context';\nimport { SessionReplayOptions } from './typings/session-replay';\nimport { VERSION } from './version';\n\nexport const DEFAULT_EVENT_PROPERTY_PREFIX = '[Amplitude]';\nexport const DEFAULT_SESSION_REPLAY_PROPERTY = `${DEFAULT_EVENT_PROPERTY_PREFIX} Session Replay ID`;\nexport class SessionReplayPlugin implements EnrichmentPlugin<BrowserClient, BrowserConfig> {\n static pluginName = '@amplitude/plugin-session-replay-browser';\n name = SessionReplayPlugin.pluginName;\n type = 'enrichment' as const;\n // this.config is defined in setup() which will always be called first\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: BrowserConfig | null = null;\n options: SessionReplayOptions;\n srInitOptions: SessionReplayBrowserOptions;\n sessionReplay: AmplitudeSessionReplay = {\n flush: flush,\n getSessionId: getSessionId,\n getSessionReplayProperties: getSessionReplayProperties,\n init: init,\n setSessionId: setSessionId,\n start: start,\n stop: stop,\n shutdown: shutdown,\n evaluateTargetingAndCapture: evaluateTargetingAndCapture,\n };\n\n constructor(options?: SessionReplayOptions) {\n this.options = { forceSessionTracking: false, ...options };\n this.srInitOptions = this.options;\n }\n\n async setup(config: BrowserConfig, _client: BrowserClient) {\n try {\n /* istanbul ignore next */\n config?.loggerProvider.log(`Installing @amplitude/plugin-session-replay, version ${VERSION}.`);\n\n this.config = config;\n\n if (this.options.forceSessionTracking) {\n if (typeof config.defaultTracking === 'boolean') {\n if (config.defaultTracking === false) {\n config.defaultTracking = {\n pageViews: false,\n formInteractions: false,\n fileDownloads: false,\n sessions: true,\n };\n }\n } else {\n config.defaultTracking = {\n ...config.defaultTracking,\n sessions: true,\n };\n }\n }\n const identityStore = getAnalyticsConnector(this.config.instanceName).identityStore;\n const userProperties = identityStore.getIdentity().userProperties;\n\n this.srInitOptions = {\n instanceName: this.config.instanceName,\n deviceId: this.options.deviceId ?? this.config.deviceId,\n optOut: this.config.optOut,\n sessionId: this.options.customSessionId ? undefined : this.config.sessionId,\n loggerProvider: this.config.loggerProvider,\n logLevel: this.config.logLevel,\n flushMaxRetries: this.config.flushMaxRetries,\n serverZone: this.config.serverZone,\n configServerUrl: this.options.configServerUrl || this.config.remoteConfig?.serverUrl,\n trackServerUrl: this.options.trackServerUrl,\n sampleRate: this.options.sampleRate,\n semanticCapture: this.options.semanticCapture,\n semanticAnalyticsContext: {\n present: true,\n autocapture: semanticAutocaptureFamilies(this.config.autocapture, this.config.defaultTracking),\n },\n privacyConfig: {\n blockSelector: this.options.privacyConfig?.blockSelector,\n maskAttributes: this.options.privacyConfig?.maskAttributes,\n maskSelector: this.options.privacyConfig?.maskSelector,\n unmaskSelector: this.options.privacyConfig?.unmaskSelector,\n defaultMaskLevel: this.options.privacyConfig?.defaultMaskLevel,\n },\n debugMode: this.options.debugMode,\n shouldInlineStylesheet: this.options.shouldInlineStylesheet,\n inlineImages: this.options.inlineImages,\n version: { type: 'plugin', version: VERSION },\n performanceConfig: this.options.performanceConfig,\n storeType: this.options.storeType,\n useWebWorker: this.options.useWebWorker ?? this.options.experimental?.useWebWorker,\n userProperties: userProperties,\n applyBackgroundColorToBlockedElements: this.options.applyBackgroundColorToBlockedElements,\n interactionConfig: this.options.interactionConfig,\n captureDocumentTitle: this.options.captureDocumentTitle,\n enableUrlChangePolling: this.options.enableUrlChangePolling,\n urlChangePollingInterval: this.options.urlChangePollingInterval,\n captureAdoptedStyleSheets: this.options.captureAdoptedStyleSheets,\n crossOriginIframes: this.options.crossOriginIframes,\n flushIntervalConfig: this.options.flushIntervalConfig,\n eagerFullSnapshotSend: this.options.eagerFullSnapshotSend,\n captureFullSnapshotOnFocus: this.options.captureFullSnapshotOnFocus,\n maxPersistedEventsSizeBytes: this.options.maxPersistedEventsSizeBytes,\n maxSingleEventSizeBytes: this.options.maxSingleEventSizeBytes,\n sendTimeoutMs: this.options.sendTimeoutMs,\n handleSendEvents: this.options.handleSendEvents,\n handleFetchConfig: this.options.handleFetchConfig,\n };\n\n await this.sessionReplay.init(config.apiKey, this.srInitOptions).promise;\n } catch (error) {\n /* istanbul ignore next */\n config?.loggerProvider.error(`Session Replay: Failed to initialize due to ${(error as Error).message}`);\n }\n }\n\n async onSessionIdChanged(sessionId: number): Promise<void> {\n this.config?.loggerProvider.debug(\n `Analytics session id is changed to ${sessionId}, SR session id is ${String(this.sessionReplay.getSessionId())}.`,\n );\n await this.sessionReplay.setSessionId(sessionId).promise;\n }\n\n async onOptOutChanged(optOut: boolean): Promise<void> {\n this.config?.loggerProvider.debug(\n `optOut is changed to ${String(optOut)}, calling ${\n optOut ? 'sessionReplay.shutdown()' : 'sessionReplay.init()'\n }.`,\n );\n // TODO: compare optOut with this.sessionReplay.getOptOut().\n // Need to add getOptOut() to the interface AmplitudeSessionReplay first.\n if (optOut) {\n this.sessionReplay.shutdown();\n } else {\n this.config != null && (await this.sessionReplay.init(this.config.apiKey, this.srInitOptions).promise);\n }\n }\n\n async execute(event: Event) {\n try {\n if (this.options.customSessionId) {\n const sessionId = this.options.customSessionId(event);\n if (sessionId) {\n // On event, synchronize the session id to the custom session id from the event. This may\n // suffer from offline/delayed events messing up the state stored\n if (sessionId !== this.sessionReplay.getSessionId()) {\n await this.sessionReplay.setSessionId(sessionId).promise;\n }\n\n const sessionRecordingProperties = this.sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n } else {\n // On event, synchronize the session id to the what's on the browserConfig (source of truth)\n // Choosing not to read from event object here, concerned about offline/delayed events messing up the state stored\n // in SR.\n const sessionId: string | number | undefined = this.config?.sessionId;\n if (sessionId && sessionId !== this.sessionReplay.getSessionId()) {\n await this.sessionReplay.setSessionId(sessionId).promise;\n }\n\n // Treating config.sessionId as source of truth, if the event's session id doesn't match, the\n // event is not of the current session (offline/late events). In that case, don't tag the events\n if (sessionId && sessionId === event.session_id) {\n let userProperties;\n if (event.event_type === SpecialEventType.IDENTIFY) {\n userProperties = parseUserProperties(event);\n }\n const globalScope = getGlobalScope();\n await this.sessionReplay.evaluateTargetingAndCapture({\n event,\n userProperties,\n page: globalScope?.location?.href != null ? { url: globalScope.location.href } : undefined,\n });\n const sessionRecordingProperties = this.sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n }\n\n if (event.event_type === SpecialEventType.IDENTIFY && event.event_properties) {\n delete event.event_properties[DEFAULT_SESSION_REPLAY_PROPERTY];\n }\n\n return Promise.resolve(event);\n } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: Failed to enrich event due to ${(error as Error).message}`);\n return Promise.resolve(event);\n }\n }\n\n async teardown(): Promise<void> {\n try {\n this.sessionReplay.shutdown();\n // the following are initialized in setup() which will always be called first\n // here we reset them to null to prevent memory leaks\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.config = null;\n } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: teardown failed due to ${(error as Error).message}`);\n }\n }\n\n getSessionReplayProperties() {\n return this.sessionReplay.getSessionReplayProperties();\n }\n\n /**\n * Start or resume session replay recording.\n * Recording still respects sample rate, targeting, opt-out, and remote capture flags.\n */\n async start() {\n await this.sessionReplay.start().promise;\n }\n\n /**\n * Stop session replay recording without removing the plugin.\n * Call {@link SessionReplayPlugin.start} to resume. Plugin teardown still uses shutdown.\n */\n stop() {\n this.sessionReplay.stop();\n }\n}\n\nexport const sessionReplayPlugin: (options?: SessionReplayOptions) => SessionReplayPlugin = (\n options?: SessionReplayOptions,\n) => {\n return new SessionReplayPlugin(options);\n};\n"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.37.0-codexsemantic-review-integration.0";
1
+ export declare const VERSION = "1.37.1";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,8CAA8C,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,WAAW,CAAC"}
@@ -1,3 +1,3 @@
1
1
  // Autogenerated by `pnpm version-file`. DO NOT EDIT
2
- export var VERSION = '1.37.0-codexsemantic-review-integration.0';
2
+ export var VERSION = '1.37.1';
3
3
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,CAAC,IAAM,OAAO,GAAG,2CAA2C,CAAC","sourcesContent":["// Autogenerated by `pnpm version-file`. DO NOT EDIT\nexport const VERSION = '1.37.0-codexsemantic-review-integration.0';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// Autogenerated by `pnpm version-file`. DO NOT EDIT\nexport const VERSION = '1.37.1';\n"]}