@amplitude/plugin-session-replay-browser 1.15.0 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.d.ts +2 -1
- package/lib/cjs/index.d.ts.map +1 -1
- package/lib/cjs/index.js +2 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/session-replay.d.ts +3 -0
- package/lib/cjs/session-replay.d.ts.map +1 -1
- package/lib/cjs/session-replay.js +23 -14
- package/lib/cjs/session-replay.js.map +1 -1
- package/lib/cjs/version.d.ts +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/cjs/version.js.map +1 -1
- package/lib/esm/index.d.ts +2 -1
- package/lib/esm/index.d.ts.map +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/session-replay.d.ts +3 -0
- package/lib/esm/session-replay.d.ts.map +1 -1
- package/lib/esm/session-replay.js +23 -14
- package/lib/esm/session-replay.js.map +1 -1
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/esm/version.js.map +1 -1
- package/lib/scripts/amplitude-min.js +1 -1
- package/lib/scripts/amplitude-min.js.gz +0 -0
- package/lib/scripts/amplitude-min.js.map +1 -1
- package/lib/scripts/amplitude-min.umd.js +1 -1
- package/lib/scripts/amplitude-min.umd.js.gz +0 -0
- package/lib/scripts/index.d.ts +2 -1
- package/lib/scripts/index.d.ts.map +1 -1
- package/lib/scripts/session-replay.d.ts +3 -0
- package/lib/scripts/session-replay.d.ts.map +1 -1
- package/lib/scripts/version.d.ts +1 -1
- package/package.json +5 -5
package/lib/cjs/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { sessionReplayPlugin as plugin, sessionReplayPlugin } from './session-replay';
|
|
1
|
+
export { sessionReplayPlugin as plugin, sessionReplayPlugin, SessionReplayPlugin } from './session-replay';
|
|
2
|
+
export { AmplitudeSessionReplay, SessionReplayOptions } from '@amplitude/session-replay-browser';
|
|
2
3
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,IAAI,MAAM,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,IAAI,MAAM,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC3G,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC"}
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sessionReplayPlugin = exports.plugin = void 0;
|
|
3
|
+
exports.SessionReplayPlugin = exports.sessionReplayPlugin = exports.plugin = void 0;
|
|
4
4
|
var session_replay_1 = require("./session-replay");
|
|
5
5
|
Object.defineProperty(exports, "plugin", { enumerable: true, get: function () { return session_replay_1.sessionReplayPlugin; } });
|
|
6
6
|
Object.defineProperty(exports, "sessionReplayPlugin", { enumerable: true, get: function () { return session_replay_1.sessionReplayPlugin; } });
|
|
7
|
+
Object.defineProperty(exports, "SessionReplayPlugin", { enumerable: true, get: function () { return session_replay_1.SessionReplayPlugin; } });
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,mDAA2G;AAAlG,wGAAA,mBAAmB,OAAU;AAAE,qHAAA,mBAAmB,OAAA;AAAE,qHAAA,mBAAmB,OAAA","sourcesContent":["export { sessionReplayPlugin as plugin, sessionReplayPlugin, SessionReplayPlugin } from './session-replay';\nexport { AmplitudeSessionReplay, SessionReplayOptions } from '@amplitude/session-replay-browser';\n"]}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { BrowserClient, BrowserConfig, EnrichmentPlugin, Event } from '@amplitude/analytics-core';
|
|
2
2
|
import * as sessionReplay from '@amplitude/session-replay-browser';
|
|
3
3
|
import { SessionReplayOptions } from './typings/session-replay';
|
|
4
|
+
import { AmplitudeSessionReplay } from '@amplitude/session-replay-browser';
|
|
4
5
|
export declare class SessionReplayPlugin implements EnrichmentPlugin<BrowserClient, BrowserConfig> {
|
|
6
|
+
static pluginName: string;
|
|
5
7
|
name: string;
|
|
6
8
|
type: "enrichment";
|
|
7
9
|
config: BrowserConfig;
|
|
8
10
|
options: SessionReplayOptions;
|
|
9
11
|
srInitOptions: sessionReplay.SessionReplayOptions;
|
|
12
|
+
sr: AmplitudeSessionReplay;
|
|
10
13
|
constructor(options?: SessionReplayOptions);
|
|
11
14
|
setup(config: BrowserConfig, _client: BrowserClient): Promise<void>;
|
|
12
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;
|
|
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;IA0DnD,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"}
|
|
@@ -6,8 +6,16 @@ var sessionReplay = tslib_1.__importStar(require("@amplitude/session-replay-brow
|
|
|
6
6
|
var version_1 = require("./version");
|
|
7
7
|
var SessionReplayPlugin = /** @class */ (function () {
|
|
8
8
|
function SessionReplayPlugin(options) {
|
|
9
|
-
this.name =
|
|
9
|
+
this.name = SessionReplayPlugin.pluginName;
|
|
10
10
|
this.type = 'enrichment';
|
|
11
|
+
this.sr = {
|
|
12
|
+
flush: sessionReplay.flush,
|
|
13
|
+
getSessionId: sessionReplay.getSessionId,
|
|
14
|
+
getSessionReplayProperties: sessionReplay.getSessionReplayProperties,
|
|
15
|
+
init: sessionReplay.init,
|
|
16
|
+
setSessionId: sessionReplay.setSessionId,
|
|
17
|
+
shutdown: sessionReplay.shutdown,
|
|
18
|
+
};
|
|
11
19
|
this.options = tslib_1.__assign({ forceSessionTracking: false }, options);
|
|
12
20
|
this.srInitOptions = this.options;
|
|
13
21
|
}
|
|
@@ -62,7 +70,7 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
62
70
|
storeType: this.options.storeType,
|
|
63
71
|
experimental: this.options.experimental,
|
|
64
72
|
};
|
|
65
|
-
return [4 /*yield*/,
|
|
73
|
+
return [4 /*yield*/, this.sr.init(config.apiKey, this.srInitOptions).promise];
|
|
66
74
|
case 1:
|
|
67
75
|
_f.sent();
|
|
68
76
|
return [3 /*break*/, 3];
|
|
@@ -81,8 +89,8 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
81
89
|
return tslib_1.__generator(this, function (_a) {
|
|
82
90
|
switch (_a.label) {
|
|
83
91
|
case 0:
|
|
84
|
-
this.config.loggerProvider.debug("Analytics session id is changed to ".concat(sessionId, ", SR session id is ").concat(String(
|
|
85
|
-
return [4 /*yield*/,
|
|
92
|
+
this.config.loggerProvider.debug("Analytics session id is changed to ".concat(sessionId, ", SR session id is ").concat(String(this.sr.getSessionId()), "."));
|
|
93
|
+
return [4 /*yield*/, this.sr.setSessionId(sessionId).promise];
|
|
86
94
|
case 1:
|
|
87
95
|
_a.sent();
|
|
88
96
|
return [2 /*return*/];
|
|
@@ -97,9 +105,9 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
97
105
|
case 0:
|
|
98
106
|
this.config.loggerProvider.debug("optOut is changed to ".concat(String(optOut), ", calling ").concat(optOut ? 'sessionReplay.shutdown()' : 'sessionReplay.init()', "."));
|
|
99
107
|
if (!optOut) return [3 /*break*/, 1];
|
|
100
|
-
|
|
108
|
+
this.sr.shutdown();
|
|
101
109
|
return [3 /*break*/, 3];
|
|
102
|
-
case 1: return [4 /*yield*/,
|
|
110
|
+
case 1: return [4 /*yield*/, this.sr.init(this.config.apiKey, this.srInitOptions).promise];
|
|
103
111
|
case 2:
|
|
104
112
|
_a.sent();
|
|
105
113
|
_a.label = 3;
|
|
@@ -119,20 +127,20 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
119
127
|
if (!this.options.customSessionId) return [3 /*break*/, 4];
|
|
120
128
|
sessionId = this.options.customSessionId(event);
|
|
121
129
|
if (!sessionId) return [3 /*break*/, 3];
|
|
122
|
-
if (!(sessionId !==
|
|
123
|
-
return [4 /*yield*/,
|
|
130
|
+
if (!(sessionId !== this.sr.getSessionId())) return [3 /*break*/, 2];
|
|
131
|
+
return [4 /*yield*/, this.sr.setSessionId(sessionId).promise];
|
|
124
132
|
case 1:
|
|
125
133
|
_b.sent();
|
|
126
134
|
_b.label = 2;
|
|
127
135
|
case 2:
|
|
128
|
-
sessionRecordingProperties =
|
|
136
|
+
sessionRecordingProperties = this.sr.getSessionReplayProperties();
|
|
129
137
|
event.event_properties = tslib_1.__assign(tslib_1.__assign({}, event.event_properties), sessionRecordingProperties);
|
|
130
138
|
_b.label = 3;
|
|
131
139
|
case 3: return [3 /*break*/, 7];
|
|
132
140
|
case 4:
|
|
133
141
|
sessionId = this.config.sessionId;
|
|
134
|
-
if (!(sessionId && sessionId !==
|
|
135
|
-
return [4 /*yield*/,
|
|
142
|
+
if (!(sessionId && sessionId !== this.sr.getSessionId())) return [3 /*break*/, 6];
|
|
143
|
+
return [4 /*yield*/, this.sr.setSessionId(sessionId).promise];
|
|
136
144
|
case 5:
|
|
137
145
|
_b.sent();
|
|
138
146
|
_b.label = 6;
|
|
@@ -140,7 +148,7 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
140
148
|
// Treating config.sessionId as source of truth, if the event's session id doesn't match, the
|
|
141
149
|
// event is not of the current session (offline/late events). In that case, don't tag the events
|
|
142
150
|
if (sessionId && sessionId === event.session_id) {
|
|
143
|
-
sessionRecordingProperties =
|
|
151
|
+
sessionRecordingProperties = this.sr.getSessionReplayProperties();
|
|
144
152
|
event.event_properties = tslib_1.__assign(tslib_1.__assign({}, event.event_properties), sessionRecordingProperties);
|
|
145
153
|
}
|
|
146
154
|
_b.label = 7;
|
|
@@ -160,7 +168,7 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
160
168
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
161
169
|
return tslib_1.__generator(this, function (_b) {
|
|
162
170
|
try {
|
|
163
|
-
|
|
171
|
+
this.sr.shutdown();
|
|
164
172
|
// the following are initialized in setup() which will always be called first
|
|
165
173
|
// here we reset them to null to prevent memory leaks
|
|
166
174
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -176,8 +184,9 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
176
184
|
});
|
|
177
185
|
};
|
|
178
186
|
SessionReplayPlugin.prototype.getSessionReplayProperties = function () {
|
|
179
|
-
return
|
|
187
|
+
return this.sr.getSessionReplayProperties();
|
|
180
188
|
};
|
|
189
|
+
SessionReplayPlugin.pluginName = '@amplitude/plugin-session-replay-browser';
|
|
181
190
|
return SessionReplayPlugin;
|
|
182
191
|
}());
|
|
183
192
|
exports.SessionReplayPlugin = SessionReplayPlugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":";;;;AACA,uFAAmE;AAEnE,qCAAoC;AAEpC;IAUE,6BAAY,OAA8B;QAT1C,SAAI,GAAG,0CAA0C,CAAC;QAClD,SAAI,GAAG,YAAqB,CAAC;QAS3B,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,EA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6F;wBAC7F,gGAAgG;wBAChG,IAAI,SAAS,IAAI,SAAS,KAAK,KAAK,CAAC,UAAU,EAAE;4BACzC,0BAA0B,GAAG,aAAa,CAAC,0BAA0B,EAAE,CAAC;4BAC9E,KAAK,CAAC,gBAAgB,yCACjB,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,aAAa,CAAC,QAAQ,EAAE,CAAC;oBACzB,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,aAAa,CAAC,0BAA0B,EAAE,CAAC;IACpD,CAAC;IACH,0BAAC;AAAD,CAAC,AA3JD,IA2JC;AA3JY,kDAAmB;AA6JzB,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';\n\nexport class SessionReplayPlugin implements EnrichmentPlugin<BrowserClient, BrowserConfig> {\n name = '@amplitude/plugin-session-replay-browser';\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\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 };\n\n await 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(sessionReplay.getSessionId())}.`,\n );\n await 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 if (optOut) {\n sessionReplay.shutdown();\n } else {\n await 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 !== sessionReplay.getSessionId()) {\n await sessionReplay.setSessionId(sessionId).promise;\n }\n\n const sessionRecordingProperties = 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 !== sessionReplay.getSessionId()) {\n await 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 = 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 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 sessionReplay.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,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,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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IAAI,SAAS,KAAK,KAAK,CAAC,UAAU,EAAE;4BACzC,0BAA0B,GAAG,IAAI,CAAC,EAAE,CAAC,0BAA0B,EAAE,CAAC;4BACxE,KAAK,CAAC,gBAAgB,yCACjB,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;IApKM,8BAAU,GAAG,0CAA0C,CAAC;IAqKjE,0BAAC;CAAA,AAtKD,IAsKC;AAtKY,kDAAmB;AAwKzB,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 };\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"]}
|
package/lib/cjs/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "1.
|
|
1
|
+
export declare const VERSION = "1.16.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/lib/cjs/version.js
CHANGED
package/lib/cjs/version.js.map
CHANGED
|
@@ -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.
|
|
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.16.0';\n"]}
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { sessionReplayPlugin as plugin, sessionReplayPlugin } from './session-replay';
|
|
1
|
+
export { sessionReplayPlugin as plugin, sessionReplayPlugin, SessionReplayPlugin } from './session-replay';
|
|
2
|
+
export { AmplitudeSessionReplay, SessionReplayOptions } from '@amplitude/session-replay-browser';
|
|
2
3
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,IAAI,MAAM,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,IAAI,MAAM,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC3G,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC"}
|
package/lib/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { sessionReplayPlugin as plugin, sessionReplayPlugin } from './session-replay';
|
|
1
|
+
export { sessionReplayPlugin as plugin, sessionReplayPlugin, SessionReplayPlugin } from './session-replay';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,IAAI,MAAM,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["export { sessionReplayPlugin as plugin, sessionReplayPlugin } from './session-replay';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,IAAI,MAAM,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["export { sessionReplayPlugin as plugin, sessionReplayPlugin, SessionReplayPlugin } from './session-replay';\nexport { AmplitudeSessionReplay, SessionReplayOptions } from '@amplitude/session-replay-browser';\n"]}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { BrowserClient, BrowserConfig, EnrichmentPlugin, Event } from '@amplitude/analytics-core';
|
|
2
2
|
import * as sessionReplay from '@amplitude/session-replay-browser';
|
|
3
3
|
import { SessionReplayOptions } from './typings/session-replay';
|
|
4
|
+
import { AmplitudeSessionReplay } from '@amplitude/session-replay-browser';
|
|
4
5
|
export declare class SessionReplayPlugin implements EnrichmentPlugin<BrowserClient, BrowserConfig> {
|
|
6
|
+
static pluginName: string;
|
|
5
7
|
name: string;
|
|
6
8
|
type: "enrichment";
|
|
7
9
|
config: BrowserConfig;
|
|
8
10
|
options: SessionReplayOptions;
|
|
9
11
|
srInitOptions: sessionReplay.SessionReplayOptions;
|
|
12
|
+
sr: AmplitudeSessionReplay;
|
|
10
13
|
constructor(options?: SessionReplayOptions);
|
|
11
14
|
setup(config: BrowserConfig, _client: BrowserClient): Promise<void>;
|
|
12
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;
|
|
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;IA0DnD,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"}
|
|
@@ -3,8 +3,16 @@ import * as sessionReplay from '@amplitude/session-replay-browser';
|
|
|
3
3
|
import { VERSION } from './version';
|
|
4
4
|
var SessionReplayPlugin = /** @class */ (function () {
|
|
5
5
|
function SessionReplayPlugin(options) {
|
|
6
|
-
this.name =
|
|
6
|
+
this.name = SessionReplayPlugin.pluginName;
|
|
7
7
|
this.type = 'enrichment';
|
|
8
|
+
this.sr = {
|
|
9
|
+
flush: sessionReplay.flush,
|
|
10
|
+
getSessionId: sessionReplay.getSessionId,
|
|
11
|
+
getSessionReplayProperties: sessionReplay.getSessionReplayProperties,
|
|
12
|
+
init: sessionReplay.init,
|
|
13
|
+
setSessionId: sessionReplay.setSessionId,
|
|
14
|
+
shutdown: sessionReplay.shutdown,
|
|
15
|
+
};
|
|
8
16
|
this.options = __assign({ forceSessionTracking: false }, options);
|
|
9
17
|
this.srInitOptions = this.options;
|
|
10
18
|
}
|
|
@@ -59,7 +67,7 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
59
67
|
storeType: this.options.storeType,
|
|
60
68
|
experimental: this.options.experimental,
|
|
61
69
|
};
|
|
62
|
-
return [4 /*yield*/,
|
|
70
|
+
return [4 /*yield*/, this.sr.init(config.apiKey, this.srInitOptions).promise];
|
|
63
71
|
case 1:
|
|
64
72
|
_f.sent();
|
|
65
73
|
return [3 /*break*/, 3];
|
|
@@ -78,8 +86,8 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
78
86
|
return __generator(this, function (_a) {
|
|
79
87
|
switch (_a.label) {
|
|
80
88
|
case 0:
|
|
81
|
-
this.config.loggerProvider.debug("Analytics session id is changed to ".concat(sessionId, ", SR session id is ").concat(String(
|
|
82
|
-
return [4 /*yield*/,
|
|
89
|
+
this.config.loggerProvider.debug("Analytics session id is changed to ".concat(sessionId, ", SR session id is ").concat(String(this.sr.getSessionId()), "."));
|
|
90
|
+
return [4 /*yield*/, this.sr.setSessionId(sessionId).promise];
|
|
83
91
|
case 1:
|
|
84
92
|
_a.sent();
|
|
85
93
|
return [2 /*return*/];
|
|
@@ -94,9 +102,9 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
94
102
|
case 0:
|
|
95
103
|
this.config.loggerProvider.debug("optOut is changed to ".concat(String(optOut), ", calling ").concat(optOut ? 'sessionReplay.shutdown()' : 'sessionReplay.init()', "."));
|
|
96
104
|
if (!optOut) return [3 /*break*/, 1];
|
|
97
|
-
|
|
105
|
+
this.sr.shutdown();
|
|
98
106
|
return [3 /*break*/, 3];
|
|
99
|
-
case 1: return [4 /*yield*/,
|
|
107
|
+
case 1: return [4 /*yield*/, this.sr.init(this.config.apiKey, this.srInitOptions).promise];
|
|
100
108
|
case 2:
|
|
101
109
|
_a.sent();
|
|
102
110
|
_a.label = 3;
|
|
@@ -116,20 +124,20 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
116
124
|
if (!this.options.customSessionId) return [3 /*break*/, 4];
|
|
117
125
|
sessionId = this.options.customSessionId(event);
|
|
118
126
|
if (!sessionId) return [3 /*break*/, 3];
|
|
119
|
-
if (!(sessionId !==
|
|
120
|
-
return [4 /*yield*/,
|
|
127
|
+
if (!(sessionId !== this.sr.getSessionId())) return [3 /*break*/, 2];
|
|
128
|
+
return [4 /*yield*/, this.sr.setSessionId(sessionId).promise];
|
|
121
129
|
case 1:
|
|
122
130
|
_b.sent();
|
|
123
131
|
_b.label = 2;
|
|
124
132
|
case 2:
|
|
125
|
-
sessionRecordingProperties =
|
|
133
|
+
sessionRecordingProperties = this.sr.getSessionReplayProperties();
|
|
126
134
|
event.event_properties = __assign(__assign({}, event.event_properties), sessionRecordingProperties);
|
|
127
135
|
_b.label = 3;
|
|
128
136
|
case 3: return [3 /*break*/, 7];
|
|
129
137
|
case 4:
|
|
130
138
|
sessionId = this.config.sessionId;
|
|
131
|
-
if (!(sessionId && sessionId !==
|
|
132
|
-
return [4 /*yield*/,
|
|
139
|
+
if (!(sessionId && sessionId !== this.sr.getSessionId())) return [3 /*break*/, 6];
|
|
140
|
+
return [4 /*yield*/, this.sr.setSessionId(sessionId).promise];
|
|
133
141
|
case 5:
|
|
134
142
|
_b.sent();
|
|
135
143
|
_b.label = 6;
|
|
@@ -137,7 +145,7 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
137
145
|
// Treating config.sessionId as source of truth, if the event's session id doesn't match, the
|
|
138
146
|
// event is not of the current session (offline/late events). In that case, don't tag the events
|
|
139
147
|
if (sessionId && sessionId === event.session_id) {
|
|
140
|
-
sessionRecordingProperties =
|
|
148
|
+
sessionRecordingProperties = this.sr.getSessionReplayProperties();
|
|
141
149
|
event.event_properties = __assign(__assign({}, event.event_properties), sessionRecordingProperties);
|
|
142
150
|
}
|
|
143
151
|
_b.label = 7;
|
|
@@ -157,7 +165,7 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
157
165
|
return __awaiter(this, void 0, void 0, function () {
|
|
158
166
|
return __generator(this, function (_b) {
|
|
159
167
|
try {
|
|
160
|
-
|
|
168
|
+
this.sr.shutdown();
|
|
161
169
|
// the following are initialized in setup() which will always be called first
|
|
162
170
|
// here we reset them to null to prevent memory leaks
|
|
163
171
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -173,8 +181,9 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
173
181
|
});
|
|
174
182
|
};
|
|
175
183
|
SessionReplayPlugin.prototype.getSessionReplayProperties = function () {
|
|
176
|
-
return
|
|
184
|
+
return this.sr.getSessionReplayProperties();
|
|
177
185
|
};
|
|
186
|
+
SessionReplayPlugin.pluginName = '@amplitude/plugin-session-replay-browser';
|
|
178
187
|
return SessionReplayPlugin;
|
|
179
188
|
}());
|
|
180
189
|
export { 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;AAEpC;IAUE,6BAAY,OAA8B;QAT1C,SAAI,GAAG,0CAA0C,CAAC;QAClD,SAAI,GAAG,YAAqB,CAAC;QAS3B,IAAI,CAAC,OAAO,cAAK,oBAAoB,EAAE,KAAK,IAAK,OAAO,CAAE,CAAC;QAC3D,IAAI,CAAC,aAAa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,CAAC,SAAS,CAAC,CAAC,OAAO,EAAA;;wBAAnD,SAAmD,CAAC;;;wBAGtD,6FAA6F;wBAC7F,gGAAgG;wBAChG,IAAI,SAAS,IAAI,SAAS,KAAK,KAAK,CAAC,UAAU,EAAE;4BACzC,0BAA0B,GAAG,aAAa,CAAC,0BAA0B,EAAE,CAAC;4BAC9E,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,aAAa,CAAC,QAAQ,EAAE,CAAC;oBACzB,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,aAAa,CAAC,0BAA0B,EAAE,CAAC;IACpD,CAAC;IACH,0BAAC;AAAD,CAAC,AA3JD,IA2JC;;AAED,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';\n\nexport class SessionReplayPlugin implements EnrichmentPlugin<BrowserClient, BrowserConfig> {\n name = '@amplitude/plugin-session-replay-browser';\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\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 };\n\n await 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(sessionReplay.getSessionId())}.`,\n );\n await 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 if (optOut) {\n sessionReplay.shutdown();\n } else {\n await 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 !== sessionReplay.getSessionId()) {\n await sessionReplay.setSessionId(sessionId).promise;\n }\n\n const sessionRecordingProperties = 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 !== sessionReplay.getSessionId()) {\n await 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 = 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 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 sessionReplay.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,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,MA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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 };\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"]}
|
package/lib/esm/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "1.
|
|
1
|
+
export declare const VERSION = "1.16.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/lib/esm/version.js
CHANGED
package/lib/esm/version.js.map
CHANGED
|
@@ -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.
|
|
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.16.0';\n"]}
|