posthog-node 4.3.2 → 4.4.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/benchmarks/rusha-vs-native.mjs +70 -0
- package/lib/index.cjs.js +6 -4
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +20 -5
- package/lib/index.esm.js +6 -4
- package/lib/index.esm.js.map +1 -1
- package/lib/posthog-core/src/types.d.ts +4 -1
- package/lib/posthog-node/src/types.d.ts +16 -4
- package/package.json +4 -4
- package/src/feature-flags.ts +2 -3
- package/src/types.ts +16 -4
- package/tsconfig.json +2 -2
- package/src/types/rusha.d.ts +0 -23
package/lib/index.d.ts
CHANGED
|
@@ -49,6 +49,8 @@ declare enum PostHogPersistedProperty {
|
|
|
49
49
|
Props = "props",
|
|
50
50
|
FeatureFlags = "feature_flags",
|
|
51
51
|
FeatureFlagPayloads = "feature_flag_payloads",
|
|
52
|
+
BootstrapFeatureFlags = "bootstrap_feature_flags",
|
|
53
|
+
BootstrapFeatureFlagPayloads = "bootstrap_feature_flag_payloads",
|
|
52
54
|
OverrideFeatureFlags = "override_feature_flags",
|
|
53
55
|
Queue = "queue",
|
|
54
56
|
OptedOut = "opted_out",
|
|
@@ -58,7 +60,8 @@ declare enum PostHogPersistedProperty {
|
|
|
58
60
|
GroupProperties = "group_properties",
|
|
59
61
|
InstalledAppBuild = "installed_app_build",
|
|
60
62
|
InstalledAppVersion = "installed_app_version",
|
|
61
|
-
SessionReplay = "session_replay"
|
|
63
|
+
SessionReplay = "session_replay",
|
|
64
|
+
DecideEndpointWasHit = "decide_endpoint_was_hit"
|
|
62
65
|
}
|
|
63
66
|
type PostHogFetchOptions = {
|
|
64
67
|
method: 'GET' | 'POST' | 'PUT' | 'PATCH';
|
|
@@ -319,13 +322,25 @@ type PostHogNodeV1 = {
|
|
|
319
322
|
}): Promise<string | boolean | undefined>;
|
|
320
323
|
/**
|
|
321
324
|
* @description Retrieves payload associated with the specified flag and matched value that is passed in.
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
+
*
|
|
326
|
+
* IMPORTANT: The `matchValue` parameter should be the value you previously obtained from `getFeatureFlag()`.
|
|
327
|
+
* If matchValue isn't passed (or is undefined), this method will automatically call `getFeatureFlag()`
|
|
328
|
+
* internally to fetch the flag value, which could result in a network call to the PostHog server if this flag can
|
|
329
|
+
* not be evaluated locally. This means that omitting `matchValue` will potentially:
|
|
330
|
+
* - Bypass local evaluation
|
|
331
|
+
* - Count as an additional flag evaluation against your quota
|
|
332
|
+
* - Impact performance due to the extra network request
|
|
333
|
+
*
|
|
334
|
+
* Example usage:
|
|
335
|
+
* ```js
|
|
336
|
+
* const flagValue = await client.getFeatureFlag('my-flag', distinctId);
|
|
337
|
+
* const payload = await client.getFeatureFlagPayload('my-flag', distinctId, flagValue);
|
|
338
|
+
* ```
|
|
325
339
|
*
|
|
326
340
|
* @param key the unique key of your feature flag
|
|
327
341
|
* @param distinctId the current unique id
|
|
328
|
-
* @param matchValue
|
|
342
|
+
* @param matchValue The flag value previously obtained from calling `getFeatureFlag()`. Can be a string or boolean.
|
|
343
|
+
* To avoid extra network calls, pass this parameter when you can.
|
|
329
344
|
* @param options: dict with optional parameters below
|
|
330
345
|
* @param onlyEvaluateLocally optional - whether to only evaluate the flag locally. Defaults to false.
|
|
331
346
|
*
|
package/lib/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createHash } from '
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
2
|
|
|
3
|
-
var version = "4.
|
|
3
|
+
var version = "4.4.0";
|
|
4
4
|
|
|
5
5
|
var PostHogPersistedProperty;
|
|
6
6
|
(function (PostHogPersistedProperty) {
|
|
@@ -9,6 +9,8 @@ var PostHogPersistedProperty;
|
|
|
9
9
|
PostHogPersistedProperty["Props"] = "props";
|
|
10
10
|
PostHogPersistedProperty["FeatureFlags"] = "feature_flags";
|
|
11
11
|
PostHogPersistedProperty["FeatureFlagPayloads"] = "feature_flag_payloads";
|
|
12
|
+
PostHogPersistedProperty["BootstrapFeatureFlags"] = "bootstrap_feature_flags";
|
|
13
|
+
PostHogPersistedProperty["BootstrapFeatureFlagPayloads"] = "bootstrap_feature_flag_payloads";
|
|
12
14
|
PostHogPersistedProperty["OverrideFeatureFlags"] = "override_feature_flags";
|
|
13
15
|
PostHogPersistedProperty["Queue"] = "queue";
|
|
14
16
|
PostHogPersistedProperty["OptedOut"] = "opted_out";
|
|
@@ -19,6 +21,7 @@ var PostHogPersistedProperty;
|
|
|
19
21
|
PostHogPersistedProperty["InstalledAppBuild"] = "installed_app_build";
|
|
20
22
|
PostHogPersistedProperty["InstalledAppVersion"] = "installed_app_version";
|
|
21
23
|
PostHogPersistedProperty["SessionReplay"] = "session_replay";
|
|
24
|
+
PostHogPersistedProperty["DecideEndpointWasHit"] = "decide_endpoint_was_hit";
|
|
22
25
|
})(PostHogPersistedProperty || (PostHogPersistedProperty = {}));
|
|
23
26
|
|
|
24
27
|
function assert(truthyValue, message) {
|
|
@@ -1782,8 +1785,7 @@ class FeatureFlagsPoller {
|
|
|
1782
1785
|
// # uniformly distributed between 0 and 1, so if we want to show this feature to 20% of traffic
|
|
1783
1786
|
// # we can do _hash(key, distinct_id) < 0.2
|
|
1784
1787
|
function _hash(key, distinctId, salt = '') {
|
|
1785
|
-
|
|
1786
|
-
const sha1Hash = createHash();
|
|
1788
|
+
const sha1Hash = createHash('sha1');
|
|
1787
1789
|
sha1Hash.update(`${key}.${distinctId}${salt}`);
|
|
1788
1790
|
return parseInt(sha1Hash.digest('hex').slice(0, 15), 16) / LONG_SCALE;
|
|
1789
1791
|
}
|