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