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/lib/index.d.ts CHANGED
@@ -103,6 +103,7 @@ declare abstract class PostHogCoreStateless {
103
103
  private requestTimeout;
104
104
  private captureMode;
105
105
  private removeDebugCallback?;
106
+ private debugMode;
106
107
  private pendingPromises;
107
108
  private _optoutOverride;
108
109
  protected _events: SimpleEventEmitter;
@@ -319,6 +320,7 @@ declare class PostHog extends PostHogCoreStateless implements PostHogNodeV1 {
319
320
  getCustomUserAgent(): string;
320
321
  enable(): void;
321
322
  disable(): void;
323
+ debug(enabled?: boolean): void;
322
324
  capture({ distinctId, event, properties, groups, sendFeatureFlags, timestamp }: EventMessageV1): void;
323
325
  identify({ distinctId, properties }: IdentifyMessageV1): void;
324
326
  alias(data: {
package/lib/index.esm.js CHANGED
@@ -155,7 +155,7 @@ function __spreadArray(to, from, pack) {
155
155
  return to.concat(ar || Array.prototype.slice.call(from));
156
156
  }
157
157
 
158
- var version = "2.5.3";
158
+ var version = "2.5.4";
159
159
 
160
160
  var PostHogPersistedProperty;
161
161
  (function (PostHogPersistedProperty) {
@@ -717,6 +717,7 @@ var SimpleEventEmitter = /** @class */ (function () {
717
717
  var PostHogCoreStateless = /** @class */ (function () {
718
718
  function PostHogCoreStateless(apiKey, options) {
719
719
  var _a, _b, _c, _d;
720
+ this.debugMode = false;
720
721
  this.pendingPromises = {};
721
722
  // internal
722
723
  this._events = new SimpleEventEmitter();
@@ -761,6 +762,7 @@ var PostHogCoreStateless = /** @class */ (function () {
761
762
  var _a;
762
763
  if (enabled === void 0) { enabled = true; }
763
764
  (_a = this.removeDebugCallback) === null || _a === void 0 ? void 0 : _a.call(this);
765
+ this.debugMode = enabled;
764
766
  if (enabled) {
765
767
  this.removeDebugCallback = this.on('*', function (event, payload) { return console.log('PostHog Debug', event, payload); });
766
768
  }
@@ -1590,6 +1592,7 @@ function () {
1590
1592
  host = _a.host,
1591
1593
  options = __rest(_a, ["pollingInterval", "personalApiKey", "projectApiKey", "timeout", "host"]);
1592
1594
 
1595
+ this.debugMode = false;
1593
1596
  this.pollingInterval = pollingInterval;
1594
1597
  this.personalApiKey = personalApiKey;
1595
1598
  this.featureFlags = [];
@@ -1605,6 +1608,14 @@ function () {
1605
1608
  void this.loadFeatureFlags();
1606
1609
  }
1607
1610
 
1611
+ FeatureFlagsPoller.prototype.debug = function (enabled) {
1612
+ if (enabled === void 0) {
1613
+ enabled = true;
1614
+ }
1615
+
1616
+ this.debugMode = enabled;
1617
+ };
1618
+
1608
1619
  FeatureFlagsPoller.prototype.getFeatureFlag = function (key, distinctId, groups, personProperties, groupProperties) {
1609
1620
  if (groups === void 0) {
1610
1621
  groups = {};
@@ -1652,9 +1663,15 @@ function () {
1652
1663
  if (featureFlag !== undefined) {
1653
1664
  try {
1654
1665
  response = this.computeFlagLocally(featureFlag, distinctId, groups, personProperties, groupProperties);
1666
+
1667
+ if (this.debugMode) {
1668
+ console.debug("Successfully computed flag locally: ".concat(key, " -> ").concat(response));
1669
+ }
1655
1670
  } catch (e) {
1656
1671
  if (e instanceof InconclusiveMatchError) {
1657
- console.error("InconclusiveMatchError when computing flag locally: ".concat(key, ": ").concat(e));
1672
+ if (this.debugMode) {
1673
+ console.debug("InconclusiveMatchError when computing flag locally: ".concat(key, ": ").concat(e));
1674
+ }
1658
1675
  } else if (e instanceof Error) {
1659
1676
  console.error("Error computing flag locally: ".concat(key, ": ").concat(e));
1660
1677
  }
@@ -2322,6 +2339,18 @@ function (_super) {
2322
2339
  return _super.prototype.optOut.call(this);
2323
2340
  };
2324
2341
 
2342
+ PostHog.prototype.debug = function (enabled) {
2343
+ var _a;
2344
+
2345
+ if (enabled === void 0) {
2346
+ enabled = true;
2347
+ }
2348
+
2349
+ _super.prototype.debug.call(this, enabled);
2350
+
2351
+ (_a = this.featureFlagsPoller) === null || _a === void 0 ? void 0 : _a.debug(enabled);
2352
+ };
2353
+
2325
2354
  PostHog.prototype.capture = function (_a) {
2326
2355
  var _this = this;
2327
2356