releases.shpreview

Backend services can now record metrics via posthog-node (alpha)

@posthog/core@1.42.0

July 15, 2026PostHog JSView original ↗
1 featureThis release1 featureNew capabilitiesAI-tallied from the release notes
From the original release noteView original ↗

1.42.0

Minor Changes

  • #4117 1eddff7 Thanks @DanielVisca! - add the posthog.metrics API (count, gauge, histogram) to posthog-node — alpha

    Backend services can now record metrics through the same statsd-style pre-aggregating client the browser SDK ships, with no OpenTelemetry setup:

    const client = new PostHog('phc_...', { metrics: { serviceName: 'billing-worker' } })
    client.metrics.count('invoices.processed', 1, { attributes: { plan: 'pro' } })
    client.metrics.gauge('queue.depth', 42)
    client.metrics.histogram('job.duration', 187, { unit: 'ms' })

    Samples aggregate in memory and flush as OTLP/JSON to /i/v1/metrics (one data point per series per window). Pending metrics are flushed on shutdown(). Core gains _sendMetricsBatch on PostHogCoreStateless (same outcome contract as _sendLogsBatch) and a shared resolveMetricsConfig, so any core-based SDK can host PostHogMetrics. (2026-07-15)

Fetched July 15, 2026