@flagix/js-sdk 1.3.0 → 1.4.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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @flagix/js-sdk@1.3.0 build /home/runner/work/flagix/flagix/sdk/javascript
2
+ > @flagix/js-sdk@1.4.0 build /home/runner/work/flagix/flagix/sdk/javascript
3
3
  > tsup src/index.ts --format cjs,esm --dts --clean
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -9,11 +9,11 @@
9
9
  CLI Cleaning output folder
10
10
  CJS Build start
11
11
  ESM Build start
12
- ESM dist/index.mjs 17.07 KB
13
- ESM ⚡️ Build success in 57ms
14
- CJS dist/index.js 18.75 KB
15
- CJS ⚡️ Build success in 58ms
12
+ ESM dist/index.mjs 16.41 KB
13
+ ESM ⚡️ Build success in 54ms
14
+ CJS dist/index.js 18.09 KB
15
+ CJS ⚡️ Build success in 55ms
16
16
  DTS Build start
17
- DTS ⚡️ Build success in 1849ms
17
+ DTS ⚡️ Build success in 1889ms
18
18
  DTS dist/index.d.ts 2.41 KB
19
19
  DTS dist/index.d.mts 2.41 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @flagix/js-sdk
2
2
 
3
+ ## 1.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - f452756: migrated internal tracking and evaluation endpoints to a generic /api/sync path. This change is to improve the SDK reliability by bypassing aggressive tracking filters in browser privacy extensions and ad-blockers
8
+
9
+ ## 1.3.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 818fc23: 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
14
+
3
15
  ## 1.3.0
4
16
 
5
17
  ### Minor Changes
