Skip to content

Commit 818fc23

Browse files
committed
fix(sdk): replaced navigator.sendBeacon with fetch
1 parent af2dda0 commit 818fc23

2 files changed

Lines changed: 6 additions & 22 deletions

File tree

.changeset/three-results-double.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@flagix/js-sdk": patch
3+
---
4+
5+
Fixed an issue where evaluation and event tracking requests were being blocked by certain browser privacy extensions and ad-blockers. Replaced navigator.sendBeacon with fetch + keepalive to improve the delivery reliability

sdk/javascript/src/client.ts

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -427,13 +427,6 @@ export class FlagixClient {
427427

428428
const payloadJson = JSON.stringify(payload);
429429

430-
if (typeof navigator !== "undefined" && navigator.sendBeacon) {
431-
const blob = new Blob([payloadJson], { type: "application/json" });
432-
if (navigator.sendBeacon(url, blob)) {
433-
return;
434-
}
435-
}
436-
437430
this.fireAndForgetFetch(url, payloadJson);
438431
}
439432

@@ -490,21 +483,7 @@ export class FlagixClient {
490483

491484
const payloadJson = JSON.stringify(payload);
492485

493-
if (typeof navigator !== "undefined" && navigator.sendBeacon) {
494-
const blob = new Blob([payloadJson], { type: "application/json" });
495-
496-
const success = navigator.sendBeacon(url, blob);
497-
498-
if (success) {
499-
log("info", `Successfully queued beacon for ${flagKey}.`);
500-
return;
501-
}
502-
503-
log("warn", `Beacon queue full for ${flagKey}. Falling back to fetch.`);
504-
this.fireAndForgetFetch(url, payloadJson);
505-
} else {
506-
this.fireAndForgetFetch(url, payloadJson);
507-
}
486+
this.fireAndForgetFetch(url, payloadJson);
508487
}
509488

510489
private fireAndForgetFetch(url: string, payloadJson: string): void {

0 commit comments

Comments
 (0)