@amplitude/plugin-session-replay-browser 1.18.2 → 1.19.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.
@@ -9,7 +9,7 @@ export declare class SessionReplayPlugin implements EnrichmentPlugin<BrowserClie
9
9
  config: BrowserConfig;
10
10
  options: SessionReplayOptions;
11
11
  srInitOptions: sessionReplay.SessionReplayOptions;
12
- sr: AmplitudeSessionReplay;
12
+ sessionReplay: AmplitudeSessionReplay;
13
13
  constructor(options?: SessionReplayOptions);
14
14
  setup(config: BrowserConfig, _client: BrowserClient): Promise<void>;
15
15
  onSessionIdChanged(sessionId: number): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClG,OAAO,KAAK,aAAa,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAE3E,qBAAa,mBAAoB,YAAW,gBAAgB,CAAC,aAAa,EAAE,aAAa,CAAC;IACxF,MAAM,CAAC,UAAU,SAA8C;IAC/D,IAAI,SAAkC;IACtC,IAAI,eAAyB;IAI7B,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,oBAAoB,CAAC;IAC9B,aAAa,EAAE,aAAa,CAAC,oBAAoB,CAAC;IAClD,EAAE,EAAE,sBAAsB,CAOxB;gBAEU,OAAO,CAAC,EAAE,oBAAoB;IAKpC,KAAK,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa;IA4DnD,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOpD,eAAe,CAAC,MAAM,EAAE,OAAO,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gBAIrE,CAAC"}
