unstale

npm / posthog-node

posthog-node

What changed in posthog-node 5, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-18.

15 breaking10 deprecations58 new APIs and options3 performance37 behavior and defaults62 fixes and other

See which of these apply to your code, ranked, in your agent:

npx @unstale/cli init

@unstale/cli on npm

posthog-node 5185 changes

Breaking changes 15

  • 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.

    5.55.1release notes

  • 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.

    5.52.4release notes

  • Bigint attributes on logs, metrics, and spans are now sent as int64 rather than as strings.

    5.51.5release notes

  • Local evaluation now honors evaluationContexts; flags whose evaluation contexts do not overlap the configured list resolve to undefined instead of being evaluated locally.

    5.51.4release notes

  • Events are dropped when the before-send hook throws, rather than being sent unmodified.

    5.49.2release notes

  • 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.

    5.49.0release notes

  • Shutdown timeouts are logged without rejecting, so callers do not receive a rejection for a timeout.

    5.48.2release notes

  • 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.

    5.47.9release notes

  • Semver values with leading zeros are rejected in both flag and override values; invalid inputs surface as InconclusiveMatchError and do not match targeting conditions.

    5.34.10release notes

  • An inactive flag now short-circuits to false even when ensure_experience_continuity is true, instead of throwing InconclusiveMatchError and resolving to undefined.

    5.34.6release notes

  • Cohort property groups containing a flag-type property now mark cohort evaluation inconclusive, so the flag returns undefined instead of a wrong definitive answer.

    5.34.6release notes

  • is_set now returns true when a property key is present, even if its value is null or undefined.

    5.34.6release notes

  • Use evaluationContexts in posthog.init to specify evaluation contexts instead of deployment environments.

    5.23.0release notes

  • The minimum supported Node.js version is now ^20.20.0 || >=22.22.0 due to an async-hooks DoS vulnerability.

    5.22.0release notes

  • Contexts inherit by default, changing how context values are passed to child contexts.

    5.17.0release notes

Deprecations 10

  • The Node SDK Sentry integration is deprecated; users are directed to PostHog Error Tracking for Node.

    5.38.3release notes

  • Imports from posthog-node/experimental are deprecated.

    5.35.0release notes

  • 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.

    5.33.0release notes

  • 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.

    5.33.0release notes

  • 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.

    5.33.0release notes

  • 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.

    5.33.0release notes

  • Manual capture('$exception') now emits a warning.

    5.24.17release notes

  • The posthog.init option is deprecated in favor of evaluationContexts; it continues to work and logs a deprecation warning.

    5.23.0release notes

  • A warning is emitted when local evaluation encounters flags with experience continuity enabled, explaining that they cause server requests on every evaluation.

    5.21.0release notes

  • The package is deprecated.

    5.14.0release notes

