Skip to content

Commit f59e5e6

Browse files
feat(backend): replace backend_repo_index_job_completed with backend_repo_first_indexed (#900)
* feat(backend): replace backend_repo_index_job_completed with backend_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> * chore: update CHANGELOG for #900 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent c510731 commit f59e5e6

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
- Replaced `backend_repo_index_job_completed` PostHog event with `backend_repo_first_indexed`, which fires only on the first successful index of a repo. [#900](https://github.com/sourcebot-dev/sourcebot/pull/900)
12+
1013
## [4.11.0] - 2026-02-18
1114

1215
### Added

packages/backend/src/posthogEvents.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ export type PosthogEventMap = {
1919
jobType: 'INDEX' | 'CLEANUP',
2020
type: string,
2121
},
22-
backend_repo_index_job_completed: {
22+
backend_repo_first_indexed: {
2323
repoId: number,
24-
jobType: 'INDEX' | 'CLEANUP',
2524
type: string,
2625
},
2726
}

packages/backend/src/repoIndexManager.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -575,11 +575,12 @@ export class RepoIndexManager {
575575
this.promClient.activeRepoIndexJobs.dec({ repo: job.data.repoName, type: jobTypeLabel });
576576
this.promClient.repoIndexJobSuccessTotal.inc({ repo: job.data.repoName, type: jobTypeLabel });
577577

578-
captureEvent('backend_repo_index_job_completed', {
579-
repoId: job.data.repoId,
580-
jobType: job.data.type,
581-
type: jobData.repo.external_codeHostType,
582-
});
578+
if (jobData.type === RepoIndexingJobType.INDEX && jobData.repo.indexedAt === null) {
579+
captureEvent('backend_repo_first_indexed', {
580+
repoId: job.data.repoId,
581+
type: jobData.repo.external_codeHostType,
582+
});
583+
}
583584
} catch (error) {
584585
Sentry.captureException(error);
585586
logger.error(`Exception thrown while executing lifecycle function \`onJobCompleted\`.`, error);

0 commit comments

Comments
 (0)