posthog-node 2.0.1 → 2.0.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 CHANGED
@@ -1,3 +1,8 @@
1
+ # 2.0.2 - 2022-08-23
2
+
3
+ 1. Removes references to `cli.js`
4
+ 2. Removes default `PostHogGlobal` export, and unifies import signature for `typescript`, `commonjs` and `esm` builds.
5
+
1
6
  # 2.0.1 - 2022-08-15
2
7
 
3
8
  Breaking changes:
@@ -5,8 +10,11 @@ Breaking changes:
5
10
  1. Feature flag defaults are no more. When we fail to compute any flag, we return `undefined`. All computed flags return either `true`, `false` or `String`.
6
11
  2. Minimum PostHog version requirement is 1.38
7
12
  3. Default polling interval for feature flags is now set at 30 seconds. If you don't want local evaluation, don't set a personal API key in the library.
13
+ 4. The `callback` parameter passed as an optional last argument to most of the methods is no longer supported
14
+ 5. The CLI is no longer supported
15
+
8
16
 
9
17
  What's new:
10
18
 
11
19
  1. You can now evaluate feature flags locally (i.e. without sending a request to your PostHog servers) by setting a personal API key, and passing in groups and person properties to `isFeatureEnabled` and `getFeatureFlag` calls.
12
- 2. Introduces a `getAllFlags` method that returns all feature flags. This is useful for when you want to seed your frontend with some initial flags, given a user ID.
20
+ 2. Introduces a `getAllFlags` method that returns all feature flags. This is useful for when you want to seed your frontend with some initial flags, given a user ID.
package/index.ts CHANGED
@@ -1,4 +1 @@
1
- import { PostHogGlobal } from './src/posthog-node'
2
1
  export * from './src/posthog-node'
3
-
4
- export default PostHogGlobal
package/lib/index.cjs.js CHANGED
@@ -151,7 +151,7 @@ function __spreadArray(to, from, pack) {
151
151
  return to.concat(ar || Array.prototype.slice.call(from));
152
152
  }
153
153
 
154
- var version = "2.0.1";
154
+ var version = "2.0.2";
155
155
 
156
156
  var PostHogPersistedProperty;