New APIs and options 58

  • Local feature flag evaluation can use a shared definition cache without a secret or personal API key.

    5.56.2release notes

  • Feature flag evaluation reasons are exposed and preserved in OpenFeature resolution metadata.

    5.54.0release notes

  • Adds an API to read a feature flag's evaluation runtime.

    5.53.0release notes

  • Adds an API to get feature flag keys by evaluation runtime.

    5.53.0release notes

  • Adds a hook that sees every span before export and may edit or drop it.

    5.52.0release notes

  • Adds experimental distributed tracing that records spans using the traces client option.

    5.52.0release notes

  • Bounds how many attributes a single span may hold.

    5.52.0release notes

  • Bounds attribute value length for spans.

    5.52.0release notes

  • Bounds how many events a single span may hold.

    5.52.0release notes

  • Bounds how many spans a single process may hold.

    5.52.0release notes

  • Bounds how long a span may be held by a single process.

    5.52.0release notes

  • Adds experimental distributed tracing that records spans using the traces client option.

    5.52.0release notes

  • Adds a client option for recording experimental distributed tracing spans.

    5.52.0release notes

  • Adds experimental distributed tracing that records spans using the traces client option.

    5.52.0release notes

  • Exception capture methods are now exposed through the IPostHog interface.

    5.51.6release notes

  • 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.

    5.50.0release notes

  • Public beta API for sending AI events to a dedicated isolated endpoint and receiving the event UUID.

    5.49.0release notes

  • Public beta API for sending AI events to a dedicated isolated endpoint and receiving the event UUID.

    5.49.0release notes

  • The property is added to $feature_flag_called events when the server explicitly reports has_experiment; it is omitted when the value is unknown.

    5.45.0release notes

  • Adds an alpha metrics API for recording count, gauge, and histogram metrics from backend services, with in-memory aggregation and OTLP/JSON flushing.

    5.43.0release notes

  • Exposes the error tracking rate-limiter bucket size so customers with high-cardinality exception types can tune the per-type allowance.

    5.42.0release notes

  • Exposes the error tracking rate-limiter refill rate so customers with high-cardinality exception types can tune the per-type allowance.

    5.42.0release notes

  • Dropped and undelivered Capture V1 events are surfaced on the client error channel as CaptureV1Error.

    5.41.0release notes

  • 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.

    5.41.0release notes

  • Adds secretKey as the canonical alias for personalApiKey; it accepts a Personal API Key or Project Secret API Key.

    5.40.0release notes

  • Adds groupIdentifyImmediate() to await the network request when identifying a group, useful in edge/serverless environments where the background queue may not flush.

    5.39.0release notes

  • Adds a helper to manage person properties from the Node.js SDK.

    5.38.0release notes

  • Adds a helper to manage person properties from the Node.js SDK.

    5.38.0release notes

  • 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.

    5.37.0release notes

  • 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.

    5.36.0release notes

  • Exposes UUID and cookie helpers from posthog-node so users can manage distinct_id outside the browser SDK.

    5.34.0release notes

  • Accepts a flags snapshot so the same flag evaluations used for branching can enrich a captured event.

    5.33.0release notes

  • Accepts a flags argument so $exception events carry the same flag context as the rest of the request's events.

    5.33.0release notes

  • Accepts a flags argument so $exception events carry the same flag context as the rest of the request's events.

    5.33.0release notes

  • Evaluates feature flags in one /flags request and returns a FeatureFlagEvaluations snapshot with methods for branching and filtering flags attached to captured events.

    5.33.0release notes

  • Pass flagKeys to scope the underlying /flags request to selected flags.

    5.33.0release notes

  • Adds Express and NestJS request context support for PostHog tracing headers.

    5.31.0release notes

  • Adds a NestJS integration with an interceptor for context propagation.

    5.28.0release notes

  • Local feature flag evaluation now supports semver_caret for semantic version comparisons.

    5.27.1release notes

  • Local feature flag evaluation now supports semver_eq for semantic version comparisons.

    5.27.1release notes

  • Local feature flag evaluation now supports semver_gt for semantic version comparisons.

    5.27.1release notes

  • Local feature flag evaluation now supports semver_gte for semantic version comparisons.

    5.27.1release notes

  • Local feature flag evaluation now supports semver_lt for semantic version comparisons.

    5.27.1release notes

  • Local feature flag evaluation now supports semver_lte for semantic version comparisons.

    5.27.1release notes

  • Local feature flag evaluation now supports semver_neq for semantic version comparisons.

    5.27.1release notes

  • Local feature flag evaluation now supports semver_tilde for semantic version comparisons.

    5.27.1release notes

  • Local feature flag evaluation now supports semver_wildcard for semantic version comparisons.

    5.27.1release notes

  • Accepts a waitUntil method for serverless environments.

    5.27.0release notes

  • Adds enterContext() to attach a context to the current async execution context.

    5.26.0release notes

  • Adds an /edge subpath export for use with non-standard edge runtimes.

    5.24.13release notes

  • Adds a method to retrieve a feature flag value and payload in a single API call.

    5.21.2release notes

  • Set strictLocalEvaluation: true at client init to prevent server fallback for flag evaluations; flags that cannot be evaluated locally return undefined.

    5.21.0release notes

  • Adds the overrideFeatureFlags() method for local testing and development.

    5.19.0release notes

  • Adds $feature_flag_error to $feature_flag_called events to track flag evaluation failures.

    5.18.0release notesrelease notes

  • Context support was added.

    5.15.0release notes

  • Adds a client configuration option for the flag definition cache provider.

    5.12.0release notes

  • Adds the FlagDefinitionCacheProvider interface for providing a flag definition cache.

    5.12.0release notes

  • Enables tracking bot traffic as $bot_pageview events when enabled.

    5.11.0release notes

Performance 3

  • Node SDK payloads use Node's zlib gzip implementation to avoid sustained memory growth from frequent Web Streams compression.

    5.48.1release notes

  • Local evaluation polling sends the latest etag in an If-None-Match header to reduce bandwidth when no flags have changed.

    5.17.2release notes

  • Cache initialization performance was improved.

    5.15.0release notes

