posthog-node 6.1.1 → 6.2.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.
Files changed (44) hide show
  1. package/dist/client.d.ts +251 -124
  2. package/dist/client.d.ts.map +1 -1
  3. package/dist/client.js +23 -4
  4. package/dist/client.mjs +23 -4
  5. package/dist/emails/emails.d.ts +2 -1
  6. package/dist/emails/emails.d.ts.map +1 -1
  7. package/dist/emails/emails.js +27 -11
  8. package/dist/emails/emails.mjs +27 -11
  9. package/dist/emails/react-renderer-import.d.ts +3 -0
  10. package/dist/emails/react-renderer-import.d.ts.map +1 -0
  11. package/dist/emails/react-renderer-import.js +50 -0
  12. package/dist/emails/react-renderer-import.mjs +6 -0
  13. package/dist/emails/types.d.ts +15 -1
  14. package/dist/emails/types.d.ts.map +1 -1
  15. package/dist/entrypoints/otel.d.ts +20 -0
  16. package/dist/entrypoints/otel.d.ts.map +1 -1
  17. package/dist/exports.d.ts +3 -2
  18. package/dist/exports.d.ts.map +1 -1
  19. package/dist/extensions/context/listeners.d.ts +3 -2
  20. package/dist/extensions/context/listeners.d.ts.map +1 -1
  21. package/dist/extensions/context/types.d.ts +2 -0
  22. package/dist/extensions/context/types.d.ts.map +1 -1
  23. package/dist/extensions/express.d.ts +30 -4
  24. package/dist/extensions/express.d.ts.map +1 -1
  25. package/dist/extensions/nestjs.d.ts +23 -0
  26. package/dist/extensions/nestjs.d.ts.map +1 -1
  27. package/dist/types.d.ts +133 -96
  28. package/dist/types.d.ts.map +1 -1
  29. package/dist/version.d.ts +1 -1
  30. package/dist/version.js +1 -1
  31. package/dist/version.mjs +1 -1
  32. package/package.json +4 -4
  33. package/src/client.ts +276 -130
  34. package/src/emails/emails.ts +35 -13
  35. package/src/emails/react-renderer-import.ts +7 -0
  36. package/src/emails/types.ts +16 -1
  37. package/src/entrypoints/otel.ts +20 -0
  38. package/src/exports.ts +3 -1
  39. package/src/extensions/context/listeners.ts +3 -2
  40. package/src/extensions/context/types.ts +2 -0
  41. package/src/extensions/express.ts +30 -4
  42. package/src/extensions/nestjs.ts +23 -0
  43. package/src/types.ts +138 -105
  44. package/src/version.ts +1 -1
package/src/types.ts CHANGED
@@ -22,13 +22,16 @@ import type { V1EventOptions } from './capture-v1/types'
22
22
  /** Processing options sent with an event to capture v1. */
23
23
  export type EventOptions = V1EventOptions
24
24
 
25
- import type { Emails } from './emails/types'
25
+ import type { EmailReactRenderer, Emails } from './emails/types'
26
26
  import type { FeatureFlagEvaluations } from './feature-flag-evaluations'
27
27
  import type { FlagDefinitionCacheInput, FlagDefinitionCacheProvider } from './extensions/feature-flags/cache'
28
28
 
