posthog-node 5.8.2 → 5.8.3
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/edge/index.cjs +13 -9
- package/dist/edge/index.cjs.map +1 -1
- package/dist/edge/index.mjs +13 -9
- package/dist/edge/index.mjs.map +1 -1
- package/dist/node/index.cjs +13 -9
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +13 -9
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.mjs
CHANGED
|
@@ -1184,7 +1184,7 @@ function snipLine(line, colno) {
|
|
|
1184
1184
|
return newLine;
|
|
1185
1185
|
}
|
|
1186
1186
|
|
|
1187
|
-
var version = "5.8.
|
|
1187
|
+
var version = "5.8.3";
|
|
1188
1188
|
|
|
1189
1189
|
/**
|
|
1190
1190
|
* A lazy value that is only computed when needed. Inspired by C#'s Lazy<T> class.
|
|
@@ -1371,12 +1371,14 @@ class FeatureFlagsPoller {
|
|
|
1371
1371
|
const payloads = {};
|
|
1372
1372
|
let fallbackToFlags = this.featureFlags.length == 0;
|
|
1373
1373
|
const flagsToEvaluate = flagKeysToExplicitlyEvaluate ? flagKeysToExplicitlyEvaluate.map(key => this.featureFlagsByKey[key]).filter(Boolean) : this.featureFlags;
|
|
1374
|
+
// Create a shared evaluation cache to prevent memory leaks when processing many flags
|
|
1375
|
+
const sharedEvaluationCache = {};
|
|
1374
1376
|
await Promise.all(flagsToEvaluate.map(async flag => {
|
|
1375
1377
|
try {
|
|
1376
1378
|
const {
|
|
1377
1379
|
value: matchValue,
|
|
1378
1380
|
payload: matchPayload
|
|
1379
|
-
} = await this.computeFlagAndPayloadLocally(flag, distinctId, groups, personProperties, groupProperties);
|
|
1381
|
+
} = await this.computeFlagAndPayloadLocally(flag, distinctId, groups, personProperties, groupProperties, undefined /* matchValue */, sharedEvaluationCache);
|
|
1380
1382
|
response[flag.key] = matchValue;
|
|
1381
1383
|
if (matchPayload) {
|
|
1382
1384
|
payloads[flag.key] = matchPayload;
|
|
@@ -1396,9 +1398,11 @@ class FeatureFlagsPoller {
|
|
|
1396
1398
|
fallbackToFlags
|
|
1397
1399
|
};
|
|
1398
1400
|
}
|
|
1399
|
-
async computeFlagAndPayloadLocally(flag, distinctId, groups = {}, personProperties = {}, groupProperties = {}, matchValue) {
|
|
1400
|
-
//
|
|
1401
|
-
|
|
1401
|
+
async computeFlagAndPayloadLocally(flag, distinctId, groups = {}, personProperties = {}, groupProperties = {}, matchValue, evaluationCache, skipLoadCheck = false) {
|
|
1402
|
+
// Only load flags if not already loaded and not skipping the check
|
|
1403
|
+
if (!skipLoadCheck) {
|
|
1404
|
+
await this.loadFeatureFlags();
|
|
1405
|
+
}
|
|
1402
1406
|
if (!this.loadedSuccessfullyOnce) {
|
|
1403
1407
|
return {
|
|
1404
1408
|
value: false,
|
|
@@ -1410,7 +1414,7 @@ class FeatureFlagsPoller {
|
|
|
1410
1414
|
if (matchValue !== undefined) {
|
|
1411
1415
|
flagValue = matchValue;
|
|
1412
1416
|
} else {
|
|
1413
|
-
flagValue = await this.computeFlagValueLocally(flag, distinctId, groups, personProperties, groupProperties);
|
|
1417
|
+
flagValue = await this.computeFlagValueLocally(flag, distinctId, groups, personProperties, groupProperties, evaluationCache);
|
|
1414
1418
|
}
|
|
1415
1419
|
// Always compute payload based on the final flagValue (whether provided or computed)
|
|
1416
1420
|
const payload = this.getFeatureFlagPayload(flag.key, flagValue);
|
|
@@ -1419,7 +1423,7 @@ class FeatureFlagsPoller {
|
|
|
1419
1423
|
payload
|
|
1420
1424
|
};
|
|
1421
1425
|
}
|
|
1422
|
-
async computeFlagValueLocally(flag, distinctId, groups = {}, personProperties = {}, groupProperties = {}) {
|
|
1426
|
+
async computeFlagValueLocally(flag, distinctId, groups = {}, personProperties = {}, groupProperties = {}, evaluationCache = {}) {
|
|
1423
1427
|
if (flag.ensure_experience_continuity) {
|
|
1424
1428
|
throw new InconclusiveMatchError('Flag has experience continuity enabled');
|
|
1425
1429
|
}
|
|
@@ -1439,9 +1443,9 @@ class FeatureFlagsPoller {
|
|
|
1439
1443
|
return false;
|
|
1440
1444
|
}
|
|
1441
1445
|
const focusedGroupProperties = groupProperties[groupName];
|
|
1442
|
-
return await this.matchFeatureFlagProperties(flag, groups[groupName], focusedGroupProperties);
|
|
1446
|
+
return await this.matchFeatureFlagProperties(flag, groups[groupName], focusedGroupProperties, evaluationCache);
|
|
1443
1447
|
} else {
|
|
1444
|
-
return await this.matchFeatureFlagProperties(flag, distinctId, personProperties);
|
|
1448
|
+
return await this.matchFeatureFlagProperties(flag, distinctId, personProperties, evaluationCache);
|
|
1445
1449
|
}
|
|
1446
1450
|
}
|
|
1447
1451
|
getFeatureFlagPayload(key, flagValue) {
|