1
- import type { QuickInputButton , QuickPick } from 'vscode' ;
1
+ import type { QuickPick } from 'vscode' ;
2
2
import { commands , Uri } from 'vscode' ;
3
3
import { getAvatarUri } from '../../avatars' ;
4
4
import type {
@@ -28,7 +28,7 @@ import {
28
28
UnpinQuickInputButton ,
29
29
UnsnoozeQuickInputButton ,
30
30
} from '../../commands/quickCommand.buttons' ;
31
- import type { LaunchpadTelemetryContext , Source , Sources } from '../../constants' ;
31
+ import type { LaunchpadTelemetryContext , Source , Sources , TelemetryEvents } from '../../constants' ;
32
32
import { Commands , previewBadge } from '../../constants' ;
33
33
import type { Container } from '../../container' ;
34
34
import type { QuickPickItemOfT } from '../../quickpicks/items/common' ;
@@ -262,8 +262,8 @@ export class FocusCommand extends QuickCommand<State> {
262
262
assertsFocusStepState ( state ) ;
263
263
264
264
if ( this . confirm ( state . confirm ) ) {
265
- await this . container . focus . ensureFocusItemCodeSuggestions ( state . item ) ;
266
265
this . sendItemActionTelemetry ( 'select' , state . item , state . item . group , context ) ;
266
+ await this . container . focus . ensureFocusItemCodeSuggestions ( state . item ) ;
267
267
268
268
const result = yield * this . confirmStep ( state , context ) ;
269
269
if ( result === StepResultBreak ) continue ;
@@ -277,10 +277,9 @@ export class FocusCommand extends QuickCommand<State> {
277
277
278
278
if ( typeof state . action === 'string' ) {
279
279
switch ( state . action ) {
280
- case 'merge' : {
280
+ case 'merge' :
281
281
void this . container . focus . merge ( state . item ) ;
282
282
break ;
283
- }
284
283
case 'open' :
285
284
this . container . focus . open ( state . item ) ;
286
285
break ;
@@ -467,15 +466,21 @@ export class FocusCommand extends QuickCommand<State> {
467
466
onDidClickButton : async ( quickpick , button ) => {
468
467
switch ( button ) {
469
468
case LaunchpadSettingsQuickInputButton :
469
+ this . sendTitleActionTelemetry ( 'settings' , context ) ;
470
470
void commands . executeCommand ( 'workbench.action.openSettings' , 'gitlens.launchpad' ) ;
471
471
break ;
472
+
472
473
case FeedbackQuickInputButton :
474
+ this . sendTitleActionTelemetry ( 'feedback' , context ) ;
473
475
void openUrl ( 'https://github.com/gitkraken/vscode-gitlens/discussions/3286' ) ;
474
476
break ;
477
+
475
478
case OpenInEditorQuickInputButton :
479
+ this . sendTitleActionTelemetry ( 'open-in-editor' , context ) ;
476
480
void executeCommand ( Commands . ShowFocusPage ) ;
477
481
break ;
478
482
case RefreshQuickInputButton :
483
+ this . sendTitleActionTelemetry ( 'refresh' , context ) ;
479
484
await updateItems ( quickpick ) ;
480
485
break ;
481
486
}
@@ -484,30 +489,36 @@ export class FocusCommand extends QuickCommand<State> {
484
489
onDidClickItemButton : async ( quickpick , button , { group, item } ) => {
485
490
switch ( button ) {
486
491
case OpenOnGitHubQuickInputButton :
492
+ this . sendItemActionTelemetry ( 'soft-open' , item , group , context ) ;
487
493
this . container . focus . open ( item ) ;
488
494
break ;
495
+
489
496
case SnoozeQuickInputButton :
497
+ this . sendItemActionTelemetry ( 'snooze' , item , group , context ) ;
490
498
await this . container . focus . snooze ( item ) ;
491
499
break ;
492
500
493
501
case UnsnoozeQuickInputButton :
502
+ this . sendItemActionTelemetry ( 'unsnooze' , item , group , context ) ;
494
503
await this . container . focus . unsnooze ( item ) ;
495
504
break ;
496
505
497
506
case PinQuickInputButton :
507
+ this . sendItemActionTelemetry ( 'pin' , item , group , context ) ;
498
508
await this . container . focus . pin ( item ) ;
499
509
break ;
500
510
501
511
case UnpinQuickInputButton :
512
+ this . sendItemActionTelemetry ( 'unpin' , item , group , context ) ;
502
513
await this . container . focus . unpin ( item ) ;
503
514
break ;
504
515
505
516
case MergeQuickInputButton :
517
+ this . sendItemActionTelemetry ( 'merge' , item , group , context ) ;
506
518
await this . container . focus . merge ( item ) ;
507
519
break ;
508
520
}
509
521
510
- this . sendItemActionTelemetry ( button , item , group , context ) ;
511
522
await updateItems ( quickpick ) ;
512
523
} ,
513
524
} ) ;
@@ -668,16 +679,21 @@ export class FocusCommand extends QuickCommand<State> {
668
679
onDidClickItemButton : ( _quickpick , button , item ) => {
669
680
switch ( button ) {
670
681
case OpenOnGitHubQuickInputButton :
682
+ this . sendItemActionTelemetry ( 'soft-open' , state . item , state . item . group , context ) ;
671
683
this . container . focus . open ( state . item ) ;
672
684
break ;
673
685
case OpenOnWebQuickInputButton :
686
+ this . sendItemActionTelemetry (
687
+ 'open-suggestion-browser' ,
688
+ state . item ,
689
+ state . item . group ,
690
+ context ,
691
+ ) ;
674
692
if ( isFocusTargetActionQuickPickItem ( item ) ) {
675
693
this . container . focus . openCodeSuggestionInBrowser ( item . item . target ) ;
676
694
}
677
695
break ;
678
696
}
679
-
680
- this . sendItemActionTelemetry ( button , state . item , state . item . group , context ) ;
681
697
} ,
682
698
} ,
683
699
) ;
@@ -888,7 +904,15 @@ export class FocusCommand extends QuickCommand<State> {
888
904
}
889
905
890
906
private sendItemActionTelemetry (
891
- buttonOrAction : QuickInputButton | FocusAction | FocusTargetAction | 'select' ,
907
+ actionOrTargetAction :
908
+ | FocusAction
909
+ | FocusTargetAction
910
+ | 'pin'
911
+ | 'unpin'
912
+ | 'snooze'
913
+ | 'unsnooze'
914
+ | 'open-suggestion-browser'
915
+ | 'select' ,
892
916
item : FocusItem ,
893
917
group : FocusGroup ,
894
918
context : Context ,
@@ -905,34 +929,10 @@ export class FocusCommand extends QuickCommand<State> {
905
929
| 'open-suggestion-browser'
906
930
| 'select'
907
931
| undefined ;
908
- if ( typeof buttonOrAction !== 'string' && 'action' in buttonOrAction ) {
909
- action = buttonOrAction . action ;
910
- } else if ( typeof buttonOrAction === 'string' ) {
911
- action = buttonOrAction ;
932
+ if ( typeof actionOrTargetAction !== 'string' && 'action' in actionOrTargetAction ) {
933
+ action = actionOrTargetAction . action ;
912
934
} else {
913
- switch ( buttonOrAction ) {
914
- case MergeQuickInputButton :
915
- action = 'merge' ;
916
- break ;
917
- case OpenOnGitHubQuickInputButton :
918
- action = 'soft-open' ;
919
- break ;
920
- case PinQuickInputButton :
921
- action = 'pin' ;
922
- break ;
923
- case UnpinQuickInputButton :
924
- action = 'unpin' ;
925
- break ;
926
- case SnoozeQuickInputButton :
927
- action = 'snooze' ;
928
- break ;
929
- case UnsnoozeQuickInputButton :
930
- action = 'unsnooze' ;
931
- break ;
932
- case OpenOnWebQuickInputButton :
933
- action = 'open-suggestion-browser' ;
934
- break ;
935
- }
935
+ action = actionOrTargetAction ;
936
936
}
937
937
if ( action == null ) return ;
938
938
@@ -985,6 +985,16 @@ export class FocusCommand extends QuickCommand<State> {
985
985
this . source ,
986
986
) ;
987
987
}
988
+
989
+ private sendTitleActionTelemetry ( action : TelemetryEvents [ 'launchpad/title/action' ] [ 'action' ] , context : Context ) {
990
+ if ( ! this . container . telemetry . enabled ) return ;
991
+
992
+ this . container . telemetry . sendEvent (
993
+ 'launchpad/title/action' ,
994
+ { ...context . telemetryContext ! , action : action } ,
995
+ this . source ,
996
+ ) ;
997
+ }
988
998
}
989
999
990
1000
async function updateContextItems ( container : Container , context : Context , options ?: { force ?: boolean } ) {
0 commit comments