157
157
  (function (PostHogPersistedProperty) {
@@ -1777,12 +1777,12 @@ function isValidRegex(regex) {
1777
1777
  var THIRTY_SECONDS = 30 * 1000;
1778
1778
  var MAX_CACHE_SIZE = 50 * 1000;
1779
1779
 
1780
- var PostHog =
1780
+ var PostHogClient =
1781
1781
  /** @class */
1782
1782
  function (_super) {
1783
- __extends(PostHog, _super);
1783
+ __extends(PostHogClient, _super);
1784
1784
 
1785
- function PostHog(apiKey, options) {
1785
+ function PostHogClient(apiKey, options) {
1786
1786
  if (options === void 0) {
1787
1787
  options = {};
1788
1788
  }
@@ -1799,48 +1799,48 @@ function (_super) {
1799
1799
  return _this;
1800
1800
  }
1801
1801
 
1802
- PostHog.prototype.getPersistedProperty = function (key) {
1802
+ PostHogClient.prototype.getPersistedProperty = function (key) {
1803
1803
  return this._memoryStorage.getProperty(key);
1804
1804
  };
1805
1805
 
1806
- PostHog.prototype.setPersistedProperty = function (key, value) {
1806
+ PostHogClient.prototype.setPersistedProperty = function (key, value) {
1807
1807
  return this._memoryStorage.setProperty(key, value);
1808
1808
  };
1809
1809
 
1810
- PostHog.prototype.getSessionId = function () {
1810
+ PostHogClient.prototype.getSessionId = function () {
1811
1811
  // Sessions don't make sense for Node
1812
1812
  return undefined;
1813
1813
  };
1814
1814
 
1815
- PostHog.prototype.fetch = function (url, options) {
1815
+ PostHogClient.prototype.fetch = function (url, options) {
1816
1816
  return undici__default["default"].fetch(url, options);
1817
1817
  };
1818
1818
 
1819
- PostHog.prototype.getLibraryId = function () {
1819
+ PostHogClient.prototype.getLibraryId = function () {
1820
1820
  return 'posthog-node';
1821
1821
  };
1822
1822
 
1823
- PostHog.prototype.getLibraryVersion = function () {
1823
+ PostHogClient.prototype.getLibraryVersion = function () {
1824
1824
  return version;
1825
1825
  };
1826
1826
 
1827
- PostHog.prototype.getCustomUserAgent = function () {
1827
+ PostHogClient.prototype.getCustomUserAgent = function () {
1828
1828
  return "posthog-node/".concat(version);
1829
1829
  };
1830
1830
 
1831
- return PostHog;
1831
+ return PostHogClient;
1832
1832
  }(PostHogCore); // The actual exported Nodejs API.
1833
1833
 
1834
1834
 
1835
- var PostHogGlobal =
1835
+ var PostHog =
1836
1836
  /** @class */
1837
1837
  function () {
1838
- function PostHogGlobal(apiKey, options) {
1838
+ function PostHog(apiKey, options) {
1839
1839
  if (options === void 0) {
1840
1840
  options = {};
1841
1841
  }
1842
1842
 
1843
- this._sharedClient = new PostHog(apiKey, options);
1843
+ this._sharedClient = new PostHogClient(apiKey, options);
1844
1844
 
1845
1845
  if (options.personalApiKey) {
1846
1846
  this.featureFlagsPoller = new FeatureFlagsPoller({
@@ -1856,22 +1856,22 @@ function () {
1856
1856
  this.maxCacheSize = options.maxCacheSize || MAX_CACHE_SIZE;
1857
1857
  }
1858
1858
 
1859
- PostHogGlobal.prototype.reInit = function (distinctId) {
1859
+ PostHog.prototype.reInit = function (distinctId) {
1860
1860
  // Certain properties we want to persist. Queue is persisted always by default.
1861
1861
  this._sharedClient.reset([PostHogPersistedProperty.OptedOut]);
1862
1862
 
1863
1863
  this._sharedClient.setPersistedProperty(PostHogPersistedProperty.DistinctId, distinctId);
1864
1864
  };
1865
1865
 
1866
- PostHogGlobal.prototype.enable = function () {
1866
+ PostHog.prototype.enable = function () {
1867
1867
  return this._sharedClient.optIn();
1868
1868
  };
1869
1869
 
1870
- PostHogGlobal.prototype.disable = function () {
1870
+ PostHog.prototype.disable = function () {
1871
1871
  return this._sharedClient.optOut();
1872
1872
  };
1873
1873
 
1874
- PostHogGlobal.prototype.capture = function (_a) {
1874
+ PostHog.prototype.capture = function (_a) {
1875
1875
  var distinctId = _a.distinctId,
1876
1876
  event = _a.event,
1877
1877
  properties = _a.properties,
@@ -1886,7 +1886,7 @@ function () {
1886
1886
  this._sharedClient.capture(event, properties, sendFeatureFlags || false);
1887
1887
  };
1888
1888
 
1889
- PostHogGlobal.prototype.identify = function (_a) {
1889
+ PostHog.prototype.identify = function (_a) {
1890
1890
  var distinctId = _a.distinctId,
1891
1891
  properties = _a.properties;
1892
1892
  this.reInit(distinctId);
@@ -1894,13 +1894,13 @@ function () {
1894
1894
  this._sharedClient.identify(distinctId, properties);
1895
1895
  };
1896
1896
 
1897
- PostHogGlobal.prototype.alias = function (data) {
1897
+ PostHog.prototype.alias = function (data) {
1898
1898
  this.reInit(data.distinctId);
1899
1899
 
1900
1900
  this._sharedClient.alias(data.alias);
1901
1901
  };
1902
1902
 
1903
- PostHogGlobal.prototype.getFeatureFlag = function (key, distinctId, options) {
1903
+ PostHog.prototype.getFeatureFlag = function (key, distinctId, options) {
1904
1904
  var _a;
1905
1905
 
1906
1906
  return __awaiter(this, void 0, void 0, function () {
@@ -1988,7 +1988,7 @@ function () {
1988
1988
  });
1989
1989
  };
1990
1990
 
1991
- PostHogGlobal.prototype.isFeatureEnabled = function (key, distinctId, options) {
1991
+ PostHog.prototype.isFeatureEnabled = function (key, distinctId, options) {
1992
1992
  return __awaiter(this, void 0, void 0, function () {
1993
1993
  var feat;
1994
1994
  return __generator(this, function (_a) {
@@ -2015,7 +2015,7 @@ function () {
2015
2015
  });
2016
2016
  };
2017
2017
 
2018
- PostHogGlobal.prototype.getAllFlags = function (distinctId, options) {
2018
+ PostHog.prototype.getAllFlags = function (distinctId, options) {
2019
2019
  var _a;
2020
2020
 
2021
2021
  return __awaiter(this, void 0, void 0, function () {
@@ -2083,7 +2083,7 @@ function () {
2083
2083
  });
2084
2084
  };
2085
2085
 
2086
- PostHogGlobal.prototype.groupIdentify = function (_a) {
2086
+ PostHog.prototype.groupIdentify = function (_a) {
2087
2087
  var groupType = _a.groupType,
2088
2088
  groupKey = _a.groupKey,
2089
2089
  properties = _a.properties;
@@ -2091,7 +2091,7 @@ function () {
2091
2091
  this._sharedClient.groupIdentify(groupType, groupKey, properties);
2092
2092
  };
2093
2093
 
2094
- PostHogGlobal.prototype.reloadFeatureFlags = function () {
2094
+ PostHog.prototype.reloadFeatureFlags = function () {
2095
2095
  var _a;
2096
2096
 
2097
2097
  return __awaiter(this, void 0, void 0, function () {
@@ -2113,15 +2113,15 @@ function () {
2113
2113
  });
2114
2114
  };
2115
2115
 
2116
- PostHogGlobal.prototype.flush = function () {
2116
+ PostHog.prototype.flush = function () {
2117
2117
  this._sharedClient.flush();
2118
2118
  };
2119
2119
 
2120
- PostHogGlobal.prototype.shutdown = function () {
2120
+ PostHog.prototype.shutdown = function () {
2121
2121
  void this.shutdownAsync();
2122
2122
  };
2123
2123
 
2124
- PostHogGlobal.prototype.shutdownAsync = function () {
2124
+ PostHog.prototype.shutdownAsync = function () {
2125
2125
  var _a;
2126
2126
 
2127
2127
  return __awaiter(this, void 0, void 0, function () {
@@ -2134,13 +2134,12 @@ function () {
2134
2134
  });
2135
2135
  };
2136
2136
 
2137
- PostHogGlobal.prototype.debug = function (enabled) {
2137
+ PostHog.prototype.debug = function (enabled) {
2138
2138
  return this._sharedClient.debug(enabled);
2139
2139
  };
2140
2140
 
2141
- return PostHogGlobal;
2141
+ return PostHog;
2142
2142
  }();
2143
2143
 
2144
- exports.PostHogGlobal = PostHogGlobal;
2145
- exports["default"] = PostHogGlobal;
2144
+ exports.PostHog = PostHog;
2146
2145
  //# sourceMappingURL=index.cjs.js.map