posthog-node
Advanced tools
Comparing version 4.5.2 to 4.6.0
# Next | ||
# 4.6.0 - 2025-02-12 | ||
## Added | ||
1. Adds ability to fetch decrypted remote config flag payloads via `getRemoteConfigPayload` | ||
# 4.5.2 - 2025-02-12 | ||
@@ -4,0 +10,0 @@ |
@@ -449,2 +449,3 @@ /// <reference types="node" /> | ||
}): Promise<JsonType | undefined>; | ||
getRemoteConfigPayload(flagKey: string): Promise<JsonType | undefined>; | ||
isFeatureEnabled(key: string, distinctId: string, options?: { | ||
@@ -451,0 +452,0 @@ groups?: Record<string, string>; |
@@ -61,4 +61,6 @@ /// <reference types="node" /> | ||
_loadFeatureFlags(): Promise<void>; | ||
private getPersonalApiKeyRequestOptions; | ||
_requestFeatureFlagDefinitions(): Promise<PostHogFetchResponse>; | ||
stopPoller(): void; | ||
_requestRemoteConfigPayload(flagKey: string): Promise<PostHogFetchResponse>; | ||
} | ||
@@ -65,0 +67,0 @@ declare function matchProperty(property: FeatureFlagCondition['properties'][number], propertyValues: Record<string, any>, warnFunction?: (msg: string) => void): boolean; |
@@ -53,2 +53,3 @@ import { JsonType, PostHogCoreOptions, PostHogCoreStateless, PostHogFetchOptions, PostHogFetchResponse, PostHogFlagsAndPayloadsResponse, PostHogPersistedProperty } from '../../posthog-core/src'; | ||
}): Promise<JsonType | undefined>; | ||
getRemoteConfigPayload(flagKey: string): Promise<JsonType | undefined>; | ||
isFeatureEnabled(key: string, distinctId: string, options?: { | ||
@@ -55,0 +56,0 @@ groups?: Record<string, string>; |
{ | ||
"name": "posthog-node", | ||
"version": "4.5.2", | ||
"version": "4.6.0", | ||
"description": "PostHog Node.js integration", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -422,7 +422,5 @@ import { createHash } from 'node:crypto' | ||
async _requestFeatureFlagDefinitions(): Promise<PostHogFetchResponse> { | ||
const url = `${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts` | ||
const options: PostHogFetchOptions = { | ||
method: 'GET', | ||
private getPersonalApiKeyRequestOptions(method: 'GET' | 'POST' | 'PUT' | 'PATCH' = 'GET'): PostHogFetchOptions { | ||
return { | ||
method, | ||
headers: { | ||
@@ -434,3 +432,9 @@ ...this.customHeaders, | ||
} | ||
} | ||
async _requestFeatureFlagDefinitions(): Promise<PostHogFetchResponse> { | ||
const url = `${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts` | ||
const options = this.getPersonalApiKeyRequestOptions() | ||
let abortTimeout = null | ||
@@ -456,2 +460,22 @@ | ||
} | ||
_requestRemoteConfigPayload(flagKey: string): Promise<PostHogFetchResponse> { | ||
const url = `${this.host}/api/projects/@current/feature_flags/${flagKey}/remote_config/` | ||
const options = this.getPersonalApiKeyRequestOptions() | ||
let abortTimeout = null | ||
if (this.timeout && typeof this.timeout === 'number') { | ||
const controller = new AbortController() | ||
abortTimeout = safeSetTimeout(() => { | ||
controller.abort() | ||
}, this.timeout) | ||
options.signal = controller.signal | ||
} | ||
try { | ||
return this.fetch(url, options) | ||
} finally { | ||
clearTimeout(abortTimeout) | ||
} | ||
} | ||
} | ||
@@ -458,0 +482,0 @@ |
@@ -362,2 +362,6 @@ import { version } from '../package.json' | ||
async getRemoteConfigPayload(flagKey: string): Promise<JsonType | undefined> { | ||
return (await this.featureFlagsPoller?._requestRemoteConfigPayload(flagKey))?.json() | ||
} | ||
async isFeatureEnabled( | ||
@@ -364,0 +368,0 @@ key: string, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1182685
16550
78
6
20