@statsig/client-core 3.30.2 → 3.31.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/package.json +1 -1
- package/src/EventBatch.d.ts +8 -0
- package/src/EventBatch.js +14 -0
- package/src/EventRetryConstants.d.ts +7 -0
- package/src/EventRetryConstants.js +12 -0
- package/src/InitializeResponse.d.ts +7 -0
- package/src/SafeJs.d.ts +1 -0
- package/src/SafeJs.js +12 -1
- package/src/StatsigMetadata.d.ts +1 -1
- package/src/StatsigMetadata.js +1 -1
- package/src/StatsigUser.js +11 -12
package/package.json
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EventBatch = void 0;
|
|
4
|
+
class EventBatch {
|
|
5
|
+
constructor(events) {
|
|
6
|
+
this.attempts = 0;
|
|
7
|
+
this.createdAt = Date.now();
|
|
8
|
+
this.events = events;
|
|
9
|
+
}
|
|
10
|
+
incrementAttempts() {
|
|
11
|
+
this.attempts++;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.EventBatch = EventBatch;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EventRetryConstants = void 0;
|
|
4
|
+
exports.EventRetryConstants = {
|
|
5
|
+
MAX_RETRY_ATTEMPTS: 5,
|
|
6
|
+
DEFAULT_BATCH_SIZE: 100,
|
|
7
|
+
MAX_PENDING_BATCHES: 10,
|
|
8
|
+
TICK_INTERVAL_MS: 1000,
|
|
9
|
+
get MAX_QUEUED_EVENTS() {
|
|
10
|
+
return this.DEFAULT_BATCH_SIZE * this.MAX_PENDING_BATCHES;
|
|
11
|
+
},
|
|
12
|
+
};
|
|
@@ -9,11 +9,18 @@ type SessionReplayFields = {
|
|
|
9
9
|
passes_session_recording_targeting?: boolean;
|
|
10
10
|
session_recording_event_triggers?: Record<string, SessionReplayTrigger>;
|
|
11
11
|
session_recording_exposure_triggers?: Record<string, SessionReplayTrigger>;
|
|
12
|
+
session_recording_privacy_settings?: SessionReplayPrivacySettings;
|
|
12
13
|
};
|
|
13
14
|
type SessionReplayTrigger = {
|
|
14
15
|
values?: string[];
|
|
15
16
|
passes_sampling?: boolean;
|
|
16
17
|
};
|
|
18
|
+
export type SessionReplayPrivacySettings = {
|
|
19
|
+
privacy_mode?: 'min' | 'input' | 'max';
|
|
20
|
+
unmasked_elements?: string[];
|
|
21
|
+
masked_elements?: string[];
|
|
22
|
+
blocked_elements?: string[];
|
|
23
|
+
};
|
|
17
24
|
type AutoCaptureFields = {
|
|
18
25
|
auto_capture_settings?: {
|
|
19
26
|
disabled_events: Record<string, boolean>;
|
package/src/SafeJs.d.ts
CHANGED
|
@@ -5,3 +5,4 @@ export declare const _addWindowEventListenerSafe: (key: string, listener: () =>
|
|
|
5
5
|
export declare const _addDocumentEventListenerSafe: (key: string, listener: () => void) => void;
|
|
6
6
|
export declare const _getCurrentPageUrlSafe: () => string | undefined;
|
|
7
7
|
export declare const _getUnloadEvent: () => string;
|
|
8
|
+
export declare const _cloneObject: <T>(tag: string, obj: T) => T | null;
|
package/src/SafeJs.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._getUnloadEvent = exports._getCurrentPageUrlSafe = exports._addDocumentEventListenerSafe = exports._addWindowEventListenerSafe = exports._isServerEnv = exports._getDocumentSafe = exports._getWindowSafe = void 0;
|
|
3
|
+
exports._cloneObject = exports._getUnloadEvent = exports._getCurrentPageUrlSafe = exports._addDocumentEventListenerSafe = exports._addWindowEventListenerSafe = exports._isServerEnv = exports._getDocumentSafe = exports._getWindowSafe = void 0;
|
|
4
|
+
const Log_1 = require("./Log");
|
|
4
5
|
const _getWindowSafe = () => {
|
|
5
6
|
return typeof window !== 'undefined' ? window : null;
|
|
6
7
|
};
|
|
@@ -55,3 +56,13 @@ const _getUnloadEvent = () => {
|
|
|
55
56
|
return eventType;
|
|
56
57
|
};
|
|
57
58
|
exports._getUnloadEvent = _getUnloadEvent;
|
|
59
|
+
const _cloneObject = (tag, obj) => {
|
|
60
|
+
try {
|
|
61
|
+
return JSON.parse(JSON.stringify(obj));
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
Log_1.Log.error(`Failed to clone object ${tag}`);
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
exports._cloneObject = _cloneObject;
|
package/src/StatsigMetadata.d.ts
CHANGED
package/src/StatsigMetadata.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StatsigMetadataProvider = exports.SDK_VERSION = void 0;
|
|
4
|
-
exports.SDK_VERSION = '3.
|
|
4
|
+
exports.SDK_VERSION = '3.31.0';
|
|
5
5
|
let metadata = {
|
|
6
6
|
sdkVersion: exports.SDK_VERSION,
|
|
7
7
|
sdkType: 'js-mono', // js-mono is overwritten by Precomp and OnDevice clients
|
package/src/StatsigUser.js
CHANGED
|
@@ -3,21 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports._getFullUserHash = exports._normalizeUser = void 0;
|
|
4
4
|
const Hashing_1 = require("./Hashing");
|
|
5
5
|
const Log_1 = require("./Log");
|
|
6
|
+
const SafeJs_1 = require("./SafeJs");
|
|
6
7
|
function _normalizeUser(original, options, fallbackEnvironment) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
copy.statsigEnvironment = options.environment;
|
|
11
|
-
}
|
|
12
|
-
else if (fallbackEnvironment != null) {
|
|
13
|
-
copy.statsigEnvironment = { tier: fallbackEnvironment };
|
|
14
|
-
}
|
|
15
|
-
return copy;
|
|
16
|
-
}
|
|
17
|
-
catch (error) {
|
|
18
|
-
Log_1.Log.error('Failed to JSON.stringify user');
|
|
8
|
+
const copy = (0, SafeJs_1._cloneObject)('StatsigUser', original);
|
|
9
|
+
if (copy == null) {
|
|
10
|
+
Log_1.Log.error('Failed to clone user');
|
|
19
11
|
return { statsigEnvironment: undefined };
|
|
20
12
|
}
|
|
13
|
+
if (options != null && options.environment != null) {
|
|
14
|
+
copy.statsigEnvironment = options.environment;
|
|
15
|
+
}
|
|
16
|
+
else if (fallbackEnvironment != null) {
|
|
17
|
+
copy.statsigEnvironment = { tier: fallbackEnvironment };
|
|
18
|
+
}
|
|
19
|
+
return copy;
|
|
21
20
|
}
|
|
22
21
|
exports._normalizeUser = _normalizeUser;
|
|
23
22
|
function _getFullUserHash(user) {
|