Conversation
Posthog monitoring (next commit) reports the same normalized paths as the prometheus metrics.
Enabled by POSTHOG_API_KEY (and optional POSTHOG_HOST). Captures an api_request event per request with normalized path, method, status and duration. Uses anonymous events (no person profiles) and normalized paths only, keeping queried postcodes out of analytics and event cardinality low. Client errors are swallowed so telemetry never surfaces in API responses; SIGTERM flushes buffered events.
Verifies no client is created without an API key, event shape and path normalisation with one, and shutdown flushing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
POSTHOG_API_KEY(and optionalPOSTHOG_HOST); disabled entirely when unset, mirroring the optional Prometheus setupapi_requestevent per request with normalized path (e.g./postcodes/:postcode), method, status and duration - reuses the PrometheusnormalizePathso raw URLs (queried postcodes) stay out of analytics and event cardinality stays lowTest plan
pnpm test test/posthog.integration.ts- covers no-op without key, client construction, event shape, path normalisation and shutdown flushpnpm buildPOSTHOG_API_KEY+POSTHOG_HOST, start the server, hit/postcodes/fooand confirm anapi_requestevent arrives in PostHogNeed help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.