@@ -8,7 +8,7 @@ var SessionReplayPlugin = /** @class */ (function () {
8
8
  function SessionReplayPlugin(options) {
9
9
  this.name = SessionReplayPlugin.pluginName;
10
10
  this.type = 'enrichment';
11
- this.sr = {
11
+ this.sessionReplay = {
12
12
  flush: sessionReplay.flush,
13
13
  getSessionId: sessionReplay.getSessionId,
14
14
  getSessionReplayProperties: sessionReplay.getSessionReplayProperties,
@@ -72,7 +72,7 @@ var SessionReplayPlugin = /** @class */ (function () {
72
72
  applyBackgroundColorToBlockedElements: this.options.applyBackgroundColorToBlockedElements,
73
73
  interactionConfig: this.options.interactionConfig,
74
74
  };
75
- return [4 /*yield*/, this.sr.init(config.apiKey, this.srInitOptions).promise];
75
+ return [4 /*yield*/, this.sessionReplay.init(config.apiKey, this.srInitOptions).promise];
76
76
  case 1:
77
77
  _f.sent();
78
78
  return [3 /*break*/, 3];
@@ -91,8 +91,8 @@ var SessionReplayPlugin = /** @class */ (function () {
91
91
  return tslib_1.__generator(this, function (_a) {
92
92
  switch (_a.label) {
93
93
  case 0:
94
- this.config.loggerProvider.debug("Analytics session id is changed to ".concat(sessionId, ", SR session id is ").concat(String(this.sr.getSessionId()), "."));
95
- return [4 /*yield*/, this.sr.setSessionId(sessionId).promise];
94
+ this.config.loggerProvider.debug("Analytics session id is changed to ".concat(sessionId, ", SR session id is ").concat(String(this.sessionReplay.getSessionId()), "."));
95
+ return [4 /*yield*/, this.sessionReplay.setSessionId(sessionId).promise];
96
96
  case 1:
97
97
  _a.sent();
98
98
  return [2 /*return*/];
@@ -107,9 +107,9 @@ var SessionReplayPlugin = /** @class */ (function () {
107
107
  case 0:
108
108
  this.config.loggerProvider.debug("optOut is changed to ".concat(String(optOut), ", calling ").concat(optOut ? 'sessionReplay.shutdown()' : 'sessionReplay.init()', "."));
109
109
  if (!optOut) return [3 /*break*/, 1];
110
- this.sr.shutdown();
110
+ this.sessionReplay.shutdown();
111
111
  return [3 /*break*/, 3];
112
- case 1: return [4 /*yield*/, this.sr.init(this.config.apiKey, this.srInitOptions).promise];
112
+ case 1: return [4 /*yield*/, this.sessionReplay.init(this.config.apiKey, this.srInitOptions).promise];
113
113
  case 2:
114
114
  _a.sent();
115
115
  _a.label = 3;
@@ -129,20 +129,20 @@ var SessionReplayPlugin = /** @class */ (function () {
129
129
  if (!this.options.customSessionId) return [3 /*break*/, 4];
130
130
  sessionId = this.options.customSessionId(event);
131
131
  if (!sessionId) return [3 /*break*/, 3];
132
- if (!(sessionId !== this.sr.getSessionId())) return [3 /*break*/, 2];
133
- return [4 /*yield*/, this.sr.setSessionId(sessionId).promise];
132
+ if (!(sessionId !== this.sessionReplay.getSessionId())) return [3 /*break*/, 2];
133
+ return [4 /*yield*/, this.sessionReplay.setSessionId(sessionId).promise];
134
134
  case 1:
135
135
  _b.sent();
136
136
  _b.label = 2;
137
137
  case 2:
138
- sessionRecordingProperties = this.sr.getSessionReplayProperties();
138
+ sessionRecordingProperties = this.sessionReplay.getSessionReplayProperties();
139
139
  event.event_properties = tslib_1.__assign(tslib_1.__assign({}, event.event_properties), sessionRecordingProperties);
140
140
  _b.label = 3;
141
141
  case 3: return [3 /*break*/, 7];
142
142
  case 4:
143
143
  sessionId = this.config.sessionId;
144
- if (!(sessionId && sessionId !== this.sr.getSessionId())) return [3 /*break*/, 6];
145
- return [4 /*yield*/, this.sr.setSessionId(sessionId).promise];
144
+ if (!(sessionId && sessionId !== this.sessionReplay.getSessionId())) return [3 /*break*/, 6];
145
+ return [4 /*yield*/, this.sessionReplay.setSessionId(sessionId).promise];
146
146
  case 5:
147
147
  _b.sent();
148
148
  _b.label = 6;
@@ -150,7 +150,7 @@ var SessionReplayPlugin = /** @class */ (function () {
150
150
  // Treating config.sessionId as source of truth, if the event's session id doesn't match, the
151
151
  // event is not of the current session (offline/late events). In that case, don't tag the events
152
152
  if (sessionId && sessionId === event.session_id) {
153
- sessionRecordingProperties = this.sr.getSessionReplayProperties();
153
+ sessionRecordingProperties = this.sessionReplay.getSessionReplayProperties();
154
154
  event.event_properties = tslib_1.__assign(tslib_1.__assign({}, event.event_properties), sessionRecordingProperties);
155
155
  }
156
156
  _b.label = 7;
@@ -170,7 +170,7 @@ var SessionReplayPlugin = /** @class */ (function () {
170
170
  return tslib_1.__awaiter(this, void 0, void 0, function () {
171
171
  return tslib_1.__generator(this, function (_b) {
172
172
  try {
173
- this.sr.shutdown();
173
+ this.sessionReplay.shutdown();
174
174
  // the following are initialized in setup() which will always be called first
175
175
  // here we reset them to null to prevent memory leaks
176
176
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -186,7 +186,7 @@ var SessionReplayPlugin = /** @class */ (function () {
186
186
  });
187
187
  };
188
188
  SessionReplayPlugin.prototype.getSessionReplayProperties = function () {
189
- return this.sr.getSessionReplayProperties();
189
+ return this.sessionReplay.getSessionReplayProperties();
190
190
  };
191
191
  SessionReplayPlugin.pluginName = '@amplitude/plugin-session-replay-browser';
192
192
  return SessionReplayPlugin;
@@ -1 +1 @@
1
- {"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":";;;;AACA,uFAAmE;AAEnE,qCAAoC;AAGpC;IAmBE,6BAAY,OAA8B;QAjB1C,SAAI,GAAG,mBAAmB,CAAC,UAAU,CAAC;QACtC,SAAI,GAAG,YAAqB,CAAC;QAO7B,OAAE,GAA2B;YAC3B,KAAK,EAAE,aAAa,CAAC,KAAK;YAC1B,YAAY,EAAE,aAAa,CAAC,YAAY;YACxC,0BAA0B,EAAE,aAAa,CAAC,0BAA0B;YACpE,IAAI,EAAE,aAAa,CAAC,IAAI;YACxB,YAAY,EAAE,aAAa,CAAC,YAAY;YACxC,QAAQ,EAAE,aAAa,CAAC,QAAQ;SACjC,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,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IAuKjE,0BAAC;CAAA,AAxKD,IAwKC;AAxKY,kDAAmB;AA0KzB,IAAM,mBAAmB,GAAyD,UACvF,OAA8B;IAE9B,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC,CAAC;AAJW,QAAA,mBAAmB,uBAI9B","sourcesContent":["import { BrowserClient, BrowserConfig, EnrichmentPlugin, Event } from '@amplitude/analytics-core';\nimport * as sessionReplay from '@amplitude/session-replay-browser';\nimport { SessionReplayOptions } from './typings/session-replay';\nimport { VERSION } from './version';\nimport { AmplitudeSessionReplay } from '@amplitude/session-replay-browser';\n\nexport class SessionReplayPlugin implements EnrichmentPlugin<BrowserClient, BrowserConfig> {\n static pluginName = '@amplitude/plugin-session-replay-browser';\n name = SessionReplayPlugin.pluginName;\n type = 'enrichment' as const;\n // this.config is defined in setup() which will always be called first\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: BrowserConfig;\n options: SessionReplayOptions;\n srInitOptions: sessionReplay.SessionReplayOptions;\n sr: AmplitudeSessionReplay = {\n flush: sessionReplay.flush,\n getSessionId: sessionReplay.getSessionId,\n getSessionReplayProperties: sessionReplay.getSessionReplayProperties,\n init: sessionReplay.init,\n setSessionId: sessionReplay.setSessionId,\n shutdown: sessionReplay.shutdown,\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\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,\n trackServerUrl: this.options.trackServerUrl,\n sampleRate: this.options.sampleRate,\n privacyConfig: {\n blockSelector: this.options.privacyConfig?.blockSelector,\n maskSelector: this.options.privacyConfig?.maskSelector,\n unmaskSelector: this.options.privacyConfig?.unmaskSelector,\n defaultMaskLevel: this.options.privacyConfig?.defaultMaskLevel,\n },\n debugMode: this.options.debugMode,\n shouldInlineStylesheet: this.options.shouldInlineStylesheet,\n version: { type: 'plugin', version: VERSION },\n performanceConfig: this.options.performanceConfig,\n storeType: this.options.storeType,\n experimental: this.options.experimental,\n applyBackgroundColorToBlockedElements: this.options.applyBackgroundColorToBlockedElements,\n interactionConfig: this.options.interactionConfig,\n };\n\n await this.sr.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.sr.getSessionId())}.`,\n );\n await this.sr.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.sr.getOptOut().\n // Need to add getOptOut() to the interface AmplitudeSessionReplay first.\n if (optOut) {\n this.sr.shutdown();\n } else {\n await this.sr.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.sr.getSessionId()) {\n await this.sr.setSessionId(sessionId).promise;\n }\n\n const sessionRecordingProperties = this.sr.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.sr.getSessionId()) {\n await this.sr.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 const sessionRecordingProperties = this.sr.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n }\n\n return Promise.resolve(event);\n } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: Failed to enrich event due to ${(error as Error).message}`);\n return Promise.resolve(event);\n }\n }\n\n async teardown(): Promise<void> {\n try {\n this.sr.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.sr.getSessionReplayProperties();\n }\n}\n\nexport const sessionReplayPlugin: (options?: SessionReplayOptions) => EnrichmentPlugin = (\n options?: SessionReplayOptions,\n) => {\n return new SessionReplayPlugin(options);\n};\n"]}
1
+ {"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":";;;;AACA,uFAAmE;AAEnE,qCAAoC;AAGpC;IAmBE,6BAAY,OAA8B;QAjB1C,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,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;IAtKM,8BAAU,GAAG,0CAA0C,CAAC;IAuKjE,0BAAC;CAAA,AAxKD,IAwKC;AAxKY,kDAAmB;AA0KzB,IAAM,mBAAmB,GAAyD,UACvF,OAA8B;IAE9B,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC,CAAC;AAJW,QAAA,mBAAmB,uBAI9B","sourcesContent":["import { BrowserClient, BrowserConfig, EnrichmentPlugin, Event } from '@amplitude/analytics-core';\nimport * as sessionReplay from '@amplitude/session-replay-browser';\nimport { SessionReplayOptions } from './typings/session-replay';\nimport { VERSION } from './version';\nimport { AmplitudeSessionReplay } from '@amplitude/session-replay-browser';\n\nexport class SessionReplayPlugin implements EnrichmentPlugin<BrowserClient, BrowserConfig> {\n static pluginName = '@amplitude/plugin-session-replay-browser';\n name = SessionReplayPlugin.pluginName;\n type = 'enrichment' as const;\n // this.config is defined in setup() which will always be called first\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: BrowserConfig;\n options: SessionReplayOptions;\n srInitOptions: sessionReplay.SessionReplayOptions;\n sessionReplay: AmplitudeSessionReplay = {\n flush: sessionReplay.flush,\n getSessionId: sessionReplay.getSessionId,\n getSessionReplayProperties: sessionReplay.getSessionReplayProperties,\n init: sessionReplay.init,\n setSessionId: sessionReplay.setSessionId,\n shutdown: sessionReplay.shutdown,\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\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,\n trackServerUrl: this.options.trackServerUrl,\n sampleRate: this.options.sampleRate,\n privacyConfig: {\n blockSelector: this.options.privacyConfig?.blockSelector,\n maskSelector: this.options.privacyConfig?.maskSelector,\n unmaskSelector: this.options.privacyConfig?.unmaskSelector,\n defaultMaskLevel: this.options.privacyConfig?.defaultMaskLevel,\n },\n debugMode: this.options.debugMode,\n shouldInlineStylesheet: this.options.shouldInlineStylesheet,\n version: { type: 'plugin', version: VERSION },\n performanceConfig: this.options.performanceConfig,\n storeType: this.options.storeType,\n experimental: this.options.experimental,\n applyBackgroundColorToBlockedElements: this.options.applyBackgroundColorToBlockedElements,\n interactionConfig: this.options.interactionConfig,\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 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 const sessionRecordingProperties = this.sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n }\n\n return Promise.resolve(event);\n } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: Failed to enrich event due to ${(error as Error).message}`);\n return Promise.resolve(event);\n }\n }\n\n async teardown(): Promise<void> {\n try {\n this.sessionReplay.shutdown();\n // the following are initialized in setup() which will always be called first\n // here we reset them to null to prevent memory leaks\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.config = null;\n } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: teardown failed due to ${(error as Error).message}`);\n }\n }\n\n getSessionReplayProperties() {\n return this.sessionReplay.getSessionReplayProperties();\n }\n}\n\nexport const sessionReplayPlugin: (options?: SessionReplayOptions) => EnrichmentPlugin = (\n options?: SessionReplayOptions,\n) => {\n return new SessionReplayPlugin(options);\n};\n"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.18.2";
1
+ export declare const VERSION = "1.19.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // Autogenerated by `yarn version-file`. DO NOT EDIT
5
- exports.VERSION = '1.18.2';
5
+ exports.VERSION = '1.19.0';
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,QAAQ,CAAC","sourcesContent":["// Autogenerated by `yarn version-file`. DO NOT EDIT\nexport const VERSION = '1.18.2';\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 `yarn version-file`. DO NOT EDIT\nexport const VERSION = '1.19.0';\n"]}
@@ -9,7 +9,7 @@ export declare class SessionReplayPlugin implements EnrichmentPlugin<BrowserClie
9
9
  config: BrowserConfig;
10
10
  options: SessionReplayOptions;
11
11
  srInitOptions: sessionReplay.SessionReplayOptions;
12
- sr: AmplitudeSessionReplay;
12
+ sessionReplay: AmplitudeSessionReplay;
13
13
  constructor(options?: SessionReplayOptions);
14
14
  setup(config: BrowserConfig, _client: BrowserClient): Promise<void>;
15
15
  onSessionIdChanged(sessionId: number): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClG,OAAO,KAAK,aAAa,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAE3E,qBAAa,mBAAoB,YAAW,gBAAgB,CAAC,aAAa,EAAE,aAAa,CAAC;IACxF,MAAM,CAAC,UAAU,SAA8C;IAC/D,IAAI,SAAkC;IACtC,IAAI,eAAyB;IAI7B,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,oBAAoB,CAAC;IAC9B,aAAa,EAAE,aAAa,CAAC,oBAAoB,CAAC;IAClD,EAAE,EAAE,sBAAsB,CAOxB;gBAEU,OAAO,CAAC,EAAE,oBAAoB;IAKpC,KAAK,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa;IA4DnD,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOpD,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAe/C,OAAO,CAAC,KAAK,EAAE,KAAK;IA6CpB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAc/B,0BAA0B;;;CAG3B;AAED,eAAO,MAAM,mBAAmB,EAAE,CAAC,OAAO,CAAC,EAAE,oBAAoB,KAAK,gBAIrE,CAAC"}
1
+ {"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClG,OAAO,KAAK,aAAa,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAE3E,qBAAa,mBAAoB,YAAW,gBAAgB,CAAC,aAAa,EAAE,aAAa,CAAC;IACxF,MAAM,CAAC,UAAU,SAA8C;IAC/D,IAAI,SAAkC;IACtC,IAAI,eAAyB;IAI7B,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,oBAAoB,CAAC;IAC9B,aAAa,EAAE,aAAa,CAAC,oBAAoB,CAAC;IAClD,aAAa,EAAE,sBAAsB,CAOnC;gBAEU,OAAO,CAAC,EAAE,oBAAoB;IAKpC,KAAK,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa;IA4DnD,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOpD,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAe/C,OAAO,CAAC,KAAK,EAAE,KAAK;IA6CpB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAc/B,0BAA0B;;;CAG3B;AAED,eAAO,MAAM,mBAAmB,EAAE,CAAC,OAAO,CAAC,EAAE,oBAAoB,KAAK,gBAIrE,CAAC"}
@@ -5,7 +5,7 @@ var SessionReplayPlugin = /** @class */ (function () {
5
5
  function SessionReplayPlugin(options) {
6
6
  this.name = SessionReplayPlugin.pluginName;
7
7
  this.type = 'enrichment';
8
- this.sr = {
8
+ this.sessionReplay = {
9
9
  flush: sessionReplay.flush,
10
10
  getSessionId: sessionReplay.getSessionId,
11
11
  getSessionReplayProperties: sessionReplay.getSessionReplayProperties,
@@ -69,7 +69,7 @@ var SessionReplayPlugin = /** @class */ (function () {
69
69
  applyBackgroundColorToBlockedElements: this.options.applyBackgroundColorToBlockedElements,
70
70
  interactionConfig: this.options.interactionConfig,
71
71
  };
72
- return [4 /*yield*/, this.sr.init(config.apiKey, this.srInitOptions).promise];
72
+ return [4 /*yield*/, this.sessionReplay.init(config.apiKey, this.srInitOptions).promise];
73
73
  case 1:
74
74
  _f.sent();
75
75
  return [3 /*break*/, 3];
@@ -88,8 +88,8 @@ var SessionReplayPlugin = /** @class */ (function () {
88
88
  return __generator(this, function (_a) {
89
89
  switch (_a.label) {
90
90
  case 0:
91
- this.config.loggerProvider.debug("Analytics session id is changed to ".concat(sessionId, ", SR session id is ").concat(String(this.sr.getSessionId()), "."));
92
- return [4 /*yield*/, this.sr.setSessionId(sessionId).promise];
91
+ this.config.loggerProvider.debug("Analytics session id is changed to ".concat(sessionId, ", SR session id is ").concat(String(this.sessionReplay.getSessionId()), "."));
92
+ return [4 /*yield*/, this.sessionReplay.setSessionId(sessionId).promise];
93
93
  case 1:
94
94
  _a.sent();
95
95
  return [2 /*return*/];
@@ -104,9 +104,9 @@ var SessionReplayPlugin = /** @class */ (function () {
104
104
  case 0:
105
105
  this.config.loggerProvider.debug("optOut is changed to ".concat(String(optOut), ", calling ").concat(optOut ? 'sessionReplay.shutdown()' : 'sessionReplay.init()', "."));
106
106
  if (!optOut) return [3 /*break*/, 1];
107
- this.sr.shutdown();
107
+ this.sessionReplay.shutdown();
108
108
  return [3 /*break*/, 3];
109
- case 1: return [4 /*yield*/, this.sr.init(this.config.apiKey, this.srInitOptions).promise];
109
+ case 1: return [4 /*yield*/, this.sessionReplay.init(this.config.apiKey, this.srInitOptions).promise];
110
110
  case 2:
111
111
  _a.sent();
112
112
  _a.label = 3;
@@ -126,20 +126,20 @@ var SessionReplayPlugin = /** @class */ (function () {
126
126
  if (!this.options.customSessionId) return [3 /*break*/, 4];
127
127
  sessionId = this.options.customSessionId(event);
128
128
  if (!sessionId) return [3 /*break*/, 3];
129
- if (!(sessionId !== this.sr.getSessionId())) return [3 /*break*/, 2];
130
- return [4 /*yield*/, this.sr.setSessionId(sessionId).promise];
129
+ if (!(sessionId !== this.sessionReplay.getSessionId())) return [3 /*break*/, 2];
130
+ return [4 /*yield*/, this.sessionReplay.setSessionId(sessionId).promise];
131
131
  case 1:
132
132
  _b.sent();
133
133
  _b.label = 2;
134
134
  case 2:
135
- sessionRecordingProperties = this.sr.getSessionReplayProperties();
135
+ sessionRecordingProperties = this.sessionReplay.getSessionReplayProperties();
136
136
  event.event_properties = __assign(__assign({}, event.event_properties), sessionRecordingProperties);
137
137
  _b.label = 3;
138
138
  case 3: return [3 /*break*/, 7];
139
139
  case 4:
140
140
  sessionId = this.config.sessionId;
141
- if (!(sessionId && sessionId !== this.sr.getSessionId())) return [3 /*break*/, 6];
142
- return [4 /*yield*/, this.sr.setSessionId(sessionId).promise];
141
+ if (!(sessionId && sessionId !== this.sessionReplay.getSessionId())) return [3 /*break*/, 6];
142
+ return [4 /*yield*/, this.sessionReplay.setSessionId(sessionId).promise];
143
143
  case 5:
144
144
  _b.sent();
145
145
  _b.label = 6;
@@ -147,7 +147,7 @@ var SessionReplayPlugin = /** @class */ (function () {
147
147
  // Treating config.sessionId as source of truth, if the event's session id doesn't match, the
148
148
  // event is not of the current session (offline/late events). In that case, don't tag the events
149
149
  if (sessionId && sessionId === event.session_id) {
150
- sessionRecordingProperties = this.sr.getSessionReplayProperties();
150
+ sessionRecordingProperties = this.sessionReplay.getSessionReplayProperties();
151
151
  event.event_properties = __assign(__assign({}, event.event_properties), sessionRecordingProperties);
152
152
  }
153
153
  _b.label = 7;
@@ -167,7 +167,7 @@ var SessionReplayPlugin = /** @class */ (function () {
167
167
  return __awaiter(this, void 0, void 0, function () {
168
168
  return __generator(this, function (_b) {
169
169
  try {
170
- this.sr.shutdown();
170
+ this.sessionReplay.shutdown();
171
171
  // the following are initialized in setup() which will always be called first
172
172
  // here we reset them to null to prevent memory leaks
173
173
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -183,7 +183,7 @@ var SessionReplayPlugin = /** @class */ (function () {
183
183
  });
184
184
  };
185
185
  SessionReplayPlugin.prototype.getSessionReplayProperties = function () {
186
- return this.sr.getSessionReplayProperties();
186
+ return this.sessionReplay.getSessionReplayProperties();
187
187
  };
188
188
  SessionReplayPlugin.pluginName = '@amplitude/plugin-session-replay-browser';
189
189
  return SessionReplayPlugin;
@@ -1 +1 @@
1
- {"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,aAAa,MAAM,mCAAmC,CAAC;AAEnE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC;IAmBE,6BAAY,OAA8B;QAjB1C,SAAI,GAAG,mBAAmB,CAAC,UAAU,CAAC;QACtC,SAAI,GAAG,YAAqB,CAAC;QAO7B,OAAE,GAA2B;YAC3B,KAAK,EAAE,aAAa,CAAC,KAAK;YAC1B,YAAY,EAAE,aAAa,CAAC,YAAY;YACxC,0BAA0B,EAAE,aAAa,CAAC,0BAA0B;YACpE,IAAI,EAAE,aAAa,CAAC,IAAI;YACxB,YAAY,EAAE,aAAa,CAAC,YAAY;YACxC,QAAQ,EAAE,aAAa,CAAC,QAAQ;SACjC,CAAC;QAGA,IAAI,CAAC,OAAO,cAAK,oBAAoB,EAAE,KAAK,IAAK,OAAO,CAAE,CAAC;QAC3D,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC;IACpC,CAAC;IAEK,mCAAK,GAAX,UAAY,MAAqB,EAAE,OAAsB;;;;;;;;wBAErD,0BAA0B;wBAC1B,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,cAAc,CAAC,GAAG,CAAC,+DAAwD,OAAO,MAAG,CAAC,CAAC;wBAE/F,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;wBAErB,IAAI,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE;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F,gGAAgG;wBAChG,IAAI,SAAS,IAAI,SAAS,KAAK,KAAK,CAAC,UAAU,EAAE;4BACzC,0BAA0B,GAAG,IAAI,CAAC,EAAE,CAAC,0BAA0B,EAAE,CAAC;4BACxE,KAAK,CAAC,gBAAgB,yBACjB,KAAK,CAAC,gBAAgB,GACtB,0BAA0B,CAC9B,CAAC;yBACH;;4BAGH,sBAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAC;;;wBAE9B,0BAA0B;wBAC1B,MAAA,IAAI,CAAC,MAAM,0CAAE,cAAc,CAAC,KAAK,CAAC,wDAAkD,OAAe,CAAC,OAAO,CAAE,CAAC,CAAC;wBAC/G,sBAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAC;;;;;KAEjC;IAEK,sCAAQ,GAAd;;;;gBACE,IAAI;oBACF,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC;oBACnB,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,EAAE,CAAC,0BAA0B,EAAE,CAAC;IAC9C,CAAC;IAtKM,8BAAU,GAAG,0CAA0C,CAAC;IAuKjE,0BAAC;CAAA,AAxKD,IAwKC;SAxKY,mBAAmB;AA0KhC,MAAM,CAAC,IAAM,mBAAmB,GAAyD,UACvF,OAA8B;IAE9B,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC,CAAC","sourcesContent":["import { BrowserClient, BrowserConfig, EnrichmentPlugin, Event } from '@amplitude/analytics-core';\nimport * as sessionReplay from '@amplitude/session-replay-browser';\nimport { SessionReplayOptions } from './typings/session-replay';\nimport { VERSION } from './version';\nimport { AmplitudeSessionReplay } from '@amplitude/session-replay-browser';\n\nexport class SessionReplayPlugin implements EnrichmentPlugin<BrowserClient, BrowserConfig> {\n static pluginName = '@amplitude/plugin-session-replay-browser';\n name = SessionReplayPlugin.pluginName;\n type = 'enrichment' as const;\n // this.config is defined in setup() which will always be called first\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: BrowserConfig;\n options: SessionReplayOptions;\n srInitOptions: sessionReplay.SessionReplayOptions;\n sr: AmplitudeSessionReplay = {\n flush: sessionReplay.flush,\n getSessionId: sessionReplay.getSessionId,\n getSessionReplayProperties: sessionReplay.getSessionReplayProperties,\n init: sessionReplay.init,\n setSessionId: sessionReplay.setSessionId,\n shutdown: sessionReplay.shutdown,\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\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,\n trackServerUrl: this.options.trackServerUrl,\n sampleRate: this.options.sampleRate,\n privacyConfig: {\n blockSelector: this.options.privacyConfig?.blockSelector,\n maskSelector: this.options.privacyConfig?.maskSelector,\n unmaskSelector: this.options.privacyConfig?.unmaskSelector,\n defaultMaskLevel: this.options.privacyConfig?.defaultMaskLevel,\n },\n debugMode: this.options.debugMode,\n shouldInlineStylesheet: this.options.shouldInlineStylesheet,\n version: { type: 'plugin', version: VERSION },\n performanceConfig: this.options.performanceConfig,\n storeType: this.options.storeType,\n experimental: this.options.experimental,\n applyBackgroundColorToBlockedElements: this.options.applyBackgroundColorToBlockedElements,\n interactionConfig: this.options.interactionConfig,\n };\n\n await this.sr.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.sr.getSessionId())}.`,\n );\n await this.sr.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.sr.getOptOut().\n // Need to add getOptOut() to the interface AmplitudeSessionReplay first.\n if (optOut) {\n this.sr.shutdown();\n } else {\n await this.sr.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.sr.getSessionId()) {\n await this.sr.setSessionId(sessionId).promise;\n }\n\n const sessionRecordingProperties = this.sr.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.sr.getSessionId()) {\n await this.sr.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 const sessionRecordingProperties = this.sr.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n }\n\n return Promise.resolve(event);\n } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: Failed to enrich event due to ${(error as Error).message}`);\n return Promise.resolve(event);\n }\n }\n\n async teardown(): Promise<void> {\n try {\n this.sr.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.sr.getSessionReplayProperties();\n }\n}\n\nexport const sessionReplayPlugin: (options?: SessionReplayOptions) => EnrichmentPlugin = (\n options?: SessionReplayOptions,\n) => {\n return new SessionReplayPlugin(options);\n};\n"]}
1
+ {"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,aAAa,MAAM,mCAAmC,CAAC;AAEnE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC;IAmBE,6BAAY,OAA8B;QAjB1C,SAAI,GAAG,mBAAmB,CAAC,UAAU,CAAC;QACtC,SAAI,GAAG,YAAqB,CAAC;QAO7B,kBAAa,GAA2B;YACtC,KAAK,EAAE,aAAa,CAAC,KAAK;YAC1B,YAAY,EAAE,aAAa,CAAC,YAAY;YACxC,0BAA0B,EAAE,aAAa,CAAC,0BAA0B;YACpE,IAAI,EAA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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;IAtKM,8BAAU,GAAG,0CAA0C,CAAC;IAuKjE,0BAAC;CAAA,AAxKD,IAwKC;SAxKY,mBAAmB;AA0KhC,MAAM,CAAC,IAAM,mBAAmB,GAAyD,UACvF,OAA8B;IAE9B,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC,CAAC","sourcesContent":["import { BrowserClient, BrowserConfig, EnrichmentPlugin, Event } from '@amplitude/analytics-core';\nimport * as sessionReplay from '@amplitude/session-replay-browser';\nimport { SessionReplayOptions } from './typings/session-replay';\nimport { VERSION } from './version';\nimport { AmplitudeSessionReplay } from '@amplitude/session-replay-browser';\n\nexport class SessionReplayPlugin implements EnrichmentPlugin<BrowserClient, BrowserConfig> {\n static pluginName = '@amplitude/plugin-session-replay-browser';\n name = SessionReplayPlugin.pluginName;\n type = 'enrichment' as const;\n // this.config is defined in setup() which will always be called first\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: BrowserConfig;\n options: SessionReplayOptions;\n srInitOptions: sessionReplay.SessionReplayOptions;\n sessionReplay: AmplitudeSessionReplay = {\n flush: sessionReplay.flush,\n getSessionId: sessionReplay.getSessionId,\n getSessionReplayProperties: sessionReplay.getSessionReplayProperties,\n init: sessionReplay.init,\n setSessionId: sessionReplay.setSessionId,\n shutdown: sessionReplay.shutdown,\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\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,\n trackServerUrl: this.options.trackServerUrl,\n sampleRate: this.options.sampleRate,\n privacyConfig: {\n blockSelector: this.options.privacyConfig?.blockSelector,\n maskSelector: this.options.privacyConfig?.maskSelector,\n unmaskSelector: this.options.privacyConfig?.unmaskSelector,\n defaultMaskLevel: this.options.privacyConfig?.defaultMaskLevel,\n },\n debugMode: this.options.debugMode,\n shouldInlineStylesheet: this.options.shouldInlineStylesheet,\n version: { type: 'plugin', version: VERSION },\n performanceConfig: this.options.performanceConfig,\n storeType: this.options.storeType,\n experimental: this.options.experimental,\n applyBackgroundColorToBlockedElements: this.options.applyBackgroundColorToBlockedElements,\n interactionConfig: this.options.interactionConfig,\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 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 const sessionRecordingProperties = this.sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n }\n\n return Promise.resolve(event);\n } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: Failed to enrich event due to ${(error as Error).message}`);\n return Promise.resolve(event);\n }\n }\n\n async teardown(): Promise<void> {\n try {\n this.sessionReplay.shutdown();\n // the following are initialized in setup() which will always be called first\n // here we reset them to null to prevent memory leaks\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.config = null;\n } catch (error) {\n /* istanbul ignore next */\n this.config?.loggerProvider.error(`Session Replay: teardown failed due to ${(error as Error).message}`);\n }\n }\n\n getSessionReplayProperties() {\n return this.sessionReplay.getSessionReplayProperties();\n }\n}\n\nexport const sessionReplayPlugin: (options?: SessionReplayOptions) => EnrichmentPlugin = (\n options?: SessionReplayOptions,\n) => {\n return new SessionReplayPlugin(options);\n};\n"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.18.2";
1
+ export declare const VERSION = "1.19.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,3 +1,3 @@
1
1
  // Autogenerated by `yarn version-file`. DO NOT EDIT
2
- export var VERSION = '1.18.2';
2
+ export var VERSION = '1.19.0';
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,QAAQ,CAAC","sourcesContent":["// Autogenerated by `yarn version-file`. DO NOT EDIT\nexport const VERSION = '1.18.2';\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 `yarn version-file`. DO NOT EDIT\nexport const VERSION = '1.19.0';\n"]}