releases.shpreview

Metrics config settable at module level; metrics client hardened

posthog-v7.28.0

1 feature2 enhancements3 fixesThis release1 featureNew capabilities2 enhancementsImprovements to existing features3 fixesBug fixesAI-tallied from the release notes
From the original release noteView original ↗

Minor changes

  • 2d7f8cc The client.metrics config can now be set through module-level settings: assign posthog.metrics = {"service_name": ..., ...} alongside posthog.api_key and the dict is applied when setup() builds the global client. Previously module-configured apps had no way to pass the metrics config, so every series recorded through the global client shipped service.name='unknown_service'. Late assignment (e.g. a Django ready() hook running after an early setup()) still applies on the next setup() call, as long as the metrics API hasn't been used yet. — Thanks @DanielVisca!

Patch changes

  • 6766309 Harden the alpha posthog.metrics client based on review follow-ups.

    • Metric attributes are now deep-snapshotted at capture time, so mutating a nested list/dict value after count()/gauge()/histogram() can no longer rewrite an already-recorded series' attributes on the wire.
    • Failed metric flushes now retry with exponential backoff (first retry at the base interval, then doubling per consecutive failure, capped at 64x the flush interval — the shared JS logs ramp) instead of the fixed cadence, and the buffered window is dropped loudly after 8 consecutive failed flushes — previously documented as 3 but effectively 4.
    • Invalid metrics client config (non-dict config or resource_attributes, non-numeric flush_interval, non-integer max_series_per_flush, non-callable before_send) now degrades to defaults with a warning instead of raising from the first client.metrics.count() call, matching the client's no-throw contract. — Thanks @DanielVisca!

Fetched July 22, 2026