@@ -17,6 +17,16 @@ const FEEDBACK_COUNTER = 'mirrord-feedback-counter';
17
17
*/
18
18
const FEEDBACK_COUNTER_REVIEW_AFTER = 100 ;
19
19
20
+ /**
21
+ * Key to access the feedback counter (see `tickDiscordCounter`) from the global user config.
22
+ */
23
+ const DISCORD_COUNTER = 'mirrord-discord-counter' ;
24
+
25
+ /**
26
+ * Amount of times we run mirrord before inviting the user to join the Discord server.
27
+ */
28
+ const DISCORD_COUNTER_PROMPT_AFTER = 10 ;
29
+
20
30
const TARGET_TYPE_DISPLAY : Record < string , string > = {
21
31
pod : 'Pod' ,
22
32
deployment : 'Deployment' ,
@@ -378,6 +388,7 @@ export class MirrordAPI {
378
388
async binaryExecute ( target : string | null , configFile : string | null , executable : string | null , configEnv : EnvVars ) : Promise < MirrordExecution > {
379
389
tickMirrordForTeamsCounter ( ) ;
380
390
tickFeedbackCounter ( ) ;
391
+ tickDiscordCounter ( ) ;
381
392
382
393
/// Create a promise that resolves when the mirrord process exits
383
394
return await vscode . window . withProgress ( {
@@ -543,3 +554,24 @@ function tickFeedbackCounter() {
543
554
. info ( ) ;
544
555
}
545
556
}
557
+
558
+ /**
559
+ * Updates the global Discord counter.
560
+ * After each `DISCORD_COUNTER_PROMPT_AFTER` mirrord runs, displays a message asking the user to join the discord.
561
+ */
562
+ function tickDiscordCounter ( ) {
563
+ const previousRuns = parseInt ( globalContext . globalState . get ( DISCORD_COUNTER ) ?? '0' ) ;
564
+ const currentRuns = previousRuns + 1 ;
565
+
566
+ globalContext . globalState . update ( DISCORD_COUNTER , currentRuns ) ;
567
+
568
+ if ( ( currentRuns % DISCORD_COUNTER_PROMPT_AFTER ) === 0 ) {
569
+ new NotificationBuilder ( )
570
+ . withMessage ( `Need any help with mirrord? Come chat with our team on Discord!` )
571
+ . withGenericAction ( "Join us!" , async ( ) => {
572
+ vscode . commands . executeCommand ( MirrordStatus . joinDiscordCommandId ) ;
573
+ } )
574
+ . withDisableAction ( 'promptReview' )
575
+ . info ( ) ;
576
+ }
577
+ }
0 commit comments