onerway-analytics 1.1.0 → 1.3.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/README.md +337 -337
- package/dist/bundle/index.js +18 -13
- package/dist/bundle/index.js.map +2 -2
- package/dist/core/analytics.d.ts +1 -0
- package/dist/core/analytics.d.ts.map +1 -1
- package/dist/core/analytics.js +36 -12
- package/package.json +1 -1
package/dist/core/analytics.js
CHANGED
|
@@ -265,10 +265,11 @@ export class Analytics {
|
|
|
265
265
|
return;
|
|
266
266
|
const apiKey = this.resolveApiKey();
|
|
267
267
|
if (!apiKey) {
|
|
268
|
-
this.log('No API key configured, dropping events');
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
268
|
+
this.log('No API key configured, dropping events (retry disabled)');
|
|
269
|
+
// HOTFIX (production): localStorage persistence disabled. Original:
|
|
270
|
+
// for (const event of events) {
|
|
271
|
+
// StorageQueue.enqueue(event);
|
|
272
|
+
// }
|
|
272
273
|
return;
|
|
273
274
|
}
|
|
274
275
|
const payload = this.buildPayload(events);
|
|
@@ -278,7 +279,15 @@ export class Analytics {
|
|
|
278
279
|
}
|
|
279
280
|
catch (error) {
|
|
280
281
|
this.log(`Batch send failed (attempt ${retryCount + 1}/${this.config.maxRetryCount + 1}):`, error);
|
|
281
|
-
|
|
282
|
+
// ====================================================================
|
|
283
|
+
// HOTFIX (production): retry / localStorage persistence DISABLED.
|
|
284
|
+
// Reason: retry loop + parallel recoverFailedEvents + fire-and-forget
|
|
285
|
+
// setTimeout caused 70+ concurrent in-flight requests on network errors.
|
|
286
|
+
// DO NOT DELETE the block below — the original implementation must be
|
|
287
|
+
// restored once the retry mechanism is rewritten (track via ticket).
|
|
288
|
+
// ====================================================================
|
|
289
|
+
const retryEnabled = Analytics.RETRY_ENABLED;
|
|
290
|
+
if (retryEnabled && retryCount < this.config.maxRetryCount) {
|
|
282
291
|
const delay = 1000 * Math.pow(2, retryCount);
|
|
283
292
|
this.log(`Retrying in ${delay}ms...`);
|
|
284
293
|
this.retrying += 1;
|
|
@@ -291,10 +300,11 @@ export class Analytics {
|
|
|
291
300
|
}, delay);
|
|
292
301
|
}
|
|
293
302
|
else {
|
|
294
|
-
this.log('Max retries reached,
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
303
|
+
this.log('Max retries reached / retry disabled, dropping events');
|
|
304
|
+
// HOTFIX (production): localStorage persistence disabled. Original:
|
|
305
|
+
// for (const event of events) {
|
|
306
|
+
// StorageQueue.enqueue(event);
|
|
307
|
+
// }
|
|
298
308
|
}
|
|
299
309
|
}
|
|
300
310
|
}
|
|
@@ -314,6 +324,12 @@ export class Analytics {
|
|
|
314
324
|
return;
|
|
315
325
|
if (!this.sampled)
|
|
316
326
|
return;
|
|
327
|
+
if (!Analytics.RETRY_ENABLED) {
|
|
328
|
+
// HOTFIX (production): storage recovery disabled. Clean any stale items
|
|
329
|
+
// so they don't accumulate forever.
|
|
330
|
+
StorageQueue.clear();
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
317
333
|
const failedEvents = StorageQueue.recover();
|
|
318
334
|
if (failedEvents.length > 0) {
|
|
319
335
|
this.log(`Recovered ${failedEvents.length} failed events from storage`);
|
|
@@ -381,9 +397,11 @@ export class Analytics {
|
|
|
381
397
|
}
|
|
382
398
|
}
|
|
383
399
|
catch {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
400
|
+
// HOTFIX (production): localStorage persistence disabled. Original:
|
|
401
|
+
// for (const event of events) {
|
|
402
|
+
// StorageQueue.enqueue(event);
|
|
403
|
+
// }
|
|
404
|
+
this.log('Failed to flush buffer on unload, dropping events (retry disabled)');
|
|
387
405
|
}
|
|
388
406
|
};
|
|
389
407
|
this.unloadHandler = handler;
|
|
@@ -401,6 +419,12 @@ export class Analytics {
|
|
|
401
419
|
});
|
|
402
420
|
}
|
|
403
421
|
}
|
|
422
|
+
// HOTFIX (production): retry / recovery / localStorage persistence DISABLED.
|
|
423
|
+
// Reason: retry loop + parallel recoverFailedEvents + fire-and-forget
|
|
424
|
+
// setTimeout caused 70+ concurrent in-flight requests on network errors.
|
|
425
|
+
// Flip this flag to true (and uncomment the StorageQueue.enqueue blocks)
|
|
426
|
+
// to restore the original behavior once the retry mechanism is rewritten.
|
|
427
|
+
Analytics.RETRY_ENABLED = false;
|
|
404
428
|
export function createAnalytics(config) {
|
|
405
429
|
return new Analytics(config);
|
|
406
430
|
}
|