posthog-node 2.5.3 → 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 +3 -0
- package/lib/index.cjs.js +31 -2
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.esm.js +31 -2
- 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 +1 -0
- package/package.json +1 -1
- package/src/feature-flags.ts +11 -1
- package/src/posthog-node.ts +5 -0
package/CHANGELOG.md
CHANGED
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
|
|