posthog-node 5.25.0 → 5.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/types.ts CHANGED
@@ -4,6 +4,7 @@ import type {
4
4
  JsonType,
5
5
  PostHogFetchOptions,
6
6
  PostHogFetchResponse,
7
+ PostHogFlagsAndPayloadsResponse,
7
8
  } from '@posthog/core'
8
9
  import { ContextData, ContextOptions } from './extensions/context/types'
9
10
 
@@ -76,6 +77,21 @@ export type OverrideFeatureFlagsOptions =
76
77
  | Record<string, FeatureFlagValue>
77
78
  | FeatureFlagOverrideOptions
78
79
 
80
+ export type BaseFlagEvaluationOptions = {
81
+ groups?: Record<string, string>
82
+ personProperties?: Record<string, string>
83
+ groupProperties?: Record<string, Record<string, string>>
84
+ onlyEvaluateLocally?: boolean
85
+ disableGeoip?: boolean
86
+ }
87
+ export type FlagEvaluationOptions = BaseFlagEvaluationOptions & {
88
+ sendFeatureFlagEvents?: boolean
89
+ }
90
+
91
+ export type AllFlagsOptions = BaseFlagEvaluationOptions & {
92
+ flagKeys?: string[]
93
+ }
94
+
79
95
  export type FeatureFlagOverrideOptions = {
80
96
  /**
81
97
  * Flag overrides. Can be:
@@ -409,6 +425,39 @@ export interface IPostHog {
409
425
  }
410
426
  ): Promise<JsonType | undefined>
411
427
 
428
+ /**
429
+ * @description Get all feature flag values using distinctId from withContext().
430
+ */
431
+ getAllFlags(options?: AllFlagsOptions): Promise<Record<string, FeatureFlagValue>>
432
+
433
+ /**
434
+ * @description Get all feature flag values for a specific user.
435
+ *
436
+ * @param distinctId - The user's distinct ID
437
+ * @param options - Optional configuration for flag evaluation
438
+ * @returns Promise that resolves to a record of flag keys and their values
439
+ */
440
+ getAllFlags(distinctId: string, options?: AllFlagsOptions): Promise<Record<string, FeatureFlagValue>>
441
+
442
+ /**
443
+ * @description Get all feature flag values and payloads using distinctId from withContext().
444
+ */
445
+ getAllFlagsAndPayloads(options?: AllFlagsOptions): Promise<PostHogFlagsAndPayloadsResponse>
446
+
447
+ /**
448
+ * @description Get all feature flag values and payloads for a specific user.
449
+ *
450
+ * @param distinctId - The user's distinct ID
451
+ * @param options - Optional configuration for flag evaluation
452
+ * @returns Promise that resolves to flags and payloads
453
+ */
454
+ getAllFlagsAndPayloads(distinctId: string, options?: AllFlagsOptions): Promise<PostHogFlagsAndPayloadsResponse>
455
+
456
+ /**
457
+ * @description Get a feature flag result using distinctId from withContext().
458
+ */
459
+ getFeatureFlagResult(key: string, options?: FlagEvaluationOptions): Promise<FeatureFlagResult | undefined>
460
+
412
461
  /**
413
462
  * @description Get the result of evaluating a feature flag, including its value and payload.
414
463
  * This is more efficient than calling getFeatureFlag and getFeatureFlagPayload separately when you need both.
@@ -431,14 +480,7 @@ export interface IPostHog {
431
480
  getFeatureFlagResult(
432
481
  key: string,
433
482
  distinctId: string,
434
- options?: {
435
- groups?: Record<string, string>
436
- personProperties?: Record<string, string>
437
- groupProperties?: Record<string, Record<string, string>>
438
- onlyEvaluateLocally?: boolean
439
- sendFeatureFlagEvents?: boolean
440
- disableGeoip?: boolean
441
- }
483
+ options?: FlagEvaluationOptions
442
484
  ): Promise<FeatureFlagResult | undefined>
443
485
 
444
486
  /**
@@ -492,6 +534,15 @@ export interface IPostHog {
492
534
  */
493
535
  withContext<T>(data: Partial<ContextData>, fn: () => T, options?: ContextOptions): T
494
536
 
537
+ /**
538
+ * @description Set context without a callback wrapper. Must be called in the same
539
+ * async scope that makes PostHog calls. Prefer `withContext()` when you can wrap
540
+ * code in a callback.
541
+ * @param data Context data to apply (distinctId, sessionId, properties)
542
+ * @param options Context options (fresh)
543
+ */
544
+ enterContext(data: Partial<ContextData>, options?: ContextOptions): void
545
+
495
546
  /**
496
547
  * @description Get the current context data.
497
548
  * @returns The current context data, or undefined if no context is set
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '5.25.0'
1
+ export const version = '5.26.0'