29
29
  export type IdentifyMessage = {
30
+ /** User distinct ID matching your frontend `posthog.identify()` call. */
30
31
  distinctId: string
32
+ /** Person properties to set directly, or via `$set`, `$set_once`, and `$anon_distinct_id`. */
31
33
  properties?: Record<string | number, any>
34
+ /** Overrides the client's `disableGeoip` setting for this event. */
32
35
  disableGeoip?: boolean
33
36
  /**
34
37
  * Processing options sent with this event to capture v1.
@@ -37,8 +40,11 @@ export type IdentifyMessage = {
37
40
  }
38
41
 
39
42
  export type SetPersonPropertiesMessage = {
43
+ /** User distinct ID. Falls back to `withContext()` when missing or blank. */
40
44
  distinctId: string
45
+ /** Person properties to overwrite (`$set`). */
41
46
  properties?: Record<string | number, any>
47
+ /** Person properties to write only when unset (`$set_once`). */
42
48
  propertiesOnce?: Record<string | number, any>
43
49
  /**
44
50
  * Processing options sent with this event to capture v1.
@@ -47,7 +53,9 @@ export type SetPersonPropertiesMessage = {
47
53
  }
48
54
 
49
55
  export type UnsetPersonPropertiesMessage = {
56
+ /** User distinct ID. Falls back to `withContext()` when missing or blank. */
50
57
  distinctId: string
58
+ /** Property name or list of property names to remove from the person profile (`$unset`). */
51
59
  properties: string | string[]
52
60
  /**
53
61
  * Processing options sent with this event to capture v1.
@@ -56,24 +64,30 @@ export type UnsetPersonPropertiesMessage = {
56
64
  }
57
65
 
58
66
  export type SendFeatureFlagsOptions = {
67
+ /** Skip remote `/flags` fallback and evaluate only against locally loaded flag definitions. */
59
68
  onlyEvaluateLocally?: boolean
69
+ /** Person properties used during flag evaluation instead of stored server properties. */
60
70
  personProperties?: Properties
71
+ /** Group properties keyed by group type for evaluating group-targeted flags. */
61
72
  groupProperties?: Record<string, Properties>
73
+ /** Restrict evaluation to these flag keys. */
62
74
  flagKeys?: string[]
63
75
  }
64
76
 
