posthog-node 4.14.0 → 5.0.0-alpha.1

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,9 @@
1
+ # 5.0.0-alpha.1 - 2025-04-29
2
+
3
+ ## Breaking changes
4
+
5
+ 1. feat: migrate to native fetch, Node 18+ required
6
+
1
7
  # 4.14.0 - 2025-04-24
2
8
 
3
9
  1. feat: Add super properties as a concept to the Node SDK
package/lib/index.cjs.js CHANGED
@@ -22,7 +22,7 @@ function _interopNamespace(e) {
22
22
  return Object.freeze(n);
23
23
  }
24
24
 
25
- var version = "4.14.0";
25
+ var version = "5.0.0-alpha.1";
26
26
 
27
27
  var PostHogPersistedProperty;
28
28
  (function (PostHogPersistedProperty) {
@@ -326,9 +326,6 @@ function safeSetTimeout(fn, timeout) {
326
326
  t?.unref && t?.unref();
327
327
  return t;
328
328
  }
329
- function getFetch() {
330
- return typeof fetch !== 'undefined' ? fetch : typeof globalThis.fetch !== 'undefined' ? globalThis.fetch : undefined;
331
- }
332
329
  // FNV-1a hash function
333
330
  // https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
334
331
  // I know, I know, I'm rolling my own hash function, but I didn't want to take on
@@ -1836,38 +1833,6 @@ class PostHogMemoryStorage {
1836
1833
  }
1837
1834
  }
1838
1835
 
1839
- /**
1840
- * Fetch wrapper
1841
- *
1842
- * We want to polyfill fetch when not available with axios but use it when it is.
1843
- * NOTE: The current version of Axios has an issue when in non-node environments like Clouflare Workers.
1844
- * This is currently solved by using the global fetch if available instead.
1845
- * See https://github.com/PostHog/posthog-js-lite/issues/127 for more info
1846
- */
1847
- let _fetch = getFetch();
1848
- if (!_fetch) {
1849
- // eslint-disable-next-line @typescript-eslint/no-var-requires
1850
- const axios = require('axios');
1851
- _fetch = async (url, options) => {
1852
- const res = await axios.request({
1853
- url,
1854
- headers: options.headers,
1855
- method: options.method.toLowerCase(),
1856
- data: options.body,
1857
- signal: options.signal,
1858
- // fetch only throws on network errors, not on HTTP errors
1859
- validateStatus: () => true
1860
- });
1861
- return {
1862
- status: res.status,
1863
- text: async () => res.data,
1864
- json: async () => res.data
1865
- };
1866
- };
1867
- }
1868
- // NOTE: We have to export this as default, even though we prefer named exports as we are relying on detecting "fetch" in the global scope
1869
- var fetch$1 = _fetch;
1870
-
1871
1836
  /**
1872
1837
  * A lazy value that is only computed when needed. Inspired by C#'s Lazy<T> class.
1873
1838
  */
@@ -2009,7 +1974,7 @@ class FeatureFlagsPoller {
2009
1974
  this.projectApiKey = projectApiKey;
2010
1975
  this.host = host;
2011
1976
  this.poller = undefined;
2012
- this.fetch = options.fetch || fetch$1;
1977
+ this.fetch = options.fetch || fetch;
2013
1978
  this.onError = options.onError;
2014
1979
  this.customHeaders = customHeaders;
2015
1980
  this.onLoad = options.onLoad;
@@ -3594,7 +3559,7 @@ class PostHog extends PostHogCoreStateless {
3594
3559
  return this._memoryStorage.setProperty(key, value);
3595
3560
  }
3596
3561
  fetch(url, options) {
3597
- return this.options.fetch ? this.options.fetch(url, options) : fetch$1(url, options);
3562
+ return this.options.fetch ? this.options.fetch(url, options) : fetch(url, options);
3598
3563
  }
3599
3564
  getLibraryId() {
3600
3565
  return 'posthog-node';