posthog-node 5.56.4 → 5.57.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { FeatureFlagValue, JsonType } from '@posthog/core'
1
+ import { FeatureFlagValue, JsonType, UnresolvedFlagReason } from '@posthog/core'
2
2
 
3
3
  import { FeatureFlagError } from './types'
4
4
 
@@ -73,6 +73,7 @@ export class FeatureFlagEvaluations {
73
73
  private readonly _groups: Record<string, string | number> | undefined
74
74
  private readonly _disableGeoip: boolean | undefined
75
75
  private readonly _flags: Record<string, EvaluatedFlagRecord>
76
+ private readonly _unresolvedFlags: Readonly<Record<string, UnresolvedFlagReason>>
76
77
  private readonly _requestId: string | undefined
77
78
  private readonly _evaluatedAt: number | undefined
78
79
  private readonly _flagDefinitionsLoadedAt: number | undefined
@@ -92,6 +93,7 @@ export class FeatureFlagEvaluations {
92
93
  groups?: Record<string, string | number>
93
94
  disableGeoip?: boolean
94
95
  flags: Record<string, EvaluatedFlagRecord>
96
+ unresolvedFlags?: Record<string, UnresolvedFlagReason>
95
97
  requestId?: string
96
98
  evaluatedAt?: number
97
99
  flagDefinitionsLoadedAt?: number
@@ -105,6 +107,7 @@ export class FeatureFlagEvaluations {
105
107
  this._groups = init.groups
106
108
  this._disableGeoip = init.disableGeoip
107
109
  this._flags = init.flags
110
+ this._unresolvedFlags = Object.freeze({ ...init.unresolvedFlags })
108
111
  this._requestId = init.requestId
109
112
  this._evaluatedAt = init.evaluatedAt
110
113
  this._flagDefinitionsLoadedAt = init.flagDefinitionsLoadedAt
@@ -216,6 +219,18 @@ export class FeatureFlagEvaluations {
216
219
  return Object.keys(this._flags)
217
220
  }
218
221
 
222
+ /**
223
+ * Flags that have a loaded local definition but that neither local evaluation nor a remote
224
+ * fallback resolved, mapped to the reason local evaluation was inconclusive. These flags are
225
+ * absent from `keys`, and their accessors return undefined (`isEnabled` returns false). Reading
226
+ * this does not count as an access and does not fire any event.
227
+ *
228
+ * Always empty on snapshots returned by `only()` / `onlyAccessed()`.
229
+ */
230
+ get unresolvedFlags(): Readonly<Record<string, UnresolvedFlagReason>> {
231
+ return this._unresolvedFlags
232
+ }
233
+
219
234
  /**
220
235
  * Build the `$feature/*` and `$active_feature_flags` event properties derived
221
236
  * from the current flag set. Called by `capture()` when an event is captured
@@ -247,6 +262,7 @@ export class FeatureFlagEvaluations {
247
262
  groups: this._groups,
248
263
  disableGeoip: this._disableGeoip,
249
264
  flags,
265
+ // `unresolvedFlags` is left out on purpose: slices carry no unresolved entries.
250
266
  requestId: this._requestId,
251
267
  evaluatedAt: this._evaluatedAt,
252
268
  flagDefinitionsLoadedAt: this._flagDefinitionsLoadedAt,
@@ -304,7 +320,8 @@ export class FeatureFlagEvaluations {
304
320
 
305
321
  // Build the comma-joined `$feature_flag_error` matching the single-flag path's
306
322
  // granularity: response-level errors (errors-while-computing, quota-limited) are
307
- // combined with per-flag errors (flag-missing) so consumers can filter by type.
323
+ // combined with per-flag errors (flag-missing or local-evaluation-inconclusive) so consumers
324
+ // can filter by type.
308
325
  const errors: string[] = []
309
326
  if (this._errorsWhileComputing) {
310
327
  errors.push(FeatureFlagError.ERRORS_WHILE_COMPUTING)
@@ -313,7 +330,11 @@ export class FeatureFlagEvaluations {
313
330
  errors.push(FeatureFlagError.QUOTA_LIMITED)
314
331
  }
315
332
  if (flag === undefined) {
316
- errors.push(FeatureFlagError.FLAG_MISSING)
333
+ errors.push(
334
+ Object.prototype.hasOwnProperty.call(this._unresolvedFlags, key)
335
+ ? FeatureFlagError.LOCAL_EVALUATION_INCONCLUSIVE
336
+ : FeatureFlagError.FLAG_MISSING
337
+ )
317
338
  }
318
339
  if (errors.length > 0) {
319
340
  properties.$feature_flag_error = errors.join(',')
package/src/types.ts CHANGED
@@ -229,6 +229,11 @@ export type PostHogOptions = Omit<PostHogCoreOptions, 'before_send' | 'flushInte
229
229
  * @deprecated Use `secretKey` instead.
230
230
  */
231
231
  personalApiKey?: string
232
+ /**
233
+ * Redact prompts, outputs and error details from every event that the PostHog AI
234
+ * integrations (`@posthog/ai`) capture with this client. Per-call privacy settings
235
+ * can only add redaction. Defaults to false.
236
+ */
232
237
  privacyMode?: boolean
233
238
  enableExceptionAutocapture?: boolean
234
239
  /**
@@ -455,12 +460,14 @@ export type PostHogFeatureFlag = {
455
460
  * Error values:
456
461
  * ERRORS_WHILE_COMPUTING: Server returned errorsWhileComputingFlags=true
457
462
  * FLAG_MISSING: Requested flag not in API response
463
+ * LOCAL_EVALUATION_INCONCLUSIVE: Flag has a loaded local definition but local evaluation could not resolve it
458
464
  * QUOTA_LIMITED: Rate/quota limit exceeded
459
465
  * UNKNOWN_ERROR: Unexpected exceptions
460
466
  */
461
467
  export const FeatureFlagError = {
462
468
  ERRORS_WHILE_COMPUTING: 'errors_while_computing_flags',
463
469
  FLAG_MISSING: 'flag_missing',
470
+ LOCAL_EVALUATION_INCONCLUSIVE: 'local_evaluation_inconclusive',
464
471
  QUOTA_LIMITED: 'quota_limited',
465
472
  UNKNOWN_ERROR: 'unknown_error',
466
473
  } as const
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "5.56.4"
1
+ export const version = "5.57.1"