Skip to content

Commit e72be11

Browse files
committed
Adds required type to 'startWork/issue/action' telemetry event
(#3774, #3775)
1 parent d40c73a commit e72be11

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/constants.telemetry.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ export type TelemetryEvents = {
328328
'startWork/issue/action': StartWorkEventData & {
329329
action: 'soft-open';
330330
connected: boolean;
331+
type: StartWorkType;
331332
} & Partial<Record<`item.${string}`, string | number | boolean>>;
332333
/** Sent when the user chooses an issue to start work in the second step */
333334
'startWork/issue/chosen': StartWorkEventData & {

src/plus/startWork/startWork.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ interface State {
5656
type?: StartWorkType;
5757
inWorktree?: boolean;
5858
}
59+
interface StateWithType extends State {
60+
type: StartWorkType;
61+
}
5962

6063
export type StartWorkType = 'branch' | 'branch-worktree' | 'issue' | 'issue-worktree';
6164
type StartWorkTypeItem = { type: StartWorkType; inWorktree?: boolean };
@@ -166,6 +169,7 @@ export class StartWorkCommand extends QuickCommand<State> {
166169
}
167170
}
168171

172+
assertsTypeStepState(state);
169173
const result = yield* this.pickIssueStep(state, context, opened);
170174
opened = true;
171175
if (result === StepResultBreak) continue;
@@ -399,7 +403,7 @@ export class StartWorkCommand extends QuickCommand<State> {
399403
}
400404

401405
private *pickIssueStep(
402-
state: StepState<State>,
406+
state: StepState<StateWithType>,
403407
context: Context,
404408
opened: boolean,
405409
): StepResultGenerator<StartWorkItem | StartWorkTypeItem> {
@@ -523,7 +527,7 @@ export class StartWorkCommand extends QuickCommand<State> {
523527
private sendItemActionTelemetry(
524528
action: 'soft-open',
525529
item: StartWorkItem,
526-
state: StepState<State>,
530+
state: StepState<StateWithType>,
527531
context: Context,
528532
) {
529533
this.container.telemetry.sendEvent('startWork/issue/action', {
@@ -617,3 +621,12 @@ function getOpenOnWebQuickInputButton(integrationId: string): QuickInputButton |
617621
return undefined;
618622
}
619623
}
624+
625+
function assertsTypeStepState(state: StepState<State>): asserts state is StepState<StateWithType> {
626+
if (state.type != null) {
627+
return;
628+
}
629+
630+
debugger;
631+
throw new Error('Missing `item` field in state of StartWork');
632+
}

0 commit comments

Comments
 (0)