Behavior and default changes 37

  • Captured exceptions are linked to active OpenTelemetry traces when the API is available.

    5.56.1release notes

  • Metrics recorded inside sampled spans now have trace exemplars attached.

    5.56.0release notes

  • Setting featureFlagsPollingInterval to null disables automatic local flag polling while retaining initialization and manual refresh.

    5.55.0release notes

  • Feature flag cache payloads now support snake_case while preserving compatibility with camelCase providers and cached data.

    5.54.1release notes

  • Error capture now includes causes and AggregateError members with relationship metadata and individual stacks, limited to 50 entries and 1,000 member inspections.

    5.52.3release notes

  • Batches over 10 MiB or too large to serialize are stopped before making a request.

    5.52.0release notes

  • Logs and metrics retries honor Retry-After, extend waits up to five minutes, add jitter, and metrics back off exponentially across consecutive failures.

    5.52.0release notes

  • 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.

    5.51.7release notes

  • 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.

    5.51.0release notes

  • Feature flag local evaluation now supports ends_with property filters, with case-insensitive matching, so matching flags no longer fall back to remote evaluation.

    5.48.0release notes

  • 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.

    5.48.0release notes

  • 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.

    5.48.0release notes

  • Feature flag local evaluation now supports starts_with property filters, with case-insensitive matching, so matching flags no longer fall back to remote evaluation.

    5.48.0release notes

  • Local feature flag polls are scheduled after each request settles.

    5.47.8release notes

  • Feature flag methods now accept numeric and boolean group property values through the shared Properties type, matching local evaluation.

    5.47.5release notes

  • Feature flag methods now accept numeric and boolean person property values through the shared Properties type, matching local evaluation.

    5.47.5release notes

  • 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.

    5.47.0release notes

  • 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.

    5.46.0release notes

  • The default maxQueueSize increases from 1000 to 10000 to reduce silent event drops during bursty workloads; an explicit option still overrides the default.

    5.44.0release notes

  • Pending metrics are flushed when shutdown() is called.

    5.43.0release notes

  • 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.

    5.41.0release notes

  • before_send is now called for identify, group identify, and alias events.

    5.39.1release notes

  • 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.

    5.38.7release notes

  • 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.

    5.38.1release notes

  • Feature flag definition cache provider types are now available from the main posthog-node export.

    5.35.0release notes

  • Local evaluation now supports mixed targeting.

    5.32.0release notes

  • Frames are sent with relative file paths.

    5.30.0release notes

  • Sends $device_id as a top-level field in /flags requests, enabling device-based bucketing during remote evaluation.

    5.29.2release notes

  • The config query parameter is omitted by default so requests retrieve only the necessary data.

    5.28.2release notes

  • Locally evaluated flags now include timing information in $feature_flag_called events, helping debug cache TTL and timing issues.

    5.26.1release notes

  • A context-sensitive override no longer requires distinctId as a parameter and instead reads it from the current context.

    5.26.0release notes

  • A context-sensitive override no longer requires distinctId as a parameter and instead reads it from the current context.

    5.26.0release notes

  • A context-sensitive override no longer requires distinctId as a parameter and instead reads it from the current context.

    5.26.0release notes

  • Traces now track the exception_id, helping correlate traces with exceptions.

    5.20.0release notes

  • Exceptions now track the LLM trace_id, helping correlate exceptions with traces.

    5.20.0release notes

  • Adds $feature_flag_evaluated_at properties to $feature_flag_called events.

    5.16.0release notes

  • The Express error handler now forwards session and distinct id.

    5.14.1release notes

