@amplitude/session-replay-browser 1.47.0-sr-trc-debug-log.4 → 1.47.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/README.md +203 -0
- package/lib/cjs/beacon-transport.d.ts +2 -0
- package/lib/cjs/beacon-transport.d.ts.map +1 -1
- package/lib/cjs/beacon-transport.js +39 -1
- package/lib/cjs/beacon-transport.js.map +1 -1
- package/lib/cjs/config/joined-config.d.ts +1 -6
- package/lib/cjs/config/joined-config.d.ts.map +1 -1
- package/lib/cjs/config/joined-config.js +23 -64
- package/lib/cjs/config/joined-config.js.map +1 -1
- package/lib/cjs/config/local-config.d.ts +4 -6
- package/lib/cjs/config/local-config.d.ts.map +1 -1
- package/lib/cjs/config/local-config.js +3 -19
- package/lib/cjs/config/local-config.js.map +1 -1
- package/lib/cjs/config/types.d.ts +74 -19
- package/lib/cjs/config/types.d.ts.map +1 -1
- package/lib/cjs/config/types.js.map +1 -1
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.d.ts.map +1 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/plugins/url-tracking-plugin.d.ts +0 -13
- package/lib/cjs/plugins/url-tracking-plugin.d.ts.map +1 -1
- package/lib/cjs/plugins/url-tracking-plugin.js +2 -6
- package/lib/cjs/plugins/url-tracking-plugin.js.map +1 -1
- package/lib/cjs/session-replay.d.ts +0 -33
- package/lib/cjs/session-replay.d.ts.map +1 -1
- package/lib/cjs/session-replay.js +40 -339
- package/lib/cjs/session-replay.js.map +1 -1
- package/lib/cjs/targeting/targeting-manager.d.ts +1 -4
- package/lib/cjs/targeting/targeting-manager.d.ts.map +1 -1
- package/lib/cjs/targeting/targeting-manager.js +10 -56
- package/lib/cjs/targeting/targeting-manager.js.map +1 -1
- package/lib/cjs/track-destination.d.ts +5 -1
- package/lib/cjs/track-destination.d.ts.map +1 -1
- package/lib/cjs/track-destination.js +212 -55
- package/lib/cjs/track-destination.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/cjs/worker/index.js +1 -1
- package/lib/esm/beacon-transport.d.ts +2 -0
- package/lib/esm/beacon-transport.d.ts.map +1 -1
- package/lib/esm/beacon-transport.js +39 -1
- package/lib/esm/beacon-transport.js.map +1 -1
- package/lib/esm/config/joined-config.d.ts +1 -6
- package/lib/esm/config/joined-config.d.ts.map +1 -1
- package/lib/esm/config/joined-config.js +23 -64
- package/lib/esm/config/joined-config.js.map +1 -1
- package/lib/esm/config/local-config.d.ts +4 -6
- package/lib/esm/config/local-config.d.ts.map +1 -1
- package/lib/esm/config/local-config.js +4 -20
- package/lib/esm/config/local-config.js.map +1 -1
- package/lib/esm/config/types.d.ts +74 -19
- package/lib/esm/config/types.d.ts.map +1 -1
- package/lib/esm/config/types.js.map +1 -1
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.d.ts.map +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/plugins/url-tracking-plugin.d.ts +0 -13
- package/lib/esm/plugins/url-tracking-plugin.d.ts.map +1 -1
- package/lib/esm/plugins/url-tracking-plugin.js +2 -6
- package/lib/esm/plugins/url-tracking-plugin.js.map +1 -1
- package/lib/esm/session-replay.d.ts +0 -33
- package/lib/esm/session-replay.d.ts.map +1 -1
- package/lib/esm/session-replay.js +40 -339
- package/lib/esm/session-replay.js.map +1 -1
- package/lib/esm/targeting/targeting-manager.d.ts +1 -4
- package/lib/esm/targeting/targeting-manager.d.ts.map +1 -1
- package/lib/esm/targeting/targeting-manager.js +10 -56
- package/lib/esm/targeting/targeting-manager.js.map +1 -1
- package/lib/esm/track-destination.d.ts +5 -1
- package/lib/esm/track-destination.d.ts.map +1 -1
- package/lib/esm/track-destination.js +212 -55
- package/lib/esm/track-destination.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/esm/worker/index.js +1 -1
- package/lib/scripts/index-min.js +1 -1
- package/lib/scripts/index-min.js.gz +0 -0
- package/lib/scripts/index-min.js.map +1 -1
- package/lib/scripts/observers-min.js +1 -1
- package/lib/scripts/observers-min.js.gz +0 -0
- package/lib/scripts/session-replay-browser-min.js +1 -1
- package/lib/scripts/session-replay-browser-min.js.gz +0 -0
- package/lib/scripts/session-replay-browser-min.js.map +1 -1
- package/lib/scripts/targeting-min.js +1 -1
- package/lib/scripts/targeting-min.js.gz +0 -0
- package/lib/scripts/worker-min.js +1 -1
- package/lib/scripts/worker-min.js.gz +0 -0
- package/package.json +4 -4
- package/lib/cjs/diagnostics.d.ts +0 -50
- package/lib/cjs/diagnostics.d.ts.map +0 -1
- package/lib/cjs/diagnostics.js +0 -67
- package/lib/cjs/diagnostics.js.map +0 -1
- package/lib/esm/diagnostics.d.ts +0 -50
- package/lib/esm/diagnostics.d.ts.map +0 -1
- package/lib/esm/diagnostics.js +0 -64
- package/lib/esm/diagnostics.js.map +0 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { __assign, __awaiter, __generator, __read, __spreadArray, __values } from "tslib";
|
|
2
2
|
import { RemoteConfigClient } from '@amplitude/analytics-core';
|
|
3
3
|
import { getDebugConfig } from '../helpers';
|
|
4
|
-
import { SrDiagnostic } from '../diagnostics';
|
|
5
4
|
import { SessionReplayLocalConfig } from './local-config';
|
|
6
5
|
// Budget for waiting on the remote config response before falling back to the local cache.
|
|
7
6
|
// The inner fetch in analytics-core uses a 1000ms per-attempt AbortController timeout with
|
|
@@ -42,20 +41,18 @@ export var removeInvalidSelectorsFromPrivacyConfig = function (privacyConfig, lo
|
|
|
42
41
|
return privacyConfig;
|
|
43
42
|
};
|
|
44
43
|
var SessionReplayJoinedConfigGenerator = /** @class */ (function () {
|
|
45
|
-
function SessionReplayJoinedConfigGenerator(remoteConfigClient, localConfig
|
|
44
|
+
function SessionReplayJoinedConfigGenerator(remoteConfigClient, localConfig) {
|
|
46
45
|
this.localConfig = localConfig;
|
|
47
46
|
this.remoteConfigClient = remoteConfigClient;
|
|
48
|
-
this.sessionId = identity === null || identity === void 0 ? void 0 : identity.sessionId;
|
|
49
|
-
this.deviceId = identity === null || identity === void 0 ? void 0 : identity.deviceId;
|
|
50
47
|
}
|
|
51
48
|
SessionReplayJoinedConfigGenerator.prototype.generateJoinedConfig = function () {
|
|
52
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
49
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
53
50
|
return __awaiter(this, void 0, void 0, function () {
|
|
54
|
-
var config, sessionReplayRemoteConfig, error_1, samplingConfig, remotePrivacyConfig, targetingConfig, localPrivacyConfig, joinedPrivacyConfig, privacyConfigSelectorMap, selectorMap,
|
|
55
|
-
var e_1,
|
|
51
|
+
var config, sessionReplayRemoteConfig, error_1, samplingConfig, remotePrivacyConfig, targetingConfig, localPrivacyConfig, joinedPrivacyConfig, privacyConfigSelectorMap, selectorMap, _h, _j, _k, selector, selectorType;
|
|
52
|
+
var e_1, _l;
|
|
56
53
|
var _this = this;
|
|
57
|
-
return __generator(this, function (
|
|
58
|
-
switch (
|
|
54
|
+
return __generator(this, function (_m) {
|
|
55
|
+
switch (_m.label) {
|
|
59
56
|
case 0:
|
|
60
57
|
config = __assign({}, this.localConfig);
|
|
61
58
|
// Special case here as optOut is implemented via getter/setter
|
|
@@ -63,16 +60,16 @@ var SessionReplayJoinedConfigGenerator = /** @class */ (function () {
|
|
|
63
60
|
// We always want captureEnabled to be true, unless there's an override
|
|
64
61
|
// in the remote config.
|
|
65
62
|
config.captureEnabled = true;
|
|
66
|
-
|
|
63
|
+
_m.label = 1;
|
|
67
64
|
case 1:
|
|
68
|
-
|
|
65
|
+
_m.trys.push([1, 3, , 4]);
|
|
69
66
|
// Subscribe with a timeout so the SDK prefers the remote response and only falls back
|
|
70
67
|
// to cache after the budget elapses. 'all' mode would race a synchronous cache read
|
|
71
68
|
// against the network and resolve on whichever fires first — cache always wins, so a
|
|
72
69
|
// stale cache silently overrides the live config (SR-4234).
|
|
73
70
|
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
74
71
|
_this.remoteConfigClient.subscribe('configs.sessionReplay', { timeout: REMOTE_CONFIG_TIMEOUT_MS }, function (remoteConfig, source) {
|
|
75
|
-
var _a
|
|
72
|
+
var _a;
|
|
76
73
|
_this.localConfig.loggerProvider.debug("Session Replay remote configuration received from ".concat(source, ":"), JSON.stringify(remoteConfig, null, 2));
|
|
77
74
|
if (!remoteConfig) {
|
|
78
75
|
reject(new Error('No remote config received'));
|
|
@@ -83,10 +80,6 @@ var SessionReplayJoinedConfigGenerator = /** @class */ (function () {
|
|
|
83
80
|
var samplingConfig = namespaceConfig.sr_sampling_config;
|
|
84
81
|
var privacyConfig = namespaceConfig.sr_privacy_config;
|
|
85
82
|
var targetingConfig = namespaceConfig.sr_targeting_config;
|
|
86
|
-
// Captured for the sr.trc.config.received diagnostics event below (remote vs cache is
|
|
87
|
-
// the crux of SR-4234 stale-cache reports).
|
|
88
|
-
var samplingForLog = samplingConfig;
|
|
89
|
-
var targetingSegments = targetingConfig === null || targetingConfig === void 0 ? void 0 : targetingConfig.segments;
|
|
90
83
|
var ugcFilterRules = (_a = config.interactionConfig) === null || _a === void 0 ? void 0 : _a.ugcFilterRules;
|
|
91
84
|
// This is intentionally forced to only be set through the remote config.
|
|
92
85
|
config.interactionConfig = namespaceConfig.sr_interaction_config;
|
|
@@ -95,33 +88,6 @@ var SessionReplayJoinedConfigGenerator = /** @class */ (function () {
|
|
|
95
88
|
}
|
|
96
89
|
// This is intentionally forced to only be set through the remote config.
|
|
97
90
|
config.loggingConfig = namespaceConfig.sr_logging_config;
|
|
98
|
-
// Team-visible diagnostics: which SOURCE the config came from (remote vs cache — the
|
|
99
|
-
// crux of SR-4234) and whether targeting was present. Counters aggregate across the
|
|
100
|
-
// customer's sessions; the event carries the full context (source, sample rate,
|
|
101
|
-
// segment count) as queryable log fields. No-op when diagnostics isn't configured.
|
|
102
|
-
try {
|
|
103
|
-
var diagnosticsClient = _this.localConfig.diagnosticsClient;
|
|
104
|
-
diagnosticsClient === null || diagnosticsClient === void 0 ? void 0 : diagnosticsClient.increment(SrDiagnostic.configSource(String(source)));
|
|
105
|
-
diagnosticsClient === null || diagnosticsClient === void 0 ? void 0 : diagnosticsClient.increment(targetingConfig ? SrDiagnostic.configHasTargeting : SrDiagnostic.configNoTargeting);
|
|
106
|
-
diagnosticsClient === null || diagnosticsClient === void 0 ? void 0 : diagnosticsClient.recordEvent(SrDiagnostic.configReceived, {
|
|
107
|
-
sessionId: _this.sessionId,
|
|
108
|
-
deviceId: _this.deviceId,
|
|
109
|
-
srId: _this.deviceId != null && _this.sessionId != null ? "".concat(_this.deviceId, "/").concat(_this.sessionId) : undefined,
|
|
110
|
-
source: String(source),
|
|
111
|
-
hasSampling: !!samplingConfig,
|
|
112
|
-
captureEnabled: samplingForLog === null || samplingForLog === void 0 ? void 0 : samplingForLog.capture_enabled,
|
|
113
|
-
sampleRate: samplingForLog === null || samplingForLog === void 0 ? void 0 : samplingForLog.sample_rate,
|
|
114
|
-
hasTargeting: !!targetingConfig,
|
|
115
|
-
targetingSegmentCount: Array.isArray(targetingSegments) ? targetingSegments.length : undefined,
|
|
116
|
-
hasPrivacy: !!privacyConfig,
|
|
117
|
-
});
|
|
118
|
-
// Flush now (vs the client's ~5-min timer). One capture POST per event — higher
|
|
119
|
-
// volume; revisit/gate before production.
|
|
120
|
-
void ((_b = diagnosticsClient === null || diagnosticsClient === void 0 ? void 0 : diagnosticsClient._flush) === null || _b === void 0 ? void 0 : _b.call(diagnosticsClient));
|
|
121
|
-
}
|
|
122
|
-
catch (_c) {
|
|
123
|
-
// diagnostics is best-effort
|
|
124
|
-
}
|
|
125
91
|
if (samplingConfig || privacyConfig || targetingConfig) {
|
|
126
92
|
sessionReplayRemoteConfig = {};
|
|
127
93
|
if (samplingConfig) {
|
|
@@ -142,18 +108,11 @@ var SessionReplayJoinedConfigGenerator = /** @class */ (function () {
|
|
|
142
108
|
// to cache after the budget elapses. 'all' mode would race a synchronous cache read
|
|
143
109
|
// against the network and resolve on whichever fires first — cache always wins, so a
|
|
144
110
|
// stale cache silently overrides the live config (SR-4234).
|
|
145
|
-
|
|
111
|
+
_m.sent();
|
|
146
112
|
return [3 /*break*/, 4];
|
|
147
113
|
case 3:
|
|
148
|
-
error_1 =
|
|
114
|
+
error_1 = _m.sent();
|
|
149
115
|
this.localConfig.loggerProvider.error('Failed to generate joined config: ', error_1);
|
|
150
|
-
try {
|
|
151
|
-
(_a = this.localConfig.diagnosticsClient) === null || _a === void 0 ? void 0 : _a.increment(SrDiagnostic.configFetchFailed);
|
|
152
|
-
void ((_c = (_b = this.localConfig.diagnosticsClient) === null || _b === void 0 ? void 0 : _b._flush) === null || _c === void 0 ? void 0 : _c.call(_b));
|
|
153
|
-
}
|
|
154
|
-
catch (_r) {
|
|
155
|
-
// diagnostics is best-effort
|
|
156
|
-
}
|
|
157
116
|
config.captureEnabled = false;
|
|
158
117
|
return [2 /*return*/, {
|
|
159
118
|
localConfig: this.localConfig,
|
|
@@ -204,14 +163,14 @@ var SessionReplayJoinedConfigGenerator = /** @class */ (function () {
|
|
|
204
163
|
// ...remotePrivacyConfig,
|
|
205
164
|
// };
|
|
206
165
|
if (remotePrivacyConfig) {
|
|
207
|
-
localPrivacyConfig = (
|
|
166
|
+
localPrivacyConfig = (_a = config.privacyConfig) !== null && _a !== void 0 ? _a : {};
|
|
208
167
|
joinedPrivacyConfig = {
|
|
209
|
-
defaultMaskLevel: (
|
|
168
|
+
defaultMaskLevel: (_c = (_b = remotePrivacyConfig.defaultMaskLevel) !== null && _b !== void 0 ? _b : localPrivacyConfig.defaultMaskLevel) !== null && _c !== void 0 ? _c : 'medium',
|
|
210
169
|
blockSelector: [],
|
|
211
170
|
maskSelector: [],
|
|
212
171
|
unmaskSelector: [],
|
|
213
|
-
maskAttributes: __spreadArray([], __read(new Set(__spreadArray(__spreadArray([], __read(((
|
|
214
|
-
urlMaskLevels: __spreadArray(__spreadArray([], __read(((
|
|
172
|
+
maskAttributes: __spreadArray([], __read(new Set(__spreadArray(__spreadArray([], __read(((_d = localPrivacyConfig.maskAttributes) !== null && _d !== void 0 ? _d : [])), false), __read(((_e = remotePrivacyConfig.maskAttributes) !== null && _e !== void 0 ? _e : [])), false))), false),
|
|
173
|
+
urlMaskLevels: __spreadArray(__spreadArray([], __read(((_f = remotePrivacyConfig.urlMaskLevels) !== null && _f !== void 0 ? _f : [])), false), __read(((_g = localPrivacyConfig.urlMaskLevels) !== null && _g !== void 0 ? _g : [])), false),
|
|
215
174
|
};
|
|
216
175
|
privacyConfigSelectorMap = function (privacyConfig) {
|
|
217
176
|
var e_2, _a, e_3, _b, e_4, _c;
|
|
@@ -263,8 +222,8 @@ var SessionReplayJoinedConfigGenerator = /** @class */ (function () {
|
|
|
263
222
|
};
|
|
264
223
|
selectorMap = __assign(__assign({}, privacyConfigSelectorMap(localPrivacyConfig)), privacyConfigSelectorMap(remotePrivacyConfig));
|
|
265
224
|
try {
|
|
266
|
-
for (
|
|
267
|
-
|
|
225
|
+
for (_h = __values(Object.entries(selectorMap)), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
226
|
+
_k = __read(_j.value, 2), selector = _k[0], selectorType = _k[1];
|
|
268
227
|
if (selectorType === 'mask') {
|
|
269
228
|
joinedPrivacyConfig.maskSelector.push(selector);
|
|
270
229
|
}
|
|
@@ -279,7 +238,7 @@ var SessionReplayJoinedConfigGenerator = /** @class */ (function () {
|
|
|
279
238
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
280
239
|
finally {
|
|
281
240
|
try {
|
|
282
|
-
if (
|
|
241
|
+
if (_j && !_j.done && (_l = _h.return)) _l.call(_h);
|
|
283
242
|
}
|
|
284
243
|
finally { if (e_1) throw e_1.error; }
|
|
285
244
|
}
|
|
@@ -334,11 +293,11 @@ export var createSessionReplayJoinedConfigGenerator = function (apiKey, options)
|
|
|
334
293
|
var localConfig, remoteConfigClient;
|
|
335
294
|
return __generator(this, function (_a) {
|
|
336
295
|
localConfig = new SessionReplayLocalConfig(apiKey, options);
|
|
337
|
-
remoteConfigClient = new RemoteConfigClient(apiKey, localConfig.loggerProvider, localConfig.serverZone, options.configServerUrl
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
296
|
+
remoteConfigClient = new RemoteConfigClient(apiKey, localConfig.loggerProvider, localConfig.serverZone, options.configServerUrl,
|
|
297
|
+
// Custom transport for the config GET. SR's FetchConfigRequest is structurally compatible
|
|
298
|
+
// with RemoteConfigFetchRequest, so the customer's handleFetchConfig drops straight in.
|
|
299
|
+
options.handleFetchConfig);
|
|
300
|
+
return [2 /*return*/, new SessionReplayJoinedConfigGenerator(remoteConfigClient, localConfig)];
|
|
342
301
|
});
|
|
343
302
|
}); };
|
|
344
303
|
//# sourceMappingURL=joined-config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"joined-config.js","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":";AAAA,OAAO,EAAgC,kBAAkB,EAAwB,MAAM,2BAA2B,CAAC;AACnH,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAS1D,2FAA2F;AAC3F,2FAA2F;AAC3F,wFAAwF;AACxF,yFAAyF;AACzF,yFAAyF;AACzF,sFAAsF;AACtF,yFAAyF;AACzF,kFAAkF;AAClF,oDAAoD;AACpD,IAAM,wBAAwB,GAAG,IAAI,CAAC;AAEtC,MAAM,CAAC,IAAM,uCAAuC,GAAG,UAAC,aAA4B,EAAE,cAAuB;IAC3G,wCAAwC;IACxC,IAAM,QAAQ,GAAG,QAAQ,CAAC,sBAAsB,EAA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AAU,EACtB,OAAO,CAAC,eAAe,CACxB,CAAC;QAEF,sBAAO,IAAI,kCAAkC,CAAC,kBAAkB,EAAE,WAAW,EAAE;gBAC7E,SAAS,EAAE,OAAO,CAAC,SAAS;gBAC5B,QAAQ,EAAE,OAAO,CAAC,QAAQ;aAC3B,CAAC,EAAC;;KACJ,CAAC","sourcesContent":["import { ILogger, IRemoteConfigClient, RemoteConfigClient, RemoteConfig, Source } from '@amplitude/analytics-core';\nimport { getDebugConfig } from '../helpers';\nimport { SrDiagnostic } from '../diagnostics';\nimport { SessionReplayOptions } from '../typings/session-replay';\nimport { SessionReplayLocalConfig } from './local-config';\nimport {\n SessionReplayLocalConfig as ISessionReplayLocalConfig,\n PrivacyConfig,\n SessionReplayConfigs,\n SessionReplayJoinedConfig,\n SessionReplayRemoteConfig,\n} from './types';\n\n// Budget for waiting on the remote config response before falling back to the local cache.\n// The inner fetch in analytics-core uses a 1000ms per-attempt AbortController timeout with\n// up to 3 retries — but this outer timeout is the only thing the SR plugin waits on, so\n// only the first attempt can possibly complete in time (attempt 2 starts at ~1000-1333ms\n// after backoff jitter and runs to ~2000-2333ms, well past any reasonable outer budget).\n// 1500ms is set above the 1000ms inner abort to avoid a tie with the inner cutoff and\n// give the first attempt's resolution path room to finish; everything else falls through\n// to the cache fallback. See SR-4234: prefer remote over a stale cache that would\n// otherwise win the synchronous race in 'all' mode.\nconst REMOTE_CONFIG_TIMEOUT_MS = 1500;\n\nexport const removeInvalidSelectorsFromPrivacyConfig = (privacyConfig: PrivacyConfig, loggerProvider: ILogger) => {\n // This allows us to not search the DOM.\n const fragment = document.createDocumentFragment();\n\n const dropInvalidSelectors = (selectors: string[] | string = []): string[] | undefined => {\n if (typeof selectors === 'string') {\n selectors = [selectors];\n }\n selectors = selectors.filter((selector: string) => {\n try {\n fragment.querySelector(selector);\n } catch {\n loggerProvider.warn(`[session-replay-browser] omitting selector \"${selector}\" because it is invalid`);\n return false;\n }\n return true;\n });\n if (selectors.length === 0) {\n return undefined;\n }\n return selectors;\n };\n privacyConfig.blockSelector = dropInvalidSelectors(privacyConfig.blockSelector);\n privacyConfig.maskSelector = dropInvalidSelectors(privacyConfig.maskSelector);\n privacyConfig.unmaskSelector = dropInvalidSelectors(privacyConfig.unmaskSelector);\n return privacyConfig;\n};\nexport class SessionReplayJoinedConfigGenerator {\n private readonly localConfig: ISessionReplayLocalConfig;\n private readonly remoteConfigClient: IRemoteConfigClient;\n // Identity for diagnostics correlation (config fetch is per-session). Sourced from init options.\n private readonly sessionId?: string | number;\n private readonly deviceId?: string;\n\n constructor(\n remoteConfigClient: IRemoteConfigClient,\n localConfig: ISessionReplayLocalConfig,\n identity?: { sessionId?: string | number; deviceId?: string },\n ) {\n this.localConfig = localConfig;\n this.remoteConfigClient = remoteConfigClient;\n this.sessionId = identity?.sessionId;\n this.deviceId = identity?.deviceId;\n }\n\n async generateJoinedConfig(): Promise<SessionReplayConfigs> {\n const config: SessionReplayJoinedConfig = { ...this.localConfig };\n // Special case here as optOut is implemented via getter/setter\n config.optOut = this.localConfig.optOut;\n // We always want captureEnabled to be true, unless there's an override\n // in the remote config.\n config.captureEnabled = true;\n let sessionReplayRemoteConfig: SessionReplayRemoteConfig | undefined;\n\n try {\n // Subscribe with a timeout so the SDK prefers the remote response and only falls back\n // to cache after the budget elapses. 'all' mode would race a synchronous cache read\n // against the network and resolve on whichever fires first — cache always wins, so a\n // stale cache silently overrides the live config (SR-4234).\n await new Promise<void>((resolve, reject) => {\n this.remoteConfigClient.subscribe(\n 'configs.sessionReplay',\n { timeout: REMOTE_CONFIG_TIMEOUT_MS },\n (remoteConfig: RemoteConfig | null, source: Source) => {\n this.localConfig.loggerProvider.debug(\n `Session Replay remote configuration received from ${source}:`,\n JSON.stringify(remoteConfig, null, 2),\n );\n\n if (!remoteConfig) {\n reject(new Error('No remote config received'));\n return;\n }\n\n // remoteConfig is already filtered to 'configs.sessionReplay' namespace\n const namespaceConfig = remoteConfig as SessionReplayRemoteConfig;\n const samplingConfig = namespaceConfig.sr_sampling_config;\n const privacyConfig = namespaceConfig.sr_privacy_config;\n const targetingConfig = namespaceConfig.sr_targeting_config;\n\n // Captured for the sr.trc.config.received diagnostics event below (remote vs cache is\n // the crux of SR-4234 stale-cache reports).\n const samplingForLog = samplingConfig as { capture_enabled?: boolean; sample_rate?: number } | undefined;\n const targetingSegments = (targetingConfig as unknown as { segments?: unknown[] } | undefined)?.segments;\n\n const ugcFilterRules = config.interactionConfig?.ugcFilterRules;\n // This is intentionally forced to only be set through the remote config.\n config.interactionConfig = namespaceConfig.sr_interaction_config;\n if (config.interactionConfig && ugcFilterRules) {\n config.interactionConfig.ugcFilterRules = ugcFilterRules;\n }\n\n // This is intentionally forced to only be set through the remote config.\n config.loggingConfig = namespaceConfig.sr_logging_config;\n\n // Team-visible diagnostics: which SOURCE the config came from (remote vs cache — the\n // crux of SR-4234) and whether targeting was present. Counters aggregate across the\n // customer's sessions; the event carries the full context (source, sample rate,\n // segment count) as queryable log fields. No-op when diagnostics isn't configured.\n try {\n const diagnosticsClient = this.localConfig.diagnosticsClient;\n diagnosticsClient?.increment(SrDiagnostic.configSource(String(source)));\n diagnosticsClient?.increment(\n targetingConfig ? SrDiagnostic.configHasTargeting : SrDiagnostic.configNoTargeting,\n );\n diagnosticsClient?.recordEvent(SrDiagnostic.configReceived, {\n sessionId: this.sessionId,\n deviceId: this.deviceId,\n srId:\n this.deviceId != null && this.sessionId != null ? `${this.deviceId}/${this.sessionId}` : undefined,\n source: String(source),\n hasSampling: !!samplingConfig,\n captureEnabled: samplingForLog?.capture_enabled,\n sampleRate: samplingForLog?.sample_rate,\n hasTargeting: !!targetingConfig,\n targetingSegmentCount: Array.isArray(targetingSegments) ? targetingSegments.length : undefined,\n hasPrivacy: !!privacyConfig,\n });\n // Flush now (vs the client's ~5-min timer). One capture POST per event — higher\n // volume; revisit/gate before production.\n void diagnosticsClient?._flush?.();\n } catch {\n // diagnostics is best-effort\n }\n\n if (samplingConfig || privacyConfig || targetingConfig) {\n sessionReplayRemoteConfig = {};\n if (samplingConfig) {\n sessionReplayRemoteConfig.sr_sampling_config = samplingConfig;\n }\n if (privacyConfig) {\n sessionReplayRemoteConfig.sr_privacy_config = privacyConfig;\n }\n if (targetingConfig) {\n sessionReplayRemoteConfig.sr_targeting_config = targetingConfig;\n }\n }\n\n resolve();\n },\n );\n });\n } catch (error) {\n this.localConfig.loggerProvider.error('Failed to generate joined config: ', error);\n try {\n this.localConfig.diagnosticsClient?.increment(SrDiagnostic.configFetchFailed);\n void this.localConfig.diagnosticsClient?._flush?.();\n } catch {\n // diagnostics is best-effort\n }\n config.captureEnabled = false;\n return {\n localConfig: this.localConfig,\n joinedConfig: config,\n remoteConfig: undefined,\n };\n }\n\n if (!sessionReplayRemoteConfig) {\n return {\n localConfig: this.localConfig,\n joinedConfig: config,\n remoteConfig: sessionReplayRemoteConfig,\n };\n }\n\n const {\n sr_sampling_config: samplingConfig,\n sr_privacy_config: remotePrivacyConfig,\n sr_targeting_config: targetingConfig,\n } = sessionReplayRemoteConfig;\n if (samplingConfig && Object.keys(samplingConfig).length > 0) {\n if (Object.prototype.hasOwnProperty.call(samplingConfig, 'capture_enabled')) {\n config.captureEnabled = samplingConfig.capture_enabled;\n } else {\n config.captureEnabled = false;\n }\n\n if (Object.prototype.hasOwnProperty.call(samplingConfig, 'sample_rate')) {\n config.sampleRate = samplingConfig.sample_rate;\n }\n\n if (Object.prototype.hasOwnProperty.call(samplingConfig, 'min_session_duration_ms')) {\n config.minSessionDurationMs = this.sanitizeMinSessionDurationMs(samplingConfig.min_session_duration_ms);\n }\n } else {\n // If config API response was valid (ie 200), but no config returned, assume that\n // customer has not yet set up config, and use sample rate from SDK options,\n // allowing for immediate replay capture\n config.captureEnabled = true;\n this.localConfig.loggerProvider.debug(\n 'Remote config successfully fetched, but no values set for project, Session Replay capture enabled.',\n );\n }\n\n // Remote config join acts somewhat like a left join between the remote and the local\n // config. That is, remote config has precedence over local values as with sampling.\n // However, non conflicting values will be added to the lists.\n // Here's an example to illustrate:\n //\n // Remote config: {'.selector1': 'MASK', '.selector2': 'UNMASK'}\n // Local config: {'.selector1': 'UNMASK', '.selector3': 'MASK'}\n //\n // Resolved config: {'.selector1': 'MASK', '.selector2': 'UNMASK', '.selector3': 'MASK'}\n // config.privacyConfig = {\n // ...(config.privacyConfig ?? {}),\n // ...remotePrivacyConfig,\n // };\n\n if (remotePrivacyConfig) {\n const localPrivacyConfig: PrivacyConfig = config.privacyConfig ?? {};\n\n const joinedPrivacyConfig: Required<PrivacyConfig> & { blockSelector: string[] } = {\n defaultMaskLevel: remotePrivacyConfig.defaultMaskLevel ?? localPrivacyConfig.defaultMaskLevel ?? 'medium',\n blockSelector: [],\n maskSelector: [],\n unmaskSelector: [],\n maskAttributes: [\n ...new Set([...(localPrivacyConfig.maskAttributes ?? []), ...(remotePrivacyConfig.maskAttributes ?? [])]),\n ],\n urlMaskLevels: [...(remotePrivacyConfig.urlMaskLevels ?? []), ...(localPrivacyConfig.urlMaskLevels ?? [])],\n };\n\n const privacyConfigSelectorMap = (privacyConfig: PrivacyConfig): Record<string, 'mask' | 'unmask' | 'block'> => {\n const selectorMap: Record<string, 'mask' | 'unmask' | 'block'> = {};\n if (typeof privacyConfig.blockSelector === 'string') {\n privacyConfig.blockSelector = [privacyConfig.blockSelector];\n }\n\n for (const selector of privacyConfig.blockSelector ?? []) {\n selectorMap[selector] = 'block';\n }\n for (const selector of privacyConfig.maskSelector ?? []) {\n selectorMap[selector] = 'mask';\n }\n for (const selector of privacyConfig.unmaskSelector ?? []) {\n selectorMap[selector] = 'unmask';\n }\n return selectorMap;\n };\n\n const selectorMap: Record<string, 'mask' | 'unmask' | 'block'> = {\n ...privacyConfigSelectorMap(localPrivacyConfig),\n ...privacyConfigSelectorMap(remotePrivacyConfig),\n };\n\n for (const [selector, selectorType] of Object.entries(selectorMap)) {\n if (selectorType === 'mask') {\n joinedPrivacyConfig.maskSelector.push(selector);\n } else if (selectorType === 'block') {\n joinedPrivacyConfig.blockSelector.push(selector);\n } else if (selectorType === 'unmask') {\n joinedPrivacyConfig.unmaskSelector.push(selector);\n }\n }\n\n config.privacyConfig = removeInvalidSelectorsFromPrivacyConfig(\n joinedPrivacyConfig,\n this.localConfig.loggerProvider,\n );\n }\n\n if (targetingConfig && Object.keys(targetingConfig).length > 0) {\n config.targetingConfig = targetingConfig;\n }\n\n this.localConfig.loggerProvider.debug(\n JSON.stringify({ name: 'session replay joined config', config: getDebugConfig(config) }, null, 2),\n );\n\n return {\n localConfig: this.localConfig,\n joinedConfig: config,\n remoteConfig: sessionReplayRemoteConfig,\n };\n }\n\n /**\n * Defensive bounds for the remote-supplied min_session_duration_ms. A misconfigured\n * value (e.g. 30_000_000) would silently suppress every replay until the config is\n * pushed again, so we clamp to a sane ceiling and warn on out-of-range inputs.\n * Returns undefined for clearly invalid values so the gate falls back to disabled\n * rather than carrying a NaN through downstream comparisons.\n */\n private sanitizeMinSessionDurationMs(raw: unknown): number | undefined {\n if (typeof raw !== 'number' || !Number.isFinite(raw)) {\n this.localConfig.loggerProvider.warn(\n `min_session_duration_ms remote value is not a finite number (got ${String(raw)}); ignoring.`,\n );\n return undefined;\n }\n if (raw < 0) {\n this.localConfig.loggerProvider.warn(`min_session_duration_ms remote value is negative (${raw}); ignoring.`);\n return undefined;\n }\n if (raw > MAX_MIN_SESSION_DURATION_MS) {\n this.localConfig.loggerProvider.warn(\n `min_session_duration_ms remote value ${raw} exceeds ${MAX_MIN_SESSION_DURATION_MS}ms ceiling; clamping.`,\n );\n return MAX_MIN_SESSION_DURATION_MS;\n }\n return raw;\n }\n}\n\n/**\n * Upper bound for the remote-configured replay min duration. 60 seconds is well above\n * any reasonable bounce threshold; values higher than this are almost certainly typos\n * (e.g. seconds confused for milliseconds, or an extra zero) and would otherwise\n * suppress every replay until the config is corrected.\n */\nexport const MAX_MIN_SESSION_DURATION_MS = 60_000;\n\nexport const createSessionReplayJoinedConfigGenerator = async (apiKey: string, options: SessionReplayOptions) => {\n const localConfig = new SessionReplayLocalConfig(apiKey, options);\n\n const remoteConfigClient = new RemoteConfigClient(\n apiKey,\n localConfig.loggerProvider,\n localConfig.serverZone,\n options.configServerUrl,\n );\n\n return new SessionReplayJoinedConfigGenerator(remoteConfigClient, localConfig, {\n sessionId: options.sessionId,\n deviceId: options.deviceId,\n });\n};\n"]}
|
|
1
|
+
{"version":3,"file":"joined-config.js","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":";AAAA,OAAO,EAAgC,kBAAkB,EAAwB,MAAM,2BAA2B,CAAC;AACnH,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAS1D,2FAA2F;AAC3F,2FAA2F;AAC3F,wFAAwF;AACxF,yFAAyF;AACzF,yFAAyF;AACzF,sFAAsF;AACtF,yFAAyF;AACzF,kFAAkF;AAClF,oDAAoD;AACpD,IAAM,wBAAwB,GAAG,IAAI,CAAC;AAEtC,MAAM,CAAC,IAAM,uCAAuC,GAAG,UAAC,aAA4B,EAAE,cAAuB;IAC3G,wCAAwC;IACxC,IAAM,QAAQ,GAAG,QAAQ,CAAC,sBAAsB,EAAE,CAAC;IAEnD,IAAM,oBAAoB,GAAG,UAAC,SAAiC;QAAjC,0BAAA,EAAA,cAAiC;QAC7D,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;YACjC,SAAS,GAAG,CAAC,SAAS,CAAC,CAAC;SACzB;QACD,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,UAAC,QAAgB;YAC5C,IAAI;gBACF,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;aAClC;YAAC,WAAM;gBACN,cAAc,CAAC,IAAI,CAAC,uDAA+C,QAAQ,6BAAyB,CAAC,CAAC;gBACtG,OAAO,KAAK,CAAC;aACd;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;QACH,IAAI,SAAS,CAAC,MAAM,KAA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,WAAW,CAAC,UAAU,EACtB,OAAO,CAAC,eAAe;QACvB,0FAA0F;QAC1F,wFAAwF;QACxF,OAAO,CAAC,iBAAiB,CAC1B,CAAC;QAEF,sBAAO,IAAI,kCAAkC,CAAC,kBAAkB,EAAE,WAAW,CAAC,EAAC;;KAChF,CAAC","sourcesContent":["import { ILogger, IRemoteConfigClient, RemoteConfigClient, RemoteConfig, Source } from '@amplitude/analytics-core';\nimport { getDebugConfig } from '../helpers';\nimport { SessionReplayOptions } from '../typings/session-replay';\nimport { SessionReplayLocalConfig } from './local-config';\nimport {\n SessionReplayLocalConfig as ISessionReplayLocalConfig,\n PrivacyConfig,\n SessionReplayConfigs,\n SessionReplayJoinedConfig,\n SessionReplayRemoteConfig,\n} from './types';\n\n// Budget for waiting on the remote config response before falling back to the local cache.\n// The inner fetch in analytics-core uses a 1000ms per-attempt AbortController timeout with\n// up to 3 retries — but this outer timeout is the only thing the SR plugin waits on, so\n// only the first attempt can possibly complete in time (attempt 2 starts at ~1000-1333ms\n// after backoff jitter and runs to ~2000-2333ms, well past any reasonable outer budget).\n// 1500ms is set above the 1000ms inner abort to avoid a tie with the inner cutoff and\n// give the first attempt's resolution path room to finish; everything else falls through\n// to the cache fallback. See SR-4234: prefer remote over a stale cache that would\n// otherwise win the synchronous race in 'all' mode.\nconst REMOTE_CONFIG_TIMEOUT_MS = 1500;\n\nexport const removeInvalidSelectorsFromPrivacyConfig = (privacyConfig: PrivacyConfig, loggerProvider: ILogger) => {\n // This allows us to not search the DOM.\n const fragment = document.createDocumentFragment();\n\n const dropInvalidSelectors = (selectors: string[] | string = []): string[] | undefined => {\n if (typeof selectors === 'string') {\n selectors = [selectors];\n }\n selectors = selectors.filter((selector: string) => {\n try {\n fragment.querySelector(selector);\n } catch {\n loggerProvider.warn(`[session-replay-browser] omitting selector \"${selector}\" because it is invalid`);\n return false;\n }\n return true;\n });\n if (selectors.length === 0) {\n return undefined;\n }\n return selectors;\n };\n privacyConfig.blockSelector = dropInvalidSelectors(privacyConfig.blockSelector);\n privacyConfig.maskSelector = dropInvalidSelectors(privacyConfig.maskSelector);\n privacyConfig.unmaskSelector = dropInvalidSelectors(privacyConfig.unmaskSelector);\n return privacyConfig;\n};\nexport class SessionReplayJoinedConfigGenerator {\n private readonly localConfig: ISessionReplayLocalConfig;\n private readonly remoteConfigClient: IRemoteConfigClient;\n\n constructor(remoteConfigClient: IRemoteConfigClient, localConfig: ISessionReplayLocalConfig) {\n this.localConfig = localConfig;\n this.remoteConfigClient = remoteConfigClient;\n }\n\n async generateJoinedConfig(): Promise<SessionReplayConfigs> {\n const config: SessionReplayJoinedConfig = { ...this.localConfig };\n // Special case here as optOut is implemented via getter/setter\n config.optOut = this.localConfig.optOut;\n // We always want captureEnabled to be true, unless there's an override\n // in the remote config.\n config.captureEnabled = true;\n let sessionReplayRemoteConfig: SessionReplayRemoteConfig | undefined;\n\n try {\n // Subscribe with a timeout so the SDK prefers the remote response and only falls back\n // to cache after the budget elapses. 'all' mode would race a synchronous cache read\n // against the network and resolve on whichever fires first — cache always wins, so a\n // stale cache silently overrides the live config (SR-4234).\n await new Promise<void>((resolve, reject) => {\n this.remoteConfigClient.subscribe(\n 'configs.sessionReplay',\n { timeout: REMOTE_CONFIG_TIMEOUT_MS },\n (remoteConfig: RemoteConfig | null, source: Source) => {\n this.localConfig.loggerProvider.debug(\n `Session Replay remote configuration received from ${source}:`,\n JSON.stringify(remoteConfig, null, 2),\n );\n\n if (!remoteConfig) {\n reject(new Error('No remote config received'));\n return;\n }\n\n // remoteConfig is already filtered to 'configs.sessionReplay' namespace\n const namespaceConfig = remoteConfig as SessionReplayRemoteConfig;\n const samplingConfig = namespaceConfig.sr_sampling_config;\n const privacyConfig = namespaceConfig.sr_privacy_config;\n const targetingConfig = namespaceConfig.sr_targeting_config;\n\n const ugcFilterRules = config.interactionConfig?.ugcFilterRules;\n // This is intentionally forced to only be set through the remote config.\n config.interactionConfig = namespaceConfig.sr_interaction_config;\n if (config.interactionConfig && ugcFilterRules) {\n config.interactionConfig.ugcFilterRules = ugcFilterRules;\n }\n\n // This is intentionally forced to only be set through the remote config.\n config.loggingConfig = namespaceConfig.sr_logging_config;\n\n if (samplingConfig || privacyConfig || targetingConfig) {\n sessionReplayRemoteConfig = {};\n if (samplingConfig) {\n sessionReplayRemoteConfig.sr_sampling_config = samplingConfig;\n }\n if (privacyConfig) {\n sessionReplayRemoteConfig.sr_privacy_config = privacyConfig;\n }\n if (targetingConfig) {\n sessionReplayRemoteConfig.sr_targeting_config = targetingConfig;\n }\n }\n\n resolve();\n },\n );\n });\n } catch (error) {\n this.localConfig.loggerProvider.error('Failed to generate joined config: ', error);\n config.captureEnabled = false;\n return {\n localConfig: this.localConfig,\n joinedConfig: config,\n remoteConfig: undefined,\n };\n }\n\n if (!sessionReplayRemoteConfig) {\n return {\n localConfig: this.localConfig,\n joinedConfig: config,\n remoteConfig: sessionReplayRemoteConfig,\n };\n }\n\n const {\n sr_sampling_config: samplingConfig,\n sr_privacy_config: remotePrivacyConfig,\n sr_targeting_config: targetingConfig,\n } = sessionReplayRemoteConfig;\n if (samplingConfig && Object.keys(samplingConfig).length > 0) {\n if (Object.prototype.hasOwnProperty.call(samplingConfig, 'capture_enabled')) {\n config.captureEnabled = samplingConfig.capture_enabled;\n } else {\n config.captureEnabled = false;\n }\n\n if (Object.prototype.hasOwnProperty.call(samplingConfig, 'sample_rate')) {\n config.sampleRate = samplingConfig.sample_rate;\n }\n\n if (Object.prototype.hasOwnProperty.call(samplingConfig, 'min_session_duration_ms')) {\n config.minSessionDurationMs = this.sanitizeMinSessionDurationMs(samplingConfig.min_session_duration_ms);\n }\n } else {\n // If config API response was valid (ie 200), but no config returned, assume that\n // customer has not yet set up config, and use sample rate from SDK options,\n // allowing for immediate replay capture\n config.captureEnabled = true;\n this.localConfig.loggerProvider.debug(\n 'Remote config successfully fetched, but no values set for project, Session Replay capture enabled.',\n );\n }\n\n // Remote config join acts somewhat like a left join between the remote and the local\n // config. That is, remote config has precedence over local values as with sampling.\n // However, non conflicting values will be added to the lists.\n // Here's an example to illustrate:\n //\n // Remote config: {'.selector1': 'MASK', '.selector2': 'UNMASK'}\n // Local config: {'.selector1': 'UNMASK', '.selector3': 'MASK'}\n //\n // Resolved config: {'.selector1': 'MASK', '.selector2': 'UNMASK', '.selector3': 'MASK'}\n // config.privacyConfig = {\n // ...(config.privacyConfig ?? {}),\n // ...remotePrivacyConfig,\n // };\n\n if (remotePrivacyConfig) {\n const localPrivacyConfig: PrivacyConfig = config.privacyConfig ?? {};\n\n const joinedPrivacyConfig: Required<PrivacyConfig> & { blockSelector: string[] } = {\n defaultMaskLevel: remotePrivacyConfig.defaultMaskLevel ?? localPrivacyConfig.defaultMaskLevel ?? 'medium',\n blockSelector: [],\n maskSelector: [],\n unmaskSelector: [],\n maskAttributes: [\n ...new Set([...(localPrivacyConfig.maskAttributes ?? []), ...(remotePrivacyConfig.maskAttributes ?? [])]),\n ],\n urlMaskLevels: [...(remotePrivacyConfig.urlMaskLevels ?? []), ...(localPrivacyConfig.urlMaskLevels ?? [])],\n };\n\n const privacyConfigSelectorMap = (privacyConfig: PrivacyConfig): Record<string, 'mask' | 'unmask' | 'block'> => {\n const selectorMap: Record<string, 'mask' | 'unmask' | 'block'> = {};\n if (typeof privacyConfig.blockSelector === 'string') {\n privacyConfig.blockSelector = [privacyConfig.blockSelector];\n }\n\n for (const selector of privacyConfig.blockSelector ?? []) {\n selectorMap[selector] = 'block';\n }\n for (const selector of privacyConfig.maskSelector ?? []) {\n selectorMap[selector] = 'mask';\n }\n for (const selector of privacyConfig.unmaskSelector ?? []) {\n selectorMap[selector] = 'unmask';\n }\n return selectorMap;\n };\n\n const selectorMap: Record<string, 'mask' | 'unmask' | 'block'> = {\n ...privacyConfigSelectorMap(localPrivacyConfig),\n ...privacyConfigSelectorMap(remotePrivacyConfig),\n };\n\n for (const [selector, selectorType] of Object.entries(selectorMap)) {\n if (selectorType === 'mask') {\n joinedPrivacyConfig.maskSelector.push(selector);\n } else if (selectorType === 'block') {\n joinedPrivacyConfig.blockSelector.push(selector);\n } else if (selectorType === 'unmask') {\n joinedPrivacyConfig.unmaskSelector.push(selector);\n }\n }\n\n config.privacyConfig = removeInvalidSelectorsFromPrivacyConfig(\n joinedPrivacyConfig,\n this.localConfig.loggerProvider,\n );\n }\n\n if (targetingConfig && Object.keys(targetingConfig).length > 0) {\n config.targetingConfig = targetingConfig;\n }\n\n this.localConfig.loggerProvider.debug(\n JSON.stringify({ name: 'session replay joined config', config: getDebugConfig(config) }, null, 2),\n );\n\n return {\n localConfig: this.localConfig,\n joinedConfig: config,\n remoteConfig: sessionReplayRemoteConfig,\n };\n }\n\n /**\n * Defensive bounds for the remote-supplied min_session_duration_ms. A misconfigured\n * value (e.g. 30_000_000) would silently suppress every replay until the config is\n * pushed again, so we clamp to a sane ceiling and warn on out-of-range inputs.\n * Returns undefined for clearly invalid values so the gate falls back to disabled\n * rather than carrying a NaN through downstream comparisons.\n */\n private sanitizeMinSessionDurationMs(raw: unknown): number | undefined {\n if (typeof raw !== 'number' || !Number.isFinite(raw)) {\n this.localConfig.loggerProvider.warn(\n `min_session_duration_ms remote value is not a finite number (got ${String(raw)}); ignoring.`,\n );\n return undefined;\n }\n if (raw < 0) {\n this.localConfig.loggerProvider.warn(`min_session_duration_ms remote value is negative (${raw}); ignoring.`);\n return undefined;\n }\n if (raw > MAX_MIN_SESSION_DURATION_MS) {\n this.localConfig.loggerProvider.warn(\n `min_session_duration_ms remote value ${raw} exceeds ${MAX_MIN_SESSION_DURATION_MS}ms ceiling; clamping.`,\n );\n return MAX_MIN_SESSION_DURATION_MS;\n }\n return raw;\n }\n}\n\n/**\n * Upper bound for the remote-configured replay min duration. 60 seconds is well above\n * any reasonable bounce threshold; values higher than this are almost certainly typos\n * (e.g. seconds confused for milliseconds, or an extra zero) and would otherwise\n * suppress every replay until the config is corrected.\n */\nexport const MAX_MIN_SESSION_DURATION_MS = 60_000;\n\nexport const createSessionReplayJoinedConfigGenerator = async (apiKey: string, options: SessionReplayOptions) => {\n const localConfig = new SessionReplayLocalConfig(apiKey, options);\n\n const remoteConfigClient = new RemoteConfigClient(\n apiKey,\n localConfig.loggerProvider,\n localConfig.serverZone,\n options.configServerUrl,\n // Custom transport for the config GET. SR's FetchConfigRequest is structurally compatible\n // with RemoteConfigFetchRequest, so the customer's handleFetchConfig drops straight in.\n options.handleFetchConfig,\n );\n\n return new SessionReplayJoinedConfigGenerator(remoteConfigClient, localConfig);\n};\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Config, Logger, FetchTransport, LogLevel
|
|
1
|
+
import { Config, Logger, FetchTransport, LogLevel } from '@amplitude/analytics-core';
|
|
2
2
|
import { SessionReplayOptions, StoreType } from '../typings/session-replay';
|
|
3
|
-
import { SessionReplayLocalConfig as ISessionReplayLocalConfig, CrossOriginIframesConfig, FlushIntervalConfig, InteractionConfig, PrivacyConfig, SessionReplayPerformanceConfig, SessionReplayVersion } from './types';
|
|
3
|
+
import { SessionReplayLocalConfig as ISessionReplayLocalConfig, CrossOriginIframesConfig, FlushIntervalConfig, InteractionConfig, PrivacyConfig, SessionReplayPerformanceConfig, SessionReplayVersion, SessionReplaySendEventsHandler, SessionReplayFetchConfigHandler } from './types';
|
|
4
4
|
export declare const getDefaultConfig: () => {
|
|
5
5
|
flushMaxRetries: number;
|
|
6
6
|
logLevel: LogLevel;
|
|
@@ -34,10 +34,8 @@ export declare class SessionReplayLocalConfig extends Config implements ISession
|
|
|
34
34
|
captureFullSnapshotOnFocus?: boolean;
|
|
35
35
|
maxPersistedEventsSizeBytes?: number;
|
|
36
36
|
maxSingleEventSizeBytes?: number;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
diagnosticsSampleRate?: number;
|
|
37
|
+
handleSendEvents?: SessionReplaySendEventsHandler;
|
|
38
|
+
handleFetchConfig?: SessionReplayFetchConfigHandler;
|
|
40
39
|
constructor(apiKey: string, options: SessionReplayOptions);
|
|
41
|
-
private createStandaloneDiagnosticsClient;
|
|
42
40
|
}
|
|
43
41
|
//# sourceMappingURL=local-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-config.d.ts","sourceRoot":"","sources":["../../../src/config/local-config.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"local-config.d.ts","sourceRoot":"","sources":["../../../src/config/local-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAW,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAY9F,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EACL,wBAAwB,IAAI,yBAAyB,EACrD,wBAAwB,EACxB,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,EACb,8BAA8B,EAC9B,oBAAoB,EACpB,8BAA8B,EAC9B,+BAA+B,EAChC,MAAM,SAAS,CAAC;AAIjB,eAAO,MAAM,gBAAgB;;;;;CAK3B,CAAC;AAEH,qBAAa,wBAAyB,SAAQ,MAAO,YAAW,yBAAyB;IACvF,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,SAAS,EAAE,SAAS,CAAC;IACrB,iBAAiB,CAAC,EAAE,8BAA8B,CAAC;IACnD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qCAAqC,CAAC,EAAE,OAAO,CAAC;IAChD,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,kBAAkB,CAAC,EAAE,wBAAwB,CAAC;IAC9C,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,gBAAgB,CAAC,EAAE,8BAA8B,CAAC;IAClD,iBAAiB,CAAC,EAAE,+BAA+B,CAAC;gBAExC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB;CAmG1D"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __assign, __extends, __read, __spreadArray } from "tslib";
|
|
2
|
-
import { Config, Logger, FetchTransport, LogLevel
|
|
2
|
+
import { Config, Logger, FetchTransport, LogLevel } from '@amplitude/analytics-core';
|
|
3
3
|
import { DEFAULT_FLUSH_MAX_INTERVAL_MS, DEFAULT_FLUSH_MIN_INTERVAL_MS, DEFAULT_PERFORMANCE_CONFIG, DEFAULT_SAMPLE_RATE, DEFAULT_SERVER_ZONE, DEFAULT_URL_CHANGE_POLLING_INTERVAL, MAX_INTERVAL, MIN_INTERVAL, UNMASK_TEXT_CLASS, } from '../constants';
|
|
4
4
|
import { SafeLoggerProvider } from '../logger';
|
|
5
5
|
import { validateUGCFilterRules } from '../helpers';
|
|
@@ -13,7 +13,7 @@ var SessionReplayLocalConfig = /** @class */ (function (_super) {
|
|
|
13
13
|
__extends(SessionReplayLocalConfig, _super);
|
|
14
14
|
function SessionReplayLocalConfig(apiKey, options) {
|
|
15
15
|
var _this = this;
|
|
16
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p
|
|
16
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
17
17
|
var defaultConfig = getDefaultConfig();
|
|
18
18
|
_this = _super.call(this, __assign(__assign({ transportProvider: defaultConfig.transportProvider, loggerProvider: new SafeLoggerProvider(options.loggerProvider || defaultConfig.loggerProvider) }, options), { apiKey: apiKey })) || this;
|
|
19
19
|
_this.flushMaxRetries =
|
|
@@ -87,26 +87,10 @@ var SessionReplayLocalConfig = /** @class */ (function (_super) {
|
|
|
87
87
|
maxIntervalMs: DEFAULT_FLUSH_MAX_INTERVAL_MS,
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
|
-
_this.
|
|
91
|
-
_this.
|
|
92
|
-
// Single diagnostics client: in plugin mode the analytics SDK passes its own client in
|
|
93
|
-
// (reused, not duplicated). Standalone SR has no analytics SDK, so create one here — but only
|
|
94
|
-
// when explicitly opted in, to avoid imposing IndexedDB + flush-timer overhead on standalone
|
|
95
|
-
// users who don't want diagnostics.
|
|
96
|
-
_this.diagnosticsClient = (_q = options.diagnosticsClient) !== null && _q !== void 0 ? _q : _this.createStandaloneDiagnosticsClient(apiKey, options);
|
|
90
|
+
_this.handleSendEvents = options.handleSendEvents;
|
|
91
|
+
_this.handleFetchConfig = options.handleFetchConfig;
|
|
97
92
|
return _this;
|
|
98
93
|
}
|
|
99
|
-
SessionReplayLocalConfig.prototype.createStandaloneDiagnosticsClient = function (apiKey, options) {
|
|
100
|
-
var diagnosticsEnabled = options.diagnosticsEnabled, diagnosticsSampleRate = options.diagnosticsSampleRate;
|
|
101
|
-
var optedIn = diagnosticsEnabled === true || (typeof diagnosticsSampleRate === 'number' && diagnosticsSampleRate > 0);
|
|
102
|
-
if (!optedIn) {
|
|
103
|
-
return undefined;
|
|
104
|
-
}
|
|
105
|
-
return new DiagnosticsClient(apiKey, this.loggerProvider, this.serverZone, {
|
|
106
|
-
enabled: diagnosticsEnabled !== null && diagnosticsEnabled !== void 0 ? diagnosticsEnabled : true,
|
|
107
|
-
sampleRate: diagnosticsSampleRate !== null && diagnosticsSampleRate !== void 0 ? diagnosticsSampleRate : 0,
|
|
108
|
-
});
|
|
109
|
-
};
|
|
110
94
|
return SessionReplayLocalConfig;
|
|
111
95
|
}(Config));
|
|
112
96
|
export { SessionReplayLocalConfig };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-config.js","sourceRoot":"","sources":["../../../src/config/local-config.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,MAAM,EAEN,MAAM,EACN,cAAc,EACd,QAAQ,EAER,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,EAC7B,0BAA0B,EAC1B,mBAAmB,EACnB,mBAAmB,EACnB,mCAAmC,EACnC,YAAY,EACZ,YAAY,EACZ,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAWtB,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM,CAAC,IAAM,gBAAgB,GAAG,cAAM,OAAA,CAAC;IACrC,eAAe,EAAE,CAAC;IAClB,QAAQ,EAAE,QAAQ,CAAC,IAAI;IACvB,cAAc,EAAE,IAAI,MAAM,EAAE;IAC5B,iBAAiB,EAAE,IAAI,cAAc,EAAE;CACxC,CAAC,EALoC,CAKpC,CAAC;AAEH;IAA8C,4CAAM;IA+BlD,kCAAY,MAAc,EAAE,OAA6B;QAAzD,iBAuGC;;QAtGC,IAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;gBACzC,sCACE,iBAAiB,EAAE,aAAa,CAAC,iBAAiB,EAClD,cAAc,EAAE,IAAI,kBAAkB,CAAC,OAAO,CAAC,cAAc,IAAI,aAAa,CAAC,cAAc,CAAC,IAC3F,OAAO,KACV,MAAM,QAAA,IACN;QACF,KAAI,CAAC,eAAe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SAAS,IAAI,SAAS,CAAC,aAAa,KAAK,SAAS,EAAE;QAClF,IAAM,YAAY,GAAG,MAAA,SAAS,CAAC,aAAa,mCAAI,YAAY,CAAC;QAC7D,IAAM,YAAY,GAAG,MAAA,SAAS,CAAC,aAAa,mCAAI,YAAY,CAAC;QAC7D,IAAI,YAAY,GAAG,YAAY,EAAE;YAC/B,IAAI,SAAS,CAAC,aAAa,KAAK,SAAS,EAAE;gBACzC,cAAc,CAAC,IAAI,CACjB,6CAAsC,YAAY,kDAAwC,YAAY,iCAA8B,CACrI,CAAC;gBACF,SAAS,CAAC,aAAa,GAAG,YAAY,CAAC;aACxC;iBAAM,IAAI,SAAS,CAAC,aAAa,KAAK,SAAS,EAAE;gBAChD,cAAc,CAAC,IAAI,CACjB,6CAAsC,YAAY,mDAAyC,YAAY,kCAA+B,CACvI,CAAC;gBACF,SAAS,CAAC,aAAa,GAAG,YAAY,CAAC;aACxC;iBAAM;gBACL,cAAc,CAAC,IAAI,CACjB,6CAAsC,SAAS,CAAC,aAAa,2CAAiC,SAAS,CAAC,aAAa,iCAA8B,CACpJ,CAAC;gBACF,SAAS,CAAC,aAAa,GAAG,SAAS,CAAC,aAAa,CAAC;aACnD;SACF;KACF;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import {\n Config,\n ILogger,\n Logger,\n FetchTransport,\n LogLevel,\n IDiagnosticsClient,\n DiagnosticsClient,\n} from '@amplitude/analytics-core';\nimport {\n DEFAULT_FLUSH_MAX_INTERVAL_MS,\n DEFAULT_FLUSH_MIN_INTERVAL_MS,\n DEFAULT_PERFORMANCE_CONFIG,\n DEFAULT_SAMPLE_RATE,\n DEFAULT_SERVER_ZONE,\n DEFAULT_URL_CHANGE_POLLING_INTERVAL,\n MAX_INTERVAL,\n MIN_INTERVAL,\n UNMASK_TEXT_CLASS,\n} from '../constants';\nimport { SessionReplayOptions, StoreType } from '../typings/session-replay';\nimport {\n SessionReplayLocalConfig as ISessionReplayLocalConfig,\n CrossOriginIframesConfig,\n FlushIntervalConfig,\n InteractionConfig,\n PrivacyConfig,\n SessionReplayPerformanceConfig,\n SessionReplayVersion,\n} from './types';\nimport { SafeLoggerProvider } from '../logger';\nimport { validateUGCFilterRules } from '../helpers';\n\nexport const getDefaultConfig = () => ({\n flushMaxRetries: 2,\n logLevel: LogLevel.Warn,\n loggerProvider: new Logger(),\n transportProvider: new FetchTransport(),\n});\n\nexport class SessionReplayLocalConfig extends Config implements ISessionReplayLocalConfig {\n apiKey: string;\n sampleRate: number;\n privacyConfig?: PrivacyConfig;\n interactionConfig?: InteractionConfig;\n debugMode?: boolean;\n configServerUrl?: string;\n trackServerUrl?: string;\n shouldInlineStylesheet?: boolean;\n version?: SessionReplayVersion;\n storeType: StoreType;\n performanceConfig?: SessionReplayPerformanceConfig;\n useWebWorker?: boolean;\n enableTransportCompression?: boolean;\n sendTimeoutMs?: number;\n applyBackgroundColorToBlockedElements?: boolean;\n enableUrlChangePolling?: boolean;\n urlChangePollingInterval?: number;\n captureDocumentTitle?: boolean;\n captureAdoptedStyleSheets?: boolean;\n crossOriginIframes?: CrossOriginIframesConfig;\n fullSnapshotIntervalMs?: number;\n flushIntervalConfig?: FlushIntervalConfig;\n eagerFullSnapshotSend?: boolean;\n captureFullSnapshotOnFocus?: boolean;\n maxPersistedEventsSizeBytes?: number;\n maxSingleEventSizeBytes?: number;\n diagnosticsClient?: IDiagnosticsClient;\n diagnosticsEnabled?: boolean;\n diagnosticsSampleRate?: number;\n\n constructor(apiKey: string, options: SessionReplayOptions) {\n const defaultConfig = getDefaultConfig();\n super({\n transportProvider: defaultConfig.transportProvider,\n loggerProvider: new SafeLoggerProvider(options.loggerProvider || defaultConfig.loggerProvider),\n ...options,\n apiKey,\n });\n this.flushMaxRetries =\n options.flushMaxRetries !== undefined && options.flushMaxRetries <= defaultConfig.flushMaxRetries\n ? options.flushMaxRetries\n : defaultConfig.flushMaxRetries;\n\n this.apiKey = apiKey;\n this.sampleRate = options.sampleRate || DEFAULT_SAMPLE_RATE;\n this.serverZone = options.serverZone || DEFAULT_SERVER_ZONE;\n this.configServerUrl = options.configServerUrl;\n this.trackServerUrl = options.trackServerUrl;\n this.shouldInlineStylesheet = options.shouldInlineStylesheet;\n this.version = options.version;\n this.performanceConfig = options.performanceConfig || DEFAULT_PERFORMANCE_CONFIG;\n this.storeType = options.storeType ?? 'memory';\n this.applyBackgroundColorToBlockedElements = options.applyBackgroundColorToBlockedElements ?? false;\n this.enableUrlChangePolling = options.enableUrlChangePolling ?? false;\n this.urlChangePollingInterval = options.urlChangePollingInterval ?? DEFAULT_URL_CHANGE_POLLING_INTERVAL;\n this.captureDocumentTitle = options.captureDocumentTitle ?? false;\n if (options.fullSnapshotIntervalMs !== undefined) {\n this.fullSnapshotIntervalMs = options.fullSnapshotIntervalMs;\n }\n if (options.eagerFullSnapshotSend !== undefined) {\n this.eagerFullSnapshotSend = options.eagerFullSnapshotSend;\n }\n // Defaults to false per the validated amp-on-amp perf config (SR-4646): the on-focus full\n // snapshot is off unless the consumer explicitly opts in. focusListener honors this by\n // skipping the snapshot whenever the value is not true.\n this.captureFullSnapshotOnFocus = options.captureFullSnapshotOnFocus ?? false;\n if (options.maxPersistedEventsSizeBytes !== undefined) {\n this.maxPersistedEventsSizeBytes = sanitizeByteSize(\n options.maxPersistedEventsSizeBytes,\n MIN_EVENT_BYTE_SIZE,\n MAX_PERSISTED_EVENTS_SIZE_CEILING,\n 'maxPersistedEventsSizeBytes',\n this.loggerProvider,\n );\n }\n if (options.maxSingleEventSizeBytes !== undefined) {\n this.maxSingleEventSizeBytes = sanitizeByteSize(\n options.maxSingleEventSizeBytes,\n MIN_EVENT_BYTE_SIZE,\n MAX_SINGLE_EVENT_SIZE_CEILING,\n 'maxSingleEventSizeBytes',\n this.loggerProvider,\n );\n }\n\n // Auto-include .amp-unmask as a default unmaskSelector entry so it works\n // symmetrically with amp-mask/amp-block without requiring explicit config (SR-2945).\n this.privacyConfig = {\n ...(options.privacyConfig ?? {}),\n unmaskSelector: Array.from(new Set([`.${UNMASK_TEXT_CLASS}`, ...(options.privacyConfig?.unmaskSelector ?? [])])),\n };\n if (options.interactionConfig) {\n this.interactionConfig = options.interactionConfig;\n\n // validate ugcFilterRules, throw error if invalid - throw error at the beginning of the config\n if (this.interactionConfig.ugcFilterRules) {\n validateUGCFilterRules(this.interactionConfig.ugcFilterRules);\n }\n }\n if (options.debugMode) {\n this.debugMode = options.debugMode;\n }\n // Support both new useWebWorker and legacy experimental.useWebWorker for backwards\n // compatibility. Defaults to true per the validated amp-on-amp perf config (SR-4646):\n // compression runs off the main thread unless the consumer explicitly sets either flag\n // to false. The top-level option wins over the legacy experimental one when both are set.\n const legacyOptions = options as { experimental?: { useWebWorker?: boolean } };\n this.useWebWorker = options.useWebWorker ?? legacyOptions.experimental?.useWebWorker ?? true;\n this.enableTransportCompression = options.enableTransportCompression ?? true;\n // Pass through undefined so the track destination applies its SEND_TIMEOUT_MS default;\n // an explicit 0 is preserved (disables the timeout).\n this.sendTimeoutMs = options.sendTimeoutMs;\n this.captureAdoptedStyleSheets = options.captureAdoptedStyleSheets ?? true;\n if (options.crossOriginIframes) {\n this.crossOriginIframes = options.crossOriginIframes;\n }\n if (options.flushIntervalConfig) {\n this.flushIntervalConfig = sanitizeFlushIntervalConfig(options.flushIntervalConfig, this.loggerProvider);\n } else {\n // Default to the validated amp-on-amp perf config (SR-4646). The values are known-valid\n // (min <= max, both above the floor), so no sanitization is required.\n this.flushIntervalConfig = {\n minIntervalMs: DEFAULT_FLUSH_MIN_INTERVAL_MS,\n maxIntervalMs: DEFAULT_FLUSH_MAX_INTERVAL_MS,\n };\n }\n this.diagnosticsEnabled = options.diagnosticsEnabled;\n this.diagnosticsSampleRate = options.diagnosticsSampleRate;\n // Single diagnostics client: in plugin mode the analytics SDK passes its own client in\n // (reused, not duplicated). Standalone SR has no analytics SDK, so create one here — but only\n // when explicitly opted in, to avoid imposing IndexedDB + flush-timer overhead on standalone\n // users who don't want diagnostics.\n this.diagnosticsClient = options.diagnosticsClient ?? this.createStandaloneDiagnosticsClient(apiKey, options);\n }\n\n private createStandaloneDiagnosticsClient(\n apiKey: string,\n options: SessionReplayOptions,\n ): IDiagnosticsClient | undefined {\n const { diagnosticsEnabled, diagnosticsSampleRate } = options;\n const optedIn =\n diagnosticsEnabled === true || (typeof diagnosticsSampleRate === 'number' && diagnosticsSampleRate > 0);\n if (!optedIn) {\n return undefined;\n }\n return new DiagnosticsClient(apiKey, this.loggerProvider, this.serverZone, {\n enabled: diagnosticsEnabled ?? true,\n sampleRate: diagnosticsSampleRate ?? 0,\n });\n }\n}\n\n// 100ms floor avoids degenerate configs (0/negative) that would split on every event.\n// Customers wanting fewer requests should be raising the value, not lowering it; the floor\n// is just a defensive guard against typos and unsigned-int rollovers.\nconst MIN_FLUSH_INTERVAL_FLOOR_MS = 100;\n\n// Shared 1 KB floor for the byte-size overrides — small enough to exercise splitting/drops\n// while debugging, large enough to avoid a 0/negative config that splits on every event.\nconst MIN_EVENT_BYTE_SIZE = 1_000;\n// Batch cap ceiling: stay under the SR ingest service's 10 MB decompressed split threshold\n// (above which the server splits the batch itself) with headroom for the request wrapper.\nconst MAX_PERSISTED_EVENTS_SIZE_CEILING = 8_000_000;\n// Single-event ceiling: the server rejects a single event above ~10 MB, so never allow an\n// override to exceed that.\nconst MAX_SINGLE_EVENT_SIZE_CEILING = 10_000_000;\n\n// Defensive bounds for the byte-size overrides. Non-finite inputs are ignored (fall back to\n// the SDK default); out-of-range values are clamped and logged so a typo can't silently\n// disable splitting or push past the server's limits.\nfunction sanitizeByteSize(\n raw: number,\n min: number,\n max: number,\n name: string,\n loggerProvider: ILogger,\n): number | undefined {\n if (!Number.isFinite(raw)) {\n loggerProvider.warn(`${name} value is not a finite number (got ${String(raw)}); ignoring.`);\n return undefined;\n }\n if (raw < min) {\n loggerProvider.warn(`${name} ${raw} is below floor ${min}; clamping.`);\n return min;\n }\n if (raw > max) {\n loggerProvider.warn(`${name} ${raw} exceeds ceiling ${max}; clamping.`);\n return max;\n }\n return raw;\n}\n\nfunction sanitizeFlushIntervalConfig(raw: FlushIntervalConfig, loggerProvider: ILogger): FlushIntervalConfig {\n const sanitized: FlushIntervalConfig = {};\n if (raw.minIntervalMs !== undefined) {\n if (!Number.isFinite(raw.minIntervalMs) || raw.minIntervalMs < MIN_FLUSH_INTERVAL_FLOOR_MS) {\n loggerProvider.warn(\n `flushIntervalConfig.minIntervalMs ${raw.minIntervalMs} is below floor ${MIN_FLUSH_INTERVAL_FLOOR_MS}ms; clamping.`,\n );\n sanitized.minIntervalMs = MIN_FLUSH_INTERVAL_FLOOR_MS;\n } else {\n sanitized.minIntervalMs = raw.minIntervalMs;\n }\n }\n if (raw.maxIntervalMs !== undefined) {\n // Unlike min, `Infinity` is a meaningful value here: it means \"no upper bound on interval\n // growth\" (Math.min(Infinity, x) === x in BaseEventsStore.shouldSplitEventsList). Reject\n // only NaN and sub-floor values; pass Infinity through.\n if (Number.isNaN(raw.maxIntervalMs) || raw.maxIntervalMs < MIN_FLUSH_INTERVAL_FLOOR_MS) {\n loggerProvider.warn(\n `flushIntervalConfig.maxIntervalMs ${raw.maxIntervalMs} is below floor ${MIN_FLUSH_INTERVAL_FLOOR_MS}ms; clamping.`,\n );\n sanitized.maxIntervalMs = MIN_FLUSH_INTERVAL_FLOOR_MS;\n } else {\n sanitized.maxIntervalMs = raw.maxIntervalMs;\n }\n }\n // Cross-validate against the SDK's effective defaults so that a partial config (only one of\n // {minIntervalMs, maxIntervalMs}) doesn't get silently clamped by the unspecified default.\n // Concrete failure mode without this: customer sets only `minIntervalMs: 30_000`, the store's\n // `maxInterval` falls back to `MAX_INTERVAL = 10_000`, and `shouldSplitEventsList` then\n // caps the effective interval at 10s — silently negating the customer's tune-up.\n // The user-supplied value always wins; we fill in the other side to match.\n if (sanitized.minIntervalMs !== undefined || sanitized.maxIntervalMs !== undefined) {\n const effectiveMin = sanitized.minIntervalMs ?? MIN_INTERVAL;\n const effectiveMax = sanitized.maxIntervalMs ?? MAX_INTERVAL;\n if (effectiveMax < effectiveMin) {\n if (sanitized.maxIntervalMs === undefined) {\n loggerProvider.warn(\n `flushIntervalConfig.minIntervalMs (${effectiveMin}) exceeds the default maxIntervalMs (${MAX_INTERVAL}); raising max to match min.`,\n );\n sanitized.maxIntervalMs = effectiveMin;\n } else if (sanitized.minIntervalMs === undefined) {\n loggerProvider.warn(\n `flushIntervalConfig.maxIntervalMs (${effectiveMax}) is below the default minIntervalMs (${MIN_INTERVAL}); lowering min to match max.`,\n );\n sanitized.minIntervalMs = effectiveMax;\n } else {\n loggerProvider.warn(\n `flushIntervalConfig.maxIntervalMs (${sanitized.maxIntervalMs}) is less than minIntervalMs (${sanitized.minIntervalMs}); raising max to match min.`,\n );\n sanitized.maxIntervalMs = sanitized.minIntervalMs;\n }\n }\n }\n return sanitized;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"local-config.js","sourceRoot":"","sources":["../../../src/config/local-config.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAW,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC9F,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,EAC7B,0BAA0B,EAC1B,mBAAmB,EACnB,mBAAmB,EACnB,mCAAmC,EACnC,YAAY,EACZ,YAAY,EACZ,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAatB,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM,CAAC,IAAM,gBAAgB,GAAG,cAAM,OAAA,CAAC;IACrC,eAAe,EAAE,CAAC;IAClB,QAAQ,EAAE,QAAQ,CAAC,IAAI;IACvB,cAAc,EAAE,IAAI,MAAM,EAAE;IAC5B,iBAAiB,EAAE,IAAI,cAAc,EAAE;CACxC,CAAC,EALoC,CAKpC,CAAC;AAEH;IAA8C,4CAAM;IA8BlD,kCAAY,MAAc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,YAAY,mDAAyC,YAAY,kCAA+B,CACvI,CAAC;gBACF,SAAS,CAAC,aAAa,GAAG,YAAY,CAAC;aACxC;iBAAM;gBACL,cAAc,CAAC,IAAI,CACjB,6CAAsC,SAAS,CAAC,aAAa,2CAAiC,SAAS,CAAC,aAAa,iCAA8B,CACpJ,CAAC;gBACF,SAAS,CAAC,aAAa,GAAG,SAAS,CAAC,aAAa,CAAC;aACnD;SACF;KACF;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import { Config, ILogger, Logger, FetchTransport, LogLevel } from '@amplitude/analytics-core';\nimport {\n DEFAULT_FLUSH_MAX_INTERVAL_MS,\n DEFAULT_FLUSH_MIN_INTERVAL_MS,\n DEFAULT_PERFORMANCE_CONFIG,\n DEFAULT_SAMPLE_RATE,\n DEFAULT_SERVER_ZONE,\n DEFAULT_URL_CHANGE_POLLING_INTERVAL,\n MAX_INTERVAL,\n MIN_INTERVAL,\n UNMASK_TEXT_CLASS,\n} from '../constants';\nimport { SessionReplayOptions, StoreType } from '../typings/session-replay';\nimport {\n SessionReplayLocalConfig as ISessionReplayLocalConfig,\n CrossOriginIframesConfig,\n FlushIntervalConfig,\n InteractionConfig,\n PrivacyConfig,\n SessionReplayPerformanceConfig,\n SessionReplayVersion,\n SessionReplaySendEventsHandler,\n SessionReplayFetchConfigHandler,\n} from './types';\nimport { SafeLoggerProvider } from '../logger';\nimport { validateUGCFilterRules } from '../helpers';\n\nexport const getDefaultConfig = () => ({\n flushMaxRetries: 2,\n logLevel: LogLevel.Warn,\n loggerProvider: new Logger(),\n transportProvider: new FetchTransport(),\n});\n\nexport class SessionReplayLocalConfig extends Config implements ISessionReplayLocalConfig {\n apiKey: string;\n sampleRate: number;\n privacyConfig?: PrivacyConfig;\n interactionConfig?: InteractionConfig;\n debugMode?: boolean;\n configServerUrl?: string;\n trackServerUrl?: string;\n shouldInlineStylesheet?: boolean;\n version?: SessionReplayVersion;\n storeType: StoreType;\n performanceConfig?: SessionReplayPerformanceConfig;\n useWebWorker?: boolean;\n enableTransportCompression?: boolean;\n sendTimeoutMs?: number;\n applyBackgroundColorToBlockedElements?: boolean;\n enableUrlChangePolling?: boolean;\n urlChangePollingInterval?: number;\n captureDocumentTitle?: boolean;\n captureAdoptedStyleSheets?: boolean;\n crossOriginIframes?: CrossOriginIframesConfig;\n fullSnapshotIntervalMs?: number;\n flushIntervalConfig?: FlushIntervalConfig;\n eagerFullSnapshotSend?: boolean;\n captureFullSnapshotOnFocus?: boolean;\n maxPersistedEventsSizeBytes?: number;\n maxSingleEventSizeBytes?: number;\n handleSendEvents?: SessionReplaySendEventsHandler;\n handleFetchConfig?: SessionReplayFetchConfigHandler;\n\n constructor(apiKey: string, options: SessionReplayOptions) {\n const defaultConfig = getDefaultConfig();\n super({\n transportProvider: defaultConfig.transportProvider,\n loggerProvider: new SafeLoggerProvider(options.loggerProvider || defaultConfig.loggerProvider),\n ...options,\n apiKey,\n });\n this.flushMaxRetries =\n options.flushMaxRetries !== undefined && options.flushMaxRetries <= defaultConfig.flushMaxRetries\n ? options.flushMaxRetries\n : defaultConfig.flushMaxRetries;\n\n this.apiKey = apiKey;\n this.sampleRate = options.sampleRate || DEFAULT_SAMPLE_RATE;\n this.serverZone = options.serverZone || DEFAULT_SERVER_ZONE;\n this.configServerUrl = options.configServerUrl;\n this.trackServerUrl = options.trackServerUrl;\n this.shouldInlineStylesheet = options.shouldInlineStylesheet;\n this.version = options.version;\n this.performanceConfig = options.performanceConfig || DEFAULT_PERFORMANCE_CONFIG;\n this.storeType = options.storeType ?? 'memory';\n this.applyBackgroundColorToBlockedElements = options.applyBackgroundColorToBlockedElements ?? false;\n this.enableUrlChangePolling = options.enableUrlChangePolling ?? false;\n this.urlChangePollingInterval = options.urlChangePollingInterval ?? DEFAULT_URL_CHANGE_POLLING_INTERVAL;\n this.captureDocumentTitle = options.captureDocumentTitle ?? false;\n if (options.fullSnapshotIntervalMs !== undefined) {\n this.fullSnapshotIntervalMs = options.fullSnapshotIntervalMs;\n }\n if (options.eagerFullSnapshotSend !== undefined) {\n this.eagerFullSnapshotSend = options.eagerFullSnapshotSend;\n }\n // Defaults to false per the validated amp-on-amp perf config (SR-4646): the on-focus full\n // snapshot is off unless the consumer explicitly opts in. focusListener honors this by\n // skipping the snapshot whenever the value is not true.\n this.captureFullSnapshotOnFocus = options.captureFullSnapshotOnFocus ?? false;\n if (options.maxPersistedEventsSizeBytes !== undefined) {\n this.maxPersistedEventsSizeBytes = sanitizeByteSize(\n options.maxPersistedEventsSizeBytes,\n MIN_EVENT_BYTE_SIZE,\n MAX_PERSISTED_EVENTS_SIZE_CEILING,\n 'maxPersistedEventsSizeBytes',\n this.loggerProvider,\n );\n }\n if (options.maxSingleEventSizeBytes !== undefined) {\n this.maxSingleEventSizeBytes = sanitizeByteSize(\n options.maxSingleEventSizeBytes,\n MIN_EVENT_BYTE_SIZE,\n MAX_SINGLE_EVENT_SIZE_CEILING,\n 'maxSingleEventSizeBytes',\n this.loggerProvider,\n );\n }\n\n // Auto-include .amp-unmask as a default unmaskSelector entry so it works\n // symmetrically with amp-mask/amp-block without requiring explicit config (SR-2945).\n this.privacyConfig = {\n ...(options.privacyConfig ?? {}),\n unmaskSelector: Array.from(new Set([`.${UNMASK_TEXT_CLASS}`, ...(options.privacyConfig?.unmaskSelector ?? [])])),\n };\n if (options.interactionConfig) {\n this.interactionConfig = options.interactionConfig;\n\n // validate ugcFilterRules, throw error if invalid - throw error at the beginning of the config\n if (this.interactionConfig.ugcFilterRules) {\n validateUGCFilterRules(this.interactionConfig.ugcFilterRules);\n }\n }\n if (options.debugMode) {\n this.debugMode = options.debugMode;\n }\n // Support both new useWebWorker and legacy experimental.useWebWorker for backwards\n // compatibility. Defaults to true per the validated amp-on-amp perf config (SR-4646):\n // compression runs off the main thread unless the consumer explicitly sets either flag\n // to false. The top-level option wins over the legacy experimental one when both are set.\n const legacyOptions = options as { experimental?: { useWebWorker?: boolean } };\n this.useWebWorker = options.useWebWorker ?? legacyOptions.experimental?.useWebWorker ?? true;\n this.enableTransportCompression = options.enableTransportCompression ?? true;\n // Pass through undefined so the track destination applies its SEND_TIMEOUT_MS default;\n // an explicit 0 is preserved (disables the timeout).\n this.sendTimeoutMs = options.sendTimeoutMs;\n this.captureAdoptedStyleSheets = options.captureAdoptedStyleSheets ?? true;\n if (options.crossOriginIframes) {\n this.crossOriginIframes = options.crossOriginIframes;\n }\n if (options.flushIntervalConfig) {\n this.flushIntervalConfig = sanitizeFlushIntervalConfig(options.flushIntervalConfig, this.loggerProvider);\n } else {\n // Default to the validated amp-on-amp perf config (SR-4646). The values are known-valid\n // (min <= max, both above the floor), so no sanitization is required.\n this.flushIntervalConfig = {\n minIntervalMs: DEFAULT_FLUSH_MIN_INTERVAL_MS,\n maxIntervalMs: DEFAULT_FLUSH_MAX_INTERVAL_MS,\n };\n }\n this.handleSendEvents = options.handleSendEvents;\n this.handleFetchConfig = options.handleFetchConfig;\n }\n}\n\n// 100ms floor avoids degenerate configs (0/negative) that would split on every event.\n// Customers wanting fewer requests should be raising the value, not lowering it; the floor\n// is just a defensive guard against typos and unsigned-int rollovers.\nconst MIN_FLUSH_INTERVAL_FLOOR_MS = 100;\n\n// Shared 1 KB floor for the byte-size overrides — small enough to exercise splitting/drops\n// while debugging, large enough to avoid a 0/negative config that splits on every event.\nconst MIN_EVENT_BYTE_SIZE = 1_000;\n// Batch cap ceiling: stay under the SR ingest service's 10 MB decompressed split threshold\n// (above which the server splits the batch itself) with headroom for the request wrapper.\nconst MAX_PERSISTED_EVENTS_SIZE_CEILING = 8_000_000;\n// Single-event ceiling: the server rejects a single event above ~10 MB, so never allow an\n// override to exceed that.\nconst MAX_SINGLE_EVENT_SIZE_CEILING = 10_000_000;\n\n// Defensive bounds for the byte-size overrides. Non-finite inputs are ignored (fall back to\n// the SDK default); out-of-range values are clamped and logged so a typo can't silently\n// disable splitting or push past the server's limits.\nfunction sanitizeByteSize(\n raw: number,\n min: number,\n max: number,\n name: string,\n loggerProvider: ILogger,\n): number | undefined {\n if (!Number.isFinite(raw)) {\n loggerProvider.warn(`${name} value is not a finite number (got ${String(raw)}); ignoring.`);\n return undefined;\n }\n if (raw < min) {\n loggerProvider.warn(`${name} ${raw} is below floor ${min}; clamping.`);\n return min;\n }\n if (raw > max) {\n loggerProvider.warn(`${name} ${raw} exceeds ceiling ${max}; clamping.`);\n return max;\n }\n return raw;\n}\n\nfunction sanitizeFlushIntervalConfig(raw: FlushIntervalConfig, loggerProvider: ILogger): FlushIntervalConfig {\n const sanitized: FlushIntervalConfig = {};\n if (raw.minIntervalMs !== undefined) {\n if (!Number.isFinite(raw.minIntervalMs) || raw.minIntervalMs < MIN_FLUSH_INTERVAL_FLOOR_MS) {\n loggerProvider.warn(\n `flushIntervalConfig.minIntervalMs ${raw.minIntervalMs} is below floor ${MIN_FLUSH_INTERVAL_FLOOR_MS}ms; clamping.`,\n );\n sanitized.minIntervalMs = MIN_FLUSH_INTERVAL_FLOOR_MS;\n } else {\n sanitized.minIntervalMs = raw.minIntervalMs;\n }\n }\n if (raw.maxIntervalMs !== undefined) {\n // Unlike min, `Infinity` is a meaningful value here: it means \"no upper bound on interval\n // growth\" (Math.min(Infinity, x) === x in BaseEventsStore.shouldSplitEventsList). Reject\n // only NaN and sub-floor values; pass Infinity through.\n if (Number.isNaN(raw.maxIntervalMs) || raw.maxIntervalMs < MIN_FLUSH_INTERVAL_FLOOR_MS) {\n loggerProvider.warn(\n `flushIntervalConfig.maxIntervalMs ${raw.maxIntervalMs} is below floor ${MIN_FLUSH_INTERVAL_FLOOR_MS}ms; clamping.`,\n );\n sanitized.maxIntervalMs = MIN_FLUSH_INTERVAL_FLOOR_MS;\n } else {\n sanitized.maxIntervalMs = raw.maxIntervalMs;\n }\n }\n // Cross-validate against the SDK's effective defaults so that a partial config (only one of\n // {minIntervalMs, maxIntervalMs}) doesn't get silently clamped by the unspecified default.\n // Concrete failure mode without this: customer sets only `minIntervalMs: 30_000`, the store's\n // `maxInterval` falls back to `MAX_INTERVAL = 10_000`, and `shouldSplitEventsList` then\n // caps the effective interval at 10s — silently negating the customer's tune-up.\n // The user-supplied value always wins; we fill in the other side to match.\n if (sanitized.minIntervalMs !== undefined || sanitized.maxIntervalMs !== undefined) {\n const effectiveMin = sanitized.minIntervalMs ?? MIN_INTERVAL;\n const effectiveMax = sanitized.maxIntervalMs ?? MAX_INTERVAL;\n if (effectiveMax < effectiveMin) {\n if (sanitized.maxIntervalMs === undefined) {\n loggerProvider.warn(\n `flushIntervalConfig.minIntervalMs (${effectiveMin}) exceeds the default maxIntervalMs (${MAX_INTERVAL}); raising max to match min.`,\n );\n sanitized.maxIntervalMs = effectiveMin;\n } else if (sanitized.minIntervalMs === undefined) {\n loggerProvider.warn(\n `flushIntervalConfig.maxIntervalMs (${effectiveMax}) is below the default minIntervalMs (${MIN_INTERVAL}); lowering min to match max.`,\n );\n sanitized.minIntervalMs = effectiveMax;\n } else {\n loggerProvider.warn(\n `flushIntervalConfig.maxIntervalMs (${sanitized.maxIntervalMs}) is less than minIntervalMs (${sanitized.minIntervalMs}); raising max to match min.`,\n );\n sanitized.maxIntervalMs = sanitized.minIntervalMs;\n }\n }\n }\n return sanitized;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IConfig, LogLevel, ILogger
|
|
1
|
+
import { IConfig, LogLevel, ILogger } from '@amplitude/analytics-core';
|
|
2
2
|
import { StoreType, ConsoleLogLevel } from '../typings/session-replay';
|
|
3
3
|
import { TargetingFlag } from '@amplitude/targeting';
|
|
4
4
|
export interface SamplingConfig {
|
|
@@ -80,6 +80,64 @@ export type UGCFilterRule = {
|
|
|
80
80
|
*/
|
|
81
81
|
replacement: string;
|
|
82
82
|
};
|
|
83
|
+
/**
|
|
84
|
+
* The fully-formed request the SDK hands to a custom `handleSendEvents` transport when
|
|
85
|
+
* uploading recorded replay events. The callback's only job is to execute this request and
|
|
86
|
+
* return the resulting `Response`; the SDK owns batching, retry, serialization and error
|
|
87
|
+
* handling around it.
|
|
88
|
+
*/
|
|
89
|
+
export interface SendEventsRequest {
|
|
90
|
+
/** The resolved track URL (respects `trackServerUrl`) including query params. */
|
|
91
|
+
url: string;
|
|
92
|
+
method: 'POST';
|
|
93
|
+
/**
|
|
94
|
+
* SDK-supplied default headers. When the body was gzipped, this includes
|
|
95
|
+
* `Content-Encoding: gzip` — drop it only if you also stop forwarding the gzipped body,
|
|
96
|
+
* otherwise the payload will not decode server-side.
|
|
97
|
+
*/
|
|
98
|
+
headers: Record<string, string>;
|
|
99
|
+
/**
|
|
100
|
+
* The serialized payload, ready to send. A gzipped `Uint8Array` when transport compression
|
|
101
|
+
* is active, otherwise the raw JSON string. Forward it unchanged — do not re-serialize.
|
|
102
|
+
*
|
|
103
|
+
* Typed as `string | Uint8Array` (not the broader `BodyInit`) because the body must be
|
|
104
|
+
* structured-cloneable to cross `postMessage` in web-worker mode; `Blob`/`FormData`/
|
|
105
|
+
* `ReadableStream` are not, and the SDK never produces them here.
|
|
106
|
+
*/
|
|
107
|
+
body: string | Uint8Array;
|
|
108
|
+
/**
|
|
109
|
+
* Whether the built-in path would set `keepalive` on this request. `true` for page-exit
|
|
110
|
+
* sends (so the request survives unload) and for small in-session batches. Forward it to
|
|
111
|
+
* your `fetch` call — i.e. `fetch(url, { method, headers, body, keepalive })` — so exit-time
|
|
112
|
+
* batches are not dropped when the page is tearing down.
|
|
113
|
+
*/
|
|
114
|
+
keepalive: boolean;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The fully-formed request the SDK hands to a custom `handleFetchConfig` transport when
|
|
118
|
+
* fetching remote configuration.
|
|
119
|
+
*/
|
|
120
|
+
export interface FetchConfigRequest {
|
|
121
|
+
/** The resolved config URL (respects `configServerUrl`) including query params. */
|
|
122
|
+
url: string;
|
|
123
|
+
method: 'GET';
|
|
124
|
+
/** SDK-supplied default headers. */
|
|
125
|
+
headers: Record<string, string>;
|
|
126
|
+
/** Abort signal the SDK uses to enforce the remote-config fetch timeout. Honor it in your fetch. */
|
|
127
|
+
signal?: AbortSignal;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Custom transport for replay event uploads. Invoked by the SDK in place of its internal
|
|
131
|
+
* `fetch`. Must return a `Response` (or Response-like with `ok`, `status`, `text()`). Called
|
|
132
|
+
* once per logical request attempt — retry is handled by the SDK around the callback, so do
|
|
133
|
+
* not implement your own retry. Thrown errors / rejected promises are surfaced to the SDK's
|
|
134
|
+
* existing retry logic.
|
|
135
|
+
*/
|
|
136
|
+
export type SessionReplaySendEventsHandler = (request: SendEventsRequest) => Promise<Response>;
|
|
137
|
+
/**
|
|
138
|
+
* Custom transport for remote-config fetches. Same contract as {@link SessionReplaySendEventsHandler}.
|
|
139
|
+
*/
|
|
140
|
+
export type SessionReplayFetchConfigHandler = (request: FetchConfigRequest) => Promise<Response>;
|
|
83
141
|
export interface CrossOriginIframesConfig {
|
|
84
142
|
enabled: boolean;
|
|
85
143
|
/**
|
|
@@ -101,24 +159,6 @@ export interface CrossOriginIframesConfig {
|
|
|
101
159
|
export interface SessionReplayLocalConfig extends IConfig {
|
|
102
160
|
apiKey: string;
|
|
103
161
|
loggerProvider: ILogger;
|
|
104
|
-
/**
|
|
105
|
-
* Optional diagnostics client used to ship SR decision/targeting telemetry to Amplitude's
|
|
106
|
-
* diagnostics backend (independent of whether a replay is recorded). In plugin mode this is
|
|
107
|
-
* forwarded from the analytics SDK's already-initialized client. No-op when absent or when
|
|
108
|
-
* diagnostics is not sampled in. See DiagnosticsClient in @amplitude/analytics-core.
|
|
109
|
-
*/
|
|
110
|
-
diagnosticsClient?: IDiagnosticsClient;
|
|
111
|
-
/**
|
|
112
|
-
* Standalone SR only: when no `diagnosticsClient` is provided (i.e. SR is not running as the
|
|
113
|
-
* analytics plugin), opt in to having SR create its own client so TRC/recording diagnostics are
|
|
114
|
-
* still shipped. Ignored when a `diagnosticsClient` is supplied. @defaultValue false
|
|
115
|
-
*/
|
|
116
|
-
diagnosticsEnabled?: boolean;
|
|
117
|
-
/**
|
|
118
|
-
* Standalone SR only: sample rate (0..1) for the diagnostics client SR creates when none is
|
|
119
|
-
* provided. A positive value also implies opting in. @defaultValue 0
|
|
120
|
-
*/
|
|
121
|
-
diagnosticsSampleRate?: number;
|
|
122
162
|
/**
|
|
123
163
|
* LogLevel.None or LogLevel.Error or LogLevel.Warn or LogLevel.Verbose or LogLevel.Debug.
|
|
124
164
|
* Sets the log level.
|
|
@@ -348,6 +388,21 @@ export interface SessionReplayLocalConfig extends IConfig {
|
|
|
348
388
|
* @defaultValue 9000000
|
|
349
389
|
*/
|
|
350
390
|
maxSingleEventSizeBytes?: number;
|
|
391
|
+
/**
|
|
392
|
+
* Optional custom transport for replay event uploads. When provided, the SDK invokes this
|
|
393
|
+
* callback in place of its internal `fetch` for every event-upload attempt, passing a
|
|
394
|
+
* fully-formed {@link SendEventsRequest} (resolved URL, headers, serialized body). The SDK
|
|
395
|
+
* still owns batching, retry, serialization and error handling. Use it to attach custom
|
|
396
|
+
* auth (e.g. a JWT `Authorization` header) and route through an authenticated proxy.
|
|
397
|
+
*
|
|
398
|
+
* Works alongside `trackServerUrl`: the URL passed to the callback already respects it.
|
|
399
|
+
*/
|
|
400
|
+
handleSendEvents?: SessionReplaySendEventsHandler;
|
|
401
|
+
/**
|
|
402
|
+
* Optional custom transport for the remote-config fetch. Same contract as `handleSendEvents`
|
|
403
|
+
* but for the config GET. The URL passed to the callback already respects `configServerUrl`.
|
|
404
|
+
*/
|
|
405
|
+
handleFetchConfig?: SessionReplayFetchConfigHandler;
|
|
351
406
|
}
|
|
352
407
|
export interface FlushIntervalConfig {
|
|
353
408
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":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