posthog-node 4.5.2 → 4.7.0

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,5 +1,17 @@
1
1
  # Next
2
2
 
3
+ # 4.7.0 - 2025-02-20
4
+
5
+ ## Added
6
+
7
+ 1. Adds the ability to capture user feedback in LLM Observability using the `captureTraceFeedback` and `captureTraceMetric` methods.
8
+
9
+ # 4.6.0 - 2025-02-12
10
+
11
+ ## Added
12
+
13
+ 1. Adds ability to fetch decrypted remote config flag payloads via `getRemoteConfigPayload`
14
+
3
15
  # 4.5.2 - 2025-02-12
4
16
 
5
17
  ## Fixed
package/lib/index.cjs.js CHANGED
@@ -7,7 +7,7 @@ var node_fs = require('node:fs');
7
7
  var node_readline = require('node:readline');
8
8
  var node_path = require('node:path');
9
9
 
10
- var version = "4.5.2";
10
+ var version = "4.7.0";
11
11
 
12
12
  var PostHogPersistedProperty;
13
13
  (function (PostHogPersistedProperty) {
@@ -1759,16 +1759,19 @@ class FeatureFlagsPoller {
1759
1759
  }
1760
1760
  }
1761
1761
  }
1762
- async _requestFeatureFlagDefinitions() {
1763
- const url = `${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`;
1764
- const options = {
1765
- method: 'GET',
1762
+ getPersonalApiKeyRequestOptions(method = 'GET') {
1763
+ return {
1764
+ method,
1766
1765
  headers: {
1767
1766
  ...this.customHeaders,
1768
1767
  'Content-Type': 'application/json',
1769
1768
  Authorization: `Bearer ${this.personalApiKey}`
1770
1769
  }
1771
1770
  };
1771
+ }
1772
+ async _requestFeatureFlagDefinitions() {
1773
+ const url = `${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`;
1774
+ const options = this.getPersonalApiKeyRequestOptions();
1772
1775
  let abortTimeout = null;
1773
1776
  if (this.timeout && typeof this.timeout === 'number') {
1774
1777
  const controller = new AbortController();
@@ -1786,6 +1789,23 @@ class FeatureFlagsPoller {
1786
1789
  stopPoller() {
1787
1790
  clearTimeout(this.poller);
1788
1791
  }
1792
+ _requestRemoteConfigPayload(flagKey) {
1793
+ const url = `${this.host}/api/projects/@current/feature_flags/${flagKey}/remote_config/`;
1794
+ const options = this.getPersonalApiKeyRequestOptions();
1795
+ let abortTimeout = null;
1796
+ if (this.timeout && typeof this.timeout === 'number') {
1797
+ const controller = new AbortController();
1798
+ abortTimeout = safeSetTimeout(() => {
1799
+ controller.abort();
1800
+ }, this.timeout);
1801
+ options.signal = controller.signal;
1802
+ }
1803
+ try {
1804
+ return this.fetch(url, options);
1805
+ } finally {
1806
+ clearTimeout(abortTimeout);
1807
+ }
1808
+ }
1789
1809
  }
1790
1810
  // # This function takes a distinct_id and a feature flag key and returns a float between 0 and 1.
1791
1811
  // # Given the same distinct_id and key, it'll always return the same float. These floats are
@@ -3159,6 +3179,9 @@ class PostHog extends PostHogCoreStateless {
3159
3179
  }
3160
3180
  return response;
3161
3181
  }
3182
+ async getRemoteConfigPayload(flagKey) {
3183
+ return (await this.featureFlagsPoller?._requestRemoteConfigPayload(flagKey))?.json();
3184
+ }
3162
3185
  async isFeatureEnabled(key, distinctId, options) {
3163
3186
  const feat = await this.getFeatureFlag(key, distinctId, options);
3164
3187
  if (feat === undefined) {