posthog-node 5.5.1 → 5.6.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/CHANGELOG.md +4 -0
- package/lib/edge/index.cjs +14 -14
- package/lib/edge/index.cjs.map +1 -1
- package/lib/edge/index.mjs +14 -14
- package/lib/edge/index.mjs.map +1 -1
- package/lib/index.d.ts +3 -0
- package/lib/node/index.cjs +14 -14
- package/lib/node/index.cjs.map +1 -1
- package/lib/node/index.mjs +14 -14
- package/lib/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/lib/edge/index.mjs
CHANGED
|
@@ -915,7 +915,7 @@ function setupExpressErrorHandler(_posthog, app) {
|
|
|
915
915
|
});
|
|
916
916
|
}
|
|
917
917
|
|
|
918
|
-
var version = "5.
|
|
918
|
+
var version = "5.6.0";
|
|
919
919
|
|
|
920
920
|
var PostHogPersistedProperty;
|
|
921
921
|
(function (PostHogPersistedProperty) {
|
|
@@ -2154,12 +2154,7 @@ class FeatureFlagsPoller {
|
|
|
2154
2154
|
if (!this.loadedSuccessfullyOnce) {
|
|
2155
2155
|
return response;
|
|
2156
2156
|
}
|
|
2157
|
-
|
|
2158
|
-
if (key === flag.key) {
|
|
2159
|
-
featureFlag = flag;
|
|
2160
|
-
break;
|
|
2161
|
-
}
|
|
2162
|
-
}
|
|
2157
|
+
featureFlag = this.featureFlagsByKey[key];
|
|
2163
2158
|
if (featureFlag !== undefined) {
|
|
2164
2159
|
try {
|
|
2165
2160
|
response = await this.computeFlagLocally(featureFlag, distinctId, groups, personProperties, groupProperties);
|
|
@@ -2195,12 +2190,13 @@ class FeatureFlagsPoller {
|
|
|
2195
2190
|
return response;
|
|
2196
2191
|
}
|
|
2197
2192
|
}
|
|
2198
|
-
async getAllFlagsAndPayloads(distinctId, groups = {}, personProperties = {}, groupProperties = {}) {
|
|
2193
|
+
async getAllFlagsAndPayloads(distinctId, groups = {}, personProperties = {}, groupProperties = {}, flagKeysToExplicitlyEvaluate) {
|
|
2199
2194
|
await this.loadFeatureFlags();
|
|
2200
2195
|
const response = {};
|
|
2201
2196
|
const payloads = {};
|
|
2202
2197
|
let fallbackToFlags = this.featureFlags.length == 0;
|
|
2203
|
-
|
|
2198
|
+
const flagsToEvaluate = flagKeysToExplicitlyEvaluate ? flagKeysToExplicitlyEvaluate.map(key => this.featureFlagsByKey[key]).filter(Boolean) : this.featureFlags;
|
|
2199
|
+
await Promise.all(flagsToEvaluate.map(async flag => {
|
|
2204
2200
|
try {
|
|
2205
2201
|
const matchValue = await this.computeFlagLocally(flag, distinctId, groups, personProperties, groupProperties);
|
|
2206
2202
|
response[flag.key] = matchValue;
|
|
@@ -3153,7 +3149,8 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
3153
3149
|
async getAllFlagsAndPayloads(distinctId, options) {
|
|
3154
3150
|
const {
|
|
3155
3151
|
groups,
|
|
3156
|
-
disableGeoip
|
|
3152
|
+
disableGeoip,
|
|
3153
|
+
flagKeys
|
|
3157
3154
|
} = options || {};
|
|
3158
3155
|
let {
|
|
3159
3156
|
onlyEvaluateLocally,
|
|
@@ -3167,7 +3164,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
3167
3164
|
if (onlyEvaluateLocally == undefined) {
|
|
3168
3165
|
onlyEvaluateLocally = false;
|
|
3169
3166
|
}
|
|
3170
|
-
const localEvaluationResult = await this.featureFlagsPoller?.getAllFlagsAndPayloads(distinctId, groups, personProperties, groupProperties);
|
|
3167
|
+
const localEvaluationResult = await this.featureFlagsPoller?.getAllFlagsAndPayloads(distinctId, groups, personProperties, groupProperties, flagKeys);
|
|
3171
3168
|
let featureFlags = {};
|
|
3172
3169
|
let featureFlagPayloads = {};
|
|
3173
3170
|
let fallbackToFlags = true;
|
|
@@ -3177,7 +3174,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
3177
3174
|
fallbackToFlags = localEvaluationResult.fallbackToFlags;
|
|
3178
3175
|
}
|
|
3179
3176
|
if (fallbackToFlags && !onlyEvaluateLocally) {
|
|
3180
|
-
const remoteEvaluationResult = await super.getFeatureFlagsAndPayloadsStateless(distinctId, groups, personProperties, groupProperties, disableGeoip);
|
|
3177
|
+
const remoteEvaluationResult = await super.getFeatureFlagsAndPayloadsStateless(distinctId, groups, personProperties, groupProperties, disableGeoip, flagKeys);
|
|
3181
3178
|
featureFlags = {
|
|
3182
3179
|
...featureFlags,
|
|
3183
3180
|
...(remoteEvaluationResult.flags || {})
|
|
@@ -3277,6 +3274,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
3277
3274
|
// Use properties directly from options if they exist
|
|
3278
3275
|
const finalPersonProperties = sendFeatureFlagsOptions?.personProperties || {};
|
|
3279
3276
|
const finalGroupProperties = sendFeatureFlagsOptions?.groupProperties || {};
|
|
3277
|
+
const flagKeys = sendFeatureFlagsOptions?.flagKeys;
|
|
3280
3278
|
// Check if we should only evaluate locally
|
|
3281
3279
|
const onlyEvaluateLocally = sendFeatureFlagsOptions?.onlyEvaluateLocally ?? false;
|
|
3282
3280
|
// If onlyEvaluateLocally is true, only use local evaluation
|
|
@@ -3291,7 +3289,8 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
3291
3289
|
personProperties: finalPersonProperties,
|
|
3292
3290
|
groupProperties: finalGroupProperties,
|
|
3293
3291
|
disableGeoip,
|
|
3294
|
-
onlyEvaluateLocally: true
|
|
3292
|
+
onlyEvaluateLocally: true,
|
|
3293
|
+
flagKeys
|
|
3295
3294
|
});
|
|
3296
3295
|
} else {
|
|
3297
3296
|
// If onlyEvaluateLocally is true but we don't have local flags, return empty
|
|
@@ -3309,7 +3308,8 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
3309
3308
|
personProperties: finalPersonProperties,
|
|
3310
3309
|
groupProperties: finalGroupProperties,
|
|
3311
3310
|
disableGeoip,
|
|
3312
|
-
onlyEvaluateLocally: true
|
|
3311
|
+
onlyEvaluateLocally: true,
|
|
3312
|
+
flagKeys
|
|
3313
3313
|
});
|
|
3314
3314
|
}
|
|
3315
3315
|
// Fall back to remote evaluation if local evaluation is not available
|