in src/common/code_suggestions/code_suggestions_telemetry_manager.ts [169:204]
static updateSuggestionState(suggestionID: string, newState: CodeSuggestionTelemetryState): void {
log.debug(`Telemetry: Transist ${suggestionID} to ${newState}`);
const currentSuggestion = this.getInstance().#suggestions.get(suggestionID);
if (!currentSuggestion) {
log.debug(`Telemetry: The suggestion with ${suggestionID} can't be found`);
return;
}
const currentState = currentSuggestion.state;
const allowedTransitions = stateGraph.get(currentState);
if (!allowedTransitions) {
log.debug(
`Telemetry: The suggestion's ${suggestionID} state ${currentState} can't be found in state graph`,
);
return;
}
if (!allowedTransitions.includes(newState)) {
log.debug(
`Telemetry: Unexpected transition from ${currentState} into ${newState} for ${suggestionID}`,
);
if (newState !== CodeSuggestionTelemetryState.ACCEPTED) {
return;
}
log.debug(
`Telemetry: Conditionally allowing transition to accepted state for ${suggestionID}`,
);
}
this.getInstance().#suggestions.set(suggestionID, { ...currentSuggestion, state: newState });
this.sendTelemetry(suggestionID).catch(e => log.warn('could not track telemetry', e));
log.debug(`Telemetry: ${suggestionID} transisted from ${currentState} to ${newState}`);
}