feat: add askgh_repo_index_requested PostHog event

Merged
MS
2mo ago
+13-0

Fixes SOU-2252

Related: https://linear.app/sourcebot/issue/SOU-2252/add-ability-to-track-who-caused-a-repo-to-be-indexed-in-public-saas

Summary

Add a new PostHog event (askgh_repo_index_requested) that fires when Ask GH requests that a repo be indexed through the POST /api/experimental/add-github-repo endpoint.

Problem

On the public app (app.sourcebot.dev), repos can be indexed via Ask GH but there was no PostHog event that attributes who requested the index. We couldn't answer "who requested indexing of torvalds/linux?"

Solution

Emit a PostHog event at the moment an Ask GH index is requested. Requester identity is handled automatically by PostHog's distinct_id (via captureEvent / tryGetPostHogDistinctId), so the event payload only needs repo context.

Event Name

askgh_repo_index_requested

Properties

PropertyTypeDescription
ownerstringGitHub repository owner
repostringGitHub repository name
repoNamestringCombined owner/repo string for easy filtering

Requester identity (signed-in vs anonymous) is inferred from PostHog's built-in distinct_id.

Querying in PostHog

Find all index requests for a specific repo:

askgh_repo_index_requested where repoName = 'torvalds/linux'

Find requests by a specific user:
Filter by distinct_id (user id for signed-in, install id for anonymous).

Where it fires

packages/web/src/features/workerApi/actions.ts - in the addGithubRepo server action, after the backend successfully processes the repo index request.

Testing

  • The event uses the existing captureEvent helper which automatically handles identity via tryGetPostHogDistinctId
  • Signed-in users are identified by their user id; anonymous requests collapse to the install id
Open in Web Open in Cursor 

Summary by cubic

Tracks successful Ask GH repo index requests in PostHog so we can attribute who requested indexing.

  • Emits askgh_repo_index_requested after the index request is processed, capturing owner, repo, and repoName.
  • Requester identity is handled by PostHog's built-in distinct ID from captureEvent, so no custom identity properties are tracked.

Summary by CodeRabbit

  • Analytics
    • Added tracking for GitHub repository indexing requests, including the repository owner, repository, and repository name.
    • Repository indexing requests continue to use the existing response validation and HTTP error handling.