posthog-node 4.3.1 → 4.3.2
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/README.md +1 -1
- package/lib/index.cjs.js +29 -55
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.esm.js +29 -55
- package/lib/index.esm.js.map +1 -1
- package/lib/posthog-node/src/types.d.ts +1 -1
- package/package.json +1 -1
- package/src/posthog-node.ts +30 -51
- package/src/types.ts +1 -1
- package/test/posthog-node.spec.ts +2 -35
package/lib/index.d.ts
CHANGED
|
@@ -319,7 +319,7 @@ type PostHogNodeV1 = {
|
|
|
319
319
|
}): Promise<string | boolean | undefined>;
|
|
320
320
|
/**
|
|
321
321
|
* @description Retrieves payload associated with the specified flag and matched value that is passed in.
|
|
322
|
-
* (Expected to be used in
|
|
322
|
+
* (Expected to be used in conjunction with getFeatureFlag but allows for manual lookup).
|
|
323
323
|
* If matchValue isn't passed, getFeatureFlag is called implicitly.
|
|
324
324
|
* Will try to evaluate for payload locally first otherwise default to network call if allowed
|
|
325
325
|
*
|
package/lib/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHash } from 'rusha';
|
|
2
2
|
|
|
3
|
-
var version = "4.3.
|
|
3
|
+
var version = "4.3.2";
|
|
4
4
|
|
|
5
5
|
var PostHogPersistedProperty;
|
|
6
6
|
(function (PostHogPersistedProperty) {
|
|
@@ -2230,70 +2230,44 @@ class PostHog extends PostHogCoreStateless {
|
|
|
2230
2230
|
async getFeatureFlagPayload(key, distinctId, matchValue, options) {
|
|
2231
2231
|
const {
|
|
2232
2232
|
groups,
|
|
2233
|
-
disableGeoip
|
|
2234
|
-
|
|
2233
|
+
disableGeoip
|
|
2234
|
+
} = options || {};
|
|
2235
|
+
let {
|
|
2236
|
+
onlyEvaluateLocally,
|
|
2237
|
+
sendFeatureFlagEvents,
|
|
2235
2238
|
personProperties,
|
|
2236
2239
|
groupProperties
|
|
2237
2240
|
} = options || {};
|
|
2238
|
-
const
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2241
|
+
const adjustedProperties = this.addLocalPersonAndGroupProperties(distinctId, groups, personProperties, groupProperties);
|
|
2242
|
+
personProperties = adjustedProperties.allPersonProperties;
|
|
2243
|
+
groupProperties = adjustedProperties.allGroupProperties;
|
|
2244
|
+
let response = undefined;
|
|
2245
|
+
// Try to get match value locally if not provided
|
|
2246
|
+
if (!matchValue) {
|
|
2243
2247
|
matchValue = await this.getFeatureFlag(key, distinctId, {
|
|
2244
2248
|
...options,
|
|
2245
|
-
onlyEvaluateLocally: true
|
|
2246
|
-
sendFeatureFlagEvents: false
|
|
2249
|
+
onlyEvaluateLocally: true
|
|
2247
2250
|
});
|
|
2248
2251
|
}
|
|
2249
|
-
let response;
|
|
2250
|
-
let payload;
|
|
2251
2252
|
if (matchValue) {
|
|
2252
|
-
response = matchValue;
|
|
2253
|
-
payload = await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(key, matchValue);
|
|
2254
|
-
} else {
|
|
2255
|
-
response = undefined;
|
|
2256
|
-
payload = undefined;
|
|
2253
|
+
response = await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(key, matchValue);
|
|
2257
2254
|
}
|
|
2258
|
-
//
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
let fetchedOrLocalFlags;
|
|
2262
|
-
let fetchedOrLocalPayloads;
|
|
2263
|
-
if (payloadWasLocallyEvaluated || onlyEvaluateLocally) {
|
|
2264
|
-
if (response !== undefined) {
|
|
2265
|
-
fetchedOrLocalFlags = {
|
|
2266
|
-
[key]: response
|
|
2267
|
-
};
|
|
2268
|
-
fetchedOrLocalPayloads = {
|
|
2269
|
-
[key]: payload
|
|
2270
|
-
};
|
|
2271
|
-
} else {
|
|
2272
|
-
fetchedOrLocalFlags = {};
|
|
2273
|
-
fetchedOrLocalPayloads = {};
|
|
2274
|
-
}
|
|
2275
|
-
} else {
|
|
2276
|
-
const fetchedData = await super.getFeatureFlagsAndPayloadsStateless(distinctId, groups, allPersonProperties, allGroupProperties, disableGeoip);
|
|
2277
|
-
fetchedOrLocalFlags = fetchedData.flags || {};
|
|
2278
|
-
fetchedOrLocalPayloads = fetchedData.payloads || {};
|
|
2255
|
+
// set defaults
|
|
2256
|
+
if (onlyEvaluateLocally == undefined) {
|
|
2257
|
+
onlyEvaluateLocally = false;
|
|
2279
2258
|
}
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
},
|
|
2293
|
-
groups,
|
|
2294
|
-
disableGeoip
|
|
2295
|
-
});
|
|
2296
|
-
return finalPayload;
|
|
2259
|
+
if (sendFeatureFlagEvents == undefined) {
|
|
2260
|
+
sendFeatureFlagEvents = true;
|
|
2261
|
+
}
|
|
2262
|
+
// set defaults
|
|
2263
|
+
if (onlyEvaluateLocally == undefined) {
|
|
2264
|
+
onlyEvaluateLocally = false;
|
|
2265
|
+
}
|
|
2266
|
+
const payloadWasLocallyEvaluated = response !== undefined;
|
|
2267
|
+
if (!payloadWasLocallyEvaluated && !onlyEvaluateLocally) {
|
|
2268
|
+
response = await super.getFeatureFlagPayloadStateless(key, distinctId, groups, personProperties, groupProperties, disableGeoip);
|
|
2269
|
+
}
|
|
2270
|
+
return response;
|
|
2297
2271
|
}
|
|
2298
2272
|
async isFeatureEnabled(key, distinctId, options) {
|
|
2299
2273
|
const feat = await this.getFeatureFlag(key, distinctId, options);
|