65
- export type EventMessage = Omit<IdentifyMessage, 'distinctId'> & {
77
+ export type EventMessage = {
66
78
  /**
67
- * The event's distinct id. When it is missing, empty or only whitespace, the context distinct id
68
- * is used; without one, the event gets a generated id and `options.process_person_profile: false`.
79
+ * The event's distinct ID. When missing, empty, or whitespace, uses `withContext()`, else generates a UUIDv7 and sets `options.process_person_profile: false`.
69
80
  */
70
81
  distinctId?: string
82
+ /** Event name (such as `'order_placed'` or `'$pageview'`). Must be 200 UTF-8 bytes or fewer. */
71
83
  event: string
72
- groups?: Record<string, string | number> // Mapping of group type to group id
84
+ /** Event properties (also accepts `$set`, `$set_once`, and `$current_url`). */
85
+ properties?: Record<string | number, any>
86
+ /** Group types and keys to associate with this event (for example `{ company: 'acme' }`, up to 5 per project). */
87
+ groups?: Record<string, string | number>
73
88
  /**
74
89
  * Attach feature flag values evaluated via `posthog.evaluateFlags()` to this event.
75
- * Prefer this over `sendFeatureFlags` — it guarantees the event carries the exact
76
- * values the code branched on and avoids a hidden `/flags` request on every capture.
90
+ * Prefer this over `sendFeatureFlags` so the event carries the exact values your code branched on without a hidden `/flags` request.
77
91
  */
78
92
  flags?: FeatureFlagEvaluations
79
93
  /**
@@ -86,6 +100,10 @@ export type EventMessage = Omit<IdentifyMessage, 'distinctId'> & {
86
100
  timestamp?: Date
87
101
  /** If provided overrides the auto-generated event UUID. Must be a valid UUID. */
88
102
  uuid?: string
103
+ /** Overrides the client's `disableGeoip` setting for this event. */
104
+ disableGeoip?: boolean
105
+ /** Processing options sent with this event to capture v1. */
106
+ options?: EventOptions
89
107
  /**
90
108
  * Internal flag set by captureException() to indicate this $exception
91
109
  * event originated from the proper exception capture path. Used to warn users who call
@@ -122,25 +140,34 @@ export type CaptureExceptionOptions = {
122
140
  * resolved and the properties and options filled from every layer, after `beforeSend`.
123
141
  */
124
142
  export type PreparedEventMessage = {
143
+ /** Resolved distinct ID after checking the call, `withContext()`, and personless fallback. */
125
144
  distinctId: string
145
+ /** Final event name after SDK normalization (such as `$bot_pageview` preview renames). */
126
146
  event: string
147
+ /** Merged event properties after context, `register()`, SDK defaults, and `beforeSend`. */
127
148
  properties: PostHogEventProperties
128
149
  /** The event's options, sent to capture unchanged. */
129
150
  options?: EventOptions
151
+ /** Canonical event UUID. */
130
152
  uuid?: string
153
+ /** Explicit event timestamp, if provided or set by `beforeSend`. */
131
154
  timestamp?: Date
155
+ /** Per-call `disableGeoip` flag, if provided. */
132
156
  disableGeoip?: boolean
133
157
  }
134
158
 
135
159
  export type GroupIdentifyMessage = {
160
+ /** Group type name (such as `'company'`). Projects support up to 5 group types. */
136
161
  groupType: string
137
- groupKey: string // Unique identifier for the group
162
+ /** Unique identifier for the group within `groupType`. */
163
+ groupKey: string
164
+ /** Group properties (`$group_set`). Set `name` for the display name in PostHog. */
138
165
  properties?: Record<string | number, any>
139
166
  /**
140
- * The event's distinct id. When it is missing, empty or only whitespace, the context distinct id
141
- * is used, then `$<groupType>_<groupKey>`.
167
+ * The event's distinct ID. When missing, empty, or whitespace, uses `withContext()`, then `$<groupType>_<groupKey>`.
142
168
  */
143
169
  distinctId?: string
170
+ /** Overrides the client's `disableGeoip` setting for this event. */
144
171
  disableGeoip?: boolean
145
172
  /**
146
173
  * Processing options sent with this event to capture v1.
@@ -180,14 +207,19 @@ export type OverrideFeatureFlagsOptions =
180
207
  | FeatureFlagOverrideOptions
181
208
 
182
209
  export type BaseFlagEvaluationOptions = {
210
+ /** Group types and keys to evaluate group-targeted flags against (for example `{ company: 'acme' }`). */
183
211
  groups?: Record<string, string>
212
+ /** Person properties used instead of stored server properties. Include `$geoip_*` keys (such as `$geoip_country_code` and `$geoip_subdivision_1_code`) to evaluate GeoIP flags using the client's location. */
184
213
  personProperties?: Properties
214
+ /** Group properties keyed by group type for evaluating group-targeted flags. */
185
215
  groupProperties?: Record<string, Properties>
186
216
  /** Skip remote fallback and omit flags that local definitions cannot resolve. */
187
217
  onlyEvaluateLocally?: boolean
218
+ /** Overrides the client's `disableGeoip` setting for this evaluation call. */
188
219
  disableGeoip?: boolean
189
220
  }
190
221
  export type FlagEvaluationOptions = BaseFlagEvaluationOptions & {
222
+ /** Whether this call sends `$feature_flag_called`, overriding the client's `sendFeatureFlagEvent` option. */
191
223
  sendFeatureFlagEvents?: boolean
192
224
  }
193
225
 
@@ -234,6 +266,24 @@ export type FeatureFlagBucketingIdentifier = 'distinct_id' | 'device_id' | '' |
234
266
  */
235
267
  export type FeatureFlagEvaluationRuntime = 'all' | 'client' | 'server'
236
268
 
269
+ /**
270
+ * Why local evaluation couldn't resolve a flag.
271
+ *
272
+ * When more than one cause applies, the SDK reports the first matching reason in this order:
273
+ *
274
+ * | Reason | Cause |
275
+ * | --- | --- |
276
+ * | `experience_continuity` | The flag uses experience continuity, which local evaluation can't resolve. |
277
+ * | `unsupported_definition` | The flag uses a rule local evaluation doesn't support, such as a static cohort, an unknown operator, or a circular or missing dependency. |
278
+ * | `unresolved_dependency` | A dependency flag has a loaded definition but stayed unresolved. |
279
+ * | `missing_context` | The call didn't pass a person property, group property, or device ID the flag needs, or passed an unusable value. |
280
+ */
281
+ export type UnresolvedFlagReason =
282
+ | 'experience_continuity'
283
+ | 'unsupported_definition'
284
+ | 'missing_context'
285
+ | 'unresolved_dependency'
286
+
237
287
  export type BeforeSendFn = (event: EventMessage) => EventMessage | null
238
288
 
239
289
  export type PostHogOptions = Omit<
@@ -248,6 +298,7 @@ export type PostHogOptions = Omit<
248
298
  | 'disableCompression'
249
299
  | 'requestTimeout'
250
300
  > & {
301
+ /** Storage backend for client opt-out state and super properties. Node holds state in memory only, so it resets on restart. */
251
302
  persistence?: 'memory'
252
303
  /**
253
304
  * Whether to strip URL fragments (`#...`) from automatically captured request URLs.
@@ -260,10 +311,9 @@ export type PostHogOptions = Omit<
260
311
  */
261
312
  disable_capture_url_hashes?: boolean
262
313
  /**
263
- * Whether to disable GeoIP lookups for events and feature flag requests. When on, every event
264
- * gets `$geoip_disable: true` unless the event, its context or `register()` sets
265
- * `$geoip_disable`. A per-call `disableGeoip` argument sets it for that event, under the event's
266
- * own `$geoip_disable` property.
314
+ * Whether to disable GeoIP lookups for events and feature flag requests. When `true`, every event gets `$geoip_disable: true` unless the event, its context, or `register()` sets `$geoip_disable`.
315
+ *
316
+ * Pass `disableGeoip: false` (here or per call) and set `$ip` in event `properties` to geolocate from a client IP. Setting `$ip` alone still skips GeoIP while `disableGeoip` is `true`.
267
317
  *
268
318
  * @default true
269
319
  */
@@ -467,12 +517,29 @@ export type PostHogOptions = Omit<
467
517
  emailRequestMaxRetries?: number
468
518
  /** The provider your email moved from, such as `'resend'`. Sent with every `posthog.emails` request. */
469
519
  migratedFrom?: string
520
+ /**
521
+ * Renders the `react` element of an `emails.send`. Set it when you bundle your app, such as
522
+ * for Cloudflare Workers, Convex, or Vercel Edge: posthog-node doesn't bundle `@react-email/render`,
523
+ * so apps that never send `react` don't carry it. Without it, posthog-node loads
524
+ * `@react-email/render` from `node_modules` when a send has `react`.
525
+ *
526
+ * @example
527
+ * ```ts
528
+ * const client = new PostHog('phc_...', { reactEmailRenderer: await import('@react-email/render') })
529
+ * ```
530
+ */
531
+ reactEmailRenderer?: EmailReactRenderer
470
532
  /**
471
533
  * Redact prompts, outputs and error details from every event that the PostHog AI
472
534
  * integrations (`@posthog/ai`) capture with this client. Per-call privacy settings
473
535
  * can only add redaction. Defaults to false.
474
536
  */
475
537
  privacyMode?: boolean
538
+ /**
539
+ * Attach process `uncaughtException` and `unhandledRejection` listeners to capture unhandled errors automatically.
540
+ *
541
+ * @default false
542
+ */
476
543
  enableExceptionAutocapture?: boolean
477
544
  /**
478
545
  * The interval in milliseconds between polls for refreshing feature flag definitions. Defaults to 30 seconds.
@@ -486,9 +553,15 @@ export type PostHogOptions = Omit<
486
553
  * per user. When the cache is full the least recently used distinct ids are evicted. Defaults to 50000.
487
554
  */
488
555
  maxCacheSize?: number
556
+ /**
557
+ * Custom HTTP transport replacing global `fetch`. Capture requests pass `redirect: 'manual'` and follow up to 5 same-origin `307` or `308` redirects, and a custom `fetch` that follows redirects itself still works.
558
+ */
489
559
  fetch?: (url: string, options: PostHogFetchOptions) => Promise<PostHogFetchResponse>
490
- // Whether to enable local evaluation and definition polling. Defaults to true when a secretKey, personalApiKey, or flagDefinitionCacheProvider is provided.
491
- // We recommend setting this to false if you are only using the secretKey for evaluating remote config payloads via `getRemoteConfigPayload` and not using local evaluation.
560
+ /**
561
+ * Whether to poll feature flag definitions for local evaluation when `secretKey`, `personalApiKey`, or `flagDefinitionCacheProvider` is set. Set to `false` when `secretKey` is only for `getRemoteConfigPayload()` or `emails`.
562
+ *
563
+ * @default true
564
+ */
492
565
  enableLocalEvaluation?: boolean
493
566
  /**
494
567
  * Optional cache provider for feature flag definitions.
@@ -764,29 +837,20 @@ export type FeatureFlagResult = {
764
837
 
765
838
  export interface IPostHog {
766
839
  /**
767
- * @description Capture allows you to capture anything a user does within your system,
768
- * which you can later use in PostHog to find patterns in usage,
769
- * work out which features to improve or where people are giving up.
770
- * A capture call requires:
771
- * @param distinctId which uniquely identifies your user
772
- * @param event We recommend using [verb] [noun], like movie played or movie updated to easily identify what your events mean later on.
773
- * @param properties OPTIONAL | which can be a object with any information you'd like to add
774
- * @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.
775
- * @param flags OPTIONAL | A `FeatureFlagEvaluations` snapshot from `evaluateFlags()`. Attaches those exact flag values to the event with no extra network call.
776
- * @param sendFeatureFlags OPTIONAL | Deprecated — prefer `flags`. Fires a hidden `/flags` request on capture to enrich the event with flag values.
777
- */
778
- capture({ distinctId, event, properties, groups, flags, sendFeatureFlags }: EventMessage): void
840
+ * Queue a custom event in memory to send asynchronously.
841
+ *
842
+ * @param props - Event payload including `event`, optional `distinctId`, `properties`, `groups`, `flags`, and `options`
843
+ */
844
+ capture(props: EventMessage): void
779
845
 
780
846
  /**
781
- * @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.
782
- * @param distinctId which uniquely identifies your user
783
- * @param event We recommend using [verb] [noun], like movie played or movie updated to easily identify what your events mean later on.
784
- * @param properties OPTIONAL | which can be a object with any information you'd like to add
785
- * @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.
786
- * @param flags OPTIONAL | A `FeatureFlagEvaluations` snapshot from `evaluateFlags()`. Attaches those exact flag values to the event with no extra network call.
787
- * @param sendFeatureFlags OPTIONAL | Deprecated — prefer `flags`. Fires a hidden `/flags` request on capture to enrich the event with flag values.
847
+ * Capture an event and wait for the HTTP send attempt to settle. Use in short-lived runtimes where the process can freeze before a background flush.
848
+ *
849
+ * Don't mix queued `capture()` and `captureImmediate()` when event order matters.
850
+ *
851
+ * @param props - Event payload including `event`, optional `distinctId`, `properties`, `groups`, `flags`, and `options`
788
852
  */
789
- captureImmediate({ distinctId, event, properties, groups, flags, sendFeatureFlags }: EventMessage): Promise<void>
853
+ captureImmediate(props: EventMessage): Promise<void>
790
854
 
791
855
  /**
792
856
  * @description Capture an exception as a $exception event.
@@ -803,87 +867,62 @@ export interface IPostHog {
803
867
  captureExceptionImmediate(error: unknown, options?: CaptureExceptionOptions): Promise<void>
804
868
 
805
869
  /**
806
- * @description Capture an AI event on the dedicated AI capture endpoint.
807
- * Beta: the signature is stable; operational limits (per-event size cap, batching, endpoint) may change without notice. Delivery is async, and no redaction or truncation is applied to the payload.
808
- * @param distinctId which uniquely identifies your user
809
- * @param event We recommend using [verb] [noun], like movie played or movie updated to easily identify what your events mean later on.
810
- * @param properties OPTIONAL | which can be a object with any information you'd like to add
811
- * @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.
812
- * @param flags OPTIONAL | A `FeatureFlagEvaluations` snapshot from `evaluateFlags()`. Attaches those exact flag values to the event with no extra network call.
813
- * @param sendFeatureFlags OPTIONAL | Deprecated — prefer `flags`. Fires a hidden `/flags` request on capture to enrich the event with flag values.
870
+ * Capture an AI event on the dedicated AI capture endpoint (`/i/v1/ai/events`).
871
+ *
872
+ * Beta: the signature is stable, while operational limits (per-event size cap, batching, endpoint) may change without notice. Delivery is async with no redaction or truncation.
873
+ *
874
+ * @param props - AI event payload including `event`, optional `distinctId`, `properties`, `groups`, `flags`, and `options`
814
875
  * @returns The event UUID, or `undefined` when the client is disabled
815
876
  */
816
- captureAi({ distinctId, event, properties, groups, flags, sendFeatureFlags }: EventMessage): string | undefined
877
+ captureAi(props: EventMessage): string | undefined
817
878
 
818
879
  /**
819
- * @description Capture an AI event on the dedicated AI capture endpoint, resolving after the send completes. Use in short-lived processes (serverless) where the runtime may freeze before a background flush runs.
820
- * @param distinctId which uniquely identifies your user
821
- * @param event We recommend using [verb] [noun], like movie played or movie updated to easily identify what your events mean later on.
822
- * @param properties OPTIONAL | which can be a object with any information you'd like to add
823
- * @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.
824
- * @param flags OPTIONAL | A `FeatureFlagEvaluations` snapshot from `evaluateFlags()`. Attaches those exact flag values to the event with no extra network call.
825
- * @param sendFeatureFlags OPTIONAL | Deprecated — prefer `flags`. Fires a hidden `/flags` request on capture to enrich the event with flag values.
880
+ * Capture an AI event on the dedicated AI capture endpoint (`/i/v1/ai/events`) and wait for the send attempt to settle.
881
+ *
882
+ * @param props - AI event payload including `event`, optional `distinctId`, `properties`, `groups`, `flags`, and `options`
826
883
  * @returns The event UUID, or `undefined` when the client is disabled
827
884
  */
828
- captureAiImmediate({
829
- distinctId,
830
- event,
831
- properties,
832
- groups,
833
- flags,
834
- sendFeatureFlags,
835
- }: EventMessage): Promise<string | undefined>
885
+ captureAiImmediate(props: EventMessage): Promise<string | undefined>
836
886
 
837
887
  /**
838
- * @description Identify lets you add metadata on your users so you can more easily identify who they are in PostHog,
839
- * and even do things like segment users by these properties.
840
- * An identify call requires:
841
- * @param distinctId which uniquely identifies your user
842
- * @param properties with a dict with any key: value pairs
888
+ * Queue an `$identify` event setting person properties for `distinctId`. Match the `distinctId` passed to frontend `posthog.identify()` so client and server activity join to one person.
889
+ *
890
+ * @param data - Identify payload with `distinctId` and optional `properties` (`$set`, `$set_once`, `$anon_distinct_id`)
843
891
  */
844
- identify({ distinctId, properties }: IdentifyMessage): void
892
+ identify(data: IdentifyMessage): void
845
893
 
846
894
  /**
847
- * @description Identify lets you add metadata on your users so you can more easily identify who they are in PostHog.
848
- * Useful for edge environments where the usual queue-based sending is not preferable. Do not mix immediate and non-immediate calls.
849
- * @param distinctId which uniquely identifies your user
850
- * @param properties with a dict with any key: value pairs
895
+ * Send an `$identify` event immediately and wait for the HTTP send attempt to settle.
896
+ *
897
+ * @param data - Identify payload with `distinctId` and optional `properties` (`$set`, `$set_once`, `$anon_distinct_id`)
851
898
  */
852
- identifyImmediate({ distinctId, properties }: IdentifyMessage): Promise<void>
899
+ identifyImmediate(data: IdentifyMessage): Promise<void>
853
900
 
854
901
  /**
855
- * @description Set properties on a person profile.
856
- * @param distinctId which uniquely identifies your user
857
- * @param properties properties to set on the person profile
858
- * @param propertiesOnce properties to set once on the person profile
902
+ * Queue a `$set` event to set or set-once properties on a person profile.
903
+ *
904
+ * @param data - Distinct ID and properties (`properties` for `$set`, `propertiesOnce` for `$set_once`)
859
905
  */
860
- setPersonProperties({ distinctId, properties, propertiesOnce }: SetPersonPropertiesMessage): void
906
+ setPersonProperties(data: SetPersonPropertiesMessage): void
861
907
 
862
908
  /**
863
- * @description Remove properties from a person profile.
864
- * @param distinctId which uniquely identifies your user
865
- * @param properties property name or property names to unset
909
+ * Queue a `$set` event carrying `$unset` to remove properties from a person profile.
910
+ *
911
+ * @param data - Distinct ID and property key or array of keys to remove
866
912
  */
867
- unsetPersonProperties({ distinctId, properties }: UnsetPersonPropertiesMessage): void
913
+ unsetPersonProperties(data: UnsetPersonPropertiesMessage): void
868
914
 
869
915
  /**
870
- * @description To marry up whatever a user does before they sign up or log in with what they do after you need to make an alias call.
871
- * This will allow you to answer questions like "Which marketing channels leads to users churning after a month?"
872
- * or "What do users do on our website before signing up?"
873
- * In a purely back-end implementation, this means whenever an anonymous user does something, you'll want to send a session ID with the capture call.
874
- * Then, when that users signs up, you want to do an alias call with the session ID and the newly created user ID.
875
- * The same concept applies for when a user logs in. If you're using PostHog in the front-end and back-end,
876
- * doing the identify call in the frontend will be enough.:
877
- * @param distinctId the current unique id
878
- * @param alias the unique ID of the user before
916
+ * Queue a `$create_alias` event linking `alias` (the previous or secondary ID) to `distinctId` (the primary user ID).
917
+ *
918
+ * @param data - Primary `distinctId`, previous `alias`, and optional `disableGeoip` or `options`
879
919
  */
880
920
  alias(data: { distinctId: string; alias: string; disableGeoip?: boolean; options?: EventOptions }): void
881
921
 
882
922
  /**
883
- * @description To marry up whatever a user does before they sign up or log in with what they do after you need to make an alias call.
884
- * Useful for edge environments where the usual queue-based sending is not preferable. Do not mix immediate and non-immediate calls.
885
- * @param distinctId the current unique id
886
- * @param alias the unique ID of the user before
923
+ * Send a `$create_alias` event immediately to link `alias` to `distinctId`.
924
+ *
925
+ * @param data - Primary `distinctId`, previous `alias`, and optional `disableGeoip` or `options`
887
926
  */
888
927
  aliasImmediate(data: {
889
928
  distinctId: string
@@ -1084,24 +1123,18 @@ export interface IPostHog {
1084
1123
  evaluateFlags(distinctId: string, options?: AllFlagsOptions): Promise<FeatureFlagEvaluations>
1085
1124
 
1086
1125
  /**
1087
- * @description Sets a groups properties, which allows asking questions like "Who are the most active companies"
1088
- * using my product in PostHog.
1126
+ * Queue a `$groupidentify` event to create or update group properties (up to 5 group types per project). Set `name` in `properties` for the UI display name.
1089
1127
  *
1090
- * @param groupType Type of group (ex: 'company'). Limited to 5 per project
1091
- * @param groupKey Unique identifier for that type of group (ex: 'id:5')
1092
- * @param properties OPTIONAL | which can be a object with any information you'd like to add
1128
+ * @param data - Group identify payload with `groupType`, `groupKey`, optional `properties`, `distinctId`, and `options`
1093
1129
  */
1094
- groupIdentify({ groupType, groupKey, properties }: GroupIdentifyMessage): void
1130
+ groupIdentify(data: GroupIdentifyMessage): void
1095
1131
 
1096
1132
  /**
1097
- * @description Sets a group's properties immediately. Useful for edge environments where the usual queue-based
1098
- * sending is not preferable. Do not mix immediate and non-immediate calls.
1133
+ * Send a `$groupidentify` event immediately and wait for the HTTP send attempt to settle.
1099
1134
  *
1100
- * @param groupType Type of group (ex: 'company'). Limited to 5 per project
1101
- * @param groupKey Unique identifier for that type of group (ex: 'id:5')
1102
- * @param properties OPTIONAL | which can be a object with any information you'd like to add
1135
+ * @param data - Group identify payload with `groupType`, `groupKey`, optional `properties`, `distinctId`, and `options`
1103
1136
  */
1104
- groupIdentifyImmediate({ groupType, groupKey, properties }: GroupIdentifyMessage): Promise<void>
1137
+ groupIdentifyImmediate(data: GroupIdentifyMessage): Promise<void>
1105
1138
 
1106
1139
  /**
1107
1140
  * @description Force an immediate reload of the polled feature flags. Please note that they are
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "6.1.1"
1
+ export const version = "6.2.1"