@amplitude/plugin-session-replay-browser 1.6.16 → 1.6.18
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/session-replay.d.ts +6 -8
- package/lib/cjs/session-replay.d.ts.map +1 -1
- package/lib/cjs/session-replay.js +22 -79
- 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/session-replay.d.ts +6 -8
- package/lib/esm/session-replay.d.ts.map +1 -1
- package/lib/esm/session-replay.js +22 -79
- 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.umd.js +1 -1
- package/lib/scripts/amplitude-min.umd.js.gz +0 -0
- package/lib/scripts/session-replay.d.ts +6 -8
- package/lib/scripts/session-replay.d.ts.map +1 -1
- package/lib/scripts/version.d.ts +1 -1
- package/package.json +3 -3
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BrowserConfig, EnrichmentPlugin, Event } from '@amplitude/analytics-types';
|
|
2
2
|
import { SessionReplayOptions } from './typings/session-replay';
|
|
3
|
-
export declare class SessionReplayPlugin implements
|
|
3
|
+
export declare class SessionReplayPlugin implements EnrichmentPlugin {
|
|
4
4
|
name: string;
|
|
5
|
-
type: "
|
|
6
|
-
clientRemove: BrowserClient['remove'];
|
|
5
|
+
type: "enrichment";
|
|
7
6
|
config: BrowserConfig;
|
|
8
7
|
options: SessionReplayOptions;
|
|
9
8
|
constructor(options?: SessionReplayOptions);
|
|
10
|
-
setup(config: BrowserConfig
|
|
11
|
-
execute(event: Event): Promise<
|
|
12
|
-
flush(): Promise<void>;
|
|
9
|
+
setup(config: BrowserConfig): Promise<void>;
|
|
10
|
+
execute(event: Event): Promise<Event>;
|
|
13
11
|
teardown(): Promise<void>;
|
|
14
12
|
getSessionReplayProperties(): {
|
|
15
13
|
[key: string]: string | boolean | null;
|
|
16
14
|
};
|
|
17
15
|
}
|
|
18
|
-
export declare const sessionReplayPlugin: (options?: SessionReplayOptions) =>
|
|
16
|
+
export declare const sessionReplayPlugin: (options?: SessionReplayOptions) => EnrichmentPlugin;
|
|
19
17
|
//# sourceMappingURL=session-replay.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAEpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGhE,qBAAa,mBAAoB,YAAW,gBAAgB;IAC1D,IAAI,SAA8C;IAClD,IAAI,eAAyB;IAI7B,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,oBAAoB,CAAC;gBAElB,OAAO,CAAC,EAAE,oBAAoB;IAQpC,KAAK,CAAC,MAAM,EAAE,aAAa;IA8C3B,OAAO,CAAC,KAAK,EAAE,KAAK;IAmBpB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAS/B,0BAA0B;;;CAG3B;AAED,eAAO,MAAM,mBAAmB,EAAE,CAAC,OAAO,CAAC,EAAE,oBAAoB,KAAK,gBAIrE,CAAC"}
|
|
@@ -3,67 +3,23 @@ exports.sessionReplayPlugin = exports.SessionReplayPlugin = void 0;
|
|
|
3
3
|
var tslib_1 = require("tslib");
|
|
4
4
|
var sessionReplay = tslib_1.__importStar(require("@amplitude/session-replay-browser"));
|
|
5
5
|
var version_1 = require("./version");
|
|
6
|
-
var ENRICHMENT_PLUGIN_NAME = '@amplitude/plugin-session-replay-enrichment-browser';
|
|
7
|
-
var SessionReplayEnrichmentPlugin = /** @class */ (function () {
|
|
8
|
-
function SessionReplayEnrichmentPlugin() {
|
|
9
|
-
this.name = ENRICHMENT_PLUGIN_NAME;
|
|
10
|
-
this.type = 'enrichment';
|
|
11
|
-
}
|
|
12
|
-
SessionReplayEnrichmentPlugin.prototype.setup = function (_config, _client) {
|
|
13
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
14
|
-
return tslib_1.__generator(this, function (_a) {
|
|
15
|
-
this.config = _config;
|
|
16
|
-
return [2 /*return*/];
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
SessionReplayEnrichmentPlugin.prototype.execute = function (event) {
|
|
21
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
22
|
-
var sessionRecordingProperties;
|
|
23
|
-
return tslib_1.__generator(this, function (_a) {
|
|
24
|
-
switch (_a.label) {
|
|
25
|
-
case 0:
|
|
26
|
-
if (!(this.config.sessionId && this.config.sessionId !== sessionReplay.getSessionId())) return [3 /*break*/, 2];
|
|
27
|
-
return [4 /*yield*/, sessionReplay.setSessionId(this.config.sessionId).promise];
|
|
28
|
-
case 1:
|
|
29
|
-
_a.sent();
|
|
30
|
-
_a.label = 2;
|
|
31
|
-
case 2:
|
|
32
|
-
// Treating config.sessionId as source of truth, if the event's session id doesn't match, the
|
|
33
|
-
// event is not of the current session (offline/late events). In that case, don't tag the events
|
|
34
|
-
if (this.config.sessionId && this.config.sessionId === event.session_id) {
|
|
35
|
-
sessionRecordingProperties = sessionReplay.getSessionReplayProperties();
|
|
36
|
-
event.event_properties = tslib_1.__assign(tslib_1.__assign({}, event.event_properties), sessionRecordingProperties);
|
|
37
|
-
}
|
|
38
|
-
return [2 /*return*/, Promise.resolve(event)];
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
return SessionReplayEnrichmentPlugin;
|
|
44
|
-
}());
|
|
45
6
|
var SessionReplayPlugin = /** @class */ (function () {
|
|
46
7
|
function SessionReplayPlugin(options) {
|
|
47
8
|
this.name = '@amplitude/plugin-session-replay-browser';
|
|
48
|
-
this.type = '
|
|
9
|
+
this.type = 'enrichment';
|
|
49
10
|
this.options = tslib_1.__assign({}, options);
|
|
50
11
|
// The user did not explicitly configure forceSessionTracking to false, default to true.
|
|
51
12
|
if (this.options.forceSessionTracking !== false) {
|
|
52
13
|
this.options.forceSessionTracking = true;
|
|
53
14
|
}
|
|
54
15
|
}
|
|
55
|
-
SessionReplayPlugin.prototype.setup = function (config
|
|
16
|
+
SessionReplayPlugin.prototype.setup = function (config) {
|
|
56
17
|
var _a, _b, _c, _d;
|
|
57
18
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
58
19
|
return tslib_1.__generator(this, function (_e) {
|
|
59
20
|
switch (_e.label) {
|
|
60
21
|
case 0:
|
|
61
|
-
if (!client) {
|
|
62
|
-
config.loggerProvider.error('SessionReplayPlugin requires v1.9.1+ of the Amplitude SDK.');
|
|
63
|
-
return [2 /*return*/];
|
|
64
|
-
}
|
|
65
22
|
config.loggerProvider.log("Installing @amplitude/plugin-session-replay, version ".concat(version_1.VERSION, "."));
|
|
66
|
-
this.clientRemove = client.remove.bind(client);
|
|
67
23
|
this.config = config;
|
|
68
24
|
if (this.options.forceSessionTracking) {
|
|
69
25
|
if (typeof config.defaultTracking === 'boolean') {
|
|
@@ -102,11 +58,6 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
102
58
|
version: { type: 'plugin', version: version_1.VERSION },
|
|
103
59
|
}).promise];
|
|
104
60
|
case 1:
|
|
105
|
-
_e.sent();
|
|
106
|
-
// add enrichment plugin to add session replay properties to events
|
|
107
|
-
return [4 /*yield*/, client.add(new SessionReplayEnrichmentPlugin()).promise];
|
|
108
|
-
case 2:
|
|
109
|
-
// add enrichment plugin to add session replay properties to events
|
|
110
61
|
_e.sent();
|
|
111
62
|
return [2 /*return*/];
|
|
112
63
|
}
|
|
@@ -115,23 +66,23 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
115
66
|
};
|
|
116
67
|
SessionReplayPlugin.prototype.execute = function (event) {
|
|
117
68
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
118
|
-
|
|
119
|
-
return [2 /*return*/, Promise.resolve({
|
|
120
|
-
event: event,
|
|
121
|
-
code: 200,
|
|
122
|
-
message: 'success',
|
|
123
|
-
})];
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
};
|
|
127
|
-
SessionReplayPlugin.prototype.flush = function () {
|
|
128
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
69
|
+
var sessionRecordingProperties;
|
|
129
70
|
return tslib_1.__generator(this, function (_a) {
|
|
130
71
|
switch (_a.label) {
|
|
131
|
-
case 0:
|
|
72
|
+
case 0:
|
|
73
|
+
if (!(this.config.sessionId && this.config.sessionId !== sessionReplay.getSessionId())) return [3 /*break*/, 2];
|
|
74
|
+
return [4 /*yield*/, sessionReplay.setSessionId(this.config.sessionId).promise];
|
|
132
75
|
case 1:
|
|
133
76
|
_a.sent();
|
|
134
|
-
|
|
77
|
+
_a.label = 2;
|
|
78
|
+
case 2:
|
|
79
|
+
// Treating config.sessionId as source of truth, if the event's session id doesn't match, the
|
|
80
|
+
// event is not of the current session (offline/late events). In that case, don't tag the events
|
|
81
|
+
if (this.config.sessionId && this.config.sessionId === event.session_id) {
|
|
82
|
+
sessionRecordingProperties = sessionReplay.getSessionReplayProperties();
|
|
83
|
+
event.event_properties = tslib_1.__assign(tslib_1.__assign({}, event.event_properties), sessionRecordingProperties);
|
|
84
|
+
}
|
|
85
|
+
return [2 /*return*/, Promise.resolve(event)];
|
|
135
86
|
}
|
|
136
87
|
});
|
|
137
88
|
});
|
|
@@ -139,21 +90,13 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
139
90
|
SessionReplayPlugin.prototype.teardown = function () {
|
|
140
91
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
141
92
|
return tslib_1.__generator(this, function (_a) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
150
|
-
// @ts-ignore
|
|
151
|
-
this.config = null;
|
|
152
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
153
|
-
// @ts-ignore
|
|
154
|
-
this.clientRemove = null;
|
|
155
|
-
return [2 /*return*/];
|
|
156
|
-
}
|
|
93
|
+
sessionReplay.shutdown();
|
|
94
|
+
// the following are initialized in setup() which will always be called first
|
|
95
|
+
// here we reset them to null to prevent memory leaks
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
97
|
+
// @ts-ignore
|
|
98
|
+
this.config = null;
|
|
99
|
+
return [2 /*return*/];
|
|
157
100
|
});
|
|
158
101
|
});
|
|
159
102
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":";;;AACA,uFAAmE;AAEnE,qCAAoC;AAEpC;IASE,6BAAY,OAA8B;QAR1C,SAAI,GAAG,0CAA0C,CAAC;QAClD,SAAI,GAAG,YAAqB,CAAC;QAQ3B,IAAI,CAAC,OAAO,wBAAQ,OAAO,CAAE,CAAC;QAC9B,wFAAwF;QACxF,IAAI,IAAI,CAAC,OAAO,CAAC,oBAAoB,KAAK,KAAK,EAAE;YAC/C,IAAI,CAAC,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;SAC1C;IACH,CAAC;IAEK,mCAAK,GAAX,UAAY,MAAqB;;;;;;wBAC/B,MAAM,CAAC,cAAc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A0B,GAA1B;QACE,OAAO,aAAa,CAAC,0BAA0B,EAAE,CAAC;IACpD,CAAC;IACH,0BAAC;AAAD,CAAC,AA9FD,IA8FC;AA9FY,kDAAmB;AAgGzB,IAAM,mBAAmB,GAAyD,UACvF,OAA8B;IAE9B,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC,CAAC;AAJW,QAAA,mBAAmB,uBAI9B","sourcesContent":["import { BrowserConfig, EnrichmentPlugin, Event } from '@amplitude/analytics-types';\nimport * as sessionReplay from '@amplitude/session-replay-browser';\nimport { SessionReplayOptions } from './typings/session-replay';\nimport { VERSION } from './version';\n\nexport class SessionReplayPlugin implements EnrichmentPlugin {\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\n constructor(options?: SessionReplayOptions) {\n this.options = { ...options };\n // The user did not explicitly configure forceSessionTracking to false, default to true.\n if (this.options.forceSessionTracking !== false) {\n this.options.forceSessionTracking = true;\n }\n }\n\n async setup(config: BrowserConfig) {\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 await sessionReplay.init(config.apiKey, {\n instanceName: this.config.instanceName,\n deviceId: this.config.deviceId,\n optOut: this.config.optOut,\n sessionId: this.config.sessionId,\n loggerProvider: this.config.loggerProvider,\n logLevel: this.config.logLevel,\n flushMaxRetries: this.config.flushMaxRetries,\n serverZone: this.config.serverZone,\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 configEndpointUrl: this.options.configEndpointUrl,\n shouldInlineStylesheet: this.options.shouldInlineStylesheet,\n version: { type: 'plugin', version: VERSION },\n }).promise;\n }\n\n async execute(event: Event) {\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 if (this.config.sessionId && this.config.sessionId !== sessionReplay.getSessionId()) {\n await sessionReplay.setSessionId(this.config.sessionId).promise;\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 (this.config.sessionId && this.config.sessionId === event.session_id) {\n const sessionRecordingProperties = sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n return Promise.resolve(event);\n }\n\n async teardown(): Promise<void> {\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 }\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"]}
|
package/lib/cjs/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "1.6.
|
|
1
|
+
export declare const VERSION = "1.6.18";
|
|
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.6.
|
|
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.6.18';\n"]}
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BrowserConfig, EnrichmentPlugin, Event } from '@amplitude/analytics-types';
|
|
2
2
|
import { SessionReplayOptions } from './typings/session-replay';
|
|
3
|
-
export declare class SessionReplayPlugin implements
|
|
3
|
+
export declare class SessionReplayPlugin implements EnrichmentPlugin {
|
|
4
4
|
name: string;
|
|
5
|
-
type: "
|
|
6
|
-
clientRemove: BrowserClient['remove'];
|
|
5
|
+
type: "enrichment";
|
|
7
6
|
config: BrowserConfig;
|
|
8
7
|
options: SessionReplayOptions;
|
|
9
8
|
constructor(options?: SessionReplayOptions);
|
|
10
|
-
setup(config: BrowserConfig
|
|
11
|
-
execute(event: Event): Promise<
|
|
12
|
-
flush(): Promise<void>;
|
|
9
|
+
setup(config: BrowserConfig): Promise<void>;
|
|
10
|
+
execute(event: Event): Promise<Event>;
|
|
13
11
|
teardown(): Promise<void>;
|
|
14
12
|
getSessionReplayProperties(): {
|
|
15
13
|
[key: string]: string | boolean | null;
|
|
16
14
|
};
|
|
17
15
|
}
|
|
18
|
-
export declare const sessionReplayPlugin: (options?: SessionReplayOptions) =>
|
|
16
|
+
export declare const sessionReplayPlugin: (options?: SessionReplayOptions) => EnrichmentPlugin;
|
|
19
17
|
//# sourceMappingURL=session-replay.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAEpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGhE,qBAAa,mBAAoB,YAAW,gBAAgB;IAC1D,IAAI,SAA8C;IAClD,IAAI,eAAyB;IAI7B,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,oBAAoB,CAAC;gBAElB,OAAO,CAAC,EAAE,oBAAoB;IAQpC,KAAK,CAAC,MAAM,EAAE,aAAa;IA8C3B,OAAO,CAAC,KAAK,EAAE,KAAK;IAmBpB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAS/B,0BAA0B;;;CAG3B;AAED,eAAO,MAAM,mBAAmB,EAAE,CAAC,OAAO,CAAC,EAAE,oBAAoB,KAAK,gBAIrE,CAAC"}
|
|
@@ -1,67 +1,23 @@
|
|
|
1
1
|
import { __assign, __awaiter, __generator } from "tslib";
|
|
2
2
|
import * as sessionReplay from '@amplitude/session-replay-browser';
|
|
3
3
|
import { VERSION } from './version';
|
|
4
|
-
var ENRICHMENT_PLUGIN_NAME = '@amplitude/plugin-session-replay-enrichment-browser';
|
|
5
|
-
var SessionReplayEnrichmentPlugin = /** @class */ (function () {
|
|
6
|
-
function SessionReplayEnrichmentPlugin() {
|
|
7
|
-
this.name = ENRICHMENT_PLUGIN_NAME;
|
|
8
|
-
this.type = 'enrichment';
|
|
9
|
-
}
|
|
10
|
-
SessionReplayEnrichmentPlugin.prototype.setup = function (_config, _client) {
|
|
11
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
12
|
-
return __generator(this, function (_a) {
|
|
13
|
-
this.config = _config;
|
|
14
|
-
return [2 /*return*/];
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
SessionReplayEnrichmentPlugin.prototype.execute = function (event) {
|
|
19
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
20
|
-
var sessionRecordingProperties;
|
|
21
|
-
return __generator(this, function (_a) {
|
|
22
|
-
switch (_a.label) {
|
|
23
|
-
case 0:
|
|
24
|
-
if (!(this.config.sessionId && this.config.sessionId !== sessionReplay.getSessionId())) return [3 /*break*/, 2];
|
|
25
|
-
return [4 /*yield*/, sessionReplay.setSessionId(this.config.sessionId).promise];
|
|
26
|
-
case 1:
|
|
27
|
-
_a.sent();
|
|
28
|
-
_a.label = 2;
|
|
29
|
-
case 2:
|
|
30
|
-
// Treating config.sessionId as source of truth, if the event's session id doesn't match, the
|
|
31
|
-
// event is not of the current session (offline/late events). In that case, don't tag the events
|
|
32
|
-
if (this.config.sessionId && this.config.sessionId === event.session_id) {
|
|
33
|
-
sessionRecordingProperties = sessionReplay.getSessionReplayProperties();
|
|
34
|
-
event.event_properties = __assign(__assign({}, event.event_properties), sessionRecordingProperties);
|
|
35
|
-
}
|
|
36
|
-
return [2 /*return*/, Promise.resolve(event)];
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
return SessionReplayEnrichmentPlugin;
|
|
42
|
-
}());
|
|
43
4
|
var SessionReplayPlugin = /** @class */ (function () {
|
|
44
5
|
function SessionReplayPlugin(options) {
|
|
45
6
|
this.name = '@amplitude/plugin-session-replay-browser';
|
|
46
|
-
this.type = '
|
|
7
|
+
this.type = 'enrichment';
|
|
47
8
|
this.options = __assign({}, options);
|
|
48
9
|
// The user did not explicitly configure forceSessionTracking to false, default to true.
|
|
49
10
|
if (this.options.forceSessionTracking !== false) {
|
|
50
11
|
this.options.forceSessionTracking = true;
|
|
51
12
|
}
|
|
52
13
|
}
|
|
53
|
-
SessionReplayPlugin.prototype.setup = function (config
|
|
14
|
+
SessionReplayPlugin.prototype.setup = function (config) {
|
|
54
15
|
var _a, _b, _c, _d;
|
|
55
16
|
return __awaiter(this, void 0, void 0, function () {
|
|
56
17
|
return __generator(this, function (_e) {
|
|
57
18
|
switch (_e.label) {
|
|
58
19
|
case 0:
|
|
59
|
-
if (!client) {
|
|
60
|
-
config.loggerProvider.error('SessionReplayPlugin requires v1.9.1+ of the Amplitude SDK.');
|
|
61
|
-
return [2 /*return*/];
|
|
62
|
-
}
|
|
63
20
|
config.loggerProvider.log("Installing @amplitude/plugin-session-replay, version ".concat(VERSION, "."));
|
|
64
|
-
this.clientRemove = client.remove.bind(client);
|
|
65
21
|
this.config = config;
|
|
66
22
|
if (this.options.forceSessionTracking) {
|
|
67
23
|
if (typeof config.defaultTracking === 'boolean') {
|
|
@@ -100,11 +56,6 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
100
56
|
version: { type: 'plugin', version: VERSION },
|
|
101
57
|
}).promise];
|
|
102
58
|
case 1:
|
|
103
|
-
_e.sent();
|
|
104
|
-
// add enrichment plugin to add session replay properties to events
|
|
105
|
-
return [4 /*yield*/, client.add(new SessionReplayEnrichmentPlugin()).promise];
|
|
106
|
-
case 2:
|
|
107
|
-
// add enrichment plugin to add session replay properties to events
|
|
108
59
|
_e.sent();
|
|
109
60
|
return [2 /*return*/];
|
|
110
61
|
}
|
|
@@ -113,23 +64,23 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
113
64
|
};
|
|
114
65
|
SessionReplayPlugin.prototype.execute = function (event) {
|
|
115
66
|
return __awaiter(this, void 0, void 0, function () {
|
|
116
|
-
|
|
117
|
-
return [2 /*return*/, Promise.resolve({
|
|
118
|
-
event: event,
|
|
119
|
-
code: 200,
|
|
120
|
-
message: 'success',
|
|
121
|
-
})];
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
};
|
|
125
|
-
SessionReplayPlugin.prototype.flush = function () {
|
|
126
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
67
|
+
var sessionRecordingProperties;
|
|
127
68
|
return __generator(this, function (_a) {
|
|
128
69
|
switch (_a.label) {
|
|
129
|
-
case 0:
|
|
70
|
+
case 0:
|
|
71
|
+
if (!(this.config.sessionId && this.config.sessionId !== sessionReplay.getSessionId())) return [3 /*break*/, 2];
|
|
72
|
+
return [4 /*yield*/, sessionReplay.setSessionId(this.config.sessionId).promise];
|
|
130
73
|
case 1:
|
|
131
74
|
_a.sent();
|
|
132
|
-
|
|
75
|
+
_a.label = 2;
|
|
76
|
+
case 2:
|
|
77
|
+
// Treating config.sessionId as source of truth, if the event's session id doesn't match, the
|
|
78
|
+
// event is not of the current session (offline/late events). In that case, don't tag the events
|
|
79
|
+
if (this.config.sessionId && this.config.sessionId === event.session_id) {
|
|
80
|
+
sessionRecordingProperties = sessionReplay.getSessionReplayProperties();
|
|
81
|
+
event.event_properties = __assign(__assign({}, event.event_properties), sessionRecordingProperties);
|
|
82
|
+
}
|
|
83
|
+
return [2 /*return*/, Promise.resolve(event)];
|
|
133
84
|
}
|
|
134
85
|
});
|
|
135
86
|
});
|
|
@@ -137,21 +88,13 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
137
88
|
SessionReplayPlugin.prototype.teardown = function () {
|
|
138
89
|
return __awaiter(this, void 0, void 0, function () {
|
|
139
90
|
return __generator(this, function (_a) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
148
|
-
// @ts-ignore
|
|
149
|
-
this.config = null;
|
|
150
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
151
|
-
// @ts-ignore
|
|
152
|
-
this.clientRemove = null;
|
|
153
|
-
return [2 /*return*/];
|
|
154
|
-
}
|
|
91
|
+
sessionReplay.shutdown();
|
|
92
|
+
// the following are initialized in setup() which will always be called first
|
|
93
|
+
// here we reset them to null to prevent memory leaks
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
95
|
+
// @ts-ignore
|
|
96
|
+
this.config = null;
|
|
97
|
+
return [2 /*return*/];
|
|
155
98
|
});
|
|
156
99
|
});
|
|
157
100
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.js","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":";
|
|
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;IASE,6BAAY,OAA8B;QAR1C,SAAI,GAAG,0CAA0C,CAAC;QAClD,SAAI,GAAG,YAAqB,CAAC;QAQ3B,IAAI,CAAC,OAAO,gBAAQ,OAAO,CAAE,CAAC;QAC9B,wFAAwF;QACxF,IAAI,IAAI,CAAC,OAAO,CAAC,oBAAoB,KAAK,KAAK,EAAE;YAC/C,IAAI,CAAC,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;SAC1C;IACH,CAAC;IAEK,mCAAK,GAAX,UAAY,MAAqB;;;;;;wBAC/B,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,+DAAwD,OAAO,MAAG,CAAC,CAAC;wBAE9F,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;wBAErB,IAAI,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE;4BACrC,IAAI,OAAO,MAAM,CAAC,eAAe,KAAK,SAAS,EAAE;gCAC/C,IAAI,MAAM,CAAC,eAAe,KAAK,KAAK,EAAE;oCACpC,MAAM,CAAC,eAAe,GAAG;wCACvB,SAAS,EAAE,KAAK;wCAChB,gBAAgB,EAAE,KAAK;wCACvB,aAAa,EAAE,KAAK;wCACpB,QAAQ,EAAE,IAAI;qCACf,CAAC;iCACH;6BACF;iCAAM;gCACL,MAAM,CAAC,eAAe,yBACjB,MAAM,CAAC,eAAe,KACzB,QAAQ,EAAE,IAAI,GACf,CAAC;6BACH;yBACF;wBAED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,KAAK,aAAa,CAAC,YAAY,EAAE,CAAA,EAA/E,wBAA+E;wBACjF,qBAAM,aAAa,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,OAAO,EAAA;;wBAA/D,SAA+D,CAAC;;;wBAElE,6FAA6F;wBAC7F,gGAAgG;wBAChG,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,KAAK,KAAK,CAAC,UAAU,EAAE;4BACjE,0BAA0B,GAAG,aAAa,CAAC,0BAA0B,EAAE,CAAC;4BAC9E,KAAK,CAAC,gBAAgB,yBACjB,KAAK,CAAC,gBAAgB,GACtB,0BAA0B,CAC9B,CAAC;yBACH;wBACD,sBAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAC;;;;KAC/B;IAEK,sCAAQ,GAAd;;;gBACE,aAAa,CAAC,QAAQ,EAAE,CAAC;gBACzB,6EAA6E;gBAC7E,qDAAqD;gBACrD,6DAA6D;gBAC7D,aAAa;gBACb,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;;;;KACpB;IAED,wDAA0B,GAA1B;QACE,OAAO,aAAa,CAAC,0BAA0B,EAAE,CAAC;IACpD,CAAC;IACH,0BAAC;AAAD,CAAC,AA9FD,IA8FC;;AAED,MAAM,CAAC,IAAM,mBAAmB,GAAyD,UACvF,OAA8B;IAE9B,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC,CAAC","sourcesContent":["import { BrowserConfig, EnrichmentPlugin, Event } from '@amplitude/analytics-types';\nimport * as sessionReplay from '@amplitude/session-replay-browser';\nimport { SessionReplayOptions } from './typings/session-replay';\nimport { VERSION } from './version';\n\nexport class SessionReplayPlugin implements EnrichmentPlugin {\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\n constructor(options?: SessionReplayOptions) {\n this.options = { ...options };\n // The user did not explicitly configure forceSessionTracking to false, default to true.\n if (this.options.forceSessionTracking !== false) {\n this.options.forceSessionTracking = true;\n }\n }\n\n async setup(config: BrowserConfig) {\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 await sessionReplay.init(config.apiKey, {\n instanceName: this.config.instanceName,\n deviceId: this.config.deviceId,\n optOut: this.config.optOut,\n sessionId: this.config.sessionId,\n loggerProvider: this.config.loggerProvider,\n logLevel: this.config.logLevel,\n flushMaxRetries: this.config.flushMaxRetries,\n serverZone: this.config.serverZone,\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 configEndpointUrl: this.options.configEndpointUrl,\n shouldInlineStylesheet: this.options.shouldInlineStylesheet,\n version: { type: 'plugin', version: VERSION },\n }).promise;\n }\n\n async execute(event: Event) {\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 if (this.config.sessionId && this.config.sessionId !== sessionReplay.getSessionId()) {\n await sessionReplay.setSessionId(this.config.sessionId).promise;\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 (this.config.sessionId && this.config.sessionId === event.session_id) {\n const sessionRecordingProperties = sessionReplay.getSessionReplayProperties();\n event.event_properties = {\n ...event.event_properties,\n ...sessionRecordingProperties,\n };\n }\n return Promise.resolve(event);\n }\n\n async teardown(): Promise<void> {\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 }\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"]}
|
package/lib/esm/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "1.6.
|
|
1
|
+
export declare const VERSION = "1.6.18";
|
|
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.6.
|
|
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.6.18';\n"]}
|