@statsig/web-analytics 3.32.2 → 3.32.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statsig/web-analytics",
3
- "version": "3.32.2",
3
+ "version": "3.32.4",
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.32.2",
13
- "@statsig/js-client": "3.32.2",
12
+ "@statsig/client-core": "3.32.4",
13
+ "@statsig/js-client": "3.32.4",
14
14
  "web-vitals": "5.0.3"
15
15
  },
16
16
  "jsdelivr": "./build/statsig-web-analytics.min.js",
@@ -237,6 +237,9 @@ class AutoCapture {
237
237
  }
238
238
  }
239
239
  _tryLogPageView(navigationType) {
240
+ if (this._webVitalsManager.flushPendingMetrics()) {
241
+ this._flushImmediately();
242
+ }
240
243
  const url = (0, commonUtils_1._getSafeUrl)();
241
244
  const last = this._previousLoggedPageViewUrl;
242
245
  if (last && url.pathname === last.pathname) {
@@ -263,6 +266,9 @@ class AutoCapture {
263
266
  this._engagementManager.bumpInactiveTimer();
264
267
  }
265
268
  _tryLogPageViewEnd(dueToInactivity = false) {
269
+ if (this._webVitalsManager.flushPendingMetrics()) {
270
+ this._flushImmediately();
271
+ }
266
272
  if (this._hasLoggedPageViewEnd) {
267
273
  return;
268
274
  }
@@ -7,6 +7,7 @@ export declare class WebVitalsManager {
7
7
  private _metricEvent;
8
8
  constructor(_enqueueFn: (eventName: AutoCaptureEventName, value: string, metadata: Record<string, unknown>) => void, _errorBoundary: ErrorBoundary);
9
9
  startTracking(): void;
10
+ flushPendingMetrics(): boolean;
10
11
  private _handleMetric;
11
12
  private _enqueueWebVitalsAutoCaptureEvent;
12
13
  }
@@ -40,6 +40,13 @@ class WebVitalsManager {
40
40
  this._errorBoundary.logError('autoCapture:WebVitalsManager', error);
41
41
  }
42
42
  }
43
+ flushPendingMetrics() {
44
+ if (this._metricEvent.metrics.length === 0) {
45
+ return false;
46
+ }
47
+ this._enqueueWebVitalsAutoCaptureEvent();
48
+ return true;
49
+ }
43
50
  _handleMetric(metric) {
44
51
  if (this._metricEvent.firstMetricTimestamp === undefined) {
45
52
  this._metricEvent.firstMetricTimestamp = Date.now();