@amplitude/plugin-session-replay-browser 1.6.19 → 1.7.0-srtargeting.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/constants.d.ts +2 -0
- package/lib/cjs/constants.d.ts.map +1 -1
- package/lib/cjs/constants.js +12 -0
- package/lib/cjs/constants.js.map +1 -1
- package/lib/cjs/helpers.d.ts +3 -0
- package/lib/cjs/helpers.d.ts.map +1 -0
- package/lib/cjs/helpers.js +20 -0
- package/lib/cjs/helpers.js.map +1 -0
- package/lib/cjs/session-replay.d.ts.map +1 -1
- package/lib/cjs/session-replay.js +24 -8
- package/lib/cjs/session-replay.js.map +1 -1
- package/lib/cjs/version.d.ts +1 -1
- package/lib/cjs/version.d.ts.map +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/cjs/version.js.map +1 -1
- package/lib/esm/constants.d.ts +2 -0
- package/lib/esm/constants.d.ts.map +1 -1
- package/lib/esm/constants.js +10 -0
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/helpers.d.ts +3 -0
- package/lib/esm/helpers.d.ts.map +1 -0
- package/lib/esm/helpers.js +17 -0
- package/lib/esm/helpers.js.map +1 -0
- package/lib/esm/session-replay.d.ts.map +1 -1
- package/lib/esm/session-replay.js +24 -8
- package/lib/esm/session-replay.js.map +1 -1
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.d.ts.map +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/constants.d.ts +2 -0
- package/lib/scripts/constants.d.ts.map +1 -1
- package/lib/scripts/helpers.d.ts +3 -0
- package/lib/scripts/helpers.d.ts.map +1 -0
- package/lib/scripts/session-replay.d.ts.map +1 -1
- package/lib/scripts/version.d.ts +1 -1
- package/lib/scripts/version.d.ts.map +1 -1
- package/package.json +3 -3
package/lib/cjs/constants.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,eAAO,MAAM,uBAAuB,qBAQnC,CAAC"}
|
package/lib/cjs/constants.js
CHANGED
|
@@ -1 +1,13 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
exports.PROPERTY_ADD_OPERATIONS = void 0;
|
|
3
|
+
var analytics_types_1 = require("@amplitude/analytics-types");
|
|
4
|
+
exports.PROPERTY_ADD_OPERATIONS = [
|
|
5
|
+
analytics_types_1.IdentifyOperation.SET,
|
|
6
|
+
analytics_types_1.IdentifyOperation.SET_ONCE,
|
|
7
|
+
analytics_types_1.IdentifyOperation.ADD,
|
|
8
|
+
analytics_types_1.IdentifyOperation.APPEND,
|
|
9
|
+
analytics_types_1.IdentifyOperation.PREPEND,
|
|
10
|
+
analytics_types_1.IdentifyOperation.POSTINSERT,
|
|
11
|
+
analytics_types_1.IdentifyOperation.POSTINSERT,
|
|
12
|
+
];
|
|
1
13
|
//# sourceMappingURL=constants.js.map
|
package/lib/cjs/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"","sourcesContent":[""]}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;AAAA,8DAA+D;AAElD,QAAA,uBAAuB,GAAG;IACrC,mCAAiB,CAAC,GAAG;IACrB,mCAAiB,CAAC,QAAQ;IAC1B,mCAAiB,CAAC,GAAG;IACrB,mCAAiB,CAAC,MAAM;IACxB,mCAAiB,CAAC,OAAO;IACzB,mCAAiB,CAAC,UAAU;IAC5B,mCAAiB,CAAC,UAAU;CAC7B,CAAC","sourcesContent":["import { IdentifyOperation } from '@amplitude/analytics-types';\n\nexport const PROPERTY_ADD_OPERATIONS = [\n IdentifyOperation.SET,\n IdentifyOperation.SET_ONCE,\n IdentifyOperation.ADD,\n IdentifyOperation.APPEND,\n IdentifyOperation.PREPEND,\n IdentifyOperation.POSTINSERT,\n IdentifyOperation.POSTINSERT,\n];\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,4BAA4B,CAAC;AAGtE,eAAO,MAAM,mBAAmB,UAAW,KAAK,mBAkB/C,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
exports.parseUserProperties = void 0;
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var constants_1 = require("./constants");
|
|
5
|
+
var parseUserProperties = function (event) {
|
|
6
|
+
if (!event.user_properties) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
var userPropertiesObj = {};
|
|
10
|
+
var userPropertyKeys = Object.keys(event.user_properties);
|
|
11
|
+
userPropertyKeys.forEach(function (identifyKey) {
|
|
12
|
+
if (constants_1.PROPERTY_ADD_OPERATIONS.includes(identifyKey)) {
|
|
13
|
+
var typedUserPropertiesOperation = event.user_properties && event.user_properties[identifyKey];
|
|
14
|
+
userPropertiesObj = tslib_1.__assign(tslib_1.__assign({}, userPropertiesObj), typedUserPropertiesOperation);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return userPropertiesObj;
|
|
18
|
+
};
|
|
19
|
+
exports.parseUserProperties = parseUserProperties;
|
|
20
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":";;;AACA,yCAAsD;AAE/C,IAAM,mBAAmB,GAAG,UAAC,KAAY;IAC9C,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE;QAC1B,OAAO;KACR;IACD,IAAI,iBAAiB,GAAG,EAAE,CAAC;IAC3B,IAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IAE5D,gBAAgB,CAAC,OAAO,CAAC,UAAC,WAAW;QACnC,IAAI,mCAAuB,CAAC,QAAQ,CAAC,WAAgC,CAAC,EAAE;YACtE,IAAM,4BAA4B,GAChC,KAAK,CAAC,eAAe,IAAK,KAAK,CAAC,eAAe,CAAC,WAAgC,CAAyB,CAAC;YAC5G,iBAAiB,yCACZ,iBAAiB,GACjB,4BAA4B,CAChC,CAAC;SACH;IACH,CAAC,CAAC,CAAC;IACH,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AAlBW,QAAA,mBAAmB,uBAkB9B","sourcesContent":["import { Event, IdentifyOperation } from '@amplitude/analytics-types';\nimport { PROPERTY_ADD_OPERATIONS } from './constants';\n\nexport const parseUserProperties = (event: Event) => {\n if (!event.user_properties) {\n return;\n }\n let userPropertiesObj = {};\n const userPropertyKeys = Object.keys(event.user_properties);\n\n userPropertyKeys.forEach((identifyKey) => {\n if (PROPERTY_ADD_OPERATIONS.includes(identifyKey as IdentifyOperation)) {\n const typedUserPropertiesOperation =\n event.user_properties && (event.user_properties[identifyKey as IdentifyOperation] as Record<string, any>);\n userPropertiesObj = {\n ...userPropertiesObj,\n ...typedUserPropertiesOperation,\n };\n }\n });\n return userPropertiesObj;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,KAAK,EAAoB,MAAM,4BAA4B,CAAC;AAGtG,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;IAkD3B,OAAO,CAAC,KAAK,EAAE,KAAK;IA4BpB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAS/B,0BAA0B;;;CAG3B;AAED,eAAO,MAAM,mBAAmB,EAAE,CAAC,OAAO,CAAC,EAAE,oBAAoB,KAAK,gBAIrE,CAAC"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
2
|
exports.sessionReplayPlugin = exports.SessionReplayPlugin = void 0;
|
|
3
3
|
var tslib_1 = require("tslib");
|
|
4
|
+
var analytics_client_common_1 = require("@amplitude/analytics-client-common");
|
|
5
|
+
var analytics_types_1 = require("@amplitude/analytics-types");
|
|
4
6
|
var sessionReplay = tslib_1.__importStar(require("@amplitude/session-replay-browser"));
|
|
7
|
+
var helpers_1 = require("./helpers");
|
|
5
8
|
var version_1 = require("./version");
|
|
6
9
|
var SessionReplayPlugin = /** @class */ (function () {
|
|
7
10
|
function SessionReplayPlugin(options) {
|
|
@@ -16,6 +19,7 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
16
19
|
SessionReplayPlugin.prototype.setup = function (config) {
|
|
17
20
|
var _a, _b, _c, _d;
|
|
18
21
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
22
|
+
var identityStore, userProperties;
|
|
19
23
|
return tslib_1.__generator(this, function (_e) {
|
|
20
24
|
switch (_e.label) {
|
|
21
25
|
case 0:
|
|
@@ -36,6 +40,8 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
36
40
|
config.defaultTracking = tslib_1.__assign(tslib_1.__assign({}, config.defaultTracking), { sessions: true });
|
|
37
41
|
}
|
|
38
42
|
}
|
|
43
|
+
identityStore = (0, analytics_client_common_1.getAnalyticsConnector)(this.config.instanceName).identityStore;
|
|
44
|
+
userProperties = identityStore.getIdentity().userProperties;
|
|
39
45
|
return [4 /*yield*/, sessionReplay.init(config.apiKey, {
|
|
40
46
|
instanceName: this.config.instanceName,
|
|
41
47
|
deviceId: this.config.deviceId,
|
|
@@ -56,6 +62,7 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
56
62
|
configEndpointUrl: this.options.configEndpointUrl,
|
|
57
63
|
shouldInlineStylesheet: this.options.shouldInlineStylesheet,
|
|
58
64
|
version: { type: 'plugin', version: version_1.VERSION },
|
|
65
|
+
userProperties: userProperties,
|
|
59
66
|
}).promise];
|
|
60
67
|
case 1:
|
|
61
68
|
_e.sent();
|
|
@@ -66,23 +73,32 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
66
73
|
};
|
|
67
74
|
SessionReplayPlugin.prototype.execute = function (event) {
|
|
68
75
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
69
|
-
var sessionRecordingProperties;
|
|
76
|
+
var identityStore, userProperties, userProperties, sessionRecordingProperties;
|
|
70
77
|
return tslib_1.__generator(this, function (_a) {
|
|
71
78
|
switch (_a.label) {
|
|
72
79
|
case 0:
|
|
73
80
|
if (!(this.config.sessionId && this.config.sessionId !== sessionReplay.getSessionId())) return [3 /*break*/, 2];
|
|
74
|
-
|
|
81
|
+
identityStore = (0, analytics_client_common_1.getAnalyticsConnector)(this.config.instanceName).identityStore;
|
|
82
|
+
userProperties = identityStore.getIdentity().userProperties;
|
|
83
|
+
return [4 /*yield*/, sessionReplay.setSessionId(this.config.sessionId, this.config.deviceId, {
|
|
84
|
+
userProperties: userProperties || {},
|
|
85
|
+
}).promise];
|
|
75
86
|
case 1:
|
|
76
87
|
_a.sent();
|
|
77
88
|
_a.label = 2;
|
|
78
89
|
case 2:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
event.event_properties = tslib_1.__assign(tslib_1.__assign({}, event.event_properties), sessionRecordingProperties);
|
|
90
|
+
if (!(this.config.sessionId && this.config.sessionId === event.session_id)) return [3 /*break*/, 4];
|
|
91
|
+
userProperties = void 0;
|
|
92
|
+
if (event.event_type === analytics_types_1.SpecialEventType.IDENTIFY) {
|
|
93
|
+
userProperties = (0, helpers_1.parseUserProperties)(event);
|
|
84
94
|
}
|
|
85
|
-
return [
|
|
95
|
+
return [4 /*yield*/, sessionReplay.evaluateTargetingAndCapture({ event: event, userProperties: userProperties })];
|
|
96
|
+
case 3:
|
|
97
|
+
_a.sent();
|
|
98
|
+
sessionRecordingProperties = sessionReplay.getSessionReplayProperties();
|
|
99
|
+
event.event_properties = tslib_1.__assign(tslib_1.__assign({}, event.event_properties), sessionRecordingProperties);
|
|
100
|
+
_a.label = 4;
|
|
101
|
+
case 4: return [2 /*return*/, Promise.resolve(event)];
|
|
86
102
|
}
|
|
87
103
|
});
|
|
88
104
|
});
|
|
@@ -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":";;;AAAA,8EAA2E;AAC3E,8DAAsG;AACtG,uFAAmE;AACnE,qCAAgD;AAEhD,qCAAoC;AAEpC;IASE,6BAAY,OAA8B;QAR1C,SAAI,GAAG,0CAA0C,CAAC;QAClD,SAAI,GAAG,YAAqB,CAAC;QAQ3B,IAAI,CAAC,OAAO,wBAAQ,OAAO,CAAE,CAA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richmentPlugin, Event, SpecialEventType } from '@amplitude/analytics-types';\nimport * as sessionReplay from '@amplitude/session-replay-browser';\nimport { parseUserProperties } from './helpers';\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 const identityStore = getAnalyticsConnector(this.config.instanceName).identityStore;\n const userProperties = identityStore.getIdentity().userProperties;\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 userProperties: userProperties,\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 const identityStore = getAnalyticsConnector(this.config.instanceName).identityStore;\n const userProperties = identityStore.getIdentity().userProperties;\n await sessionReplay.setSessionId(this.config.sessionId, this.config.deviceId, {\n userProperties: userProperties || {},\n }).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 let userProperties;\n if (event.event_type === SpecialEventType.IDENTIFY) {\n userProperties = parseUserProperties(event);\n }\n await sessionReplay.evaluateTargetingAndCapture({ event, userProperties });\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.
|
|
1
|
+
export declare const VERSION = "1.7.0-srtargeting.1";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/lib/cjs/version.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,wBAAwB,CAAC"}
|
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,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;AAAA,oDAAoD;AACvC,QAAA,OAAO,GAAG,qBAAqB,CAAC","sourcesContent":["// Autogenerated by `yarn version-file`. DO NOT EDIT\nexport const VERSION = '1.7.0-srtargeting.1';\n"]}
|
package/lib/esm/constants.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,eAAO,MAAM,uBAAuB,qBAQnC,CAAC"}
|
package/lib/esm/constants.js
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
+
import { IdentifyOperation } from '@amplitude/analytics-types';
|
|
2
|
+
export var PROPERTY_ADD_OPERATIONS = [
|
|
3
|
+
IdentifyOperation.SET,
|
|
4
|
+
IdentifyOperation.SET_ONCE,
|
|
5
|
+
IdentifyOperation.ADD,
|
|
6
|
+
IdentifyOperation.APPEND,
|
|
7
|
+
IdentifyOperation.PREPEND,
|
|
8
|
+
IdentifyOperation.POSTINSERT,
|
|
9
|
+
IdentifyOperation.POSTINSERT,
|
|
10
|
+
];
|
|
1
11
|
//# sourceMappingURL=constants.js.map
|
package/lib/esm/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"","sourcesContent":[""]}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,CAAC,IAAM,uBAAuB,GAAG;IACrC,iBAAiB,CAAC,GAAG;IACrB,iBAAiB,CAAC,QAAQ;IAC1B,iBAAiB,CAAC,GAAG;IACrB,iBAAiB,CAAC,MAAM;IACxB,iBAAiB,CAAC,OAAO;IACzB,iBAAiB,CAAC,UAAU;IAC5B,iBAAiB,CAAC,UAAU;CAC7B,CAAC","sourcesContent":["import { IdentifyOperation } from '@amplitude/analytics-types';\n\nexport const PROPERTY_ADD_OPERATIONS = [\n IdentifyOperation.SET,\n IdentifyOperation.SET_ONCE,\n IdentifyOperation.ADD,\n IdentifyOperation.APPEND,\n IdentifyOperation.PREPEND,\n IdentifyOperation.POSTINSERT,\n IdentifyOperation.POSTINSERT,\n];\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,4BAA4B,CAAC;AAGtE,eAAO,MAAM,mBAAmB,UAAW,KAAK,mBAkB/C,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { PROPERTY_ADD_OPERATIONS } from './constants';
|
|
3
|
+
export var parseUserProperties = function (event) {
|
|
4
|
+
if (!event.user_properties) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
var userPropertiesObj = {};
|
|
8
|
+
var userPropertyKeys = Object.keys(event.user_properties);
|
|
9
|
+
userPropertyKeys.forEach(function (identifyKey) {
|
|
10
|
+
if (PROPERTY_ADD_OPERATIONS.includes(identifyKey)) {
|
|
11
|
+
var typedUserPropertiesOperation = event.user_properties && event.user_properties[identifyKey];
|
|
12
|
+
userPropertiesObj = __assign(__assign({}, userPropertiesObj), typedUserPropertiesOperation);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
return userPropertiesObj;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,CAAC,IAAM,mBAAmB,GAAG,UAAC,KAAY;IAC9C,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE;QAC1B,OAAO;KACR;IACD,IAAI,iBAAiB,GAAG,EAAE,CAAC;IAC3B,IAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IAE5D,gBAAgB,CAAC,OAAO,CAAC,UAAC,WAAW;QACnC,IAAI,uBAAuB,CAAC,QAAQ,CAAC,WAAgC,CAAC,EAAE;YACtE,IAAM,4BAA4B,GAChC,KAAK,CAAC,eAAe,IAAK,KAAK,CAAC,eAAe,CAAC,WAAgC,CAAyB,CAAC;YAC5G,iBAAiB,yBACZ,iBAAiB,GACjB,4BAA4B,CAChC,CAAC;SACH;IACH,CAAC,CAAC,CAAC;IACH,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC","sourcesContent":["import { Event, IdentifyOperation } from '@amplitude/analytics-types';\nimport { PROPERTY_ADD_OPERATIONS } from './constants';\n\nexport const parseUserProperties = (event: Event) => {\n if (!event.user_properties) {\n return;\n }\n let userPropertiesObj = {};\n const userPropertyKeys = Object.keys(event.user_properties);\n\n userPropertyKeys.forEach((identifyKey) => {\n if (PROPERTY_ADD_OPERATIONS.includes(identifyKey as IdentifyOperation)) {\n const typedUserPropertiesOperation =\n event.user_properties && (event.user_properties[identifyKey as IdentifyOperation] as Record<string, any>);\n userPropertiesObj = {\n ...userPropertiesObj,\n ...typedUserPropertiesOperation,\n };\n }\n });\n return userPropertiesObj;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"session-replay.d.ts","sourceRoot":"","sources":["../../src/session-replay.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,KAAK,EAAoB,MAAM,4BAA4B,CAAC;AAGtG,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;IAkD3B,OAAO,CAAC,KAAK,EAAE,KAAK;IA4BpB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAS/B,0BAA0B;;;CAG3B;AAED,eAAO,MAAM,mBAAmB,EAAE,CAAC,OAAO,CAAC,EAAE,oBAAoB,KAAK,gBAIrE,CAAC"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { __assign, __awaiter, __generator } from "tslib";
|
|
2
|
+
import { getAnalyticsConnector } from '@amplitude/analytics-client-common';
|
|
3
|
+
import { SpecialEventType } from '@amplitude/analytics-types';
|
|
2
4
|
import * as sessionReplay from '@amplitude/session-replay-browser';
|
|
5
|
+
import { parseUserProperties } from './helpers';
|
|
3
6
|
import { VERSION } from './version';
|
|
4
7
|
var SessionReplayPlugin = /** @class */ (function () {
|
|
5
8
|
function SessionReplayPlugin(options) {
|
|
@@ -14,6 +17,7 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
14
17
|
SessionReplayPlugin.prototype.setup = function (config) {
|
|
15
18
|
var _a, _b, _c, _d;
|
|
16
19
|
return __awaiter(this, void 0, void 0, function () {
|
|
20
|
+
var identityStore, userProperties;
|
|
17
21
|
return __generator(this, function (_e) {
|
|
18
22
|
switch (_e.label) {
|
|
19
23
|
case 0:
|
|
@@ -34,6 +38,8 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
34
38
|
config.defaultTracking = __assign(__assign({}, config.defaultTracking), { sessions: true });
|
|
35
39
|
}
|
|
36
40
|
}
|
|
41
|
+
identityStore = getAnalyticsConnector(this.config.instanceName).identityStore;
|
|
42
|
+
userProperties = identityStore.getIdentity().userProperties;
|
|
37
43
|
return [4 /*yield*/, sessionReplay.init(config.apiKey, {
|
|
38
44
|
instanceName: this.config.instanceName,
|
|
39
45
|
deviceId: this.config.deviceId,
|
|
@@ -54,6 +60,7 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
54
60
|
configEndpointUrl: this.options.configEndpointUrl,
|
|
55
61
|
shouldInlineStylesheet: this.options.shouldInlineStylesheet,
|
|
56
62
|
version: { type: 'plugin', version: VERSION },
|
|
63
|
+
userProperties: userProperties,
|
|
57
64
|
}).promise];
|
|
58
65
|
case 1:
|
|
59
66
|
_e.sent();
|
|
@@ -64,23 +71,32 @@ var SessionReplayPlugin = /** @class */ (function () {
|
|
|
64
71
|
};
|
|
65
72
|
SessionReplayPlugin.prototype.execute = function (event) {
|
|
66
73
|
return __awaiter(this, void 0, void 0, function () {
|
|
67
|
-
var sessionRecordingProperties;
|
|
74
|
+
var identityStore, userProperties, userProperties, sessionRecordingProperties;
|
|
68
75
|
return __generator(this, function (_a) {
|
|
69
76
|
switch (_a.label) {
|
|
70
77
|
case 0:
|
|
71
78
|
if (!(this.config.sessionId && this.config.sessionId !== sessionReplay.getSessionId())) return [3 /*break*/, 2];
|
|
72
|
-
|
|
79
|
+
identityStore = getAnalyticsConnector(this.config.instanceName).identityStore;
|
|
80
|
+
userProperties = identityStore.getIdentity().userProperties;
|
|
81
|
+
return [4 /*yield*/, sessionReplay.setSessionId(this.config.sessionId, this.config.deviceId, {
|
|
82
|
+
userProperties: userProperties || {},
|
|
83
|
+
}).promise];
|
|
73
84
|
case 1:
|
|
74
85
|
_a.sent();
|
|
75
86
|
_a.label = 2;
|
|
76
87
|
case 2:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
event.event_properties = __assign(__assign({}, event.event_properties), sessionRecordingProperties);
|
|
88
|
+
if (!(this.config.sessionId && this.config.sessionId === event.session_id)) return [3 /*break*/, 4];
|
|
89
|
+
userProperties = void 0;
|
|
90
|
+
if (event.event_type === SpecialEventType.IDENTIFY) {
|
|
91
|
+
userProperties = parseUserProperties(event);
|
|
82
92
|
}
|
|
83
|
-
return [
|
|
93
|
+
return [4 /*yield*/, sessionReplay.evaluateTargetingAndCapture({ event: event, userProperties: userProperties })];
|
|
94
|
+
case 3:
|
|
95
|
+
_a.sent();
|
|
96
|
+
sessionRecordingProperties = sessionReplay.getSessionReplayProperties();
|
|
97
|
+
event.event_properties = __assign(__assign({}, event.event_properties), sessionRecordingProperties);
|
|
98
|
+
_a.label = 4;
|
|
99
|
+
case 4: return [2 /*return*/, Promise.resolve(event)];
|
|
84
100
|
}
|
|
85
101
|
});
|
|
86
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":";AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAA0C,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACtG,OAAO,KAAK,aAAa,MAAM,mCAAmC,CA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GC;;AAED,MAAM,CAAC,IAAM,mBAAmB,GAAyD,UACvF,OAA8B;IAE9B,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC,CAAC","sourcesContent":["import { getAnalyticsConnector } from '@amplitude/analytics-client-common';\nimport { BrowserConfig, EnrichmentPlugin, Event, SpecialEventType } from '@amplitude/analytics-types';\nimport * as sessionReplay from '@amplitude/session-replay-browser';\nimport { parseUserProperties } from './helpers';\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 const identityStore = getAnalyticsConnector(this.config.instanceName).identityStore;\n const userProperties = identityStore.getIdentity().userProperties;\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 userProperties: userProperties,\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 const identityStore = getAnalyticsConnector(this.config.instanceName).identityStore;\n const userProperties = identityStore.getIdentity().userProperties;\n await sessionReplay.setSessionId(this.config.sessionId, this.config.deviceId, {\n userProperties: userProperties || {},\n }).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 let userProperties;\n if (event.event_type === SpecialEventType.IDENTIFY) {\n userProperties = parseUserProperties(event);\n }\n await sessionReplay.evaluateTargetingAndCapture({ event, userProperties });\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.
|
|
1
|
+
export declare const VERSION = "1.7.0-srtargeting.1";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/lib/esm/version.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,wBAAwB,CAAC"}
|
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,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,CAAC,IAAM,OAAO,GAAG,qBAAqB,CAAC","sourcesContent":["// Autogenerated by `yarn version-file`. DO NOT EDIT\nexport const VERSION = '1.7.0-srtargeting.1';\n"]}
|