refactor(core): Decouple source control telemetry from internal hooks (no-changelog) (#10095)

This commit is contained in:
Iván Ovejero
2024-07-18 15:00:24 +02:00
committed by GitHub
parent 028a8a2c75
commit f876f9ec8b
8 changed files with 184 additions and 110 deletions

View File

@@ -23,6 +23,24 @@ export class TelemetryEventRelay {
this.eventRelay.on('team-project-updated', (event) => this.teamProjectUpdated(event));
this.eventRelay.on('team-project-deleted', (event) => this.teamProjectDeleted(event));
this.eventRelay.on('team-project-created', (event) => this.teamProjectCreated(event));
this.eventRelay.on('source-control-settings-updated', (event) =>
this.sourceControlSettingsUpdated(event),
);
this.eventRelay.on('source-control-user-started-pull-ui', (event) =>
this.sourceControlUserStartedPullUi(event),
);
this.eventRelay.on('source-control-user-finished-pull-ui', (event) =>
this.sourceControlUserFinishedPullUi(event),
);
this.eventRelay.on('source-control-user-pulled-api', (event) =>
this.sourceControlUserPulledApi(event),
);
this.eventRelay.on('source-control-user-started-push-ui', (event) =>
this.sourceControlUserStartedPushUi(event),
);
this.eventRelay.on('source-control-user-finished-push-ui', (event) =>
this.sourceControlUserFinishedPushUi(event),
);
}
private teamProjectUpdated({ userId, role, members, projectId }: Event['team-project-updated']) {
@@ -57,4 +75,82 @@ export class TelemetryEventRelay {
role,
});
}
private sourceControlSettingsUpdated({
branchName,
readOnlyInstance,
repoType,
connected,
}: Event['source-control-settings-updated']) {
void this.telemetry.track('User updated source control settings', {
branch_name: branchName,
read_only_instance: readOnlyInstance,
repo_type: repoType,
connected,
});
}
private sourceControlUserStartedPullUi({
workflowUpdates,
workflowConflicts,
credConflicts,
}: Event['source-control-user-started-pull-ui']) {
void this.telemetry.track('User started pull via UI', {
workflow_updates: workflowUpdates,
workflow_conflicts: workflowConflicts,
cred_conflicts: credConflicts,
});
}
private sourceControlUserFinishedPullUi({
workflowUpdates,
}: Event['source-control-user-finished-pull-ui']) {
void this.telemetry.track('User finished pull via UI', {
workflow_updates: workflowUpdates,
});
}
private sourceControlUserPulledApi({
workflowUpdates,
forced,
}: Event['source-control-user-pulled-api']) {
console.log('source-control-user-pulled-api', {
workflow_updates: workflowUpdates,
forced,
});
void this.telemetry.track('User pulled via API', {
workflow_updates: workflowUpdates,
forced,
});
}
private sourceControlUserStartedPushUi({
workflowsEligible,
workflowsEligibleWithConflicts,
credsEligible,
credsEligibleWithConflicts,
variablesEligible,
}: Event['source-control-user-started-push-ui']) {
void this.telemetry.track('User started push via UI', {
workflows_eligible: workflowsEligible,
workflows_eligible_with_conflicts: workflowsEligibleWithConflicts,
creds_eligible: credsEligible,
creds_eligible_with_conflicts: credsEligibleWithConflicts,
variables_eligible: variablesEligible,
});
}
private sourceControlUserFinishedPushUi({
workflowsEligible,
workflowsPushed,
credsPushed,
variablesPushed,
}: Event['source-control-user-finished-push-ui']) {
void this.telemetry.track('User finished push via UI', {
workflows_eligible: workflowsEligible,
workflows_pushed: workflowsPushed,
creds_pushed: credsPushed,
variables_pushed: variablesPushed,
});
}
}