@statsig/web-analytics 3.29.1 → 3.30.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/package.json +3 -3
- package/src/AutoCapture.d.ts +1 -1
- package/src/AutoCapture.js +38 -12
- package/src/ConsoleLogManager.js +9 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statsig/web-analytics",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.30.1",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"homepage": "https://github.com/statsig-io/js-client-monorepo",
|
|
6
6
|
"repository": {
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"directory": "packages/web-analytics"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@statsig/client-core": "3.
|
|
13
|
-
"@statsig/js-client": "3.
|
|
12
|
+
"@statsig/client-core": "3.30.1",
|
|
13
|
+
"@statsig/js-client": "3.30.1",
|
|
14
14
|
"web-vitals": "5.0.3"
|
|
15
15
|
},
|
|
16
16
|
"jsdelivr": "./build/statsig-web-analytics.min.js",
|
package/src/AutoCapture.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare class StatsigAutoCapturePlugin implements StatsigPlugin<Precomput
|
|
|
6
6
|
constructor(_options?: AutoCaptureOptions | undefined);
|
|
7
7
|
bind(client: PrecomputedEvaluationsInterface): void;
|
|
8
8
|
}
|
|
9
|
-
export declare function runStatsigAutoCapture(client: PrecomputedEvaluationsInterface, options?: AutoCaptureOptions): AutoCapture;
|
|
9
|
+
export declare function runStatsigAutoCapture(client: PrecomputedEvaluationsInterface, options?: AutoCaptureOptions): AutoCapture | null;
|
|
10
10
|
export declare class AutoCapture {
|
|
11
11
|
private _client;
|
|
12
12
|
private _errorBoundary;
|
package/src/AutoCapture.js
CHANGED
|
@@ -29,6 +29,10 @@ class StatsigAutoCapturePlugin {
|
|
|
29
29
|
exports.StatsigAutoCapturePlugin = StatsigAutoCapturePlugin;
|
|
30
30
|
function runStatsigAutoCapture(client, options) {
|
|
31
31
|
var _a;
|
|
32
|
+
// Early exit for server-side rendering - plugins should only run in browser
|
|
33
|
+
if ((0, client_core_1._isServerEnv)()) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
32
36
|
const { sdkKey } = client.getContext();
|
|
33
37
|
if (!(0, client_core_1._isServerEnv)()) {
|
|
34
38
|
const global = (0, client_core_1._getStatsigGlobal)();
|
|
@@ -113,18 +117,40 @@ class AutoCapture {
|
|
|
113
117
|
return;
|
|
114
118
|
}
|
|
115
119
|
(0, commonUtils_1._registerEventHandler)(win, 'popstate', () => this._tryLogPageView('popstate'));
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
120
|
+
if (win.history &&
|
|
121
|
+
typeof Proxy === 'function' &&
|
|
122
|
+
typeof win.history.pushState === 'function') {
|
|
123
|
+
try {
|
|
124
|
+
const originalPushState = win.history.pushState;
|
|
125
|
+
win.history.pushState = new Proxy(originalPushState, {
|
|
126
|
+
apply: (target, thisArg, [state, unused, url]) => {
|
|
127
|
+
const result = target.apply(thisArg, [state, unused, url]);
|
|
128
|
+
this._tryLogPageView('pushstate');
|
|
129
|
+
return result;
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
catch (e) {
|
|
134
|
+
// Silently fail if Proxy creation is not supported
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (win.history &&
|
|
138
|
+
typeof Proxy === 'function' &&
|
|
139
|
+
typeof win.history.replaceState === 'function') {
|
|
140
|
+
try {
|
|
141
|
+
const originalReplaceState = win.history.replaceState;
|
|
142
|
+
win.history.replaceState = new Proxy(originalReplaceState, {
|
|
143
|
+
apply: (target, thisArg, [state, unused, url]) => {
|
|
144
|
+
const result = target.apply(thisArg, [state, unused, url]);
|
|
145
|
+
this._tryLogPageView('replacestate');
|
|
146
|
+
return result;
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
catch (e) {
|
|
151
|
+
// Silently fail if Proxy creation is not supported (important-comment)
|
|
152
|
+
}
|
|
153
|
+
}
|
|
128
154
|
this._tryLogPageView();
|
|
129
155
|
}
|
|
130
156
|
_autoLogEvent(event) {
|
package/src/ConsoleLogManager.js
CHANGED
|
@@ -15,9 +15,9 @@ const ConsoleLogPriority = {
|
|
|
15
15
|
warn: 40,
|
|
16
16
|
error: 50,
|
|
17
17
|
};
|
|
18
|
-
const DEFAULT_MAX_KEYS =
|
|
18
|
+
const DEFAULT_MAX_KEYS = 50;
|
|
19
19
|
const DEFAULT_MAX_DEPTH = 10;
|
|
20
|
-
const DEFAULT_MAX_STRING_LENGTH =
|
|
20
|
+
const DEFAULT_MAX_STRING_LENGTH = 2500;
|
|
21
21
|
class ConsoleLogManager {
|
|
22
22
|
constructor(_enqueueFn, _errorBoundary, _options) {
|
|
23
23
|
var _a, _b, _c, _d;
|
|
@@ -88,13 +88,18 @@ class ConsoleLogManager {
|
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
_enqueueConsoleLog(level, payload, trace) {
|
|
91
|
-
if (!this._shouldLog())
|
|
91
|
+
if (!this._shouldLog(payload))
|
|
92
92
|
return;
|
|
93
93
|
const metadata = Object.assign({ status: level === 'log' ? 'info' : level, log_level: level, payload,
|
|
94
94
|
trace, timestamp: Date.now(), source: this.__source }, (0, metadataUtils_1._gatherAllMetadata)((0, commonUtils_1._getSafeUrl)()));
|
|
95
95
|
this._enqueueFn(AutoCaptureEvent_1.AutoCaptureEventName.CONSOLE_LOG, payload.join(' '), metadata);
|
|
96
96
|
}
|
|
97
|
-
_shouldLog() {
|
|
97
|
+
_shouldLog(payload) {
|
|
98
|
+
for (const p of payload) {
|
|
99
|
+
if (p.includes('[Statsig]')) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
98
103
|
if (!this._options.sampleRate ||
|
|
99
104
|
typeof this._options.sampleRate !== 'number' ||
|
|
100
105
|
this._options.sampleRate <= 0 ||
|