From b4461aa60d25224d224aa7d83508d52c378b83cb Mon Sep 17 00:00:00 2001 From: Svilen Stefanov Date: Tue, 22 Sep 2026 01:22:20 +0200 Subject: [PATCH] feat(action): attribute PR-comment clicks to the Action The review comment links to the webview, and that traffic arrives unattributable. In September 144 people landed on /owner/repo/pull/N pages but only 27 carried a github.com referrer: referrers get stripped, and links get pasted into Slack. So "a teammate clicked the PR comment" and "someone shared the URL" are indistinguishable, and the Action's contribution to webview usage cannot be measured at all. UTM rather than a bare ?src=, because the webview's PostHog client computes utm_* per event from the URL independently of its autocapture settings, and person_profiles:'always' means anonymous visitors get $initial_utm_* stamped on them. That is exactly the population in question. A custom param would sit only inside $current_url and would need web-app code to promote it; this needs no change on the other side and starts a baseline the day it ships. utm_campaign=gh_action is deliberate: source+medium alone cannot separate the Action from a future bot or GitHub App comment, and a campaign value puts the Action's always-on baseline in the same breakdown as a marketing push. Verified against 6 input shapes (dotted repo names, github.io repos, 5-digit PRs, unresolved merge base, missing artifact URL) and rendered through GitHub's own /markdown API to confirm the href survives encoding intact. Owner and repo names cannot contain ? or #, so the query cannot be swallowed into the path. Nothing parses this URL; the sticky-comment action matches its own HTML marker, not the body. Known conflation: action.yml pipes the same body into $GITHUB_STEP_SUMMARY, so clicks from the Actions run page will also attribute as pr_comment. Co-Authored-By: Claude Opus 5 (1M context) --- scripts/action/build-review-comment.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/action/build-review-comment.sh b/scripts/action/build-review-comment.sh index d28d0e2..14d7ba2 100755 --- a/scripts/action/build-review-comment.sh +++ b/scripts/action/build-review-comment.sh @@ -8,7 +8,13 @@ fi RUN_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" # Stable PR route: the webview resolves the repo/PR's latest artifact itself, # so the link stays valid across runs instead of pinning one run id. -WEBVIEW_URL="https://app.codeboarding.org/${GITHUB_REPOSITORY}/pull/${PR_NUMBER}" +# Standard utm_* rather than a bespoke ?src=: PostHog lifts utm_* into person and +# session properties by itself, so this is attributable the day the action ships, +# with no matching change in the web app. Without it the only evidence a visit +# came from here is a github.com referrer, which most clients strip and a link +# pasted into chat never had. Constant across runs on purpose: a run id here +# would scatter one pull request's clicks across a new value per re-run. +WEBVIEW_URL="https://app.codeboarding.org/${GITHUB_REPOSITORY}/pull/${PR_NUMBER}?utm_source=github&utm_medium=pr_comment&utm_campaign=gh_action" BODY="${RUNNER_TEMP}/review-comment.md" printf '### CodeBoarding review\n\n**Status:** %s changed %s\n' "$N_CHANGED" "$COMPONENT_NOUN" > "$BODY" printf '\nSee the full change in [CodeBoarding](%s).\n' "$WEBVIEW_URL" >> "$BODY"