npm / posthog-node
posthog-node
What changed in posthog-node 5 to 6, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
100 breaking2 security14 deprecations95 new APIs and options4 performance71 behavior and defaults82 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initposthog-node 6133 changes
Breaking changes 78
Transactional email requests now use /api/messaging/ instead of the /api/projects/@current/ alias. This requires PostHog Cloud or self-hosted PostHog from 2026-11-18; older self-hosted versions return 404.
alias no longer takes its alias target from context or register().
Hooks receive copies of plain objects and arrays, so nested edits no longer mutate caller, register, or context values; class instances are not copied.
Changing the message's disableGeoip field in the hook has no effect; edit properties instead.
An event is dropped if the hook leaves distinctId missing, null, or non-string; caller non-string IDs are converted to strings before the hook, while an empty string is still sent to capture and dropped there.
Changing the message's groups field in the hook has no effect; edit properties instead.
A throwing hook still drops the event, but its error log now names the event and error type, omits the error message, and appears even when debug is off.
The 5.x.x name was ignored in 6.0.0 without a warning, so a before_send hook did not run there.
Hooks now see SDK-added properties and an options object before sending. Hooks returning a new message must copy options; edits to groups or sendFeatureFlags no longer affect the preceding feature flag request.
Hooks receive copies of plain objects and arrays, so nested mutations no longer alter caller, register, or context values.
Hooks now see SDK-added properties and options before sending; returned messages must copy options to preserve them, and hook changes can affect or remove event values.
Configuration uses
beforeSendinstead ofbefore_send. The hook now sees SDK-added properties andoptions; hooks returning a new message must preserveoptions.Capture v1 batches are no longer split and retried after a 413; a 413 fails the whole batch and events are lost.
A 2xx response without a results field fails the whole batch and reports through the error event without resending; an empty results object still means delivery succeeded.
Events now send only through capture v1, with AI events on their own lane.
Follows only same-origin 307 and 308 redirects; invalid event UUIDs are replaced with a warning, and dropped duplicate copies are reported.
Capture drops an invalid event instead of rejecting the whole request, allowing the rest of a batch to be delivered; drops are reported through error.
AI events use a separate queue, batches, and requests; events with properties larger than 8 MiB are dropped, and event names must start with $ai_.
Use captureAi or captureAiImmediate for $ai_ events; only these methods use the AI endpoint, while capture sends them to the analytics endpoint temporarily.
Events sent with captureAi must have names starting with $ai_; other event names are dropped and reported as misrouted_event.
AI events larger than 8 MiB of properties are dropped before sending and reported through error.
On posthog-node 6.x.x, @posthog/ai sends every AI event with captureAi; enableFullAiCapture then controls only string truncation and media redaction.
Replaces CaptureV1Error.
The SDK reports capture v1 dropped events as failures, including events dropped inside a successful 2xx response; a 402 fails the batch without retry.
Reserved exception properties such as $exception_level passed in properties are ignored so the SDK's value is sent.
TypeScript callers must replace positional arguments after error with an options object containing fields such as distinctId, properties, and level; JavaScript positional calls still work.
The method takes an options object after
errorinstead of positional arguments; TypeScript callers must use the options object.Renamed to CaptureError.
Renames the configuration option
custom_blocked_useragentstocustomBlockedUserAgents.Renames the configuration option
disable_capture_url_hashestodisableCaptureUrlHashes.A personal API key used as the project token disables the client, as do missing or empty tokens. Pass disabled: true to build a client intentionally disabled.
Property precedence changes: event, context, register, and before_send values for $geoip_disable can override the client setting; a per-call disableGeoip argument overrides context and register.
The per-call setting now sends $geoip_disable: false when false, and takes precedence over context and register settings; a call property can still override it.
An empty or whitespace distinct ID counts as missing; group identify falls back to the context ID, then $<type>_<key>.
A non-string distinctId passed to capture is converted to a string before before_send runs.
Empty or whitespace-only IDs count as missing; IDs over 200 UTF-8 bytes cause the event to be dropped and reported, rather than shortened.
Empty or whitespace-only IDs count as missing and fall back to the context ID or a generated personless ID; IDs over 200 UTF-8 bytes are dropped and reported.
Removed; use withContext to scope async context to a callback.
Every delivery failure is emitted as a CaptureError on the error event, with details such as endpoint, requestId, drops, and retryExhausted.
Events with missing, empty, non-string, malformed Unicode, or over-200-byte names are dropped and reported instead of being sent.
Event, context, and registered values take precedence over SDK-added values, and before_send can see and change them.
An object with its own
toJSONis kept whole during layered property merging, leaving itstoJSONto decide what is sent.An event with a property value that throws during reading or serialization is dropped alone and reported as unserializable; the report contains no event content and the error is not kept or logged.
Capture keeps only the first event for each UUID in a request and reports later copies; accepted UUID forms are normalized to lowercase hyphenated form, while other values are replaced with generated UUIDs.
Missing, empty, non-string, or ill-formed Unicode event names and ill-formed Unicode IDs are dropped and reported; lone surrogates in property strings are replaced with U+FFFD.
Properties owned by the SDK, such as $exception_list and $exception_level, are ignored in properties; reserved properties the SDK does not set can still pass through context or register().
This option no longer controls capture retry waits, but still applies to other requests.
No longer rejects on delivery failures; failures arrive through the error event.
flush and shutdown now send analytics and AI lanes at the same time; shutdown uses one deadline for both.
Group identification now falls back to the context distinct ID before generating a group ID, and never adds the context session ID.
Call-level groups merge key by key into the call's $groups property, and groups wins when both set the same key.
Analytics event methods, including captureImmediate, now send to this capture v1 endpoint; reverse proxies must forward it.
These events default to
process_person_profile: true; context and registered person-processing settings no longer turn that processing off for them.Capture drops events whose option value it cannot read and reports the error through the error event with details invalid_options.
Exception level sets $exception_level; the TypeScript type accepts fatal, error, warning, log, info, and debug, while runtime also maps documented aliases case-insensitively.
A
$libset on the event, in context, or withregister()now wins over the SDK's library identity values.Now applies to analytics events only.
NaN, Infinity, and -Infinity are sent as null; NaN under $set clears that person property.
Every capture call takes a per-event options map sent unchanged; legacy option properties still work, but an option overrides its legacy property.
Capture and related methods accept processing options alongside properties. Options are sent as given; unreadable values drop the event, while non-object values are logged and ignored.
A phx_... personal API key used as the project API key disables the client like a missing key, and the error log never includes the key.
With posthog-node 6.x.x, the integration sends every AI event with captureAi; enableFullAiCapture then controls only string truncation and media redaction.
No longer read; capture always uses capture v1.
Returns a flat message with top-level options, uuid, timestamp, and disableGeoip.
The returned message is flat: uuid, timestamp, and disableGeoip are top-level fields, while options holds event options.
Renames the configuration option
__preview_capture_bot_pageviewsto__previewCaptureBotPageviews.For listed identity and group events with a distinct ID not generated by the SDK, the property defaults to true unless the call sets it.
Identify-style events now default to person processing unless a personless distinct ID is generated; null counts as unset, and before_send can change the option.
MCP events from sessions with no resolved identity carry process_person_profile: false; per-event values take precedence over registerOptions() or context values.
Lone surrogates in property strings are replaced with U+FFFD so the event is kept.
Lone surrogates in property strings are replaced with U+FFFD, and NaN and infinities are sent as null rather than failing the request.
Now returns a promise.
SDK configuration names now use camelCase.
The /flags request now runs before before_send and uses the event's distinct ID; hook edits to groups or sendFeatureFlags no longer affect that request.
Capture v1 sends this as a top-level event field rather than a property; string values pass through, null and undefined are unset, and other values cause the event to be dropped with a warning.
An event with a property value that throws during reading or serialization is dropped alone and reported through error, without including event content.
Use withContext to scope async context to a callback.
Using zstd compression requires Node 22.15 or later and falls back to gzip elsewhere, including the edge build.
Deprecations 5
Accepted again as a deprecated alias for its camelCase name; the camelCase option wins if both are set.
The 5.x.x name is a deprecated alias that still works after 6.0.0, logs one deprecation error per process, and will be removed in the next major version. beforeSend wins if both are set.
JavaScript positional calls still work but log one deprecation error per method per process; use the options object instead, as positional calls will be removed in the next major version.
JavaScript positional calls still work but log one deprecation error per method per process and will be removed in the next major version; arguments after the options object are ignored with one warning per process.
The 5.x.x name is a deprecated alias that still works after 6.0.0, logs one deprecation error per process, and will be removed in the next major version. disableCaptureUrlHashes wins if both are set.
New APIs and options 17
New AI capture compression configuration option.
New AI capture queue-size configuration option.
New AI capture request-timeout configuration option.
New capture compression configuration option.
The exported error type represents delivery failures and exposes endpoint, requestId, drops, retryExhausted, and cause details.
Now takes an options object with distinctId, properties, options, uuid, flags, and level; the old positional form still works in 6.x and logs a deprecation error once per method.
New capture retry configuration option.
New client option, defaulting to true, controls whether Express and NestJS integrations read tracing headers into request context.
Defaults to true.
Pass
disabled: trueto intentionally build a disabled client, for example in tests.Event options are typed booleans with support for additional JSON-valued options.
@posthog/mcp accepts per-event options per call or from an instrument() callback and passes them as the event's options; its beforeSend hook can change them.
Pass per-event options to the LangChain callback handler and the OpenAI Agents, Claude Agent SDK, Google ADK, and Genkit integrations.
Set per-event options on wrapped provider calls and withTracing() in @posthog/ai.
Sets options on every event, like register() does for properties; it returns a promise.
Removes one registered option and returns a promise.
Accepts options that apply to every event in the context.
Behavior and default changes 27
Analytics and AI events are batched and sent on separate lanes, in batches of about 5 MiB at most; network-failed events are retained and retried on the next flush.
A throwing hook is logged with console.error even when debug is off; the log names only the event and error type.
Capture now drops only the malformed event before sending, allowing the rest of the batch to be delivered.
Retries only 404, 408, 429, 500, 502, 503, 504, and network errors, with exponential backoff, jitter, a 30-second maximum, and at least Retry-After.
Sends to /i/v1/ai/events.
Generated event UUIDs and personless distinct IDs now take their random bits from crypto.getRandomValues instead of Math.random.
Debug mode logs event names, UUIDs, and counts instead of whole events; capture errors can still include server or proxy response text.
Every delivery failure is reported on this event as a CaptureError, with endpoint, request ID, dropped-event details, retry state, and any underlying request error.
Call evaluateFlags() yourself and pass its snapshot as flags to avoid the automatic /flags request.
An unparseable timestamp is replaced with the current time and now logs a warning that never includes the value.
The fallback distinct ID now uses the passed ID, then context ID, then a generated group ID; groupIdentify also receives context and register properties and options.
captureAi and captureAiImmediate now send to this endpoint; reverse proxies must forward it.
identify and alias now add the context session ID as $session_id, and context and register properties and options reach these events.
Exception level is read case-insensitively, aliases critical to fatal and warn to warning, and defaults unknown values to error.
The field sets $exception_level, defaults to error, and accepts the documented TypeScript levels; runtime aliases are normalized case-insensitively and unknown values are ignored.
Events send $lib and $lib_version in properties; a $lib supplied on the event, in context, or with register wins, and before_send can change or remove them.
Event and context values can override the SDK library label; relayed events keep their library identity, and before_send now sees the SDK-filled result.
The zstd compression option requires Node 22.15 or later and falls back to gzip elsewhere, including the edge build.
A non-object options value is logged as an error and ignored while the event is still sent.
The client sends its library name and version in this request header; PostHog uses it to fill missing or invalid event library identity fields.
Disabling captureTracingHeaders does not disable the cookie fallback; leave readPostHogCookie off as well to stop all request linking.
Proxies must forward both capture routes and required headers, accept request bodies up to 20 MB, and pass capture responses through. Capture requests follow only same-origin 307 and 308 redirects, up to five times.
Logs no longer print whole events or hook error messages; debug logs show event names, UUIDs, and counts instead.
A non-string value is dropped with a warning.
Timestamps are sent in UTC with millisecond precision, and invalid timestamps are replaced with the current time with a warning that omits the value.
Now returns a promise.
Generated personless distinct IDs and event UUIDs are now UUIDv7, with random bits from crypto.getRandomValues instead of Math.random.
Fixes and other changes 6
Null-valued custom exception properties are dropped after beforeSend without undoing redaction or changing array positions.
F alsey JSON payloads from legacy flag responses are preserved in feature flag snapshots.
Context and register() properties and options now reach identify, alias, and groupIdentify events, not only capture.
identify and alias now add the context session ID as $session_id, like capture.
Applications using the listed wrapper packages should declare posthog-node in their own dependencies to control when they upgrade to 6.x.x.
An event whose property value throws during reading or serialization is dropped alone and reported through the error event as a local drop, covering analytics and AI lanes.
posthog-node 5235 changes
Breaking changes 22
Failed flag evaluations are omitted from the returned flags.
Failed flag evaluations return undefined instead of exposing failed values or payloads.
For config version 2 flags, events now include the reason code and rule attribution instead of $feature_flag_reason.
A flag record with a field of the wrong JSON type now reads as disabled: getters return false and the flag has no payload.
Sends a flat request body with template_id and distinct_id at the top level.
A condition with a filter local evaluation cannot check and a filter that does not match resolves locally as no match, rather than falling back to a server request or staying unresolved.
$feature_flag_called events from snapshot reads report local_evaluation_inconclusive instead of flag_missing for these flags.
Returns a snapshot, so changing individual keys no longer affects deduplication; the cache evicts only the least recently used distinct IDs instead of clearing entirely.
Server-side feature flags now resolve in posthog-node even when a proxy rewrites the request's User-Agent; flags restricted to the client runtime resolve to undefined.
Bigint attributes on logs, metrics, and spans are now sent as int64 rather than as strings.
Local evaluation now honors evaluationContexts; flags whose evaluation contexts do not overlap the configured list resolve to undefined instead of being evaluated locally.
Events are dropped when the before-send hook throws, rather than being sent unmodified.
Replaces the internal AI capture options; when set, wrappers route through the AI endpoint and skip redaction and truncation, while privacy mode still takes precedence.
Shutdown timeouts are logged without rejecting, so callers do not receive a rejection for a timeout.
No longer suppresses Node's default crash on unhandled promise rejections; fatal rejections in strict or warn-with-error-code mode and rejections handled by another unhandledRejection listener are no longer captured.
Semver values with leading zeros are rejected in both flag and override values; invalid inputs surface as InconclusiveMatchError and do not match targeting conditions.
An inactive flag now short-circuits to false even when ensure_experience_continuity is true, instead of throwing InconclusiveMatchError and resolving to undefined.
Cohort property groups containing a flag-type property now mark cohort evaluation inconclusive, so the flag returns undefined instead of a wrong definitive answer.
is_set now returns true when a property key is present, even if its value is null or undefined.
Use evaluationContexts in posthog.init to specify evaluation contexts instead of deployment environments.
The minimum supported Node.js version is now ^20.20.0 || >=22.22.0 due to an async-hooks DoS vulnerability.
Contexts inherit by default, changing how context values are passed to child contexts.
Security 2
A send with templateKey accepts sensitive to mark an email as sensitive; sensitive emails keep content out of PostHog's logs.
The client privacyMode option now applies to AI integrations, keeping prompts out of errors, provider metadata and OTel spans in privacy mode, and redacting MCP tool credentials.
Deprecations 9
captureEngagement is deprecated in favor of tracking: { engagement: false }. It continues to work, but a send cannot set both.
The Node SDK Sentry integration is deprecated; users are directed to PostHog Error Tracking for Node.
Imports from posthog-node/experimental are deprecated.
The sendFeatureFlags option is deprecated; it continues to work but logs a deduped warning the first time it is used, and removal is planned for the next major version.
Deprecated; it continues to work but logs a deduped warning the first time it is used, and removal is planned for the next major version.
Manual capture('$exception') now emits a warning.
The posthog.init option is deprecated in favor of evaluationContexts; it continues to work and logs a deprecation warning.
A warning is emitted when local evaluation encounters flags with experience continuity enabled, explaining that they cause server requests on every evaluation.
The package is deprecated.
New APIs and options 78
Send email with cc, bcc, and attachments. The SDK uploads files PostHog does not have yet and sends the email with their hashes; emails support at most 10 files and 40 MB after Base64 encoding.
A send with templateKey accepts tracking to control opens, clicks, and engagement events. Without it, existing tracking behavior remains.
Opt a recipient out of email topics, or back in, with one call that sends the whole change in one request using the client's secretKey.
posthog.emails.send() accepts a React Email element through react and renders it with the optional @react-email/render peer dependency.
The NestJS interceptor can take the request's distinct ID from a getDistinctId option or from identity already set in the PostHog context.
Adds a metrics flush callers can request once per unit of work; concurrent calls share one queued send, and the flush waits out metrics backoff.
Adds request instrumentation for fetch-API servers, including request context, server spans, 5xx error marking, and HTTP server metrics.
Adds middleware for fetch-API servers such as Hono, Bun, Deno, and Next route handlers, with request context, server spans, error marking, and HTTP server metrics.
Adds a logs API, including posthog.logger.info(...) and posthog.captureLog(...), configured with the logs option; records attach active span trace and span ids and withContext distinctId and sessionId.
The Span handle exposes a spanId getter, allowing correlation of logs from other loggers with a trace without parsing traceparent().
The Span handle exposes a traceId getter, allowing correlation of logs from other loggers with a trace without parsing traceparent().
metrics.histogram() accepts a bounds option for setting bucket boundaries; beforeSend can see and change them.
Set appHost to your PostHog app URL when self-hosting PostHog or sending through a reverse proxy.
Pass your own idempotencyKey so job runner retries are safe and do not send the email twice.
Set migratedFrom on the client to tell PostHog which email provider you moved from.
Send emails with content rendered by your code by providing a templateKey, subject, and html, text, or both. Sends also support from, replyTo, and captureEngagement.
Pass a project secret API key as secretKey to the client to send emails or read statuses, depending on its Transactional email scope.
A new client option for sending transactional email from a PostHog email template.
Read what happened to a sent email using the message ID returned by send().
Send transactional email from a PostHog email template.
The Express and NestJS integrations can read session and identified-user IDs from the posthog-js cookie when requests have no tracing headers, linking backend events to browser sessions on same-site requests without frontend configuration.
isEnabled() and getFlag() accept sendFeatureFlagEvents to override the setting for one read, allowing experiment exposures to be sent from snapshot reads when sendFeatureFlagEvent is false.
Adds an optional OpenTelemetry context processor.
Adds an optional signal that ends a context's lifetime.
evaluateFlags() snapshots report flags whose local evaluation could not resolve via unresolvedFlags.
Local feature flag evaluation can use a shared definition cache without a secret or personal API key.
Feature flag evaluation reasons are exposed and preserved in OpenFeature resolution metadata.
Adds an API to read a feature flag's evaluation runtime.
Adds an API to get feature flag keys by evaluation runtime.
Adds a hook that sees every span before export and may edit or drop it.
Bounds how many attributes a single span may hold.
Bounds attribute value length for spans.
Bounds how many events a single span may hold.
Bounds how many spans a single process may hold.
Bounds how long a span may be held by a single process.
Adds experimental distributed tracing that records spans using the traces client option.
Adds a client option for recording experimental distributed tracing spans.
Exception capture methods are now exposed through the IPostHog interface.
Accepts an optional defaultValue returned when a flag has no value; present flag values still take precedence, and omitting the option preserves false-on-miss behavior.
Public beta API for sending AI events to a dedicated isolated endpoint and receiving the event UUID.
The property is added to $feature_flag_called events when the server explicitly reports has_experiment; it is omitted when the value is unknown.
Adds an alpha metrics API for recording count, gauge, and histogram metrics from backend services, with in-memory aggregation and OTLP/JSON flushing.
Exposes the error tracking rate-limiter bucket size so customers with high-cardinality exception types can tune the per-type allowance.
Exposes the error tracking rate-limiter refill rate so customers with high-cardinality exception types can tune the per-type allowance.
Dropped and undelivered Capture V1 events are surfaced on the client error channel as CaptureV1Error.
Set POSTHOG_CAPTURE_MODE=v1 to send analytics events to Capture V1 instead of the legacy /batch/ endpoint. Capture V1 uses Bearer auth and per-event partial retries; the default remains v0.
Adds secretKey as the canonical alias for personalApiKey; it accepts a Personal API Key or Project Secret API Key.
Adds groupIdentifyImmediate() to await the network request when identifying a group, useful in edge/serverless environments where the background queue may not flush.
Adds a helper to manage person properties from the Node.js SDK.
Local evaluation now supports the early_exit condition option, stopping with false when matching property filters are excluded by the rollout percentage instead of falling through to later groups.
Adds configurable isServer behavior, defaulting to true, to set the $is_server event property; set it to false for client or CLI use so the device OS is attributed normally.
Exposes UUID and cookie helpers from posthog-node so users can manage distinct_id outside the browser SDK.
Accepts a flags snapshot so the same flag evaluations used for branching can enrich a captured event.
Accepts a flags argument so $exception events carry the same flag context as the rest of the request's events.
Evaluates feature flags in one /flags request and returns a FeatureFlagEvaluations snapshot with methods for branching and filtering flags attached to captured events.
Pass flagKeys to scope the underlying /flags request to selected flags.
Adds Express and NestJS request context support for PostHog tracing headers.
Adds a NestJS integration with an interceptor for context propagation.
Local feature flag evaluation now supports semver_caret for semantic version comparisons.
Local feature flag evaluation now supports semver_eq for semantic version comparisons.
Local feature flag evaluation now supports semver_gt for semantic version comparisons.
Local feature flag evaluation now supports semver_gte for semantic version comparisons.
Local feature flag evaluation now supports semver_lt for semantic version comparisons.
Local feature flag evaluation now supports semver_lte for semantic version comparisons.
Local feature flag evaluation now supports semver_neq for semantic version comparisons.
Local feature flag evaluation now supports semver_tilde for semantic version comparisons.
Local feature flag evaluation now supports semver_wildcard for semantic version comparisons.
Accepts a waitUntil method for serverless environments.
Adds enterContext() to attach a context to the current async execution context.
Adds an /edge subpath export for use with non-standard edge runtimes.
Adds a method to retrieve a feature flag value and payload in a single API call.
Set strictLocalEvaluation: true at client init to prevent server fallback for flag evaluations; flags that cannot be evaluated locally return undefined.
Adds the overrideFeatureFlags() method for local testing and development.
Adds $feature_flag_error to $feature_flag_called events to track flag evaluation failures.
Context support was added.
Adds a client configuration option for the flag definition cache provider.
Adds the FlagDefinitionCacheProvider interface for providing a flag definition cache.
Enables tracking bot traffic as $bot_pageview events when enabled.
Performance 4
Client-only flag warnings and unnecessary server fallback are skipped during bulk evaluation.
Node SDK payloads use Node's zlib gzip implementation to avoid sustained memory growth from frequent Web Streams compression.
Local evaluation polling sends the latest etag in an If-None-Match header to reduce bandwidth when no flags have changed.
Cache initialization performance was improved.
Behavior and default changes 44
Config version 2 experiment splits now send $experiment_exposure events.
Requests now use
/flags/?v=4and read typed flag records; well-formed responses preserve existing getter and event values.With POSTHOG_CAPTURE_MODE=v1, capture retries 404 and 429 responses like 408 and 5xx instead of failing the batch immediately.
Convex functions in the default runtime can now import posthog-node without requiring the "use node" directive.
The configured serviceName from traces or metrics is stamped on events as service_name.
The experimental duration histogram uses new bucket boundaries, allowing its p50 and p95 to resolve between 50ms and 5s.
The SDK retries requests that hit a network error, rate limit, or outage twice by default.
A failed email call returns an EmailError containing PostHog's code and the HTTP statusCode.
The load-time warning also logs when strictLocalEvaluation is true.
Captured exceptions are linked to active OpenTelemetry traces when the API is available.
Metrics recorded inside sampled spans now have trace exemplars attached.
Setting featureFlagsPollingInterval to null disables automatic local flag polling while retaining initialization and manual refresh.
Feature flag cache payloads now support snake_case while preserving compatibility with camelCase providers and cached data.
Error capture now includes causes and AggregateError members with relationship metadata and individual stacks, limited to 50 entries and 1,000 member inspections.
Batches over 10 MiB or too large to serialize are stopped before making a request.
Logs and metrics retries honor Retry-After, extend waits up to five minutes, add jitter, and metrics back off exponentially across consecutive failures.
A false value means a conclusive off evaluation, while undefined means no evaluation is available. Remote evaluation omits globally inactive flags; backend local evaluation can resolve cached inactive definitions to false.
When a requested flag is missing from loaded local definitions, scoped calls now fall back to remote evaluation instead of omitting the flag without making a request.
Feature flag local evaluation now supports ends_with property filters, with case-insensitive matching, so matching flags no longer fall back to remote evaluation.
Feature flag local evaluation now supports not_ends_with property filters, with case-insensitive matching, so matching flags no longer fall back to remote evaluation.
Feature flag local evaluation now supports not_starts_with property filters, with case-insensitive matching, so matching flags no longer fall back to remote evaluation.
Feature flag local evaluation now supports starts_with property filters, with case-insensitive matching, so matching flags no longer fall back to remote evaluation.
Local feature flag polls are scheduled after each request settles.
Feature flag methods now accept numeric and boolean group property values through the shared Properties type, matching local evaluation.
Feature flag methods now accept numeric and boolean person property values through the shared Properties type, matching local evaluation.
Exception events include the injected release id as $release_id when one can be read, allowing PostHog to attach exceptions to a release without joining through symbol sets.
When the server enables minimal events, evaluations of flags not linked to experiments emit events rebuilt from an allowlist; missing signals and experiment-linked flags retain the full event.
The default maxQueueSize increases from 1000 to 10000 to reduce silent event drops during bursty workloads; an explicit option still overrides the default.
Pending metrics are flushed when shutdown() is called.
In v1 mode, $ai_* events continue to use the legacy submitter and an isolated in-memory queue, flushed independently so the transports do not share batches.
before_send is now called for identify, group identify, and alias events.
Feature flag requests are retried only after transient network errors. The retry count defaults to 1 and can be set to 0 to disable retries.
Batch payloads no longer send the top-level type, library, and library_version fields. SDK metadata uses properties.$lib and properties.$lib_version, falling back to legacy queued values when those properties are missing.
Feature flag definition cache provider types are now available from the main posthog-node export.
Local evaluation now supports mixed targeting.
Frames are sent with relative file paths.
Sends $device_id as a top-level field in /flags requests, enabling device-based bucketing during remote evaluation.
The config query parameter is omitted by default so requests retrieve only the necessary data.
Locally evaluated flags now include timing information in $feature_flag_called events, helping debug cache TTL and timing issues.
A context-sensitive override no longer requires distinctId as a parameter and instead reads it from the current context.
Traces now track the exception_id, helping correlate traces with exceptions.
Exceptions now track the LLM trace_id, helping correlate exceptions with traces.
Adds $feature_flag_evaluated_at properties to $feature_flag_called events.
The Express error handler now forwards session and distinct id.
Fixes and other changes 76
shutdown() now also sends logs captured while its logs flush was in flight, instead of dropping them.
Fixes matching for empty OR conditions and legacy cohort groups.
Falls back to the server for unsupported group types.
Fixes nested cohort not_in conditions in local feature flag evaluation.
Relative date filters no longer roll past the end of a shorter month; for example, 1m on March 31 resolves to February 28, matching the flags service.
A response whose flags field is not an object is treated as a failed request instead of throwing a TypeError, and is reported to error event listeners.
Node stack frames for functions named async are parsed when the filename has no leading parenthesis.
Unhandled promise rejections are captured even when the app or framework has an unhandledRejection listener, with deduplication across clients and within an event-loop turn. Capture timing, flush and shutdown behavior, and control-flow error handling are also adjusted.
Later conditions can resolve a flag locally when an unexpected error follows a filter that local evaluation cannot check, instead of failing the whole flag.
When a flag depends on one that only the server can evaluate, evaluation falls back to the server and unresolvedFlags reports the flag as unresolved_dependency.
Reads from an evaluateFlags() snapshot now honor sendFeatureFlagEvent: false, so snapshot reads no longer send feature flag events when that setting is disabled.
esbuild no longer fails to bundle posthog-node when the optional peer is not installed.
Falls back instead of returning inconsistent local regex flag results for Unicode and advanced patterns.
Falls back from local flag evaluation when a required property value is undefined.
Local flag evaluation now matches null properties with string operators, so negated operators such as not_icontains match instead of failing.
Types now accept non-null events while still allowing null returns to drop events.
Local feature flag evaluation now honors filters.holdout before release conditions, assigning held-out users the holdout variant and matching server evaluation.
Spans that run past the age limit and then end are exported; maxSpanAgeMs now evicts spans only once maxLiveSpans is reached, preventing their children from being orphaned.
Local feature flag evaluation respects the definitions response version: version 2 uses explicit boolean/string equality and per-member array matching, while missing or other versions retain service legacy matching.
Express exception events now report the final HTTP status instead of the initial response status.
Child spans now share their parent's clock, preventing them from appearing to start before or end after their parent, including when the system clock changes mid-trace.
A throwing getter no longer breaks every metrics export; its key is recorded as
[Unserializable]instead.Logs and metrics always send service.name and telemetry.sdk.* even when a resourceAttributes value is too large to encode in full.
Parsed stack traces now collapse repeated frame cycles to reduce grouping differences caused by recursion depth while preserving distinct throw locations.
Local feature flag evaluation now matches the flags service for string operators, exact-value coercion, and JSON stringification.
Narrows the bot-detection blocklist entry to pinterestbot so users of Pinterest's in-app browser are no longer misclassified as bots and excluded from analytics.
Omitted local evaluation properties are treated as inconclusive for is_not_set.
Empty feature flag evaluation key scopes are handled without running local or remote evaluation.
The Node SDK sends raw gzip bytes instead of wrapping them in a Blob, avoiding a native BlobReader leak on Node 24.16 and later. Compression behavior, headers, and wire format are unchanged.
Fixes remotely evaluated results to return an undefined variant instead of null.
Logs and metrics are no longer silently dropped for attributes containing certain unsupported or unusually large values; attributes are capped and excess content is marked as [Truncated].
OtlpAnyValue.intValue is typed as string | number, so code reading the field must handle both types.
Capture timestamp overrides are normalized to equivalent UTC ISO strings in the browser and Node.js SDKs and shared core.
The Node.js shutdown() return type is corrected to Promise<void>.
Configured request timeouts are now enforced while consuming Capture V1 response bodies.
Request timeouts remain active while the response body is consumed.
Minimal events retain $referring_domain and canonical utm_*/campaign parameters, preventing a flag-called event from setting session attribution and channel type to NULL.
Bounds stack source context reads and skips non-regular or oversized files.
Completed lifecycle timeout handles are cleared so successful shutdowns do not leave timers running.
Events added to a full queue are preserved while an earlier batch is being flushed.
The timeout remains active until the request settles, including while the response body is consumed.
When the supplied ID matches the persisted distinct ID, identify() now marks the user identified and captures a person-processed $set event.
NestJS request context is isolated per Observable subscription.
Normalizes V8 Promise combinator stack frames so input indexes are not treated as source filenames.
Avoids Edge runtime warnings related to native compression and fatal error handling.
The default Node.js event flush interval is fixed at 5 seconds.
Stops duplicating distinct_id inside /flags person properties.
Requests to /flags that receive HTTP 502 or 504 responses are retried across SDKs using the shared core flags client.
Node flush() waits for pending asynchronous SDK work before draining the event queue, so helper-produced events are not missed; pending work rejections no longer prevent queued events from flushing.
Event batches with circular property references are safely serialized instead of crashing during flush.
Local evaluation now applies the in/not_in operator to cohort membership, fixing inverted cohort-exclusion flags.
Only stamp $groups from the top-level groups when present.
Feature flag called events are deduplicated per returned flag value.
Respect disable_capture_url_hashes when capturing Express and NestJS request URLs.
Custom event UUID overrides are validated, and a new UUID is generated when an override is invalid.
Initialization paths with missing or blank PostHog project tokens now disable or no-op instead of throwing or sending requests.
captureException was unified in posthog core.
The deduplication key now includes group context, so events fire independently per group combination.
identifyImmediate now awaits the underlying network request, preventing the $identify event from being dropped when short-lived runtimes exit after await.
Local gt/gte/lt/lte evaluation now compares numerically when both sides parse as finite numbers, avoiding incorrect lexicographic comparisons.
Local evaluation resolves is_not_set as true when the property key is absent and false when present, rather than throwing InconclusiveMatchError.
Flag-level condition properties with negation: true are now inverted, matching the existing cohort-path behavior.
The fetch response body is consumed to prevent Cloudflare Workers runtime warnings.
Local evaluation polling now uses /flags/definitions instead of /api/feature_flag/local_evaluation.
Surrounding whitespace is trimmed from user-provided API keys, personal API keys, and host config values before they are used.
Local flag evaluation cache now preserves $set_once semantics.
captureException now uses distinctId from request context.
Fixed the return value of captureExceptionImmediate.
Client shutdown now awaits the feature flags poller stopping.
Super properties added with register now work.
In Node, before_send now infers its type as EventMessage or null instead of any.
getFeatureFlag() respects exponential backoff for HTTP 401, 403, and 429 responses.
Fixes the frame platform property for $exception events.
fetch is called without a bound context, preventing issues in edge runtimes such as Cloudflare.
Fixes a crash when calling getFeatureFlagPayloads for a flag that depends on a static cohort.
Fixes server fallback when a static cohort condition is followed by a matching condition.