@@ -72,6 +72,7 @@ export default class MDBExtensionController implements vscode.Disposable {
72
72
_editDocumentCodeLensProvider : EditDocumentCodeLensProvider ;
73
73
_exportToLanguageCodeLensProvider : ExportToLanguageCodeLensProvider ;
74
74
_participantController : ParticipantController ;
75
+ _startupNotificationShown = false ;
75
76
76
77
constructor (
77
78
context : vscode . ExtensionContext ,
@@ -166,6 +167,7 @@ export default class MDBExtensionController implements vscode.Disposable {
166
167
this . registerCommands ( ) ;
167
168
this . showOverviewPageIfRecentlyInstalled ( ) ;
168
169
void this . showSurveyForEstablishedUsers ( ) ;
170
+ void this . showCopilotIntroductionForEstablishedUsers ( ) ;
169
171
}
170
172
171
173
registerCommands = ( ) : void => {
@@ -909,23 +911,82 @@ export default class MDBExtensionController implements vscode.Disposable {
909
911
}
910
912
}
911
913
914
+ async showCopilotIntroductionForEstablishedUsers ( ) : Promise < void > {
915
+ const copilotIntroductionShown =
916
+ this . _storageController . get (
917
+ StorageVariables . GLOBAL_COPILOT_INTRODUCTION_SHOWN
918
+ ) === true ;
919
+
920
+ // Show the toast when startup notifications have not been shown
921
+ // to the user yet and they have saved connections
922
+ // -> they haven't just started using this extension.
923
+ if (
924
+ this . _startupNotificationShown ||
925
+ copilotIntroductionShown ||
926
+ ! this . _connectionStorage . hasSavedConnections ( )
927
+ ) {
928
+ return ;
929
+ }
930
+
931
+ this . _startupNotificationShown = true ;
932
+
933
+ const action = 'Chat with @MongoDB' ;
934
+ const text =
935
+ 'Generate queries, interact with documentation, and explore your database schema using the MongoDB Copilot extension. Give it a try!' ;
936
+ const result = await vscode . window . showInformationMessage (
937
+ text ,
938
+ { } ,
939
+ {
940
+ title : action ,
941
+ }
942
+ ) ;
943
+
944
+ const copilot = vscode . extensions . getExtension ( 'github.copilot-chat' ) ;
945
+ if ( result ?. title === action ) {
946
+ await vscode . commands . executeCommand ( 'workbench.action.chat.newChat' ) ;
947
+ await vscode . commands . executeCommand (
948
+ 'workbench.action.chat.clearHistory'
949
+ ) ;
950
+ await vscode . commands . executeCommand ( 'workbench.action.chat.open' , {
951
+ query : '@MongoDB' ,
952
+ isPartialQuery : true ,
953
+ } ) ;
954
+ this . _telemetryService . trackCopilotIntroductionClicked ( {
955
+ is_copilot_active : ! ! copilot ?. isActive ,
956
+ } ) ;
957
+ } else {
958
+ this . _telemetryService . trackCopilotIntroductionDismissed ( {
959
+ is_copilot_active : ! ! copilot ?. isActive ,
960
+ } ) ;
961
+ }
962
+
963
+ // Whether action was taken or the prompt dismissed, we won't show this again.
964
+ void this . _storageController . update (
965
+ StorageVariables . GLOBAL_COPILOT_INTRODUCTION_SHOWN ,
966
+ true
967
+ ) ;
968
+ }
969
+
912
970
async showSurveyForEstablishedUsers ( ) : Promise < void > {
913
971
const surveyId = '9viN9wcbsC3zvHyg7' ;
914
972
915
973
const hasBeenShownSurveyAlready =
916
974
this . _storageController . get ( StorageVariables . GLOBAL_SURVEY_SHOWN ) ===
917
975
surveyId ;
918
976
919
- // Show the survey when it hasn't been show to the
920
- // user yet, and they have saved connections
977
+ // Show the toast when startup notifications have not been shown
978
+ // to the user yet and they have saved connections
921
979
// -> they haven't just started using this extension
922
980
if (
981
+ this . _startupNotificationShown ||
923
982
hasBeenShownSurveyAlready ||
924
983
! this . _connectionStorage . hasSavedConnections ( )
925
984
) {
926
985
return ;
927
986
}
928
987
988
+ this . _startupNotificationShown = true ;
989
+
929
990
const action = 'Share your thoughts' ;
930
991
const text = 'How can we make the MongoDB extension better for you?' ;
931
992
const link = 'https://forms.gle/9viN9wcbsC3zvHyg7' ;
0 commit comments