posthog-node 2.5.2 → 2.5.4
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 +7 -0
- package/lib/index.cjs.js +43 -6
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +4 -1
- package/lib/index.esm.js +43 -6
- package/lib/index.esm.js.map +1 -1
- package/lib/posthog-core/src/index.d.ts +1 -0
- package/lib/posthog-node/src/feature-flags.d.ts +2 -0
- package/lib/posthog-node/src/posthog-node.d.ts +2 -1
- package/lib/posthog-node/src/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/feature-flags.ts +11 -1
- package/src/posthog-node.ts +12 -4
- package/src/types.ts +1 -0
- package/test/posthog-node.spec.ts +24 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# 2.5.4 - 2023-02-27
|
|
2
|
+
|
|
3
|
+
1. Fix error log for local evaluation of feature flags (InconclusiveMatchError(s)) to only show during debug mode.
|
|
4
|
+
# 2.5.3 - 2023-02-21
|
|
5
|
+
|
|
6
|
+
1. Allow passing in a distinctId to `groupIdentify()`.
|
|
7
|
+
2. Fix a bug with active feature flags on capture events, where non-active flags would be added to the list as well.
|
|
1
8
|
# 2.5.2 - 2023-02-17
|
|
2
9
|
|
|
3
10
|
1. Fix issue where properties passed to `.identify` were not set correctly
|
package/lib/index.cjs.js
CHANGED
|
@@ -163,7 +163,7 @@ function __spreadArray(to, from, pack) {
|
|
|
163
163
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
var version = "2.5.
|
|
166
|
+
var version = "2.5.4";
|
|
167
167
|
|
|
168
168
|
var PostHogPersistedProperty;
|
|
169
169
|
(function (PostHogPersistedProperty) {
|
|
@@ -725,6 +725,7 @@ var SimpleEventEmitter = /** @class */ (function () {
|
|
|
725
725
|
var PostHogCoreStateless = /** @class */ (function () {
|
|
726
726
|
function PostHogCoreStateless(apiKey, options) {
|
|
727
727
|
var _a, _b, _c, _d;
|
|
728
|
+
this.debugMode = false;
|
|
728
729
|
this.pendingPromises = {};
|
|
729
730
|
// internal
|
|
730
731
|
this._events = new SimpleEventEmitter();
|
|
@@ -769,6 +770,7 @@ var PostHogCoreStateless = /** @class */ (function () {
|
|
|
769
770
|
var _a;
|
|
770
771
|
if (enabled === void 0) { enabled = true; }
|
|
771
772
|
(_a = this.removeDebugCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
773
|
+
this.debugMode = enabled;
|
|
772
774
|
if (enabled) {
|
|
773
775
|
this.removeDebugCallback = this.on('*', function (event, payload) { return console.log('PostHog Debug', event, payload); });
|
|
774
776
|
}
|
|
@@ -1598,6 +1600,7 @@ function () {
|
|
|
1598
1600
|
host = _a.host,
|
|
1599
1601
|
options = __rest(_a, ["pollingInterval", "personalApiKey", "projectApiKey", "timeout", "host"]);
|
|
1600
1602
|
|
|
1603
|
+
this.debugMode = false;
|
|
1601
1604
|
this.pollingInterval = pollingInterval;
|
|
1602
1605
|
this.personalApiKey = personalApiKey;
|
|
1603
1606
|
this.featureFlags = [];
|
|
@@ -1613,6 +1616,14 @@ function () {
|
|
|
1613
1616
|
void this.loadFeatureFlags();
|
|
1614
1617
|
}
|
|
1615
1618
|
|
|
1619
|
+
FeatureFlagsPoller.prototype.debug = function (enabled) {
|
|
1620
|
+
if (enabled === void 0) {
|
|
1621
|
+
enabled = true;
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
this.debugMode = enabled;
|
|
1625
|
+
};
|
|
1626
|
+
|
|
1616
1627
|
FeatureFlagsPoller.prototype.getFeatureFlag = function (key, distinctId, groups, personProperties, groupProperties) {
|
|
1617
1628
|
if (groups === void 0) {
|
|
1618
1629
|
groups = {};
|
|
@@ -1660,9 +1671,15 @@ function () {
|
|
|
1660
1671
|
if (featureFlag !== undefined) {
|
|
1661
1672
|
try {
|
|
1662
1673
|
response = this.computeFlagLocally(featureFlag, distinctId, groups, personProperties, groupProperties);
|
|
1674
|
+
|
|
1675
|
+
if (this.debugMode) {
|
|
1676
|
+
console.debug("Successfully computed flag locally: ".concat(key, " -> ").concat(response));
|
|
1677
|
+
}
|
|
1663
1678
|
} catch (e) {
|
|
1664
1679
|
if (e instanceof InconclusiveMatchError) {
|
|
1665
|
-
|
|
1680
|
+
if (this.debugMode) {
|
|
1681
|
+
console.debug("InconclusiveMatchError when computing flag locally: ".concat(key, ": ").concat(e));
|
|
1682
|
+
}
|
|
1666
1683
|
} else if (e instanceof Error) {
|
|
1667
1684
|
console.error("Error computing flag locally: ".concat(key, ": ").concat(e));
|
|
1668
1685
|
}
|
|
@@ -2330,6 +2347,18 @@ function (_super) {
|
|
|
2330
2347
|
return _super.prototype.optOut.call(this);
|
|
2331
2348
|
};
|
|
2332
2349
|
|
|
2350
|
+
PostHog.prototype.debug = function (enabled) {
|
|
2351
|
+
var _a;
|
|
2352
|
+
|
|
2353
|
+
if (enabled === void 0) {
|
|
2354
|
+
enabled = true;
|
|
2355
|
+
}
|
|
2356
|
+
|
|
2357
|
+
_super.prototype.debug.call(this, enabled);
|
|
2358
|
+
|
|
2359
|
+
(_a = this.featureFlagsPoller) === null || _a === void 0 ? void 0 : _a.debug(enabled);
|
|
2360
|
+
};
|
|
2361
|
+
|
|
2333
2362
|
PostHog.prototype.capture = function (_a) {
|
|
2334
2363
|
var _this = this;
|
|
2335
2364
|
|
|
@@ -2355,12 +2384,19 @@ function (_super) {
|
|
|
2355
2384
|
var _b = _a[_i],
|
|
2356
2385
|
feature = _b[0],
|
|
2357
2386
|
variant = _b[1];
|
|
2358
|
-
|
|
2387
|
+
|
|
2388
|
+
if (variant !== false) {
|
|
2389
|
+
featureVariantProperties["$feature/".concat(feature)] = variant;
|
|
2390
|
+
}
|
|
2359
2391
|
}
|
|
2360
2392
|
}
|
|
2361
2393
|
|
|
2394
|
+
var activeFlags = Object.keys(flags || {}).filter(function (flag) {
|
|
2395
|
+
return (flags === null || flags === void 0 ? void 0 : flags[flag]) !== false;
|
|
2396
|
+
});
|
|
2397
|
+
|
|
2362
2398
|
var flagProperties = __assign({
|
|
2363
|
-
$active_feature_flags:
|
|
2399
|
+
$active_feature_flags: activeFlags || undefined
|
|
2364
2400
|
}, featureVariantProperties);
|
|
2365
2401
|
|
|
2366
2402
|
_capture(__assign(__assign(__assign({}, properties), {
|
|
@@ -2647,9 +2683,10 @@ function (_super) {
|
|
|
2647
2683
|
PostHog.prototype.groupIdentify = function (_a) {
|
|
2648
2684
|
var groupType = _a.groupType,
|
|
2649
2685
|
groupKey = _a.groupKey,
|
|
2650
|
-
properties = _a.properties
|
|
2686
|
+
properties = _a.properties,
|
|
2687
|
+
distinctId = _a.distinctId;
|
|
2651
2688
|
|
|
2652
|
-
_super.prototype.groupIdentifyStateless.call(this, groupType, groupKey, properties);
|
|
2689
|
+
_super.prototype.groupIdentifyStateless.call(this, groupType, groupKey, properties, undefined, distinctId);
|
|
2653
2690
|
};
|
|
2654
2691
|
|
|
2655
2692
|
PostHog.prototype.reloadFeatureFlags = function () {
|