@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.
- package/.turbo/turbo-build.log +6 -6
- package/CHANGELOG.md +12 -0
- package/dist/index.js +3 -20
- package/dist/index.mjs +3 -20
- package/package.json +1 -1
- package/src/client.ts +3 -24
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @flagix/js-sdk@1.
|
|
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
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
[34mCLI[39m Cleaning output folder
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
11
|
[34mESM[39m Build start
|
|
12
|
-
[32mESM[39m [1mdist/index.mjs [22m[
|
|
13
|
-
[32mESM[39m ⚡️ Build success in
|
|
14
|
-
[32mCJS[39m [1mdist/index.js [22m[32m18.
|
|
15
|
-
[32mCJS[39m ⚡️ Build success in
|
|
12
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m16.41 KB[39m
|
|
13
|
+
[32mESM[39m ⚡️ Build success in 54ms
|
|
14
|
+
[32mCJS[39m [1mdist/index.js [22m[32m18.09 KB[39m
|
|
15
|
+
[32mCJS[39m ⚡️ Build success in 55ms
|
|
16
16
|
[34mDTS[39m Build start
|
|
17
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
+
[32mDTS[39m ⚡️ Build success in 1889ms
|
|
18
18
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m2.41 KB[39m
|
|
19
19
|
[32mDTS[39m [1mdist/index.d.mts [22m[32m2.41 KB[39m
|
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/
|
|
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/
|
|
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
|
-
|
|
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/
|
|
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/
|
|
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
|
-
|
|
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
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/
|
|
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/
|
|
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
|
-
|
|
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 {
|