chore(ci): capture PR age metrics to PostHog on merge#2516
Closed
pauldambra wants to merge 1 commit into
Closed
Conversation
Adds a Closed PR workflow that fires a posthog-ci-pr-stats event when a PR is merged, mirroring the measurement already running in PostHog/posthog. Events go to project 2 via POSTHOG_API_TOKEN and carry repository/actor metadata (added by posthog-github-action v1.2.0) so PR velocity can be tracked per repo. Generated-By: PostHog Code Task-Id: 50da29c4-f95f-45b8-83a5-f0682414bedf
Member
Author
Closing in favour of an org-level approach: a single GitHub organization webhook feeding a PostHog incoming-webhook HogFunction that emits |
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.
Problem
We track PR throughput and age-to-merge for
PostHog/posthogvia aposthog-ci-pr-statsevent (theposthog-pr-metricsaction in project 2), butPostHog/codehas no equivalent, so its PRs are invisible in that view.Changes
Adds
.github/workflows/pr-closed.ymlwith a singlereport-pr-agejob that, when a PR is merged from a branch in this repo, fires aposthog-ci-pr-statsevent to PostHog project 2 (via the orgPOSTHOG_API_TOKENsecret — already used by this repo'spr-approval-agent.yml).It mirrors the job already running in
PostHog/posthog. Each event carriesprAgeInSeconds,isRevert,prTitle,prNumber, plusrepository/actor/actor_typemetadata added automatically byposthog-github-action@v1.2.0— so events from all repos land in the same project and can be split byrepository.CI-only; no runtime code changes. Forks are excluded (same-repo head check).
How did you test this?
Not yet runtime-tested — the capture only fires on a real merge event. I verified the workflow is valid YAML and that
POSTHOG_API_TOKENis already referenced by this repo's existingpr-approval-agent.yml, confirming the secret is available here. First merged PR after this lands will produce aposthog-ci-pr-statsevent withrepository=PostHog/code.Automatic notifications
Created with PostHog Code