@formo/analytics 1.34.1 → 1.35.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.
@@ -80,7 +80,7 @@ var MIN_QUEUE_SIZE = 200; // 200 bytes
80
80
  // keepalive fetch requests. Payloads exceeding this are silently cancelled,
81
81
  // producing a TypeError: Failed to fetch that cannot be resolved by retrying.
82
82
  var KEEPALIVE_PAYLOAD_LIMIT = 64 * 1024; // 64kB
83
- var DEFAULT_FLUSH_INTERVAL = 1000 * 30; // 1 MINUTE
83
+ var DEFAULT_FLUSH_INTERVAL = 1000 * 30; // 30 SECONDS
84
84
  var MAX_FLUSH_INTERVAL = 1000 * 300; // 5 MINUTES
85
85
  var MIN_FLUSH_INTERVAL = 1000 * 10; // 10 SECONDS
86
86
  var EventQueue = /** @class */ (function () {
@@ -148,7 +148,12 @@ var EventQueue = /** @class */ (function () {
148
148
  this.flushAt = (0, utils_1.clampNumber)(options.flushAt || DEFAULT_FLUSH_AT, MAX_FLUSH_AT, MIN_FLUSH_AT);
149
149
  this.maxQueueSize = (0, utils_1.clampNumber)(options.maxQueueSize || DEFAULT_QUEUE_SIZE, MAX_QUEUE_SIZE, MIN_QUEUE_SIZE);
150
150
  this.flushIntervalMs = (0, utils_1.clampNumber)(options.flushInterval || DEFAULT_FLUSH_INTERVAL, MAX_FLUSH_INTERVAL, MIN_FLUSH_INTERVAL);
151
- this.flushed = true;
151
+ // Start un-flushed so the first event of the page load is sent
152
+ // immediately (see enqueue). Short visits — e.g. ad-click landings in
153
+ // mobile in-app browsers — often end with the webview process killed
154
+ // before any pagehide/visibilitychange fires, so an event that waits
155
+ // for the batch timer or a lifecycle flush is lost with the process.
156
+ this.flushed = false;
152
157
  this.errorHandler = options.errorHandler;
153
158
  this.pendingFlush = null;
154
159
  this.timer = null;
@@ -259,11 +264,11 @@ var EventQueue = /** @class */ (function () {
259
264
  // before opt-out. Drop everything rather than send post-withdrawal.
260
265
  if (this.canSend && !this.canSend()) {
261
266
  this.clear();
262
- callback();
267
+ safeCall(callback);
263
268
  return [2 /*return*/, Promise.resolve()];
264
269
  }
265
270
  if (!this.queue.length) {
266
- callback();
271
+ safeCall(callback);
267
272
  return [2 /*return*/, Promise.resolve()];
268
273
  }
269
274
  if (!this.pendingFlush) return [3 /*break*/, 2];
@@ -1,2 +1,2 @@
1
- export declare const version = "1.34.1";
1
+ export declare const version = "1.35.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -3,5 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
4
  // This file is auto-generated by scripts/update-version.js during npm version
5
5
  // Do not edit manually - it will be overwritten
6
- exports.version = '1.34.1';
6
+ exports.version = '1.35.0';
7
7
  //# sourceMappingURL=version.js.map
@@ -74,7 +74,7 @@ var MIN_QUEUE_SIZE = 200; // 200 bytes
74
74
  // keepalive fetch requests. Payloads exceeding this are silently cancelled,
75
75
  // producing a TypeError: Failed to fetch that cannot be resolved by retrying.
76
76
  var KEEPALIVE_PAYLOAD_LIMIT = 64 * 1024; // 64kB
77
- var DEFAULT_FLUSH_INTERVAL = 1000 * 30; // 1 MINUTE
77
+ var DEFAULT_FLUSH_INTERVAL = 1000 * 30; // 30 SECONDS
78
78
  var MAX_FLUSH_INTERVAL = 1000 * 300; // 5 MINUTES
79
79
  var MIN_FLUSH_INTERVAL = 1000 * 10; // 10 SECONDS
80
80
  var EventQueue = /** @class */ (function () {
@@ -142,7 +142,12 @@ var EventQueue = /** @class */ (function () {
142
142
  this.flushAt = clampNumber(options.flushAt || DEFAULT_FLUSH_AT, MAX_FLUSH_AT, MIN_FLUSH_AT);
143
143
  this.maxQueueSize = clampNumber(options.maxQueueSize || DEFAULT_QUEUE_SIZE, MAX_QUEUE_SIZE, MIN_QUEUE_SIZE);
144
144
  this.flushIntervalMs = clampNumber(options.flushInterval || DEFAULT_FLUSH_INTERVAL, MAX_FLUSH_INTERVAL, MIN_FLUSH_INTERVAL);
145
- this.flushed = true;
145
+ // Start un-flushed so the first event of the page load is sent
146
+ // immediately (see enqueue). Short visits — e.g. ad-click landings in
147
+ // mobile in-app browsers — often end with the webview process killed
148
+ // before any pagehide/visibilitychange fires, so an event that waits
149
+ // for the batch timer or a lifecycle flush is lost with the process.
150
+ this.flushed = false;
146
151
  this.errorHandler = options.errorHandler;
147
152
  this.pendingFlush = null;
148
153
  this.timer = null;
@@ -253,11 +258,11 @@ var EventQueue = /** @class */ (function () {
253
258
  // before opt-out. Drop everything rather than send post-withdrawal.
254
259
  if (this.canSend && !this.canSend()) {
255
260
  this.clear();
256
- callback();
261
+ safeCall(callback);
257
262
  return [2 /*return*/, Promise.resolve()];
258
263
  }
259
264
  if (!this.queue.length) {
260
- callback();
265
+ safeCall(callback);
261
266
  return [2 /*return*/, Promise.resolve()];
262
267
  }
263
268
  if (!this.pendingFlush) return [3 /*break*/, 2];
@@ -1,2 +1,2 @@
1
- export declare const version = "1.34.1";
1
+ export declare const version = "1.35.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,4 +1,4 @@
1
1
  // This file is auto-generated by scripts/update-version.js during npm version
2
2
  // Do not edit manually - it will be overwritten
3
- export var version = '1.34.1';
3
+ export var version = '1.35.0';
4
4
  //# sourceMappingURL=version.js.map