package/dist/index.js CHANGED
@@ -395,7 +395,7 @@ var FlagixClient = class {
395
395
  * Records a custom event (conversion) for analytics and A/B testing.
396
396
  */
397
397
  track(eventName, properties, contextOverrides) {
398
- const url = `${this.apiBaseUrl}/api/track/event`;
398
+ const url = `${this.apiBaseUrl}/api/sync/event`;
399
399
  const finalContext = { ...this.context, ...contextOverrides };
400
400
  const distinctId = (0, import_evaluation_core.resolveIdentifier)(finalContext);
401
401
  const payload = {
@@ -406,12 +406,6 @@ var FlagixClient = class {
406
406
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
407
407
  };
408
408
  const payloadJson = JSON.stringify(payload);
409
- if (typeof navigator !== "undefined" && navigator.sendBeacon) {
410
- const blob = new Blob([payloadJson], { type: "application/json" });
411
- if (navigator.sendBeacon(url, blob)) {
412
- return;
413
- }
414
- }
415
409
  this.fireAndForgetFetch(url, payloadJson);
416
410
  }
417
411
  /**
@@ -442,7 +436,7 @@ var FlagixClient = class {
442
436
  * Asynchronously sends an evaluation event to the backend tracking service.
443
437
  */
444
438
  trackEvaluation(flagKey, result, context) {
445
- const url = `${this.apiBaseUrl}/api/track/evaluation`;
439
+ const url = `${this.apiBaseUrl}/api/sync/evaluation`;
446
440
  const distinctId = (0, import_evaluation_core.resolveIdentifier)(context);
447
441
  const payload = {
448
442
  apiKey: this.apiKey,
@@ -455,18 +449,7 @@ var FlagixClient = class {
455
449
  evaluatedAt: (/* @__PURE__ */ new Date()).toISOString()
456
450
  };
457
451
  const payloadJson = JSON.stringify(payload);
458
- if (typeof navigator !== "undefined" && navigator.sendBeacon) {
459
- const blob = new Blob([payloadJson], { type: "application/json" });
460
- const success = navigator.sendBeacon(url, blob);
461
- if (success) {
462
- log("info", `Successfully queued beacon for ${flagKey}.`);
463
- return;
464
- }
465
- log("warn", `Beacon queue full for ${flagKey}. Falling back to fetch.`);
466
- this.fireAndForgetFetch(url, payloadJson);
467
- } else {
468
- this.fireAndForgetFetch(url, payloadJson);
469
- }
452
+ this.fireAndForgetFetch(url, payloadJson);
470
453
  }
471
454
  fireAndForgetFetch(url, payloadJson) {
472
455
  fetch(url, {
package/dist/index.mjs CHANGED
@@ -359,7 +359,7 @@ var FlagixClient = class {
359
359
  * Records a custom event (conversion) for analytics and A/B testing.
360
360
  */
361
361
  track(eventName, properties, contextOverrides) {
362
- const url = `${this.apiBaseUrl}/api/track/event`;
362
+ const url = `${this.apiBaseUrl}/api/sync/event`;
363
363
  const finalContext = { ...this.context, ...contextOverrides };
364
364
  const distinctId = resolveIdentifier(finalContext);
365
365
  const payload = {
@@ -370,12 +370,6 @@ var FlagixClient = class {
370
370
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
371
371
  };
372
372
  const payloadJson = JSON.stringify(payload);
373
- if (typeof navigator !== "undefined" && navigator.sendBeacon) {
374
- const blob = new Blob([payloadJson], { type: "application/json" });
375
- if (navigator.sendBeacon(url, blob)) {
376
- return;
377
- }
378
- }
379
373
  this.fireAndForgetFetch(url, payloadJson);
380
374
  }
381
375
  /**
@@ -406,7 +400,7 @@ var FlagixClient = class {
406
400
  * Asynchronously sends an evaluation event to the backend tracking service.
407
401
  */
408
402
  trackEvaluation(flagKey, result, context) {
409
- const url = `${this.apiBaseUrl}/api/track/evaluation`;
403
+ const url = `${this.apiBaseUrl}/api/sync/evaluation`;
410
404
  const distinctId = resolveIdentifier(context);
411
405
  const payload = {
412
406
  apiKey: this.apiKey,
@@ -419,18 +413,7 @@ var FlagixClient = class {
419
413
  evaluatedAt: (/* @__PURE__ */ new Date()).toISOString()
420
414
  };
421
415
  const payloadJson = JSON.stringify(payload);
422
- if (typeof navigator !== "undefined" && navigator.sendBeacon) {
423
- const blob = new Blob([payloadJson], { type: "application/json" });
424
- const success = navigator.sendBeacon(url, blob);
425
- if (success) {
426
- log("info", `Successfully queued beacon for ${flagKey}.`);
427
- return;
428
- }
429
- log("warn", `Beacon queue full for ${flagKey}. Falling back to fetch.`);
430
- this.fireAndForgetFetch(url, payloadJson);
431
- } else {
432
- this.fireAndForgetFetch(url, payloadJson);
433
- }
416
+ this.fireAndForgetFetch(url, payloadJson);
434
417
  }
435
418
  fireAndForgetFetch(url, payloadJson) {
436
419
  fetch(url, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flagix/js-sdk",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Flagix Javascript SDK",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
package/src/client.ts CHANGED
@@ -412,7 +412,7 @@ export class FlagixClient {
412
412
  properties?: Record<string, unknown>,
413
413
  contextOverrides?: EvaluationContext
414
414
  ): void {
415
- const url = `${this.apiBaseUrl}/api/track/event`;
415
+ const url = `${this.apiBaseUrl}/api/sync/event`;
416
416
 
417
417
  const finalContext = { ...this.context, ...contextOverrides };
418
418
  const distinctId = resolveIdentifier(finalContext);
@@ -427,13 +427,6 @@ export class FlagixClient {
427
427
 
428
428
  const payloadJson = JSON.stringify(payload);
429
429
 
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
-
437
430
  this.fireAndForgetFetch(url, payloadJson);
438
431
  }
439
432
 
@@ -473,7 +466,7 @@ export class FlagixClient {
473
466
  result: FlagVariation,
474
467
  context: EvaluationContext
475
468
  ): void {
476
- const url = `${this.apiBaseUrl}/api/track/evaluation`;
469
+ const url = `${this.apiBaseUrl}/api/sync/evaluation`;
477
470
 
478
471
  const distinctId = resolveIdentifier(context);
479
472
 
@@ -490,21 +483,7 @@ export class FlagixClient {
490
483
 
491
484
  const payloadJson = JSON.stringify(payload);
492
485
 
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);
508
487
  }
509
488
 
510
489
  private fireAndForgetFetch(url: string, payloadJson: string): void {