Skip to content

chore(ci): capture PR age metrics to PostHog on merge#2516

Closed
pauldambra wants to merge 1 commit into
mainfrom
posthog-code/add-pr-metrics-capture
Closed

chore(ci): capture PR age metrics to PostHog on merge#2516
pauldambra wants to merge 1 commit into
mainfrom
posthog-code/add-pr-metrics-capture

Conversation

@pauldambra

Copy link
Copy Markdown
Member

Problem

We track PR throughput and age-to-merge for PostHog/posthog via a posthog-ci-pr-stats event (the posthog-pr-metrics action in project 2), but PostHog/code has no equivalent, so its PRs are invisible in that view.

Changes

Adds .github/workflows/pr-closed.yml with a single report-pr-age job that, when a PR is merged from a branch in this repo, fires a posthog-ci-pr-stats event to PostHog project 2 (via the org POSTHOG_API_TOKEN secret — already used by this repo's pr-approval-agent.yml).

It mirrors the job already running in PostHog/posthog. Each event carries prAgeInSeconds, isRevert, prTitle, prNumber, plus repository/actor/actor_type metadata added automatically by posthog-github-action@v1.2.0 — so events from all repos land in the same project and can be split by repository.

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_TOKEN is already referenced by this repo's existing pr-approval-agent.yml, confirming the secret is available here. First merged PR after this lands will produce a posthog-ci-pr-stats event with repository=PostHog/code.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog Code

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
@pauldambra

Copy link
Copy Markdown
Member Author

🤖 PostHog Code (automated agent) — posted on behalf of @pauldambra.

Closing in favour of an org-level approach: a single GitHub organization webhook feeding a PostHog incoming-webhook HogFunction that emits posthog-ci-pr-stats. That covers every repo (including future ones) with no per-repo workflow file, so this per-repo PR is no longer needed.

@pauldambra pauldambra closed this Jun 7, 2026
@pauldambra pauldambra deleted the posthog-code/add-pr-metrics-capture branch June 7, 2026 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant