feat(backend): replace backend_repo_index_job_completed with backend_repo_first_indexed#900
Conversation
…repo_first_indexed Replaces the high-volume per-index PostHog event with one that fires only on the first successful index of a repo, enabling accurate tracking of unique repositories ever indexed without flooding the event stream. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
You have run out of free Bugbot PR reviews for this billing cycle. This will reset on March 14. To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial. |
This comment has been minimized.
This comment has been minimized.
WalkthroughThe pull request replaces the general Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/backend/src/repoIndexManager.ts (1)
578-583: Add an inline comment to document the intentional stale-value read.
jobData.repo.indexedAtis the value fetched at line 514 — beforedb.repo.updatesetsindexedAt: new Date()at line 547. This is the correct sentinel for "first ever successful index", but the implicit ordering dependency is easy to accidentally break during future refactoring (e.g., merging the twodb.repo.updatecalls).📝 Suggested comment
+ // jobData.repo.indexedAt holds the value *before* the db.repo.update + // above set it to `new Date()`. A null value here means this is the + // first time this repo has been successfully indexed. if (jobData.type === RepoIndexingJobType.INDEX && jobData.repo.indexedAt === null) { captureEvent('backend_repo_first_indexed', { repoId: job.data.repoId, type: jobData.repo.external_codeHostType, }); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/backend/src/repoIndexManager.ts` around lines 578 - 583, Add an inline comment at the check that reads jobData.repo.indexedAt === null (used with RepoIndexingJobType.INDEX/jobData) explaining this is an intentional stale-value read: jobData.repo.indexedAt was fetched earlier (when jobData was built) and is used as the sentinel for "first ever successful index" even though db.repo.update later sets indexedAt; mention the ordering dependency and warn that merging or reordering the db.repo.update calls (or changing where jobData is sourced) would break this logic so future maintainers should preserve the read-before-update pattern.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/backend/src/repoIndexManager.ts`:
- Around line 578-583: Add an inline comment at the check that reads
jobData.repo.indexedAt === null (used with RepoIndexingJobType.INDEX/jobData)
explaining this is an intentional stale-value read: jobData.repo.indexedAt was
fetched earlier (when jobData was built) and is used as the sentinel for "first
ever successful index" even though db.repo.update later sets indexedAt; mention
the ordering dependency and warn that merging or reordering the db.repo.update
calls (or changing where jobData is sourced) would break this logic so future
maintainers should preserve the read-before-update pattern.
Summary
backend_repo_index_job_completedPostHog event, which was firing on every re-index and generating enormous event volume (2M+ events/week, dominated by a single looping install)backend_repo_first_indexedwhich fires only the first time a repo is successfully indexed (indexedAt === nullbefore the update), enabling accurate tracking of unique repositories ever indexedTest plan
backend_repo_first_indexedfires when a new repo is indexed for the first timebackend_repo_index_job_completedno longer appears in PostHog🤖 Generated with Claude Code
Summary by CodeRabbit
Changed