Skip to content

Commit 279de65

Browse files
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>
1 parent c510731 commit 279de65

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

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)