Fixes and other changes 62

  • Types now accept non-null events while still allowing null returns to drop events.

    5.55.3release notes

  • Local feature flag evaluation now honors filters.holdout before release conditions, assigning held-out users the holdout variant and matching server evaluation.

    5.52.6release notes

  • 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.

    5.52.5release notes

  • 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.

    5.52.5release notes

  • Express exception events now report the final HTTP status instead of the initial response status.

    5.52.2release notes

  • 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.

    5.52.1release notes

  • A throwing getter no longer breaks every metrics export; its key is recorded as [Unserializable] instead.

    5.52.0release notes

  • Logs and metrics always send service.name and telemetry.sdk.* even when a resourceAttributes value is too large to encode in full.

    5.52.0release notes

  • Logs and metrics always send service.name and telemetry.sdk.* even when a resourceAttributes value is too large to encode in full.

    5.52.0release notes

  • Parsed stack traces now collapse repeated frame cycles to reduce grouping differences caused by recursion depth while preserving distinct throw locations.

    5.51.8release notes

  • Local feature flag evaluation now matches the flags service for string operators, exact-value coercion, and JSON stringification.

    5.51.5release notes

  • 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.

    5.51.4release notes

  • Omitted local evaluation properties are treated as inconclusive for is_not_set.

    5.51.3release notes

  • Empty feature flag evaluation key scopes are handled without running local or remote evaluation.

    5.51.2release notes

  • 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.

    5.51.1release notes

  • Fixes remotely evaluated results to return an undefined variant instead of null.

    5.49.4release notes

  • 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].

    5.49.3release notes

  • OtlpAnyValue.intValue is typed as string | number, so code reading the field must handle both types.

    5.49.3release notes

  • Capture timestamp overrides are normalized to equivalent UTC ISO strings in the browser and Node.js SDKs and shared core.

    5.49.1release notes

  • The Node.js shutdown() return type is corrected to Promise<void>.

    5.48.2release notes

  • Configured request timeouts are now enforced while consuming Capture V1 response bodies.

    5.48.1release notes

  • Request timeouts remain active while the response body is consumed.

    5.47.11release notes

  • Minimal events retain $referring_domain and canonical utm_*/campaign parameters, preventing a flag-called event from setting session attribution and channel type to NULL.

    5.47.10release notes

  • Bounds stack source context reads and skips non-regular or oversized files.

    5.47.7release notes

  • Completed lifecycle timeout handles are cleared so successful shutdowns do not leave timers running.

    5.47.6release notes

  • Events added to a full queue are preserved while an earlier batch is being flushed.

    5.47.4release notes

  • The timeout remains active until the request settles, including while the response body is consumed.

    5.47.3release notes

  • When the supplied ID matches the persisted distinct ID, identify() now marks the user identified and captures a person-processed $set event.

    5.47.2release notes

  • NestJS request context is isolated per Observable subscription.

    5.47.1release notes

  • Normalizes V8 Promise combinator stack frames so input indexes are not treated as source filenames.

    5.46.1release notes

  • Avoids Edge runtime warnings related to native compression and fatal error handling.

    5.45.2release notes

  • The default Node.js event flush interval is fixed at 5 seconds.

    5.45.1release notes

  • Stops duplicating distinct_id inside /flags person properties.

    5.39.4release notes

  • Requests to /flags that receive HTTP 502 or 504 responses are retried across SDKs using the shared core flags client.

    5.39.3release notes

  • 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.

    5.39.2release notes

  • Event batches with circular property references are safely serialized instead of crashing during flush.

    5.39.1release notes

  • Local evaluation now applies the in/not_in operator to cohort membership, fixing inverted cohort-exclusion flags.

    5.38.8release notes

  • Only stamp $groups from the top-level groups when present.

    5.38.6release notes

  • Feature flag called events are deduplicated per returned flag value.

    5.38.5release notes

  • Respect disable_capture_url_hashes when capturing Express and NestJS request URLs.

    5.38.4release notes

  • Custom event UUID overrides are validated, and a new UUID is generated when an override is invalid.

    5.38.2release notes

  • Initialization paths with missing or blank PostHog project tokens now disable or no-op instead of throwing or sending requests.

    5.35.9release notes

  • captureException was unified in posthog core.

    5.35.6release notes

  • The deduplication key now includes group context, so events fire independently per group combination.

    5.35.2release notes

  • identifyImmediate now awaits the underlying network request, preventing the $identify event from being dropped when short-lived runtimes exit after await.

    5.34.8release notes

  • Local gt/gte/lt/lte evaluation now compares numerically when both sides parse as finite numbers, avoiding incorrect lexicographic comparisons.

    5.34.6release notes

  • Local evaluation resolves is_not_set as true when the property key is absent and false when present, rather than throwing InconclusiveMatchError.

    5.34.6release notes

  • Flag-level condition properties with negation: true are now inverted, matching the existing cohort-path behavior.

    5.34.6release notes

  • The fetch response body is consumed to prevent Cloudflare Workers runtime warnings.

    5.33.2release notes

  • Local evaluation polling now uses /flags/definitions instead of /api/feature_flag/local_evaluation.

    5.29.4release notes

  • Surrounding whitespace is trimmed from user-provided API keys, personal API keys, and host config values before they are used.

    5.29.3release notes

  • Local flag evaluation cache now preserves $set_once semantics.

    5.29.0release notes

  • captureException now uses distinctId from request context.

    5.28.6release notes

  • Fixed the return value of captureExceptionImmediate.

    5.28.3release notes

  • Client shutdown now awaits the feature flags poller stopping.

    5.28.2release notes

  • Super properties added with register now work.

    5.25.0release notes

  • In Node, before_send now infers its type as EventMessage or null instead of any.

    5.24.5release notes

  • getFeatureFlag() respects exponential backoff for HTTP 401, 403, and 429 responses.

    5.18.1release notes

  • Fixes the frame platform property for $exception events.

    5.13.0release notes

  • fetch is called without a bound context, preventing issues in edge runtimes such as Cloudflare.

    5.13.0release notes

  • Fixes a crash when calling getFeatureFlagPayloads for a flag that depends on a static cohort.

    5.10.2release notes

  • Fixes server fallback when a static cohort condition is followed by a matching condition.

    5.10.1release notes