@shellapps/experience 1.15.0 → 1.15.1
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/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +14 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -376,12 +376,16 @@ declare class FeatureFlagClient {
|
|
|
376
376
|
private transport;
|
|
377
377
|
private appId;
|
|
378
378
|
private profileId;
|
|
379
|
+
private sessionId;
|
|
379
380
|
private flagCache;
|
|
380
381
|
private cacheTimeoutMs;
|
|
381
382
|
private eventSource;
|
|
382
383
|
private debug;
|
|
383
384
|
constructor(transport: Transport, appId: string, debug?: boolean);
|
|
384
385
|
setProfileId(profileId: string): void;
|
|
386
|
+
setSessionId(sessionId: string): void;
|
|
387
|
+
/** Returns profileId if logged in, otherwise sessionId as anonymous identifier */
|
|
388
|
+
private getResolverId;
|
|
385
389
|
fetchFlags(): Promise<void>;
|
|
386
390
|
getFlag<T>(key: string, defaultValue: T): T;
|
|
387
391
|
getFlagSync<T>(key: string, defaultValue: T): T;
|
package/dist/index.d.ts
CHANGED
|
@@ -376,12 +376,16 @@ declare class FeatureFlagClient {
|
|
|
376
376
|
private transport;
|
|
377
377
|
private appId;
|
|
378
378
|
private profileId;
|
|
379
|
+
private sessionId;
|
|
379
380
|
private flagCache;
|
|
380
381
|
private cacheTimeoutMs;
|
|
381
382
|
private eventSource;
|
|
382
383
|
private debug;
|
|
383
384
|
constructor(transport: Transport, appId: string, debug?: boolean);
|
|
384
385
|
setProfileId(profileId: string): void;
|
|
386
|
+
setSessionId(sessionId: string): void;
|
|
387
|
+
/** Returns profileId if logged in, otherwise sessionId as anonymous identifier */
|
|
388
|
+
private getResolverId;
|
|
385
389
|
fetchFlags(): Promise<void>;
|
|
386
390
|
getFlag<T>(key: string, defaultValue: T): T;
|
|
387
391
|
getFlagSync<T>(key: string, defaultValue: T): T;
|
package/dist/index.js
CHANGED
|
@@ -1840,6 +1840,7 @@ var DataTTracker = class {
|
|
|
1840
1840
|
var FeatureFlagClient = class {
|
|
1841
1841
|
constructor(transport, appId, debug = false) {
|
|
1842
1842
|
this.profileId = null;
|
|
1843
|
+
this.sessionId = null;
|
|
1843
1844
|
this.flagCache = /* @__PURE__ */ new Map();
|
|
1844
1845
|
this.cacheTimeoutMs = 5 * 60 * 1e3;
|
|
1845
1846
|
// 5 minutes
|
|
@@ -1853,9 +1854,17 @@ var FeatureFlagClient = class {
|
|
|
1853
1854
|
this.profileId = profileId;
|
|
1854
1855
|
this.flagCache.clear();
|
|
1855
1856
|
}
|
|
1857
|
+
setSessionId(sessionId) {
|
|
1858
|
+
this.sessionId = sessionId;
|
|
1859
|
+
}
|
|
1860
|
+
/** Returns profileId if logged in, otherwise sessionId as anonymous identifier */
|
|
1861
|
+
getResolverId() {
|
|
1862
|
+
return this.profileId || this.sessionId || void 0;
|
|
1863
|
+
}
|
|
1856
1864
|
async fetchFlags() {
|
|
1857
1865
|
try {
|
|
1858
|
-
const
|
|
1866
|
+
const resolverId = this.getResolverId();
|
|
1867
|
+
const flags = await this.transport.fetchFlags(this.appId, resolverId);
|
|
1859
1868
|
const now = Date.now();
|
|
1860
1869
|
for (const [key, value] of Object.entries(flags)) {
|
|
1861
1870
|
this.flagCache.set(key, {
|
|
@@ -1951,8 +1960,9 @@ var FeatureFlagClient = class {
|
|
|
1951
1960
|
const baseEndpoint = endpoint || this.transport["config"].endpoint;
|
|
1952
1961
|
const streamUrl = `${baseEndpoint}/api/v1/flags/${this.appId}/resolve/stream`;
|
|
1953
1962
|
const url = new URL(streamUrl);
|
|
1954
|
-
|
|
1955
|
-
|
|
1963
|
+
const resolverId = this.getResolverId();
|
|
1964
|
+
if (resolverId) {
|
|
1965
|
+
url.searchParams.set("profileId", resolverId);
|
|
1956
1966
|
}
|
|
1957
1967
|
try {
|
|
1958
1968
|
this.eventSource = new EventSource(url.toString());
|
|
@@ -2384,6 +2394,7 @@ var _Experience = class _Experience {
|
|
|
2384
2394
|
this.autoTracker = new AutoTracker(this.batcher, this.sessionManager.getSessionId());
|
|
2385
2395
|
this.dataTTracker = new DataTTracker(this.batcher, this.sessionManager.getSessionId());
|
|
2386
2396
|
this.flagClient = new FeatureFlagClient(this.transport, this.config.appId, this.config.debug);
|
|
2397
|
+
this.flagClient.setSessionId(this.sessionManager.getSessionId());
|
|
2387
2398
|
this.offlineQueue = new OfflineQueue(this.transport, this.config.debug);
|
|
2388
2399
|
this.setupFailureHandling();
|
|
2389
2400
|
this.enableFeatures();
|