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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Next
|
|
2
2
|
|
|
3
|
+
# 4.3.2 - 2024-12-11
|
|
4
|
+
|
|
5
|
+
1. REVERT: Fix bug where this SDK incorrectly sent `$feature_flag_called` events with null values when using `getFeatureFlagPayload`.
|
|
6
|
+
|
|
3
7
|
# 4.3.1 - 2024-11-26
|
|
4
8
|
|
|
5
9
|
1. Fix bug where this SDK incorrectly sent `$feature_flag_called` events with null values when using `getFeatureFlagPayload`.
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Please see the main [PostHog docs](https://www.posthog.com/docs).
|
|
4
4
|
|
|
5
|
-
Specifically, the [Node.js
|
|
5
|
+
Specifically, the [Node.js docs](https://posthog.com/docs/libraries/node) details.
|
|
6
6
|
|
|
7
7
|
## Questions?
|
|
8
8
|
|
package/lib/index.cjs.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var rusha = require('rusha');
|
|
6
6
|
|
|
7
|
-
var version = "4.3.
|
|
7
|
+
var version = "4.3.2";
|
|
8
8
|
|
|
9
9
|
var PostHogPersistedProperty;
|
|
10
10
|
(function (PostHogPersistedProperty) {
|
|
@@ -2234,70 +2234,44 @@ class PostHog extends PostHogCoreStateless {
|
|
|
2234
2234
|
async getFeatureFlagPayload(key, distinctId, matchValue, options) {
|
|
2235
2235
|
const {
|
|
2236
2236
|
groups,
|
|
2237
|
-
disableGeoip
|
|
2238
|
-
|
|
2237
|
+
disableGeoip
|
|
2238
|
+
} = options || {};
|
|
2239
|
+
let {
|
|
2240
|
+
onlyEvaluateLocally,
|
|
2241
|
+
sendFeatureFlagEvents,
|
|
2239
2242
|
personProperties,
|
|
2240
2243
|
groupProperties
|
|
2241
2244
|
} = options || {};
|
|
2242
|
-
const
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2245
|
+
const adjustedProperties = this.addLocalPersonAndGroupProperties(distinctId, groups, personProperties, groupProperties);
|
|
2246
|
+
personProperties = adjustedProperties.allPersonProperties;
|
|
2247
|
+
groupProperties = adjustedProperties.allGroupProperties;
|
|
2248
|
+
let response = undefined;
|
|
2249
|
+
// Try to get match value locally if not provided
|
|
2250
|
+
if (!matchValue) {
|
|
2247
2251
|
matchValue = await this.getFeatureFlag(key, distinctId, {
|
|
2248
2252
|
...options,
|
|
2249
|
-
onlyEvaluateLocally: true
|
|
2250
|
-
sendFeatureFlagEvents: false
|
|
2253
|
+
onlyEvaluateLocally: true
|
|
2251
2254
|
});
|
|
2252
2255
|
}
|
|
2253
|
-
let response;
|
|
2254
|
-
let payload;
|
|
2255
2256
|
if (matchValue) {
|
|
2256
|
-
response = matchValue;
|
|
2257
|
-
payload = await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(key, matchValue);
|
|
2258
|
-
} else {
|
|
2259
|
-
response = undefined;
|
|
2260
|
-
payload = undefined;
|
|
2257
|
+
response = await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(key, matchValue);
|
|
2261
2258
|
}
|
|
2262
|
-
//
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
let fetchedOrLocalFlags;
|
|
2266
|
-
let fetchedOrLocalPayloads;
|
|
2267
|
-
if (payloadWasLocallyEvaluated || onlyEvaluateLocally) {
|
|
2268
|
-
if (response !== undefined) {
|
|
2269
|
-
fetchedOrLocalFlags = {
|
|
2270
|
-
[key]: response
|
|
2271
|
-
};
|
|
2272
|
-
fetchedOrLocalPayloads = {
|
|
2273
|
-
[key]: payload
|
|
2274
|
-
};
|
|
2275
|
-
} else {
|
|
2276
|
-
fetchedOrLocalFlags = {};
|
|
2277
|
-
fetchedOrLocalPayloads = {};
|
|
2278
|
-
}
|
|
2279
|
-
} else {
|
|
2280
|
-
const fetchedData = await super.getFeatureFlagsAndPayloadsStateless(distinctId, groups, allPersonProperties, allGroupProperties, disableGeoip);
|
|
2281
|
-
fetchedOrLocalFlags = fetchedData.flags || {};
|
|
2282
|
-
fetchedOrLocalPayloads = fetchedData.payloads || {};
|
|
2259
|
+
// set defaults
|
|
2260
|
+
if (onlyEvaluateLocally == undefined) {
|
|
2261
|
+
onlyEvaluateLocally = false;
|
|
2283
2262
|
}
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
},
|
|
2297
|
-
groups,
|
|
2298
|
-
disableGeoip
|
|
2299
|
-
});
|
|
2300
|
-
return finalPayload;
|
|
2263
|
+
if (sendFeatureFlagEvents == undefined) {
|
|
2264
|
+
sendFeatureFlagEvents = true;
|
|
2265
|
+
}
|
|
2266
|
+
// set defaults
|
|
2267
|
+
if (onlyEvaluateLocally == undefined) {
|
|
2268
|
+
onlyEvaluateLocally = false;
|
|
2269
|
+
}
|
|
2270
|
+
const payloadWasLocallyEvaluated = response !== undefined;
|
|
2271
|
+
if (!payloadWasLocallyEvaluated && !onlyEvaluateLocally) {
|
|
2272
|
+
response = await super.getFeatureFlagPayloadStateless(key, distinctId, groups, personProperties, groupProperties, disableGeoip);
|
|
2273
|
+
}
|
|
2274
|
+
return response;
|
|
2301
2275
|
}
|
|
2302
2276
|
async isFeatureEnabled(key, distinctId, options) {
|
|
2303
2277
|
const feat = await this.getFeatureFlag(key, distinctId, options);
|