Packages

posthog-node

6.0.5 · 19 Nov 2026MIT23.9M / weekRepositorynpmAtom feed

Your version

370 stable releases, newest first, by release line. Notes are quoted as the maintainers published them.

  1. 6.x · latest line
  2. 6.0.5

    19 Nov 2026
    • Keep falsy payloads (0, false, "") for locally evaluated flags in evaluateFlags and getAllFlagsAndPayloads
      (2026-11-19)

  3. 6.0.4

    18 Nov 2026
    • Send transactional email requests to /api/messaging/ instead of the /api/projects/@current/ alias, which PostHog is removing. Needs PostHog Cloud, or a self-hosted PostHog from 2026-11-18 or later. Older self-hosted versions answer these calls with a 404.
      (2026-11-18)

  4. 6.0.3

    18 Nov 2026
    • Removed

      Drop null-valued custom exception properties after beforeSend without undoing redaction or changing array positions.
      (2026-11-18)

    • Preserve falsy JSON payloads in feature flag snapshots from legacy flag responses.
      (2026-11-18)

  5. 6.0.2

    17 Nov 2026
    • Accept the 5.x option names before_send, custom_blocked_useragents, disable_capture_url_hashes, and __preview_capture_bot_pageviews again as deprecated aliases. Each one maps to its camelCase name and logs one deprecation error per process. When both names are set, the camelCase one wins. In 6.0.0 the old names were ignored without a warning, so a before_send hook stopped running.
      (2026-11-17)

  6. 6.0.1

    17 Nov 2026
    • Add the missing commas to the captureImmediate and identify doc comment examples, so the examples parse when you copy them.
      (2026-11-17)

  7. 6.0.0

    17 Nov 2026
    • Breaking

      Remove enterContext(); use withContext() to scope async context to a callback.
      (2026-11-17)

    • Breaking

      Use camelCase SDK configuration names and typed boolean event options with support for additional JSON-valued options.
      (2026-11-17)

    • Breaking

      captureException() and captureExceptionImmediate() take an options object (distinctId, properties, options, uuid, flags, level). The old positional form still works in posthog-node 6.x.x and logs a deprecation error once per method. level is read case-insensitively, with the same aliases as posthog-python (critical → fatal, warn → warning). An unknown level keeps error.
      registerOptions() and unregisterOptions() return a promise, and prepareEventMessage() returns a flat message with top-level options, uuid, timestamp and disableGeoip. (2026-11-17)

  8. 5.x
  9. 5.74.0

    15 Nov 2026
    • Treat failed flag evaluations as unavailable: Node getFeatureFlag()/isFeatureEnabled() return undefined, getAllFlags() omits failed keys, and no failed values or payloads are exposed.
      (2026-11-15)

  10. 5.73.1

    14 Nov 2026
    • node: shutdown() now also sends logs captured while its logs flush was in flight, instead of dropping them
      (2026-11-14)

  11. 5.73.0

    13 Nov 2026
    • Send $experiment_exposure for config version 2 experiment splits, and send the reason code and rule attribution on $feature_flag_called for config version 2 flags in place of $feature_flag_reason.
      (2026-11-13)

    • Request /flags/?v=4 instead of /flags/?v=2 and read its typed flag records. For a well-formed response, flag getters and $feature_flag_called events return the same values as before. A PostHog server that does not serve v=4 answers as it does for v=2, and that response is read as before.

      A flag record with a field of the wrong JSON type, such as a string metadata.version, now reads as disabled: flag getters return false and it has no payload. Other flags in the same response are not affected. This applies to both response versions, so tests that mock /flags may need to match the new URL and send correctly typed fields. (2026-11-13)

  12. 5.72.0

    13 Nov 2026
    • Send cc, bcc and attachments with email from code. The SDK uploads each file PostHog doesn't have yet, then sends the email with the files' hashes. An email carries at most 10 files and 40 MB after Base64 encoding, about 29 MB of files.
      (2026-11-13)

  13. 5.71.0

    12 Nov 2026
    • A send with templateKey now takes tracking and sensitive.

      tracking chooses what PostHog tracks for the email. tracking: true turns on opens, clicks and engagement events. tracking: false turns them all off. An object such as { clicks: true } or { engagement: false } turns each kind on or off, and a key you leave out keeps its default. Without it, PostHog counts opens, captures engagement events, and counts clicks only when the email isn't sensitive.

      sensitive marks an email that carries login links, reset tokens or codes. A sensitive email keeps its links as they are unless tracking turns clicks on, leaves its subject off engagement events, and keeps its content out of PostHog's logs. Without it, a send whose templateKey matches a template saved in PostHog follows that template's setting, and any other send is sensitive. PostHog refuses sensitive: false when the matching template is sensitive. A send that sets neither option works exactly as before.

      captureEngagement is deprecated in favor of tracking: { engagement: false }. It keeps working, but PostHog refuses a send that sets both.

      tracking and sensitive need PostHog's API support, which is rolling out. Until it reaches your PostHog instance, PostHog refuses a send that sets either one. (2026-11-12)

  14. 5.70.0

    12 Nov 2026
    • Opt a recipient out of email topics, or back in, with posthog.emails.setPreferences({ to, topics, allMarketing }). One call sends the whole change in one request, using the client's secretKey.
      (2026-11-12)

  15. 5.69.0

    11 Nov 2026
    • posthog.emails.send() takes a React Email element as react and renders it with the optional peer @react-email/render.
      (2026-11-11)

  16. 5.68.2

    10 Nov 2026
    • With POSTHOG_CAPTURE_MODE=v1, capture now retries 404 and 429 responses like 408 and 5xx instead of failing the batch at once.
      (2026-11-10)

  17. 5.68.1

    10 Nov 2026
    • Fix empty OR and legacy cohort group matching, and fall back to the server for unsupported group types.
      (2026-11-10)

  18. 5.68.0

    10 Nov 2026
    • node: Let the NestJS interceptor take the request's distinct ID from a getDistinctId option or from identity already set in the PostHog context
      (2026-11-10)

  19. 5.67.2

    10 Nov 2026
    • Fix nested cohort not_in conditions in local feature flag evaluation.
      (2026-11-10)

  20. 5.67.1

    10 Nov 2026
    • Relative date filters in local flag evaluation no longer roll past the end of a shorter month. 1m on March 31 now resolves to February 28, matching the flags service.
      (2026-11-10)

  21. 5.67.0

    10 Nov 2026
    • node: Add instrumentRequest and posthogHonoMiddleware for fetch-API servers (Hono, Bun, Deno, Next route handlers). They read x-posthog-session-id, wrap the request in withContext, open a server span that continues traceparent and is named by route, mark 5xx as errors, and record http.server.request.duration and http.server.request.count.

      feat(core): add PostHogMetrics.flushCoalesced(), a flush that callers can request once per unit of work: concurrent calls share one queued send, and it waits out a metrics backoff. (2026-11-10)

  22. 5.66.0

    10 Nov 2026
    • Convex functions in the default runtime can now import posthog-node without "use node".
      (2026-11-10)

  23. 5.65.0

    10 Nov 2026
    • node: Stamp the configured serviceName (from traces or metrics) on events as service_name
      (2026-11-10)

    • node: Add a logs API, posthog.logger.info(...) and posthog.captureLog(...), configured with the logs option. Records attach the active span's trace and span ids and the withContext distinctId and sessionId, and serviceName defaults to the traces or metrics one.
      (2026-11-10)

    • node: Expose traceId and spanId getters on the Span handle, for correlating logs from other loggers with a trace without parsing traceparent()
      (2026-11-10)

  24. 5.64.0

    9 Nov 2026
    • node: Expose traceId and spanId getters on the Span handle, for correlating logs from other loggers with a trace without parsing traceparent()
      (2026-11-09)

  25. 5.63.2

    9 Nov 2026
    • Treat a /flags response whose flags field is not an object as a failed request instead of throwing a TypeError, and report it to error event listeners.
      (2026-11-09)

  26. 5.63.1

    6 Nov 2026
    • Parse Node stack frames for functions named async without a leading parenthesis in the filename.
      (2026-11-06)

  27. 5.63.0

    5 Nov 2026
    • metrics.histogram() accepts a bounds option that sets the histogram's bucket boundaries, and beforeSend sees and can change them. The first sample of a histogram (name and unit) fixes its bounds until the client resets. A later sample with different bounds is recorded in the fixed buckets and logs a warning, and a sample with invalid bounds is dropped. The experimental posthog.flags.request.duration histogram now uses the bounds [50, 75, 100, 150, 200, 300, 400, 500, 750, 1000, 1500, 2000, 3000, 5000, 10000] ms, so its p50 and p95 resolve between 50ms and 5s. This changes the metric's buckets, which its experimental status allows.
      (2026-11-05)

  28. 5.62.0

    5 Nov 2026
    • posthog.emails.send() can now send email content your code rendered, such as HTML from React Email. Give the email a templateKey and a subject, and pass html, text or both.

      const posthog = new PostHog("phc_...", { secretKey: "phs_..." });
      
      const { data, error } = await posthog.emails.send({
        to: "user@example.com",
        distinctId: "user_123",
        templateKey: "password-reset",
        subject: "Reset your password",
        html: renderedHtml,
      });
      if (error) throw error;
      
      // 'delivered', 'bounced', ...
      const { data: status } = await posthog.emails.get(data.id);

      You need a project secret API key, the kind that starts with phs_. Create one under Project secret API keys in your project settings. Set its Transactional email scope to Write to send emails, or to Read for a key that only reads statuses. Pass it to the client as secretKey. Set appHost to your PostHog app URL when you self-host PostHog or send through a reverse proxy.

      PostHog records each email's delivery, opens and clicks on the person with that distinctId. It groups every email with the same templateKey, so you see their metrics and logs in one place. The SDK retries a request that hits a network error, a rate limit or an outage twice by default. Every send carries an idempotency key, so a retry never sends the email twice. Pass your own idempotencyKey, such as welcome:user_123, and your job runner's retries are safe too.

      A send with your own content also takes from, replyTo and captureEngagement: false. Set migratedFrom on the client to tell PostHog which email provider you moved from. A failed call returns an EmailError with PostHog's code and the HTTP statusCode.

      Docs: Send transactional emails with Node.js and the transactional email overview. (2026-11-05)

  29. 5.61.3

    5 Nov 2026
    • Skip client-only flag warnings and unnecessary server fallback during bulk evaluation.
      (2026-11-05)

  30. 5.61.2

    2 Nov 2026
    • posthog.emails.send() now sends a flat request body with template_id and distinct_id at the top level.
      (2026-11-02)

  31. 5.61.1

    30 Oct 2026
    • Exception autocapture now captures unhandled promise rejections when the app or framework (for example Next.js, Nitro or PM2) has its own unhandledRejection listener, without changing what Node does with the rejection. Each occurrence is captured once per project, however many clients the app creates, and an error reported more than once in the same turn of the event loop (rethrown by a host listener, or one Error object rejected by two promises) is captured once. When the process survives the error, autocapture captures it at the end of the current turn of the event loop, so that a captureException call for the same error in that turn, from the app's own listener or a framework's error hook such as Nitro's, is the one sent, with its distinctId and properties. A captureException call for an error that autocapture already captured in the same turn is skipped. When the app flushes or shuts down a client, that client captures at once what is still waiting for the end of the turn, so a crash handler that flushes or shuts down and then exits still sends the error. A crash is captured whatever the error, an AbortError or a framework's control flow included. A rejection that the app handles only later is still captured, as Node reports it as unhandled. Next.js and React control-flow errors and AbortError rejections are skipped when the process survives them.
      (2026-10-30)

  32. 5.61.0

    30 Oct 2026
    • Send transactional email from a PostHog email template with posthog.emails.send(), using the new appHost, emailRequestTimeoutMs and emailRequestMaxRetries client options. Read what happened to a sent email with posthog.emails.get(id), using the message ID that send() returned.
      (2026-10-30)

  33. 5.60.1

    29 Oct 2026
    • Let later conditions resolve a flag locally when an unexpected error follows a filter that local evaluation cannot check, instead of failing the whole flag
      (2026-10-29)

    • Fall back to the server when a flag depends on a flag that only the server can evaluate (for example, one with a static cohort), instead of letting a later condition choose a different value locally. unresolvedFlags reports such a flag as unresolved_dependency
      (2026-10-29)

  34. 5.60.0

    29 Oct 2026
    • The Express and NestJS integrations can read the session ID, and the distinct ID of an identified user, from the posthog-js cookie when a request has no tracing headers, so backend events link to browser sessions on same-site requests without frontend configuration. Turn it on with the readPostHogCookie option.
      (2026-10-29)

  35. 5.59.0

    28 Oct 2026
    • Reads from an evaluateFlags() snapshot now honor sendFeatureFlagEvent: false, and isEnabled() / getFlag() accept a sendFeatureFlagEvents option that overrides it for one read. If you set sendFeatureFlagEvent: false and rely on snapshot reads for experiment exposures, pass sendFeatureFlagEvents: true on those reads.
      (2026-10-28)

  36. 5.58.0

    28 Oct 2026
    • Add an optional OpenTelemetry context processor, and an optional signal that ends a context's lifetime.
      (2026-10-28)

  37. 5.57.2

    25 Oct 2026
    • Esbuild no longer fails to bundle posthog-node when the optional @opentelemetry/api peer is not installed
      (2026-10-25)

  38. 5.57.1

    23 Oct 2026
    • Apply the client privacyMode option to AI integrations, keep prompts out of errors, provider metadata and OTel spans in privacy mode, and redact MCP tool credentials
      (2026-10-23)

    • Fall back instead of returning inconsistent local regex flag results for Unicode and advanced patterns.
      (2026-10-23)

  39. 5.57.0

    22 Oct 2026
    • Report flags local evaluation could not resolve on evaluateFlags() snapshots via unresolvedFlags, tag reads of them with local_evaluation_inconclusive, and warn once about flags whose definition local evaluation does not support

      Behavior changes:

  40. 5.56.4

    21 Oct 2026
    • Fall back from local flag evaluation when a required property value is undefined.
      (2026-10-21)

  41. 5.56.3

    21 Oct 2026
    • Local flag evaluation now matches a null property with string operators like the flags service, so negated operators such as not_icontains match instead of failing.
      (2026-10-21)

  42. 5.56.2

    16 Oct 2026
    • Allow local feature flag evaluation from a shared definition cache without a secret or personal API key.
      (2026-10-16)

  43. 5.56.1

    14 Oct 2026
    • Link captured exceptions to active OpenTelemetry traces when the API is available.
      (2026-10-14)

  44. 5.56.0

    13 Oct 2026
    • Attach trace exemplars to metrics recorded inside sampled spans.
      (2026-10-13)

  45. 5.55.3

    12 Oct 2026
    • Fix before_send callback types to accept non-null events while still allowing null returns to drop events.
      (2026-10-12)

  46. 5.55.2

    11 Oct 2026
    • Clarify which server-only credentials to use for local evaluation when a project API key is supplied instead.
      (2026-10-11)

  47. 5.55.1

    8 Oct 2026
    • Evict only the least recently used distinct ids from the $feature_flag_called dedupe cache instead of clearing it entirely. distinctIdHasSentFlagCalls now returns a snapshot, so writing or deleting individual keys on it no longer changes deduplication.
      (2026-10-08)

  48. 5.55.0

    30 Sep 2026
    • Allow featureFlagsPollingInterval: null to disable automatic local flag polling while retaining initialization and manual refresh.
      (2026-09-30)

  49. 5.54.1

    25 Sep 2026
    • Support snake_case feature flag cache payloads while preserving compatibility with camelCase providers and cached data.
      (2026-09-25)

  50. 5.54.0

    25 Sep 2026
    • Expose feature flag evaluation reasons and preserve them in OpenFeature resolution metadata.
      (2026-09-25)

  51. 5.53.0

    23 Sep 2026
    • Read a feature flag's evaluation runtime with getFeatureFlagEvaluationRuntime(key) and getFeatureFlagKeysByEvaluationRuntime(runtime)
      (2026-09-23)

  52. 5.52.6

    23 Sep 2026
    • Honor filters.holdout during local feature flag evaluation. A user in an experiment holdout now receives the holdout-<id> variant instead of being bucketed into a regular variant, matching how the server evaluates the same flag. The holdout is resolved before the release conditions, so a held-out user never reaches the flag's targeting — including when those conditions would have excluded them, so isFeatureEnabled can return true where it previously returned false. Experiments with an active holdout will see variant assignment change for the held-out share of traffic on upgrade, bringing locally evaluated assignments in line with server-evaluated ones.
      (2026-09-23)

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.