@statsig/web-analytics 3.8.3 → 3.9.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 +3 -3
- package/src/AutoCapture.d.ts +2 -1
- package/src/AutoCapture.js +14 -7
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statsig/web-analytics",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@statsig/client-core": "3.
|
|
6
|
-
"@statsig/js-client": "3.
|
|
5
|
+
"@statsig/client-core": "3.9.0",
|
|
6
|
+
"@statsig/js-client": "3.9.0"
|
|
7
7
|
},
|
|
8
8
|
"jsdelivr": "./build/statsig-web-analytics.min.js",
|
|
9
9
|
"type": "commonjs",
|
package/src/AutoCapture.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export declare class AutoCapture {
|
|
|
18
18
|
private _disabledEvents;
|
|
19
19
|
private _previousLoggedPageViewUrl;
|
|
20
20
|
private _eventFilterFunc?;
|
|
21
|
+
private _hasLoggedPageViewEnd;
|
|
21
22
|
constructor(_client: PrecomputedEvaluationsInterface, options?: AutoCaptureOptions);
|
|
22
23
|
private _addEventHandlers;
|
|
23
24
|
private _addPageViewTracking;
|
|
@@ -26,8 +27,8 @@ export declare class AutoCapture {
|
|
|
26
27
|
private _logError;
|
|
27
28
|
private _logSessionStart;
|
|
28
29
|
private _tryLogPageView;
|
|
30
|
+
private _tryLogPageViewEnd;
|
|
29
31
|
private _logPerformance;
|
|
30
|
-
private _pageUnloadHandler;
|
|
31
32
|
private _enqueueAutoCapture;
|
|
32
33
|
private _scrollEventHandler;
|
|
33
34
|
private _isNewSession;
|
package/src/AutoCapture.js
CHANGED
|
@@ -31,6 +31,7 @@ class AutoCapture {
|
|
|
31
31
|
this._deepestScroll = 0;
|
|
32
32
|
this._disabledEvents = {};
|
|
33
33
|
this._previousLoggedPageViewUrl = null;
|
|
34
|
+
this._hasLoggedPageViewEnd = false;
|
|
34
35
|
const { sdkKey, errorBoundary, values } = _client.getContext();
|
|
35
36
|
this._disabledEvents = (_b = (_a = values === null || values === void 0 ? void 0 : values.auto_capture_settings) === null || _a === void 0 ? void 0 : _a.disabled_events) !== null && _b !== void 0 ? _b : {};
|
|
36
37
|
this._errorBoundary = errorBoundary;
|
|
@@ -61,7 +62,8 @@ class AutoCapture {
|
|
|
61
62
|
(0, Utils_1._registerEventHandler)(doc, 'click', eventHandler);
|
|
62
63
|
(0, Utils_1._registerEventHandler)(doc, 'submit', eventHandler);
|
|
63
64
|
(0, Utils_1._registerEventHandler)(win, 'error', eventHandler);
|
|
64
|
-
(0, Utils_1._registerEventHandler)(win, '
|
|
65
|
+
(0, Utils_1._registerEventHandler)(win, 'pagehide', () => this._tryLogPageViewEnd());
|
|
66
|
+
(0, Utils_1._registerEventHandler)(win, 'beforeunload', () => this._tryLogPageViewEnd());
|
|
65
67
|
(0, Utils_1._registerEventHandler)(win, 'scroll', () => this._scrollEventHandler());
|
|
66
68
|
}
|
|
67
69
|
_addPageViewTracking() {
|
|
@@ -147,12 +149,23 @@ class AutoCapture {
|
|
|
147
149
|
return;
|
|
148
150
|
}
|
|
149
151
|
this._previousLoggedPageViewUrl = url;
|
|
152
|
+
this._hasLoggedPageViewEnd = false;
|
|
150
153
|
const payload = (0, payloadUtils_1._gatherPageViewPayload)(url);
|
|
151
154
|
this._enqueueAutoCapture(AutoCaptureEvent_1.AutoCaptureEventName.PAGE_VIEW, (0, Utils_1._getSanitizedPageUrl)(), payload, {
|
|
152
155
|
flushImmediately: true,
|
|
153
156
|
addNewSessionMetadata: true,
|
|
154
157
|
});
|
|
155
158
|
}
|
|
159
|
+
_tryLogPageViewEnd() {
|
|
160
|
+
if (this._hasLoggedPageViewEnd) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
this._hasLoggedPageViewEnd = true;
|
|
164
|
+
this._enqueueAutoCapture(AutoCaptureEvent_1.AutoCaptureEventName.PAGE_VIEW_END, (0, Utils_1._getSanitizedPageUrl)(), {
|
|
165
|
+
scrollDepth: this._deepestScroll,
|
|
166
|
+
pageViewLength: Date.now() - this._startTime,
|
|
167
|
+
}, { flushImmediately: true });
|
|
168
|
+
}
|
|
156
169
|
_logPerformance() {
|
|
157
170
|
const win = (0, client_core_1._getWindowSafe)();
|
|
158
171
|
if (typeof (win === null || win === void 0 ? void 0 : win.performance) === 'undefined' ||
|
|
@@ -189,12 +202,6 @@ class AutoCapture {
|
|
|
189
202
|
this._enqueueAutoCapture(AutoCaptureEvent_1.AutoCaptureEventName.PERFORMANCE, (0, Utils_1._getSanitizedPageUrl)(), metadata);
|
|
190
203
|
}, 1);
|
|
191
204
|
}
|
|
192
|
-
_pageUnloadHandler() {
|
|
193
|
-
this._enqueueAutoCapture(AutoCaptureEvent_1.AutoCaptureEventName.PAGE_VIEW_END, (0, Utils_1._getSanitizedPageUrl)(), {
|
|
194
|
-
scrollDepth: this._deepestScroll,
|
|
195
|
-
pageViewLength: Date.now() - this._startTime,
|
|
196
|
-
}, { flushImmediately: true });
|
|
197
|
-
}
|
|
198
205
|
_enqueueAutoCapture(eventName, value, metadata, options) {
|
|
199
206
|
var _a, _b, _c;
|
|
200
207
|
const subname = eventName.slice('auto_capture::'.length);
|