posthog-node
Advanced tools
| import { FeatureFlagValue, JsonType } from '@posthog/core'; | ||
| /** | ||
| * Internal per-flag record stored by a {@link FeatureFlagEvaluations} instance. | ||
| * Not part of the public API. | ||
| * | ||
| * @internal | ||
| */ | ||
| export type EvaluatedFlagRecord = { | ||
| key: string; | ||
| enabled: boolean; | ||
| variant: string | undefined; | ||
| payload: JsonType | undefined; | ||
| id: number | undefined; | ||
| version: number | undefined; | ||
| reason: string | undefined; | ||
| locallyEvaluated: boolean; | ||
| }; | ||
| /** | ||
| * Parameters passed to the host when a `$feature_flag_called` event should be captured. | ||
| * | ||
| * @internal | ||
| */ | ||
| export type FlagCalledEventParams = { | ||
| distinctId: string; | ||
| key: string; | ||
| response: FeatureFlagValue | undefined; | ||
| groups: Record<string, string | number> | undefined; | ||
| disableGeoip: boolean | undefined; | ||
| properties: Record<string, any>; | ||
| }; | ||
| /** | ||
| * Thin interface the evaluations object uses to talk back to the PostHog client. | ||
| * Keeps the class decoupled from the full client surface area. | ||
| * | ||
| * @internal | ||
| */ | ||
| export interface FeatureFlagEvaluationsHost { | ||
| captureFlagCalledEventIfNeeded(params: FlagCalledEventParams): void; | ||
| logWarning(message: string): void; | ||
| } | ||
| /** | ||
| * A snapshot of feature flag evaluations for a single distinctId at a point in time. | ||
| * | ||
| * Returned by {@link IPostHog.evaluateFlags} — branch on `isEnabled()` / `getFlag()` | ||
| * and pass the same object to `capture()` via the `flags` option so the captured event | ||
| * carries the exact flag values the code branched on. | ||
| * | ||
| * ```ts | ||
| * const flags = await posthog.evaluateFlags(distinctId, { personProperties: { plan: 'enterprise' } }) | ||
| * | ||
| * if (flags.isEnabled('new-dashboard')) { | ||
| * renderNewDashboard() | ||
| * } | ||
| * | ||
| * posthog.capture({ distinctId, event: 'page_viewed', flags }) | ||
| * ``` | ||
| * | ||
| * To narrow the set of flags that get attached to a captured event, use the in-memory | ||
| * helpers `only([...])` and `onlyAccessed()`. To narrow the set of flags requested from | ||
| * the server in the first place, pass `flagKeys` to `evaluateFlags()`. | ||
| */ | ||
| export declare class FeatureFlagEvaluations { | ||
| private readonly _host; | ||
| private readonly _distinctId; | ||
| private readonly _groups; | ||
| private readonly _disableGeoip; | ||
| private readonly _flags; | ||
| private readonly _requestId; | ||
| private readonly _evaluatedAt; | ||
| private readonly _flagDefinitionsLoadedAt; | ||
| private readonly _errorsWhileComputing; | ||
| private readonly _quotaLimited; | ||
| private readonly _accessed; | ||
| private readonly _isSlice; | ||
| /** | ||
| * @internal — instances are created by the SDK via `posthog.evaluateFlags()`. | ||
| */ | ||
| constructor(init: { | ||
| host: FeatureFlagEvaluationsHost; | ||
| distinctId: string; | ||
| groups?: Record<string, string | number>; | ||
| disableGeoip?: boolean; | ||
| flags: Record<string, EvaluatedFlagRecord>; | ||
| requestId?: string; | ||
| evaluatedAt?: number; | ||
| flagDefinitionsLoadedAt?: number; | ||
| errorsWhileComputing?: boolean; | ||
| quotaLimited?: boolean; | ||
| accessed?: Set<string>; | ||
| isSlice?: boolean; | ||
| }); | ||
| /** | ||
| * Check whether a feature flag is enabled. Fires a `$feature_flag_called` event | ||
| * on the first access per (distinctId, flag, value) tuple, deduped via the SDK's | ||
| * existing cache. | ||
| * | ||
| * Flags that were not returned from the underlying evaluation are treated as | ||
| * disabled (returns `false`). | ||
| */ | ||
| isEnabled(key: string): boolean; | ||
| /** | ||
| * Get the evaluated value of a feature flag. Fires a `$feature_flag_called` event | ||
| * on the first access per (distinctId, flag, value) tuple. | ||
| * | ||
| * Returns the variant string for multivariate flags, `true` for enabled flags | ||
| * without a variant, `false` for disabled flags, and `undefined` for flags that | ||
| * were not returned by the evaluation. | ||
| */ | ||
| getFlag(key: string): FeatureFlagValue | undefined; | ||
| /** | ||
| * Get the payload associated with a feature flag. Does not count as an access | ||
| * for `onlyAccessed()` and does not fire any event. | ||
| */ | ||
| getFlagPayload(key: string): JsonType | undefined; | ||
| /** | ||
| * Return a filtered copy containing only flags that have been accessed via | ||
| * `isEnabled()` or `getFlag()` before this call. | ||
| * | ||
| * Order-dependent: if nothing has been accessed yet, the returned snapshot is | ||
| * empty. The method honors its name — pre-access if you want a populated result. | ||
| * | ||
| * **Note:** the returned snapshot is intended for `capture()`, not for further | ||
| * branching. Calling `isEnabled()` / `getFlag()` on it for a key that was filtered | ||
| * out is a no-op (no event is fired) — the flag wasn't actually missing, it was | ||
| * excluded from the slice. | ||
| */ | ||
| onlyAccessed(): FeatureFlagEvaluations; | ||
| /** | ||
| * Return a filtered copy containing only flags with the given keys. Keys that | ||
| * are not present in the evaluation are dropped and logged as a warning. | ||
| * | ||
| * **Note:** like `onlyAccessed()`, the returned snapshot is intended for `capture()`. | ||
| * Branching on a filtered key that was excluded from the slice is a no-op. | ||
| */ | ||
| only(keys: string[]): FeatureFlagEvaluations; | ||
| /** | ||
| * Returns the flag keys that are part of this evaluation. | ||
| */ | ||
| get keys(): string[]; | ||
| /** | ||
| * Build the `$feature/*` and `$active_feature_flags` event properties derived | ||
| * from the current flag set. Called by `capture()` when an event is captured | ||
| * with `flags: ...`. | ||
| * | ||
| * @internal | ||
| */ | ||
| _getEventProperties(): Record<string, any>; | ||
| private _cloneWith; | ||
| private _recordAccess; | ||
| } | ||
| //# sourceMappingURL=feature-flag-evaluations.d.ts.map |
| {"version":3,"file":"feature-flag-evaluations.d.ts","sourceRoot":"","sources":["../src/feature-flag-evaluations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAI1D;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,OAAO,EAAE,QAAQ,GAAG,SAAS,CAAA;IAC7B,EAAE,EAAE,MAAM,GAAG,SAAS,CAAA;IACtB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,MAAM,EAAE,MAAM,GAAG,SAAS,CA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EAAE,MAAM,CAAA;QAClB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAA;QACxC,YAAY,CAAC,EAAE,OAAO,CAAA;QACtB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAA;QAC1C,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,uBAAuB,CAAC,EAAE,MAAM,CAAA;QAChC,oBAAoB,CAAC,EAAE,OAAO,CAAA;QAC9B,YAAY,CAAC,EAAE,OAAO,CAAA;QACtB,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;QACtB,OAAO,CAAC,EAAE,OAAO,CAAA;KAClB;IAeD;;;;;;;OAOG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAM/B;;;;;;;OAOG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS;IAYlD;;;OAGG;IACH,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS;IAIjD;;;;;;;;;;;OAWG;IACH,YAAY,IAAI,sBAAsB;IAWtC;;;;;;OAMG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,sBAAsB;IAmB5C;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,EAAE,CAEnB;IAED;;;;;;OAMG;IACH,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAiB1C,OAAO,CAAC,UAAU;IAoBlB,OAAO,CAAC,aAAa;CAgEtB"} |
| "use strict"; | ||
| var __webpack_require__ = {}; | ||
| (()=>{ | ||
| __webpack_require__.d = (exports1, definition)=>{ | ||
| for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, { | ||
| enumerable: true, | ||
| get: definition[key] | ||
| }); | ||
| }; | ||
| })(); | ||
| (()=>{ | ||
| __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop); | ||
| })(); | ||
| (()=>{ | ||
| __webpack_require__.r = (exports1)=>{ | ||
| if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, { | ||
| value: 'Module' | ||
| }); | ||
| Object.defineProperty(exports1, '__esModule', { | ||
| value: true | ||
| }); | ||
| }; | ||
| })(); | ||
| var __webpack_exports__ = {}; | ||
| __webpack_require__.r(__webpack_exports__); | ||
| __webpack_require__.d(__webpack_exports__, { | ||
| FeatureFlagEvaluations: ()=>FeatureFlagEvaluations | ||
| }); | ||
| const external_types_js_namespaceObject = require("./types.js"); | ||
| class FeatureFlagEvaluations { | ||
| constructor(init){ | ||
| this._host = init.host; | ||
| this._distinctId = init.distinctId; | ||
| this._groups = init.groups; | ||
| this._disableGeoip = init.disableGeoip; | ||
| this._flags = init.flags; | ||
| this._requestId = init.requestId; | ||
| this._evaluatedAt = init.evaluatedAt; | ||
| this._flagDefinitionsLoadedAt = init.flagDefinitionsLoadedAt; | ||
| this._errorsWhileComputing = init.errorsWhileComputing ?? false; | ||
| this._quotaLimited = init.quotaLimited ?? false; | ||
| this._accessed = init.accessed ?? new Set(); | ||
| this._isSlice = init.isSlice ?? false; | ||
| } | ||
| isEnabled(key) { | ||
| const flag = this._flags[key]; | ||
| this._recordAccess(key); | ||
| return flag?.enabled ?? false; | ||
| } | ||
| getFlag(key) { | ||
| const flag = this._flags[key]; | ||
| this._recordAccess(key); | ||
| if (!flag) return; | ||
| if (!flag.enabled) return false; | ||
| return flag.variant ?? true; | ||
| } | ||
| getFlagPayload(key) { | ||
| return this._flags[key]?.payload; | ||
| } | ||
| onlyAccessed() { | ||
| const filtered = {}; | ||
| for (const key of this._accessed){ | ||
| const flag = this._flags[key]; | ||
| if (flag) filtered[key] = flag; | ||
| } | ||
| return this._cloneWith(filtered); | ||
| } | ||
| only(keys) { | ||
| const filtered = {}; | ||
| const missing = []; | ||
| for (const key of keys){ | ||
| const flag = this._flags[key]; | ||
| if (flag) filtered[key] = flag; | ||
| else missing.push(key); | ||
| } | ||
| if (missing.length > 0) this._host.logWarning(`FeatureFlagEvaluations.only() was called with flag keys that are not in the evaluation set and will be dropped: ${missing.join(', ')}`); | ||
| return this._cloneWith(filtered); | ||
| } | ||
| get keys() { | ||
| return Object.keys(this._flags); | ||
| } | ||
| _getEventProperties() { | ||
| const properties = {}; | ||
| const activeFlags = []; | ||
| for (const [key, flag] of Object.entries(this._flags)){ | ||
| const value = false === flag.enabled ? false : flag.variant ?? true; | ||
| properties[`$feature/${key}`] = value; | ||
| if (flag.enabled) activeFlags.push(key); | ||
| } | ||
| if (activeFlags.length > 0) { | ||
| activeFlags.sort(); | ||
| properties['$active_feature_flags'] = activeFlags; | ||
| } | ||
| return properties; | ||
| } | ||
| _cloneWith(flags) { | ||
| return new FeatureFlagEvaluations({ | ||
| host: this._host, | ||
| distinctId: this._distinctId, | ||
| groups: this._groups, | ||
| disableGeoip: this._disableGeoip, | ||
| flags, | ||
| requestId: this._requestId, | ||
| evaluatedAt: this._evaluatedAt, | ||
| flagDefinitionsLoadedAt: this._flagDefinitionsLoadedAt, | ||
| errorsWhileComputing: this._errorsWhileComputing, | ||
| quotaLimited: this._quotaLimited, | ||
| accessed: new Set(this._accessed), | ||
| isSlice: true | ||
| }); | ||
| } | ||
| _recordAccess(key) { | ||
| this._accessed.add(key); | ||
| if ('' === this._distinctId) return; | ||
| if (this._isSlice && !(key in this._flags)) return; | ||
| const flag = this._flags[key]; | ||
| const response = void 0 === flag ? void 0 : false === flag.enabled ? false : flag.variant ?? true; | ||
| const properties = { | ||
| $feature_flag: key, | ||
| $feature_flag_response: response, | ||
| $feature_flag_id: flag?.id, | ||
| $feature_flag_version: flag?.version, | ||
| $feature_flag_reason: flag?.reason, | ||
| locally_evaluated: flag?.locallyEvaluated ?? false, | ||
| [`$feature/${key}`]: response, | ||
| $feature_flag_request_id: this._requestId, | ||
| $feature_flag_evaluated_at: flag?.locallyEvaluated ? Date.now() : this._evaluatedAt | ||
| }; | ||
| if (flag?.locallyEvaluated && void 0 !== this._flagDefinitionsLoadedAt) properties.$feature_flag_definitions_loaded_at = this._flagDefinitionsLoadedAt; | ||
| const errors = []; | ||
| if (this._errorsWhileComputing) errors.push(external_types_js_namespaceObject.FeatureFlagError.ERRORS_WHILE_COMPUTING); | ||
| if (this._quotaLimited) errors.push(external_types_js_namespaceObject.FeatureFlagError.QUOTA_LIMITED); | ||
| if (void 0 === flag) errors.push(external_types_js_namespaceObject.FeatureFlagError.FLAG_MISSING); | ||
| if (errors.length > 0) properties.$feature_flag_error = errors.join(','); | ||
| this._host.captureFlagCalledEventIfNeeded({ | ||
| distinctId: this._distinctId, | ||
| key, | ||
| response, | ||
| groups: this._groups, | ||
| disableGeoip: this._disableGeoip, | ||
| properties | ||
| }); | ||
| } | ||
| } | ||
| exports.FeatureFlagEvaluations = __webpack_exports__.FeatureFlagEvaluations; | ||
| for(var __webpack_i__ in __webpack_exports__)if (-1 === [ | ||
| "FeatureFlagEvaluations" | ||
| ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__]; | ||
| Object.defineProperty(exports, '__esModule', { | ||
| value: true | ||
| }); |
| import { FeatureFlagError } from "./types.mjs"; | ||
| class FeatureFlagEvaluations { | ||
| constructor(init){ | ||
| this._host = init.host; | ||
| this._distinctId = init.distinctId; | ||
| this._groups = init.groups; | ||
| this._disableGeoip = init.disableGeoip; | ||
| this._flags = init.flags; | ||
| this._requestId = init.requestId; | ||
| this._evaluatedAt = init.evaluatedAt; | ||
| this._flagDefinitionsLoadedAt = init.flagDefinitionsLoadedAt; | ||
| this._errorsWhileComputing = init.errorsWhileComputing ?? false; | ||
| this._quotaLimited = init.quotaLimited ?? false; | ||
| this._accessed = init.accessed ?? new Set(); | ||
| this._isSlice = init.isSlice ?? false; | ||
| } | ||
| isEnabled(key) { | ||
| const flag = this._flags[key]; | ||
| this._recordAccess(key); | ||
| return flag?.enabled ?? false; | ||
| } | ||
| getFlag(key) { | ||
| const flag = this._flags[key]; | ||
| this._recordAccess(key); | ||
| if (!flag) return; | ||
| if (!flag.enabled) return false; | ||
| return flag.variant ?? true; | ||
| } | ||
| getFlagPayload(key) { | ||
| return this._flags[key]?.payload; | ||
| } | ||
| onlyAccessed() { | ||
| const filtered = {}; | ||
| for (const key of this._accessed){ | ||
| const flag = this._flags[key]; | ||
| if (flag) filtered[key] = flag; | ||
| } | ||
| return this._cloneWith(filtered); | ||
| } | ||
| only(keys) { | ||
| const filtered = {}; | ||
| const missing = []; | ||
| for (const key of keys){ | ||
| const flag = this._flags[key]; | ||
| if (flag) filtered[key] = flag; | ||
| else missing.push(key); | ||
| } | ||
| if (missing.length > 0) this._host.logWarning(`FeatureFlagEvaluations.only() was called with flag keys that are not in the evaluation set and will be dropped: ${missing.join(', ')}`); | ||
| return this._cloneWith(filtered); | ||
| } | ||
| get keys() { | ||
| return Object.keys(this._flags); | ||
| } | ||
| _getEventProperties() { | ||
| const properties = {}; | ||
| const activeFlags = []; | ||
| for (const [key, flag] of Object.entries(this._flags)){ | ||
| const value = false === flag.enabled ? false : flag.variant ?? true; | ||
| properties[`$feature/${key}`] = value; | ||
| if (flag.enabled) activeFlags.push(key); | ||
| } | ||
| if (activeFlags.length > 0) { | ||
| activeFlags.sort(); | ||
| properties['$active_feature_flags'] = activeFlags; | ||
| } | ||
| return properties; | ||
| } | ||
| _cloneWith(flags) { | ||
| return new FeatureFlagEvaluations({ | ||
| host: this._host, | ||
| distinctId: this._distinctId, | ||
| groups: this._groups, | ||
| disableGeoip: this._disableGeoip, | ||
| flags, | ||
| requestId: this._requestId, | ||
| evaluatedAt: this._evaluatedAt, | ||
| flagDefinitionsLoadedAt: this._flagDefinitionsLoadedAt, | ||
| errorsWhileComputing: this._errorsWhileComputing, | ||
| quotaLimited: this._quotaLimited, | ||
| accessed: new Set(this._accessed), | ||
| isSlice: true | ||
| }); | ||
| } | ||
| _recordAccess(key) { | ||
| this._accessed.add(key); | ||
| if ('' === this._distinctId) return; | ||
| if (this._isSlice && !(key in this._flags)) return; | ||
| const flag = this._flags[key]; | ||
| const response = void 0 === flag ? void 0 : false === flag.enabled ? false : flag.variant ?? true; | ||
| const properties = { | ||
| $feature_flag: key, | ||
| $feature_flag_response: response, | ||
| $feature_flag_id: flag?.id, | ||
| $feature_flag_version: flag?.version, | ||
| $feature_flag_reason: flag?.reason, | ||
| locally_evaluated: flag?.locallyEvaluated ?? false, | ||
| [`$feature/${key}`]: response, | ||
| $feature_flag_request_id: this._requestId, | ||
| $feature_flag_evaluated_at: flag?.locallyEvaluated ? Date.now() : this._evaluatedAt | ||
| }; | ||
| if (flag?.locallyEvaluated && void 0 !== this._flagDefinitionsLoadedAt) properties.$feature_flag_definitions_loaded_at = this._flagDefinitionsLoadedAt; | ||
| const errors = []; | ||
| if (this._errorsWhileComputing) errors.push(FeatureFlagError.ERRORS_WHILE_COMPUTING); | ||
| if (this._quotaLimited) errors.push(FeatureFlagError.QUOTA_LIMITED); | ||
| if (void 0 === flag) errors.push(FeatureFlagError.FLAG_MISSING); | ||
| if (errors.length > 0) properties.$feature_flag_error = errors.join(','); | ||
| this._host.captureFlagCalledEventIfNeeded({ | ||
| distinctId: this._distinctId, | ||
| key, | ||
| response, | ||
| groups: this._groups, | ||
| disableGeoip: this._disableGeoip, | ||
| properties | ||
| }); | ||
| } | ||
| } | ||
| export { FeatureFlagEvaluations }; |
| import { FeatureFlagValue, JsonType } from '@posthog/core' | ||
| import { FeatureFlagError } from './types' | ||
| /** | ||
| * Internal per-flag record stored by a {@link FeatureFlagEvaluations} instance. | ||
| * Not part of the public API. | ||
| * | ||
| * @internal | ||
| */ | ||
| export type EvaluatedFlagRecord = { | ||
| key: string | ||
| enabled: boolean | ||
| variant: string | undefined | ||
| payload: JsonType | undefined | ||
| id: number | undefined | ||
| version: number | undefined | ||
| reason: string | undefined | ||
| locallyEvaluated: boolean | ||
| } | ||
| /** | ||
| * Parameters passed to the host when a `$feature_flag_called` event should be captured. | ||
| * | ||
| * @internal | ||
| */ | ||
| export type FlagCalledEventParams = { | ||
| distinctId: string | ||
| key: string | ||
| response: FeatureFlagValue | undefined | ||
| groups: Record<string, string | number> | undefined | ||
| disableGeoip: boolean | undefined | ||
| properties: Record<string, any> | ||
| } | ||
| /** | ||
| * Thin interface the evaluations object uses to talk back to the PostHog client. | ||
| * Keeps the class decoupled from the full client surface area. | ||
| * | ||
| * @internal | ||
| */ | ||
| export interface FeatureFlagEvaluationsHost { | ||
| captureFlagCalledEventIfNeeded(params: FlagCalledEventParams): void | ||
| logWarning(message: string): void | ||
| } | ||
| /** | ||
| * A snapshot of feature flag evaluations for a single distinctId at a point in time. | ||
| * | ||
| * Returned by {@link IPostHog.evaluateFlags} — branch on `isEnabled()` / `getFlag()` | ||
| * and pass the same object to `capture()` via the `flags` option so the captured event | ||
| * carries the exact flag values the code branched on. | ||
| * | ||
| * ```ts | ||
| * const flags = await posthog.evaluateFlags(distinctId, { personProperties: { plan: 'enterprise' } }) | ||
| * | ||
| * if (flags.isEnabled('new-dashboard')) { | ||
| * renderNewDashboard() | ||
| * } | ||
| * | ||
| * posthog.capture({ distinctId, event: 'page_viewed', flags }) | ||
| * ``` | ||
| * | ||
| * To narrow the set of flags that get attached to a captured event, use the in-memory | ||
| * helpers `only([...])` and `onlyAccessed()`. To narrow the set of flags requested from | ||
| * the server in the first place, pass `flagKeys` to `evaluateFlags()`. | ||
| */ | ||
| export class FeatureFlagEvaluations { | ||
| private readonly _host: FeatureFlagEvaluationsHost | ||
| private readonly _distinctId: string | ||
| private readonly _groups: Record<string, string | number> | undefined | ||
| private readonly _disableGeoip: boolean | undefined | ||
| private readonly _flags: Record<string, EvaluatedFlagRecord> | ||
| private readonly _requestId: string | undefined | ||
| private readonly _evaluatedAt: number | undefined | ||
| private readonly _flagDefinitionsLoadedAt: number | undefined | ||
| private readonly _errorsWhileComputing: boolean | ||
| private readonly _quotaLimited: boolean | ||
| private readonly _accessed: Set<string> | ||
| // True for snapshots produced by `only()` / `onlyAccessed()` — used to suppress | ||
| // misleading `flag_missing` events when branching is performed on a filtered slice. | ||
| private readonly _isSlice: boolean | ||
| /** | ||
| * @internal — instances are created by the SDK via `posthog.evaluateFlags()`. | ||
| */ | ||
| constructor(init: { | ||
| host: FeatureFlagEvaluationsHost | ||
| distinctId: string | ||
| groups?: Record<string, string | number> | ||
| disableGeoip?: boolean | ||
| flags: Record<string, EvaluatedFlagRecord> | ||
| requestId?: string | ||
| evaluatedAt?: number | ||
| flagDefinitionsLoadedAt?: number | ||
| errorsWhileComputing?: boolean | ||
| quotaLimited?: boolean | ||
| accessed?: Set<string> | ||
| isSlice?: boolean | ||
| }) { | ||
| this._host = init.host | ||
| this._distinctId = init.distinctId | ||
| this._groups = init.groups | ||
| this._disableGeoip = init.disableGeoip | ||
| this._flags = init.flags | ||
| this._requestId = init.requestId | ||
| this._evaluatedAt = init.evaluatedAt | ||
| this._flagDefinitionsLoadedAt = init.flagDefinitionsLoadedAt | ||
| this._errorsWhileComputing = init.errorsWhileComputing ?? false | ||
| this._quotaLimited = init.quotaLimited ?? false | ||
| this._accessed = init.accessed ?? new Set() | ||
| this._isSlice = init.isSlice ?? false | ||
| } | ||
| /** | ||
| * Check whether a feature flag is enabled. Fires a `$feature_flag_called` event | ||
| * on the first access per (distinctId, flag, value) tuple, deduped via the SDK's | ||
| * existing cache. | ||
| * | ||
| * Flags that were not returned from the underlying evaluation are treated as | ||
| * disabled (returns `false`). | ||
| */ | ||
| isEnabled(key: string): boolean { | ||
| const flag = this._flags[key] | ||
| this._recordAccess(key) | ||
| return flag?.enabled ?? false | ||
| } | ||
| /** | ||
| * Get the evaluated value of a feature flag. Fires a `$feature_flag_called` event | ||
| * on the first access per (distinctId, flag, value) tuple. | ||
| * | ||
| * Returns the variant string for multivariate flags, `true` for enabled flags | ||
| * without a variant, `false` for disabled flags, and `undefined` for flags that | ||
| * were not returned by the evaluation. | ||
| */ | ||
| getFlag(key: string): FeatureFlagValue | undefined { | ||
| const flag = this._flags[key] | ||
| this._recordAccess(key) | ||
| if (!flag) { | ||
| return undefined | ||
| } | ||
| if (!flag.enabled) { | ||
| return false | ||
| } | ||
| return flag.variant ?? true | ||
| } | ||
| /** | ||
| * Get the payload associated with a feature flag. Does not count as an access | ||
| * for `onlyAccessed()` and does not fire any event. | ||
| */ | ||
| getFlagPayload(key: string): JsonType | undefined { | ||
| return this._flags[key]?.payload | ||
| } | ||
| /** | ||
| * Return a filtered copy containing only flags that have been accessed via | ||
| * `isEnabled()` or `getFlag()` before this call. | ||
| * | ||
| * Order-dependent: if nothing has been accessed yet, the returned snapshot is | ||
| * empty. The method honors its name — pre-access if you want a populated result. | ||
| * | ||
| * **Note:** the returned snapshot is intended for `capture()`, not for further | ||
| * branching. Calling `isEnabled()` / `getFlag()` on it for a key that was filtered | ||
| * out is a no-op (no event is fired) — the flag wasn't actually missing, it was | ||
| * excluded from the slice. | ||
| */ | ||
| onlyAccessed(): FeatureFlagEvaluations { | ||
| const filtered: Record<string, EvaluatedFlagRecord> = {} | ||
| for (const key of this._accessed) { | ||
| const flag = this._flags[key] | ||
| if (flag) { | ||
| filtered[key] = flag | ||
| } | ||
| } | ||
| return this._cloneWith(filtered) | ||
| } | ||
| /** | ||
| * Return a filtered copy containing only flags with the given keys. Keys that | ||
| * are not present in the evaluation are dropped and logged as a warning. | ||
| * | ||
| * **Note:** like `onlyAccessed()`, the returned snapshot is intended for `capture()`. | ||
| * Branching on a filtered key that was excluded from the slice is a no-op. | ||
| */ | ||
| only(keys: string[]): FeatureFlagEvaluations { | ||
| const filtered: Record<string, EvaluatedFlagRecord> = {} | ||
| const missing: string[] = [] | ||
| for (const key of keys) { | ||
| const flag = this._flags[key] | ||
| if (flag) { | ||
| filtered[key] = flag | ||
| } else { | ||
| missing.push(key) | ||
| } | ||
| } | ||
| if (missing.length > 0) { | ||
| this._host.logWarning( | ||
| `FeatureFlagEvaluations.only() was called with flag keys that are not in the evaluation set and will be dropped: ${missing.join(', ')}` | ||
| ) | ||
| } | ||
| return this._cloneWith(filtered) | ||
| } | ||
| /** | ||
| * Returns the flag keys that are part of this evaluation. | ||
| */ | ||
| get keys(): string[] { | ||
| return Object.keys(this._flags) | ||
| } | ||
| /** | ||
| * Build the `$feature/*` and `$active_feature_flags` event properties derived | ||
| * from the current flag set. Called by `capture()` when an event is captured | ||
| * with `flags: ...`. | ||
| * | ||
| * @internal | ||
| */ | ||
| _getEventProperties(): Record<string, any> { | ||
| const properties: Record<string, any> = {} | ||
| const activeFlags: string[] = [] | ||
| for (const [key, flag] of Object.entries(this._flags)) { | ||
| const value = flag.enabled === false ? false : (flag.variant ?? true) | ||
| properties[`$feature/${key}`] = value | ||
| if (flag.enabled) { | ||
| activeFlags.push(key) | ||
| } | ||
| } | ||
| if (activeFlags.length > 0) { | ||
| activeFlags.sort() | ||
| properties['$active_feature_flags'] = activeFlags | ||
| } | ||
| return properties | ||
| } | ||
| private _cloneWith(flags: Record<string, EvaluatedFlagRecord>): FeatureFlagEvaluations { | ||
| return new FeatureFlagEvaluations({ | ||
| host: this._host, | ||
| distinctId: this._distinctId, | ||
| groups: this._groups, | ||
| disableGeoip: this._disableGeoip, | ||
| flags, | ||
| requestId: this._requestId, | ||
| evaluatedAt: this._evaluatedAt, | ||
| flagDefinitionsLoadedAt: this._flagDefinitionsLoadedAt, | ||
| errorsWhileComputing: this._errorsWhileComputing, | ||
| quotaLimited: this._quotaLimited, | ||
| // Copy the accessed set so the child can track further access independently | ||
| // of the parent. Callers expect `onlyAccessed()` on the parent to reflect | ||
| // only what the parent saw, not what happened on filtered views. | ||
| accessed: new Set(this._accessed), | ||
| isSlice: true, | ||
| }) | ||
| } | ||
| private _recordAccess(key: string): void { | ||
| this._accessed.add(key) | ||
| // Empty snapshots (no resolvable distinctId) are returned by `evaluateFlags()` as a | ||
| // safety fallback. Firing $feature_flag_called for them would emit events with an | ||
| // empty distinct_id, polluting analytics — short-circuit here instead. | ||
| if (this._distinctId === '') { | ||
| return | ||
| } | ||
| // On filtered slices (returned by `only()` / `onlyAccessed()`), a key absent from | ||
| // the slice doesn't mean the flag is missing from PostHog — it was filtered out. | ||
| // Don't fire a misleading `flag_missing` event; slices are intended for `capture()`, | ||
| // not for further branching. | ||
| if (this._isSlice && !(key in this._flags)) { | ||
| return | ||
| } | ||
| const flag = this._flags[key] | ||
| const response: FeatureFlagValue | undefined = | ||
| flag === undefined ? undefined : flag.enabled === false ? false : (flag.variant ?? true) | ||
| const properties: Record<string, any> = { | ||
| $feature_flag: key, | ||
| $feature_flag_response: response, | ||
| $feature_flag_id: flag?.id, | ||
| $feature_flag_version: flag?.version, | ||
| $feature_flag_reason: flag?.reason, | ||
| locally_evaluated: flag?.locallyEvaluated ?? false, | ||
| [`$feature/${key}`]: response, | ||
| $feature_flag_request_id: this._requestId, | ||
| $feature_flag_evaluated_at: flag?.locallyEvaluated ? Date.now() : this._evaluatedAt, | ||
| } | ||
| if (flag?.locallyEvaluated && this._flagDefinitionsLoadedAt !== undefined) { | ||
| properties.$feature_flag_definitions_loaded_at = this._flagDefinitionsLoadedAt | ||
| } | ||
| // Build the comma-joined `$feature_flag_error` matching the single-flag path's | ||
| // granularity: response-level errors (errors-while-computing, quota-limited) are | ||
| // combined with per-flag errors (flag-missing) so consumers can filter by type. | ||
| const errors: string[] = [] | ||
| if (this._errorsWhileComputing) { | ||
| errors.push(FeatureFlagError.ERRORS_WHILE_COMPUTING) | ||
| } | ||
| if (this._quotaLimited) { | ||
| errors.push(FeatureFlagError.QUOTA_LIMITED) | ||
| } | ||
| if (flag === undefined) { | ||
| errors.push(FeatureFlagError.FLAG_MISSING) | ||
| } | ||
| if (errors.length > 0) { | ||
| properties.$feature_flag_error = errors.join(',') | ||
| } | ||
| this._host.captureFlagCalledEventIfNeeded({ | ||
| distinctId: this._distinctId, | ||
| key, | ||
| response, | ||
| groups: this._groups, | ||
| disableGeoip: this._disableGeoip, | ||
| properties, | ||
| }) | ||
| } | ||
| } |
+101
-2
| import { FeatureFlagValue, JsonType, PostHogCaptureOptions, PostHogCoreStateless, PostHogFetchOptions, PostHogFetchResponse, PostHogFlagsAndPayloadsResponse, PostHogPersistedProperty } from '@posthog/core'; | ||
| import { EventMessage, FeatureFlagResult, GroupIdentifyMessage, IdentifyMessage, IPostHog, OverrideFeatureFlagsOptions, PostHogOptions, FlagEvaluationOptions, AllFlagsOptions } from './types'; | ||
| import { FeatureFlagEvaluations, FlagCalledEventParams } from './feature-flag-evaluations'; | ||
| import ErrorTracking from './extensions/error-tracking'; | ||
| import { PostHogEventProperties } from '@posthog/core'; | ||
| import { ContextData, ContextOptions, IPostHogContext } from './extensions/context/types'; | ||
| /** | ||
| * @internal — clears the process-wide deprecation dedup set. Test-only. | ||
| */ | ||
| export declare function _resetDeprecationWarningsForTests(): void; | ||
| export declare abstract class PostHogBackendClient extends PostHogCoreStateless implements IPostHog { | ||
@@ -451,2 +456,7 @@ private _memoryStorage; | ||
| * | ||
| * @deprecated Use {@link evaluateFlags} and call `flags.getFlag(key)` on the returned snapshot. | ||
| * This consolidates flag evaluation into a single `/flags` request per incoming request and | ||
| * avoids drift between the values your code branched on and the values attached to events. | ||
| * Will be removed in the next major version. | ||
| * | ||
| * @param key - The feature flag key | ||
@@ -494,2 +504,6 @@ * @param distinctId - The user's distinct ID | ||
| * | ||
| * @deprecated Use {@link evaluateFlags} and call `flags.getFlagPayload(key)` on the returned | ||
| * snapshot. This consolidates flag evaluation into a single `/flags` request per incoming | ||
| * request. Will be removed in the next major version. | ||
| * | ||
| * @param key - The feature flag key | ||
@@ -589,2 +603,6 @@ * @param distinctId - The user's distinct ID | ||
| * | ||
| * @deprecated Use {@link evaluateFlags} and call `flags.isEnabled(key)` on the returned snapshot. | ||
| * This consolidates flag evaluation into a single `/flags` request per incoming request. | ||
| * Will be removed in the next major version. | ||
| * | ||
| * @param key - The feature flag key | ||
@@ -675,2 +693,80 @@ * @param distinctId - The user's distinct ID | ||
| /** | ||
| * Evaluate all feature flags for a user in a single call and return a | ||
| * {@link FeatureFlagEvaluations} snapshot. Branch on `.isEnabled()` / `.getFlag()`, | ||
| * then pass the same snapshot to `capture()` via the `flags` option so the | ||
| * captured event carries the exact flag values the code branched on. | ||
| * | ||
| * Prefer this over repeated `isFeatureEnabled()` / `getFeatureFlag()` calls and | ||
| * over `capture({ sendFeatureFlags: true })` — it consolidates flag evaluation | ||
| * into a single `/flags` request per incoming request. | ||
| * | ||
| * **Local evaluation is transparent.** When the poller can resolve a flag from | ||
| * cached definitions, no network call is made and the snapshot's `$feature_flag_called` | ||
| * events are tagged `locally_evaluated: true`. | ||
| * | ||
| * **Trim the request.** Pass `flagKeys` to scope the underlying `/flags` request | ||
| * to a subset of flags — useful when you only need a few flags and want to reduce | ||
| * the response payload. | ||
| * | ||
| * **Trim the event payload.** Use `flags.only([...])` or `flags.onlyAccessed()` | ||
| * to filter which flags get attached to a captured event without re-fetching. | ||
| * | ||
| * @example | ||
| * Basic usage: | ||
| * ```ts | ||
| * const flags = await client.evaluateFlags('user_123', { | ||
| * personProperties: { plan: 'enterprise' }, | ||
| * }) | ||
| * if (flags.isEnabled('new-dashboard')) { | ||
| * renderNewDashboard() | ||
| * } | ||
| * client.capture({ distinctId: 'user_123', event: 'page_viewed', flags }) | ||
| * ``` | ||
| * | ||
| * @example | ||
| * Scope the `/flags` request to specific keys: | ||
| * ```ts | ||
| * const flags = await client.evaluateFlags('user_123', { | ||
| * flagKeys: ['new-dashboard', 'checkout-flow'], | ||
| * personProperties: { plan: 'enterprise' }, | ||
| * }) | ||
| * ``` | ||
| * | ||
| * @example | ||
| * Attach only the flags the developer actually checked: | ||
| * ```ts | ||
| * const flags = await client.evaluateFlags('user_123') | ||
| * if (flags.isEnabled('new-dashboard')) { ... } | ||
| * client.capture({ distinctId: 'user_123', event: 'page_viewed', flags: flags.onlyAccessed() }) | ||
| * ``` | ||
| * | ||
| * @example | ||
| * Use `withContext()` to avoid repeating the distinctId: | ||
| * ```ts | ||
| * await client.withContext({ distinctId: 'user_123' }, async () => { | ||
| * const flags = await client.evaluateFlags() | ||
| * if (flags.isEnabled('new-dashboard')) { ... } | ||
| * client.capture({ event: 'page_viewed', flags }) | ||
| * }) | ||
| * ``` | ||
| * | ||
| * {@label Feature flags} | ||
| * | ||
| * @param distinctIdOrOptions - The user's distinct ID, or options when the distinctId comes from `withContext()` | ||
| * @param options - Optional configuration for flag evaluation. Supports the same fields as `getAllFlags()`, including `flagKeys` to scope the `/flags` request. | ||
| * @returns Promise that resolves to a `FeatureFlagEvaluations` snapshot | ||
| */ | ||
| evaluateFlags(options?: AllFlagsOptions): Promise<FeatureFlagEvaluations>; | ||
| evaluateFlags(distinctId: string, options?: AllFlagsOptions): Promise<FeatureFlagEvaluations>; | ||
| /** | ||
| * Fires a `$feature_flag_called` event for the given flag if the (distinctId, flag, response) | ||
| * triple hasn't already been reported for this client. Shared by the single-flag evaluation | ||
| * path and `FeatureFlagEvaluations.isEnabled() / getFlag()` so both paths dedupe identically. | ||
| * | ||
| * @internal | ||
| */ | ||
| protected _captureFlagCalledEventIfNeeded(params: FlagCalledEventParams): void; | ||
| private _featureFlagEvaluationsHost?; | ||
| private _getFeatureFlagEvaluationsHost; | ||
| /** | ||
| * Create or update a group and its properties. | ||
@@ -881,4 +977,6 @@ * | ||
| * @param additionalProperties - Optional additional properties to include | ||
| * @param uuid - Optional event UUID | ||
| * @param flags - Optional `FeatureFlagEvaluations` snapshot to attach the same flag context as your other events | ||
| */ | ||
| captureException(error: unknown, distinctId?: string, additionalProperties?: Record<string | number, any>, uuid?: EventMessage['uuid']): void; | ||
| captureException(error: unknown, distinctId?: string, additionalProperties?: Record<string | number, any>, uuid?: EventMessage['uuid'], flags?: FeatureFlagEvaluations): void; | ||
| /** | ||
@@ -917,5 +1015,6 @@ * Capture an error exception as an event immediately (synchronously). | ||
| * @param additionalProperties - Optional additional properties to include | ||
| * @param flags - Optional `FeatureFlagEvaluations` snapshot to attach the same flag context as your other events | ||
| * @returns Promise that resolves when the error is captured | ||
| */ | ||
| captureExceptionImmediate(error: unknown, distinctId?: string, additionalProperties?: Record<string | number, any>): Promise<void>; | ||
| captureExceptionImmediate(error: unknown, distinctId?: string, additionalProperties?: Record<string | number, any>, flags?: FeatureFlagEvaluations): Promise<void>; | ||
| prepareEventMessage(props: EventMessage): Promise<{ | ||
@@ -922,0 +1021,0 @@ distinctId: string; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,gBAAgB,EAGhB,QAAQ,EACR,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,+BAA+B,EAE/B,wBAAwB,EACzB,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,YAAY,EAIZ,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,QAAQ,EACR,2BAA2B,EAC3B,cAAc,EAEd,qBAAqB,EACrB,eAAe,EAChB,MAAM,SAAS,CAAA;AAOhB,OAAO,aAAa,MAAM,6BAA6B,CAAA;AACvD,OAAO,EAAkB,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAGtE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AA2BzF,8BAAsB,oBAAqB,SAAQ,oBAAqB,YAAW,QAAQ;IACzF,OAAO,CAAC,cAAc,CAA6B;IAEnD,OAAO,CAAC,kBAAkB,CAAC,CAAoB;IAC/C,SAAS,CAAC,aAAa,EAAE,aAAa,CAAA;IACtC,OAAO,CAAC,YAAY,CAAQ;IAC5B,SAAgB,OAAO,EAAE,cAAc,CAAA;IACvC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,eAAe,CAAA;IAG5C,OAAO,CAAC,cAAc,CAAC,CAAkC;IACzD,OAAO,CAAC,iBAAiB,CAAC,CAA0B;IAEpD,0BAA0B,EAAE,MAAM,CAAC,MAAM,EAAE,MAA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IxE;;;;;;;;;;;;;;;;;;;OAmBG;IACG,SAAS,CAAC,iBAAiB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAa5C,2BAA2B;IAqCzC,OAAO,CAAC,0BAA0B;YA+BpB,uBAAuB;IAkErC,OAAO,CAAC,gCAAgC;IAqBxC,OAAO,CAAC,kCAAkC;IAe1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACH,gBAAgB,CACd,KAAK,EAAE,OAAO,EACd,UAAU,CAAC,EAAE,MAAM,EACnB,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EACnD,IAAI,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,EAC3B,KAAK,CAAC,EAAE,sBAAsB,GAC7B,IAAI;IAWP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACG,yBAAyB,CAC7B,KAAK,EAAE,OAAO,EACd,UAAU,CAAC,EAAE,MAAM,EACnB,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EACnD,KAAK,CAAC,EAAE,sBAAsB,GAC7B,OAAO,CAAC,IAAI,CAAC;IAWH,mBAAmB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC;QAC7D,UAAU,EAAE,MAAM,CAAA;QAClB,KAAK,EAAE,MAAM,CAAA;QACb,UAAU,EAAE,sBAAsB,CAAA;QAClC,OAAO,EAAE,qBAAqB,CAAA;KAC/B,CAAC;IA8HF,OAAO,CAAC,cAAc;CAuBvB"} |
+202
-46
@@ -36,2 +36,3 @@ "use strict"; | ||
| __webpack_require__.d(__webpack_exports__, { | ||
| _resetDeprecationWarningsForTests: ()=>_resetDeprecationWarningsForTests, | ||
| PostHogBackendClient: ()=>PostHogBackendClient | ||
@@ -42,2 +43,3 @@ }); | ||
| const external_types_js_namespaceObject = require("./types.js"); | ||
| const external_feature_flag_evaluations_js_namespaceObject = require("./feature-flag-evaluations.js"); | ||
| const feature_flags_js_namespaceObject = require("./extensions/feature-flags/feature-flags.js"); | ||
@@ -53,2 +55,11 @@ const index_js_namespaceObject = require("./extensions/error-tracking/index.js"); | ||
| const DEFAULT_NODE_HOST = 'https://us.i.posthog.com'; | ||
| const _emittedDeprecations = new Set(); | ||
| function emitDeprecationWarningOnce(id, message) { | ||
| if (_emittedDeprecations.has(id)) return; | ||
| _emittedDeprecations.add(id); | ||
| console.warn(`[PostHog] ${message}`); | ||
| } | ||
| function _resetDeprecationWarningsForTests() { | ||
| _emittedDeprecations.clear(); | ||
| } | ||
| function normalizeApiKey(value) { | ||
@@ -65,2 +76,10 @@ return 'string' == typeof value ? value.trim() : ''; | ||
| } | ||
| function buildFlagEventProperties(flagValues) { | ||
| if (!flagValues) return {}; | ||
| const additionalProperties = {}; | ||
| for (const [feature, variant] of Object.entries(flagValues))additionalProperties[`$feature/${feature}`] = variant; | ||
| const activeFlags = Object.keys(flagValues).filter((flag)=>false !== flagValues[flag]).sort(); | ||
| if (activeFlags.length > 0) additionalProperties['$active_feature_flags'] = activeFlags; | ||
| return additionalProperties; | ||
| } | ||
| class PostHogBackendClient extends core_namespaceObject.PostHogCoreStateless { | ||
@@ -362,33 +381,26 @@ constructor(apiKey, options = {}){ | ||
| const response = void 0 === result ? void 0 : false === result.enabled ? false : result.variant ?? true; | ||
| const featureFlagReportedKey = `${key}_${response}`; | ||
| if (!(distinctId in this.distinctIdHasSentFlagCalls) || !this.distinctIdHasSentFlagCalls[distinctId].includes(featureFlagReportedKey)) { | ||
| if (Object.keys(this.distinctIdHasSentFlagCalls).length >= this.maxCacheSize) this.distinctIdHasSentFlagCalls = {}; | ||
| if (Array.isArray(this.distinctIdHasSentFlagCalls[distinctId])) this.distinctIdHasSentFlagCalls[distinctId].push(featureFlagReportedKey); | ||
| else this.distinctIdHasSentFlagCalls[distinctId] = [ | ||
| featureFlagReportedKey | ||
| ]; | ||
| const properties = { | ||
| $feature_flag: key, | ||
| $feature_flag_response: response, | ||
| $feature_flag_id: flagId, | ||
| $feature_flag_version: flagVersion, | ||
| $feature_flag_reason: flagReason, | ||
| locally_evaluated: flagWasLocallyEvaluated, | ||
| [`$feature/${key}`]: response, | ||
| $feature_flag_request_id: requestId, | ||
| $feature_flag_evaluated_at: flagWasLocallyEvaluated ? Date.now() : evaluatedAt | ||
| }; | ||
| if (flagWasLocallyEvaluated && this.featureFlagsPoller) { | ||
| const flagDefinitionsLoadedAt = this.featureFlagsPoller.getFlagDefinitionsLoadedAt(); | ||
| if (void 0 !== flagDefinitionsLoadedAt) properties.$feature_flag_definitions_loaded_at = flagDefinitionsLoadedAt; | ||
| } | ||
| if (featureFlagError) properties.$feature_flag_error = featureFlagError; | ||
| this.capture({ | ||
| distinctId, | ||
| event: '$feature_flag_called', | ||
| properties, | ||
| groups, | ||
| disableGeoip | ||
| }); | ||
| const properties = { | ||
| $feature_flag: key, | ||
| $feature_flag_response: response, | ||
| $feature_flag_id: flagId, | ||
| $feature_flag_version: flagVersion, | ||
| $feature_flag_reason: flagReason, | ||
| locally_evaluated: flagWasLocallyEvaluated, | ||
| [`$feature/${key}`]: response, | ||
| $feature_flag_request_id: requestId, | ||
| $feature_flag_evaluated_at: flagWasLocallyEvaluated ? Date.now() : evaluatedAt | ||
| }; | ||
| if (flagWasLocallyEvaluated && this.featureFlagsPoller) { | ||
| const flagDefinitionsLoadedAt = this.featureFlagsPoller.getFlagDefinitionsLoadedAt(); | ||
| if (void 0 !== flagDefinitionsLoadedAt) properties.$feature_flag_definitions_loaded_at = flagDefinitionsLoadedAt; | ||
| } | ||
| if (featureFlagError) properties.$feature_flag_error = featureFlagError; | ||
| this._captureFlagCalledEventIfNeeded({ | ||
| distinctId, | ||
| key, | ||
| response, | ||
| groups, | ||
| disableGeoip, | ||
| properties | ||
| }); | ||
| } | ||
@@ -402,2 +414,3 @@ if (void 0 !== result && void 0 !== this._payloadOverrides && key in this._payloadOverrides) result = { | ||
| async getFeatureFlag(key, distinctId, options) { | ||
| emitDeprecationWarningOnce('getFeatureFlag', "`getFeatureFlag` is deprecated and will be removed in a future major version. Use `posthog.evaluateFlags(distinctId, ...)` and call `flags.getFlag(key)` instead — this consolidates flag evaluation into a single `/flags` request per incoming request."); | ||
| const result = await this._getFeatureFlagResult(key, distinctId, { | ||
@@ -412,2 +425,3 @@ ...options, | ||
| async getFeatureFlagPayload(key, distinctId, matchValue, options) { | ||
| emitDeprecationWarningOnce('getFeatureFlagPayload', "`getFeatureFlagPayload` is deprecated and will be removed in a future major version. Use `posthog.evaluateFlags(distinctId, ...)` and call `flags.getFlagPayload(key)` instead — this consolidates flag evaluation into a single `/flags` request per incoming request."); | ||
| if (void 0 !== this._payloadOverrides && key in this._payloadOverrides) return this._payloadOverrides[key]; | ||
@@ -440,4 +454,10 @@ const result = await this._getFeatureFlagResult(key, distinctId, { | ||
| async isFeatureEnabled(key, distinctId, options) { | ||
| const feat = await this.getFeatureFlag(key, distinctId, options); | ||
| if (void 0 === feat) return; | ||
| emitDeprecationWarningOnce('isFeatureEnabled', "`isFeatureEnabled` is deprecated and will be removed in a future major version. Use `posthog.evaluateFlags(distinctId, ...)` and call `flags.isEnabled(key)` instead — this consolidates flag evaluation into a single `/flags` request per incoming request."); | ||
| const result = await this._getFeatureFlagResult(key, distinctId, { | ||
| ...options, | ||
| sendFeatureFlagEvents: options?.sendFeatureFlagEvents ?? this.options.sendFeatureFlagEvent ?? true | ||
| }); | ||
| if (void 0 === result) return; | ||
| if (false === result.enabled) return false; | ||
| const feat = result.variant ?? true; | ||
| return !!feat || false; | ||
@@ -503,2 +523,132 @@ } | ||
| } | ||
| async evaluateFlags(distinctIdOrOptions, options) { | ||
| const { distinctId: resolvedDistinctId, options: resolvedOptions } = this._resolveDistinctId(distinctIdOrOptions, options); | ||
| if (!resolvedDistinctId) { | ||
| this._logger.warn("[PostHog] distinctId is required to evaluate feature flags \u2014 pass it explicitly or use withContext()"); | ||
| return new external_feature_flag_evaluations_js_namespaceObject.FeatureFlagEvaluations({ | ||
| host: this._getFeatureFlagEvaluationsHost(), | ||
| distinctId: '', | ||
| flags: {} | ||
| }); | ||
| } | ||
| const { groups, disableGeoip, flagKeys } = resolvedOptions || {}; | ||
| let { onlyEvaluateLocally, personProperties, groupProperties } = resolvedOptions || {}; | ||
| const adjustedProperties = this.addLocalPersonAndGroupProperties(resolvedDistinctId, groups, personProperties, groupProperties); | ||
| personProperties = adjustedProperties.allPersonProperties; | ||
| groupProperties = adjustedProperties.allGroupProperties; | ||
| const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, personProperties, groupProperties); | ||
| if (void 0 == onlyEvaluateLocally) onlyEvaluateLocally = this.options.strictLocalEvaluation ?? false; | ||
| const records = {}; | ||
| let requestId; | ||
| let evaluatedAt; | ||
| let errorsWhileComputing = false; | ||
| let quotaLimited = false; | ||
| const localResult = await this.featureFlagsPoller?.getAllFlagsAndPayloads(evaluationContext, flagKeys); | ||
| const locallyEvaluatedKeys = new Set(); | ||
| if (localResult) for (const [key, value] of Object.entries(localResult.response)){ | ||
| const flagDef = this.featureFlagsPoller?.featureFlagsByKey[key]; | ||
| records[key] = { | ||
| key, | ||
| enabled: false !== value, | ||
| variant: 'string' == typeof value ? value : void 0, | ||
| payload: localResult.payloads[key], | ||
| id: flagDef?.id, | ||
| version: void 0, | ||
| reason: 'Evaluated locally', | ||
| locallyEvaluated: true | ||
| }; | ||
| locallyEvaluatedKeys.add(key); | ||
| } | ||
| const fallbackToFlags = localResult ? localResult.fallbackToFlags : true; | ||
| if (fallbackToFlags && !onlyEvaluateLocally) { | ||
| const details = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups, evaluationContext.personProperties, evaluationContext.groupProperties, disableGeoip, flagKeys); | ||
| if (details) { | ||
| requestId = details.requestId; | ||
| evaluatedAt = details.evaluatedAt; | ||
| errorsWhileComputing = Boolean(details.errorsWhileComputingFlags); | ||
| quotaLimited = Array.isArray(details.quotaLimited) && details.quotaLimited.includes('feature_flags'); | ||
| for (const [key, detail] of Object.entries(details.flags)){ | ||
| if (locallyEvaluatedKeys.has(key)) continue; | ||
| let parsedPayload; | ||
| if (detail.metadata?.payload !== void 0) try { | ||
| parsedPayload = JSON.parse(detail.metadata.payload); | ||
| } catch { | ||
| parsedPayload = detail.metadata.payload; | ||
| } | ||
| records[key] = { | ||
| key, | ||
| enabled: detail.enabled, | ||
| variant: detail.variant, | ||
| payload: parsedPayload, | ||
| id: detail.metadata?.id, | ||
| version: detail.metadata?.version, | ||
| reason: detail.reason?.description ?? detail.reason?.code, | ||
| locallyEvaluated: false | ||
| }; | ||
| } | ||
| } | ||
| } | ||
| if (void 0 !== this._flagOverrides) for (const [key, value] of Object.entries(this._flagOverrides)){ | ||
| if (void 0 === value) { | ||
| delete records[key]; | ||
| continue; | ||
| } | ||
| const existing = records[key]; | ||
| records[key] = { | ||
| key, | ||
| enabled: false !== value, | ||
| variant: 'string' == typeof value ? value : void 0, | ||
| payload: existing?.payload, | ||
| id: existing?.id, | ||
| version: existing?.version, | ||
| reason: existing?.reason, | ||
| locallyEvaluated: existing?.locallyEvaluated ?? false | ||
| }; | ||
| } | ||
| if (void 0 !== this._payloadOverrides) for (const [key, payload] of Object.entries(this._payloadOverrides)){ | ||
| const existing = records[key]; | ||
| if (existing) records[key] = { | ||
| ...existing, | ||
| payload | ||
| }; | ||
| } | ||
| return new external_feature_flag_evaluations_js_namespaceObject.FeatureFlagEvaluations({ | ||
| host: this._getFeatureFlagEvaluationsHost(), | ||
| distinctId: resolvedDistinctId, | ||
| groups, | ||
| disableGeoip, | ||
| flags: records, | ||
| requestId, | ||
| evaluatedAt, | ||
| flagDefinitionsLoadedAt: this.featureFlagsPoller?.getFlagDefinitionsLoadedAt(), | ||
| errorsWhileComputing, | ||
| quotaLimited | ||
| }); | ||
| } | ||
| _captureFlagCalledEventIfNeeded(params) { | ||
| const { distinctId, key, response, groups, disableGeoip, properties } = params; | ||
| const featureFlagReportedKey = `${key}_${response}`; | ||
| if (distinctId in this.distinctIdHasSentFlagCalls && this.distinctIdHasSentFlagCalls[distinctId].includes(featureFlagReportedKey)) return; | ||
| if (Object.keys(this.distinctIdHasSentFlagCalls).length >= this.maxCacheSize) this.distinctIdHasSentFlagCalls = {}; | ||
| if (Array.isArray(this.distinctIdHasSentFlagCalls[distinctId])) this.distinctIdHasSentFlagCalls[distinctId].push(featureFlagReportedKey); | ||
| else this.distinctIdHasSentFlagCalls[distinctId] = [ | ||
| featureFlagReportedKey | ||
| ]; | ||
| this.capture({ | ||
| distinctId, | ||
| event: '$feature_flag_called', | ||
| properties, | ||
| groups, | ||
| disableGeoip | ||
| }); | ||
| } | ||
| _getFeatureFlagEvaluationsHost() { | ||
| if (!this._featureFlagEvaluationsHost) this._featureFlagEvaluationsHost = { | ||
| captureFlagCalledEventIfNeeded: (params)=>this._captureFlagCalledEventIfNeeded(params), | ||
| logWarning: (message)=>{ | ||
| if (false !== this.options.featureFlagsLogWarnings) console.warn(`[PostHog] ${message}`); | ||
| } | ||
| }; | ||
| return this._featureFlagEvaluationsHost; | ||
| } | ||
| groupIdentify({ groupType, groupKey, properties, distinctId, disableGeoip }) { | ||
@@ -680,3 +830,3 @@ super.groupIdentifyStateless(groupType, groupKey, properties, { | ||
| } | ||
| captureException(error, distinctId, additionalProperties, uuid) { | ||
| captureException(error, distinctId, additionalProperties, uuid, flags) { | ||
| if (!index_js_default().isPreviouslyCapturedError(error)) { | ||
@@ -688,7 +838,8 @@ const syntheticException = new Error('PostHog syntheticException'); | ||
| ...msg, | ||
| uuid | ||
| uuid, | ||
| flags | ||
| }))); | ||
| } | ||
| } | ||
| async captureExceptionImmediate(error, distinctId, additionalProperties) { | ||
| async captureExceptionImmediate(error, distinctId, additionalProperties, flags) { | ||
| if (!index_js_default().isPreviouslyCapturedError(error)) { | ||
@@ -698,7 +849,10 @@ const syntheticException = new Error('PostHog syntheticException'); | ||
| syntheticException | ||
| }, distinctId, additionalProperties).then((msg)=>this.captureImmediate(msg))); | ||
| }, distinctId, additionalProperties).then((msg)=>this.captureImmediate({ | ||
| ...msg, | ||
| flags | ||
| }))); | ||
| } | ||
| } | ||
| async prepareEventMessage(props) { | ||
| const { distinctId, event, properties, groups, sendFeatureFlags, timestamp, disableGeoip, uuid } = props; | ||
| const { distinctId, event, properties, groups, flags, sendFeatureFlags, timestamp, disableGeoip, uuid } = props; | ||
| const contextData = this.context?.get(); | ||
@@ -721,2 +875,3 @@ let mergedDistinctId = distinctId || contextData?.distinctId; | ||
| groups, | ||
| flags, | ||
| sendFeatureFlags, | ||
@@ -729,14 +884,13 @@ timestamp, | ||
| const eventProperties = await Promise.resolve().then(async ()=>{ | ||
| if (flags) { | ||
| if (sendFeatureFlags) console.warn('[PostHog] Both `flags` and `sendFeatureFlags` were passed to capture(); using `flags` and ignoring `sendFeatureFlags`.'); | ||
| return flags._getEventProperties(); | ||
| } | ||
| if (sendFeatureFlags) { | ||
| emitDeprecationWarningOnce('sendFeatureFlags', "`sendFeatureFlags` is deprecated and will be removed in a future major version. Pass a `flags` snapshot from `posthog.evaluateFlags(...)` instead — it avoids a second `/flags` request per capture and guarantees the event carries the exact flag values your code branched on."); | ||
| const sendFeatureFlagsOptions = 'object' == typeof sendFeatureFlags ? sendFeatureFlags : void 0; | ||
| return await this.getFeatureFlagsForEvent(eventMessage.distinctId, groups, disableGeoip, sendFeatureFlagsOptions); | ||
| const flagValues = await this.getFeatureFlagsForEvent(eventMessage.distinctId, groups, disableGeoip, sendFeatureFlagsOptions); | ||
| return buildFlagEventProperties(flagValues); | ||
| } | ||
| eventMessage.event; | ||
| return {}; | ||
| }).then((flags)=>{ | ||
| const additionalProperties = {}; | ||
| if (flags) for (const [feature, variant] of Object.entries(flags))additionalProperties[`$feature/${feature}`] = variant; | ||
| const activeFlags = Object.keys(flags || {}).filter((flag)=>flags?.[flag] !== false).sort(); | ||
| if (activeFlags.length > 0) additionalProperties['$active_feature_flags'] = activeFlags; | ||
| return additionalProperties; | ||
| }).catch(()=>({})).then((additionalProperties)=>{ | ||
@@ -789,4 +943,6 @@ const props = { | ||
| exports.PostHogBackendClient = __webpack_exports__.PostHogBackendClient; | ||
| exports._resetDeprecationWarningsForTests = __webpack_exports__._resetDeprecationWarningsForTests; | ||
| for(var __webpack_i__ in __webpack_exports__)if (-1 === [ | ||
| "PostHogBackendClient" | ||
| "PostHogBackendClient", | ||
| "_resetDeprecationWarningsForTests" | ||
| ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__]; | ||
@@ -793,0 +949,0 @@ Object.defineProperty(exports, '__esModule', { |
+199
-46
| import { version } from "./version.mjs"; | ||
| import { PostHogCoreStateless, isBlockedUA, isPlainObject, safeSetTimeout, uuidv7 } from "@posthog/core"; | ||
| import { FeatureFlagError } from "./types.mjs"; | ||
| import { FeatureFlagEvaluations } from "./feature-flag-evaluations.mjs"; | ||
| import { FeatureFlagsPoller, InconclusiveMatchError, RequiresServerEvaluation } from "./extensions/feature-flags/feature-flags.mjs"; | ||
@@ -13,2 +14,11 @@ import error_tracking from "./extensions/error-tracking/index.mjs"; | ||
| const DEFAULT_NODE_HOST = 'https://us.i.posthog.com'; | ||
| const _emittedDeprecations = new Set(); | ||
| function emitDeprecationWarningOnce(id, message) { | ||
| if (_emittedDeprecations.has(id)) return; | ||
| _emittedDeprecations.add(id); | ||
| console.warn(`[PostHog] ${message}`); | ||
| } | ||
| function _resetDeprecationWarningsForTests() { | ||
| _emittedDeprecations.clear(); | ||
| } | ||
| function normalizeApiKey(value) { | ||
@@ -25,2 +35,10 @@ return 'string' == typeof value ? value.trim() : ''; | ||
| } | ||
| function buildFlagEventProperties(flagValues) { | ||
| if (!flagValues) return {}; | ||
| const additionalProperties = {}; | ||
| for (const [feature, variant] of Object.entries(flagValues))additionalProperties[`$feature/${feature}`] = variant; | ||
| const activeFlags = Object.keys(flagValues).filter((flag)=>false !== flagValues[flag]).sort(); | ||
| if (activeFlags.length > 0) additionalProperties['$active_feature_flags'] = activeFlags; | ||
| return additionalProperties; | ||
| } | ||
| class PostHogBackendClient extends PostHogCoreStateless { | ||
@@ -322,33 +340,26 @@ constructor(apiKey, options = {}){ | ||
| const response = void 0 === result ? void 0 : false === result.enabled ? false : result.variant ?? true; | ||
| const featureFlagReportedKey = `${key}_${response}`; | ||
| if (!(distinctId in this.distinctIdHasSentFlagCalls) || !this.distinctIdHasSentFlagCalls[distinctId].includes(featureFlagReportedKey)) { | ||
| if (Object.keys(this.distinctIdHasSentFlagCalls).length >= this.maxCacheSize) this.distinctIdHasSentFlagCalls = {}; | ||
| if (Array.isArray(this.distinctIdHasSentFlagCalls[distinctId])) this.distinctIdHasSentFlagCalls[distinctId].push(featureFlagReportedKey); | ||
| else this.distinctIdHasSentFlagCalls[distinctId] = [ | ||
| featureFlagReportedKey | ||
| ]; | ||
| const properties = { | ||
| $feature_flag: key, | ||
| $feature_flag_response: response, | ||
| $feature_flag_id: flagId, | ||
| $feature_flag_version: flagVersion, | ||
| $feature_flag_reason: flagReason, | ||
| locally_evaluated: flagWasLocallyEvaluated, | ||
| [`$feature/${key}`]: response, | ||
| $feature_flag_request_id: requestId, | ||
| $feature_flag_evaluated_at: flagWasLocallyEvaluated ? Date.now() : evaluatedAt | ||
| }; | ||
| if (flagWasLocallyEvaluated && this.featureFlagsPoller) { | ||
| const flagDefinitionsLoadedAt = this.featureFlagsPoller.getFlagDefinitionsLoadedAt(); | ||
| if (void 0 !== flagDefinitionsLoadedAt) properties.$feature_flag_definitions_loaded_at = flagDefinitionsLoadedAt; | ||
| } | ||
| if (featureFlagError) properties.$feature_flag_error = featureFlagError; | ||
| this.capture({ | ||
| distinctId, | ||
| event: '$feature_flag_called', | ||
| properties, | ||
| groups, | ||
| disableGeoip | ||
| }); | ||
| const properties = { | ||
| $feature_flag: key, | ||
| $feature_flag_response: response, | ||
| $feature_flag_id: flagId, | ||
| $feature_flag_version: flagVersion, | ||
| $feature_flag_reason: flagReason, | ||
| locally_evaluated: flagWasLocallyEvaluated, | ||
| [`$feature/${key}`]: response, | ||
| $feature_flag_request_id: requestId, | ||
| $feature_flag_evaluated_at: flagWasLocallyEvaluated ? Date.now() : evaluatedAt | ||
| }; | ||
| if (flagWasLocallyEvaluated && this.featureFlagsPoller) { | ||
| const flagDefinitionsLoadedAt = this.featureFlagsPoller.getFlagDefinitionsLoadedAt(); | ||
| if (void 0 !== flagDefinitionsLoadedAt) properties.$feature_flag_definitions_loaded_at = flagDefinitionsLoadedAt; | ||
| } | ||
| if (featureFlagError) properties.$feature_flag_error = featureFlagError; | ||
| this._captureFlagCalledEventIfNeeded({ | ||
| distinctId, | ||
| key, | ||
| response, | ||
| groups, | ||
| disableGeoip, | ||
| properties | ||
| }); | ||
| } | ||
@@ -362,2 +373,3 @@ if (void 0 !== result && void 0 !== this._payloadOverrides && key in this._payloadOverrides) result = { | ||
| async getFeatureFlag(key, distinctId, options) { | ||
| emitDeprecationWarningOnce('getFeatureFlag', "`getFeatureFlag` is deprecated and will be removed in a future major version. Use `posthog.evaluateFlags(distinctId, ...)` and call `flags.getFlag(key)` instead — this consolidates flag evaluation into a single `/flags` request per incoming request."); | ||
| const result = await this._getFeatureFlagResult(key, distinctId, { | ||
@@ -372,2 +384,3 @@ ...options, | ||
| async getFeatureFlagPayload(key, distinctId, matchValue, options) { | ||
| emitDeprecationWarningOnce('getFeatureFlagPayload', "`getFeatureFlagPayload` is deprecated and will be removed in a future major version. Use `posthog.evaluateFlags(distinctId, ...)` and call `flags.getFlagPayload(key)` instead — this consolidates flag evaluation into a single `/flags` request per incoming request."); | ||
| if (void 0 !== this._payloadOverrides && key in this._payloadOverrides) return this._payloadOverrides[key]; | ||
@@ -400,4 +413,10 @@ const result = await this._getFeatureFlagResult(key, distinctId, { | ||
| async isFeatureEnabled(key, distinctId, options) { | ||
| const feat = await this.getFeatureFlag(key, distinctId, options); | ||
| if (void 0 === feat) return; | ||
| emitDeprecationWarningOnce('isFeatureEnabled', "`isFeatureEnabled` is deprecated and will be removed in a future major version. Use `posthog.evaluateFlags(distinctId, ...)` and call `flags.isEnabled(key)` instead — this consolidates flag evaluation into a single `/flags` request per incoming request."); | ||
| const result = await this._getFeatureFlagResult(key, distinctId, { | ||
| ...options, | ||
| sendFeatureFlagEvents: options?.sendFeatureFlagEvents ?? this.options.sendFeatureFlagEvent ?? true | ||
| }); | ||
| if (void 0 === result) return; | ||
| if (false === result.enabled) return false; | ||
| const feat = result.variant ?? true; | ||
| return !!feat || false; | ||
@@ -463,2 +482,132 @@ } | ||
| } | ||
| async evaluateFlags(distinctIdOrOptions, options) { | ||
| const { distinctId: resolvedDistinctId, options: resolvedOptions } = this._resolveDistinctId(distinctIdOrOptions, options); | ||
| if (!resolvedDistinctId) { | ||
| this._logger.warn("[PostHog] distinctId is required to evaluate feature flags \u2014 pass it explicitly or use withContext()"); | ||
| return new FeatureFlagEvaluations({ | ||
| host: this._getFeatureFlagEvaluationsHost(), | ||
| distinctId: '', | ||
| flags: {} | ||
| }); | ||
| } | ||
| const { groups, disableGeoip, flagKeys } = resolvedOptions || {}; | ||
| let { onlyEvaluateLocally, personProperties, groupProperties } = resolvedOptions || {}; | ||
| const adjustedProperties = this.addLocalPersonAndGroupProperties(resolvedDistinctId, groups, personProperties, groupProperties); | ||
| personProperties = adjustedProperties.allPersonProperties; | ||
| groupProperties = adjustedProperties.allGroupProperties; | ||
| const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, personProperties, groupProperties); | ||
| if (void 0 == onlyEvaluateLocally) onlyEvaluateLocally = this.options.strictLocalEvaluation ?? false; | ||
| const records = {}; | ||
| let requestId; | ||
| let evaluatedAt; | ||
| let errorsWhileComputing = false; | ||
| let quotaLimited = false; | ||
| const localResult = await this.featureFlagsPoller?.getAllFlagsAndPayloads(evaluationContext, flagKeys); | ||
| const locallyEvaluatedKeys = new Set(); | ||
| if (localResult) for (const [key, value] of Object.entries(localResult.response)){ | ||
| const flagDef = this.featureFlagsPoller?.featureFlagsByKey[key]; | ||
| records[key] = { | ||
| key, | ||
| enabled: false !== value, | ||
| variant: 'string' == typeof value ? value : void 0, | ||
| payload: localResult.payloads[key], | ||
| id: flagDef?.id, | ||
| version: void 0, | ||
| reason: 'Evaluated locally', | ||
| locallyEvaluated: true | ||
| }; | ||
| locallyEvaluatedKeys.add(key); | ||
| } | ||
| const fallbackToFlags = localResult ? localResult.fallbackToFlags : true; | ||
| if (fallbackToFlags && !onlyEvaluateLocally) { | ||
| const details = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups, evaluationContext.personProperties, evaluationContext.groupProperties, disableGeoip, flagKeys); | ||
| if (details) { | ||
| requestId = details.requestId; | ||
| evaluatedAt = details.evaluatedAt; | ||
| errorsWhileComputing = Boolean(details.errorsWhileComputingFlags); | ||
| quotaLimited = Array.isArray(details.quotaLimited) && details.quotaLimited.includes('feature_flags'); | ||
| for (const [key, detail] of Object.entries(details.flags)){ | ||
| if (locallyEvaluatedKeys.has(key)) continue; | ||
| let parsedPayload; | ||
| if (detail.metadata?.payload !== void 0) try { | ||
| parsedPayload = JSON.parse(detail.metadata.payload); | ||
| } catch { | ||
| parsedPayload = detail.metadata.payload; | ||
| } | ||
| records[key] = { | ||
| key, | ||
| enabled: detail.enabled, | ||
| variant: detail.variant, | ||
| payload: parsedPayload, | ||
| id: detail.metadata?.id, | ||
| version: detail.metadata?.version, | ||
| reason: detail.reason?.description ?? detail.reason?.code, | ||
| locallyEvaluated: false | ||
| }; | ||
| } | ||
| } | ||
| } | ||
| if (void 0 !== this._flagOverrides) for (const [key, value] of Object.entries(this._flagOverrides)){ | ||
| if (void 0 === value) { | ||
| delete records[key]; | ||
| continue; | ||
| } | ||
| const existing = records[key]; | ||
| records[key] = { | ||
| key, | ||
| enabled: false !== value, | ||
| variant: 'string' == typeof value ? value : void 0, | ||
| payload: existing?.payload, | ||
| id: existing?.id, | ||
| version: existing?.version, | ||
| reason: existing?.reason, | ||
| locallyEvaluated: existing?.locallyEvaluated ?? false | ||
| }; | ||
| } | ||
| if (void 0 !== this._payloadOverrides) for (const [key, payload] of Object.entries(this._payloadOverrides)){ | ||
| const existing = records[key]; | ||
| if (existing) records[key] = { | ||
| ...existing, | ||
| payload | ||
| }; | ||
| } | ||
| return new FeatureFlagEvaluations({ | ||
| host: this._getFeatureFlagEvaluationsHost(), | ||
| distinctId: resolvedDistinctId, | ||
| groups, | ||
| disableGeoip, | ||
| flags: records, | ||
| requestId, | ||
| evaluatedAt, | ||
| flagDefinitionsLoadedAt: this.featureFlagsPoller?.getFlagDefinitionsLoadedAt(), | ||
| errorsWhileComputing, | ||
| quotaLimited | ||
| }); | ||
| } | ||
| _captureFlagCalledEventIfNeeded(params) { | ||
| const { distinctId, key, response, groups, disableGeoip, properties } = params; | ||
| const featureFlagReportedKey = `${key}_${response}`; | ||
| if (distinctId in this.distinctIdHasSentFlagCalls && this.distinctIdHasSentFlagCalls[distinctId].includes(featureFlagReportedKey)) return; | ||
| if (Object.keys(this.distinctIdHasSentFlagCalls).length >= this.maxCacheSize) this.distinctIdHasSentFlagCalls = {}; | ||
| if (Array.isArray(this.distinctIdHasSentFlagCalls[distinctId])) this.distinctIdHasSentFlagCalls[distinctId].push(featureFlagReportedKey); | ||
| else this.distinctIdHasSentFlagCalls[distinctId] = [ | ||
| featureFlagReportedKey | ||
| ]; | ||
| this.capture({ | ||
| distinctId, | ||
| event: '$feature_flag_called', | ||
| properties, | ||
| groups, | ||
| disableGeoip | ||
| }); | ||
| } | ||
| _getFeatureFlagEvaluationsHost() { | ||
| if (!this._featureFlagEvaluationsHost) this._featureFlagEvaluationsHost = { | ||
| captureFlagCalledEventIfNeeded: (params)=>this._captureFlagCalledEventIfNeeded(params), | ||
| logWarning: (message)=>{ | ||
| if (false !== this.options.featureFlagsLogWarnings) console.warn(`[PostHog] ${message}`); | ||
| } | ||
| }; | ||
| return this._featureFlagEvaluationsHost; | ||
| } | ||
| groupIdentify({ groupType, groupKey, properties, distinctId, disableGeoip }) { | ||
@@ -640,3 +789,3 @@ super.groupIdentifyStateless(groupType, groupKey, properties, { | ||
| } | ||
| captureException(error, distinctId, additionalProperties, uuid) { | ||
| captureException(error, distinctId, additionalProperties, uuid, flags) { | ||
| if (!error_tracking.isPreviouslyCapturedError(error)) { | ||
@@ -648,7 +797,8 @@ const syntheticException = new Error('PostHog syntheticException'); | ||
| ...msg, | ||
| uuid | ||
| uuid, | ||
| flags | ||
| }))); | ||
| } | ||
| } | ||
| async captureExceptionImmediate(error, distinctId, additionalProperties) { | ||
| async captureExceptionImmediate(error, distinctId, additionalProperties, flags) { | ||
| if (!error_tracking.isPreviouslyCapturedError(error)) { | ||
@@ -658,7 +808,10 @@ const syntheticException = new Error('PostHog syntheticException'); | ||
| syntheticException | ||
| }, distinctId, additionalProperties).then((msg)=>this.captureImmediate(msg))); | ||
| }, distinctId, additionalProperties).then((msg)=>this.captureImmediate({ | ||
| ...msg, | ||
| flags | ||
| }))); | ||
| } | ||
| } | ||
| async prepareEventMessage(props) { | ||
| const { distinctId, event, properties, groups, sendFeatureFlags, timestamp, disableGeoip, uuid } = props; | ||
| const { distinctId, event, properties, groups, flags, sendFeatureFlags, timestamp, disableGeoip, uuid } = props; | ||
| const contextData = this.context?.get(); | ||
@@ -681,2 +834,3 @@ let mergedDistinctId = distinctId || contextData?.distinctId; | ||
| groups, | ||
| flags, | ||
| sendFeatureFlags, | ||
@@ -689,14 +843,13 @@ timestamp, | ||
| const eventProperties = await Promise.resolve().then(async ()=>{ | ||
| if (flags) { | ||
| if (sendFeatureFlags) console.warn('[PostHog] Both `flags` and `sendFeatureFlags` were passed to capture(); using `flags` and ignoring `sendFeatureFlags`.'); | ||
| return flags._getEventProperties(); | ||
| } | ||
| if (sendFeatureFlags) { | ||
| emitDeprecationWarningOnce('sendFeatureFlags', "`sendFeatureFlags` is deprecated and will be removed in a future major version. Pass a `flags` snapshot from `posthog.evaluateFlags(...)` instead — it avoids a second `/flags` request per capture and guarantees the event carries the exact flag values your code branched on."); | ||
| const sendFeatureFlagsOptions = 'object' == typeof sendFeatureFlags ? sendFeatureFlags : void 0; | ||
| return await this.getFeatureFlagsForEvent(eventMessage.distinctId, groups, disableGeoip, sendFeatureFlagsOptions); | ||
| const flagValues = await this.getFeatureFlagsForEvent(eventMessage.distinctId, groups, disableGeoip, sendFeatureFlagsOptions); | ||
| return buildFlagEventProperties(flagValues); | ||
| } | ||
| eventMessage.event; | ||
| return {}; | ||
| }).then((flags)=>{ | ||
| const additionalProperties = {}; | ||
| if (flags) for (const [feature, variant] of Object.entries(flags))additionalProperties[`$feature/${feature}`] = variant; | ||
| const activeFlags = Object.keys(flags || {}).filter((flag)=>flags?.[flag] !== false).sort(); | ||
| if (activeFlags.length > 0) additionalProperties['$active_feature_flags'] = activeFlags; | ||
| return additionalProperties; | ||
| }).catch(()=>({})).then((additionalProperties)=>{ | ||
@@ -748,2 +901,2 @@ const props = { | ||
| } | ||
| export { PostHogBackendClient }; | ||
| export { PostHogBackendClient, _resetDeprecationWarningsForTests }; |
| export * from './extensions/sentry-integration'; | ||
| export * from './extensions/express'; | ||
| export * from './types'; | ||
| export { FeatureFlagEvaluations } from './feature-flag-evaluations'; | ||
| export { FeatureFlagError } from '@posthog/core'; | ||
| export type { FeatureFlagErrorType } from '@posthog/core'; | ||
| //# sourceMappingURL=exports.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAA;AAC/C,cAAc,sBAAsB,CAAA;AACpC,cAAc,SAAS,CAAA;AAIvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChD,YAAY,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA"} | ||
| {"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAA;AAC/C,cAAc,sBAAsB,CAAA;AACpC,cAAc,SAAS,CAAA;AAEvB,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;AAInE,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChD,YAAY,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA"} |
+13
-3
@@ -9,2 +9,5 @@ "use strict"; | ||
| }, | ||
| "./feature-flag-evaluations": function(module) { | ||
| module.exports = require("./feature-flag-evaluations.js"); | ||
| }, | ||
| "./types": function(module) { | ||
@@ -61,3 +64,4 @@ module.exports = require("./types.js"); | ||
| __webpack_require__.d(__webpack_exports__, { | ||
| FeatureFlagError: ()=>_posthog_core__WEBPACK_IMPORTED_MODULE_3__.FeatureFlagError | ||
| FeatureFlagError: ()=>_posthog_core__WEBPACK_IMPORTED_MODULE_4__.FeatureFlagError, | ||
| FeatureFlagEvaluations: ()=>_feature_flag_evaluations__WEBPACK_IMPORTED_MODULE_3__.FeatureFlagEvaluations | ||
| }); | ||
@@ -67,2 +71,3 @@ var _extensions_sentry_integration__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./extensions/sentry-integration"); | ||
| for(var __WEBPACK_IMPORT_KEY__ in _extensions_sentry_integration__WEBPACK_IMPORTED_MODULE_0__)if ([ | ||
| "FeatureFlagEvaluations", | ||
| "FeatureFlagError", | ||
@@ -77,2 +82,3 @@ "default" | ||
| for(var __WEBPACK_IMPORT_KEY__ in _extensions_express__WEBPACK_IMPORTED_MODULE_1__)if ([ | ||
| "FeatureFlagEvaluations", | ||
| "FeatureFlagError", | ||
@@ -87,2 +93,3 @@ "default" | ||
| for(var __WEBPACK_IMPORT_KEY__ in _types__WEBPACK_IMPORTED_MODULE_2__)if ([ | ||
| "FeatureFlagEvaluations", | ||
| "FeatureFlagError", | ||
@@ -94,7 +101,10 @@ "default" | ||
| __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__); | ||
| var _posthog_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("@posthog/core"); | ||
| var _feature_flag_evaluations__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./feature-flag-evaluations"); | ||
| var _posthog_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("@posthog/core"); | ||
| })(); | ||
| exports.FeatureFlagError = __webpack_exports__.FeatureFlagError; | ||
| exports.FeatureFlagEvaluations = __webpack_exports__.FeatureFlagEvaluations; | ||
| for(var __webpack_i__ in __webpack_exports__)if (-1 === [ | ||
| "FeatureFlagError" | ||
| "FeatureFlagError", | ||
| "FeatureFlagEvaluations" | ||
| ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__]; | ||
@@ -101,0 +111,0 @@ Object.defineProperty(exports, '__esModule', { |
+2
-1
@@ -0,1 +1,2 @@ | ||
| import { FeatureFlagEvaluations } from "./feature-flag-evaluations.mjs"; | ||
| import { FeatureFlagError } from "@posthog/core"; | ||
@@ -5,2 +6,2 @@ export * from "./extensions/sentry-integration.mjs"; | ||
| export * from "./types.mjs"; | ||
| export { FeatureFlagError }; | ||
| export { FeatureFlagError, FeatureFlagEvaluations }; |
+64
-4
| import type { PostHogCoreOptions, FeatureFlagValue, JsonType, PostHogFetchOptions, PostHogFetchResponse, PostHogFlagsAndPayloadsResponse } from '@posthog/core'; | ||
| import { ContextData, ContextOptions } from './extensions/context/types'; | ||
| import type { FeatureFlagEvaluations } from './feature-flag-evaluations'; | ||
| import type { FlagDefinitionCacheProvider } from './extensions/feature-flags/cache'; | ||
@@ -19,2 +20,13 @@ export type IdentifyMessage = { | ||
| groups?: Record<string, string | number>; | ||
| /** | ||
| * Attach feature flag values evaluated via `posthog.evaluateFlags()` to this event. | ||
| * Prefer this over `sendFeatureFlags` — it guarantees the event carries the exact | ||
| * values the code branched on and avoids a hidden `/flags` request on every capture. | ||
| */ | ||
| flags?: FeatureFlagEvaluations; | ||
| /** | ||
| * @deprecated Use the `flags` option with a `FeatureFlagEvaluations` object obtained | ||
| * from `posthog.evaluateFlags()` instead. `sendFeatureFlags` fires a separate `/flags` | ||
| * request on capture and may return different values than the ones the code branched on. | ||
| */ | ||
| sendFeatureFlags?: boolean | SendFeatureFlagsOptions; | ||
@@ -190,2 +202,10 @@ timestamp?: Date; | ||
| /** | ||
| * Controls whether `FeatureFlagEvaluations` filter helpers (`onlyAccessed()` and | ||
| * `only()`) log warnings when their input is unexpected — for example, calling | ||
| * `onlyAccessed()` before accessing any flags, or passing unknown keys to `only()`. | ||
| * | ||
| * @default true | ||
| */ | ||
| featureFlagsLogWarnings?: boolean; | ||
| /** | ||
| * Provides the API to extend the lifetime of a serverless invocation until | ||
@@ -281,5 +301,6 @@ * background work (like flushing analytics events) completes after the response | ||
| * @param groups OPTIONAL | object of what groups are related to this event, example: { company: 'id:5' }. Can be used to analyze companies instead of users. | ||
| * @param sendFeatureFlags OPTIONAL | Used with experiments. Determines whether to send feature flag values with the event. | ||
| * @param flags OPTIONAL | A `FeatureFlagEvaluations` snapshot from `evaluateFlags()`. Attaches those exact flag values to the event with no extra network call. | ||
| * @param sendFeatureFlags OPTIONAL | Deprecated — prefer `flags`. Fires a hidden `/flags` request on capture to enrich the event with flag values. | ||
| */ | ||
| capture({ distinctId, event, properties, groups, sendFeatureFlags }: EventMessage): void; | ||
| capture({ distinctId, event, properties, groups, flags, sendFeatureFlags }: EventMessage): void; | ||
| /** | ||
@@ -291,5 +312,6 @@ * @description Capture an event immediately. Useful for edge environments where the usual queue-based sending is not preferable. Do not mix immediate and non-immediate calls. | ||
| * @param groups OPTIONAL | object of what groups are related to this event, example: { company: 'id:5' }. Can be used to analyze companies instead of users. | ||
| * @param sendFeatureFlags OPTIONAL | Used with experiments. Determines whether to send feature flag values with the event. | ||
| * @param flags OPTIONAL | A `FeatureFlagEvaluations` snapshot from `evaluateFlags()`. Attaches those exact flag values to the event with no extra network call. | ||
| * @param sendFeatureFlags OPTIONAL | Deprecated — prefer `flags`. Fires a hidden `/flags` request on capture to enrich the event with flag values. | ||
| */ | ||
| captureImmediate({ distinctId, event, properties, groups, sendFeatureFlags }: EventMessage): Promise<void>; | ||
| captureImmediate({ distinctId, event, properties, groups, flags, sendFeatureFlags }: EventMessage): Promise<void>; | ||
| /** | ||
@@ -350,2 +372,5 @@ * @description Identify lets you add metadata on your users so you can more easily identify who they are in PostHog, | ||
| * @returns true if the flag is on, false if the flag is off, undefined if there was an error. | ||
| * | ||
| * @deprecated Use {@link IPostHog.evaluateFlags} and call `flags.isEnabled(key)` on the | ||
| * returned snapshot. Will be removed in the next major version. | ||
| */ | ||
@@ -374,2 +399,5 @@ isFeatureEnabled(key: string, distinctId: string, options?: { | ||
| * @returns true or string(for multivariates) if the flag is on, false if the flag is off, undefined if there was an error. | ||
| * | ||
| * @deprecated Use {@link IPostHog.evaluateFlags} and call `flags.getFlag(key)` on the | ||
| * returned snapshot. Will be removed in the next major version. | ||
| */ | ||
@@ -408,2 +436,5 @@ getFeatureFlag(key: string, distinctId: string, options?: { | ||
| * @returns payload of a json type object | ||
| * | ||
| * @deprecated Use {@link IPostHog.evaluateFlags} and call `flags.getFlagPayload(key)` on | ||
| * the returned snapshot. Will be removed in the next major version. | ||
| */ | ||
@@ -462,2 +493,31 @@ getFeatureFlagPayload(key: string, distinctId: string, matchValue?: FeatureFlagValue, options?: { | ||
| /** | ||
| * @description Evaluate all feature flags for a user in a single call and return a | ||
| * {@link FeatureFlagEvaluations} snapshot. Branch on `.isEnabled()` / `.getFlag()`, | ||
| * then pass the same snapshot to `capture()` via the `flags` option so events carry | ||
| * the exact flag values the code branched on. | ||
| * | ||
| * Prefer this over calling `isFeatureEnabled()` / `getFeatureFlag()` repeatedly and | ||
| * over `capture({ sendFeatureFlags: true })` — it avoids multiple `/flags` requests | ||
| * per incoming request. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const flags = await posthog.evaluateFlags('user_123', { personProperties: { plan: 'enterprise' } }) | ||
| * if (flags.isEnabled('new-dashboard')) { | ||
| * renderNewDashboard() | ||
| * } | ||
| * posthog.capture({ distinctId: 'user_123', event: 'page_viewed', flags }) | ||
| * ``` | ||
| * | ||
| * @param options - Optional configuration for flag evaluation. Pass `flagKeys` to scope the underlying `/flags` request to a subset of flags. | ||
| */ | ||
| evaluateFlags(options?: AllFlagsOptions): Promise<FeatureFlagEvaluations>; | ||
| /** | ||
| * @description Evaluate all feature flags for a specific user. | ||
| * | ||
| * @param distinctId - The user's distinct ID | ||
| * @param options - Optional configuration for flag evaluation. Pass `flagKeys` to scope the underlying `/flags` request to a subset of flags. | ||
| */ | ||
| evaluateFlags(distinctId: string, options?: AllFlagsOptions): Promise<FeatureFlagEvaluations>; | ||
| /** | ||
| * @description Sets a groups properties, which allows asking questions like "Who are the most active companies" | ||
@@ -464,0 +524,0 @@ * using my product in PostHog. |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,gBAAgB,EAChB,QAAQ,EACR,mBAAmB,EACnB,oBAAoB,EACpB,+BAA+B,EAChC,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAExE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAA;AAEnF,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAA;IACzC,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;IACrD,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CACp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U,EAAE,EAAE,oBAAoB,GAAG,IAAI,CAAA;IAE9E;;;OAGG;IACH,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IAEnC;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,oBAAoB,CAAC,SAAS,EAAE,2BAA2B,GAAG,IAAI,CAAA;IAElE;;;;;;OAMG;IACH,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,CAAC,CAAA;IAEpF;;;;;;OAMG;IACH,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,IAAI,CAAA;IAExE;;;OAGG;IACH,UAAU,IAAI,WAAW,GAAG,SAAS,CAAA;IAErC;;;;;OAKG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAE1C;;;;OAIG;IACH,2BAA2B,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAEjE;;;OAGG;IACH,sBAAsB,IAAI,OAAO,CAAA;CAClC"} |
@@ -1,2 +0,2 @@ | ||
| export declare const version = "5.32.1"; | ||
| export declare const version = "5.33.0"; | ||
| //# sourceMappingURL=version.d.ts.map |
+1
-1
@@ -29,3 +29,3 @@ "use strict"; | ||
| }); | ||
| const version = '5.32.1'; | ||
| const version = '5.33.0'; | ||
| exports.version = __webpack_exports__.version; | ||
@@ -32,0 +32,0 @@ for(var __webpack_i__ in __webpack_exports__)if (-1 === [ |
+1
-1
@@ -1,2 +0,2 @@ | ||
| const version = '5.32.1'; | ||
| const version = '5.33.0'; | ||
| export { version }; |
+1
-1
| { | ||
| "name": "posthog-node", | ||
| "version": "5.32.1", | ||
| "version": "5.33.0", | ||
| "description": "PostHog Node.js integration", | ||
@@ -5,0 +5,0 @@ "repository": { |
+2
-0
@@ -5,2 +5,4 @@ export * from './extensions/sentry-integration' | ||
| export { FeatureFlagEvaluations } from './feature-flag-evaluations' | ||
| // Re-export FeatureFlagError from core for backwards compatibility. | ||
@@ -7,0 +9,0 @@ // These were originally defined in posthog-node and moved to core for reuse across SDKs. |
+65
-4
@@ -11,2 +11,3 @@ import type { | ||
| import type { FeatureFlagEvaluations } from './feature-flag-evaluations' | ||
| import type { FlagDefinitionCacheProvider } from './extensions/feature-flags/cache' | ||
@@ -31,2 +32,13 @@ | ||
| groups?: Record<string, string | number> // Mapping of group type to group id | ||
| /** | ||
| * Attach feature flag values evaluated via `posthog.evaluateFlags()` to this event. | ||
| * Prefer this over `sendFeatureFlags` — it guarantees the event carries the exact | ||
| * values the code branched on and avoids a hidden `/flags` request on every capture. | ||
| */ | ||
| flags?: FeatureFlagEvaluations | ||
| /** | ||
| * @deprecated Use the `flags` option with a `FeatureFlagEvaluations` object obtained | ||
| * from `posthog.evaluateFlags()` instead. `sendFeatureFlags` fires a separate `/flags` | ||
| * request on capture and may return different values than the ones the code branched on. | ||
| */ | ||
| sendFeatureFlags?: boolean | SendFeatureFlagsOptions | ||
@@ -222,2 +234,10 @@ timestamp?: Date | ||
| /** | ||
| * Controls whether `FeatureFlagEvaluations` filter helpers (`onlyAccessed()` and | ||
| * `only()`) log warnings when their input is unexpected — for example, calling | ||
| * `onlyAccessed()` before accessing any flags, or passing unknown keys to `only()`. | ||
| * | ||
| * @default true | ||
| */ | ||
| featureFlagsLogWarnings?: boolean | ||
| /** | ||
| * Provides the API to extend the lifetime of a serverless invocation until | ||
@@ -318,5 +338,6 @@ * background work (like flushing analytics events) completes after the response | ||
| * @param groups OPTIONAL | object of what groups are related to this event, example: { company: 'id:5' }. Can be used to analyze companies instead of users. | ||
| * @param sendFeatureFlags OPTIONAL | Used with experiments. Determines whether to send feature flag values with the event. | ||
| * @param flags OPTIONAL | A `FeatureFlagEvaluations` snapshot from `evaluateFlags()`. Attaches those exact flag values to the event with no extra network call. | ||
| * @param sendFeatureFlags OPTIONAL | Deprecated — prefer `flags`. Fires a hidden `/flags` request on capture to enrich the event with flag values. | ||
| */ | ||
| capture({ distinctId, event, properties, groups, sendFeatureFlags }: EventMessage): void | ||
| capture({ distinctId, event, properties, groups, flags, sendFeatureFlags }: EventMessage): void | ||
@@ -329,5 +350,6 @@ /** | ||
| * @param groups OPTIONAL | object of what groups are related to this event, example: { company: 'id:5' }. Can be used to analyze companies instead of users. | ||
| * @param sendFeatureFlags OPTIONAL | Used with experiments. Determines whether to send feature flag values with the event. | ||
| * @param flags OPTIONAL | A `FeatureFlagEvaluations` snapshot from `evaluateFlags()`. Attaches those exact flag values to the event with no extra network call. | ||
| * @param sendFeatureFlags OPTIONAL | Deprecated — prefer `flags`. Fires a hidden `/flags` request on capture to enrich the event with flag values. | ||
| */ | ||
| captureImmediate({ distinctId, event, properties, groups, sendFeatureFlags }: EventMessage): Promise<void> | ||
| captureImmediate({ distinctId, event, properties, groups, flags, sendFeatureFlags }: EventMessage): Promise<void> | ||
@@ -387,2 +409,5 @@ /** | ||
| * @returns true if the flag is on, false if the flag is off, undefined if there was an error. | ||
| * | ||
| * @deprecated Use {@link IPostHog.evaluateFlags} and call `flags.isEnabled(key)` on the | ||
| * returned snapshot. Will be removed in the next major version. | ||
| */ | ||
@@ -416,2 +441,5 @@ isFeatureEnabled( | ||
| * @returns true or string(for multivariates) if the flag is on, false if the flag is off, undefined if there was an error. | ||
| * | ||
| * @deprecated Use {@link IPostHog.evaluateFlags} and call `flags.getFlag(key)` on the | ||
| * returned snapshot. Will be removed in the next major version. | ||
| */ | ||
@@ -455,2 +483,5 @@ getFeatureFlag( | ||
| * @returns payload of a json type object | ||
| * | ||
| * @deprecated Use {@link IPostHog.evaluateFlags} and call `flags.getFlagPayload(key)` on | ||
| * the returned snapshot. Will be removed in the next major version. | ||
| */ | ||
@@ -525,2 +556,32 @@ getFeatureFlagPayload( | ||
| /** | ||
| * @description Evaluate all feature flags for a user in a single call and return a | ||
| * {@link FeatureFlagEvaluations} snapshot. Branch on `.isEnabled()` / `.getFlag()`, | ||
| * then pass the same snapshot to `capture()` via the `flags` option so events carry | ||
| * the exact flag values the code branched on. | ||
| * | ||
| * Prefer this over calling `isFeatureEnabled()` / `getFeatureFlag()` repeatedly and | ||
| * over `capture({ sendFeatureFlags: true })` — it avoids multiple `/flags` requests | ||
| * per incoming request. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * const flags = await posthog.evaluateFlags('user_123', { personProperties: { plan: 'enterprise' } }) | ||
| * if (flags.isEnabled('new-dashboard')) { | ||
| * renderNewDashboard() | ||
| * } | ||
| * posthog.capture({ distinctId: 'user_123', event: 'page_viewed', flags }) | ||
| * ``` | ||
| * | ||
| * @param options - Optional configuration for flag evaluation. Pass `flagKeys` to scope the underlying `/flags` request to a subset of flags. | ||
| */ | ||
| evaluateFlags(options?: AllFlagsOptions): Promise<FeatureFlagEvaluations> | ||
| /** | ||
| * @description Evaluate all feature flags for a specific user. | ||
| * | ||
| * @param distinctId - The user's distinct ID | ||
| * @param options - Optional configuration for flag evaluation. Pass `flagKeys` to scope the underlying `/flags` request to a subset of flags. | ||
| */ | ||
| evaluateFlags(distinctId: string, options?: AllFlagsOptions): Promise<FeatureFlagEvaluations> | ||
| /** | ||
| * @description Sets a groups properties, which allows asking questions like "Who are the most active companies" | ||
@@ -527,0 +588,0 @@ * using my product in PostHog. |
+1
-1
@@ -1,1 +0,1 @@ | ||
| export const version = '5.32.1' | ||
| export const version = '5.33.0' |
Sorry, the diff of this file is too big to display
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
635576
13.31%123
4.24%14068
12.96%47
14.63%