@@ -12,8 +12,8 @@ import { lastUserAction } from './goLanguageServer';
12
12
import { daysBetween , flushSurveyConfig , getStateConfig , minutesBetween , timeMinute } from './goSurvey' ;
13
13
14
14
// Start and end dates of the survey.
15
- export const startDate = new Date ( '2021-09-01 ' ) ; // TODO(rstambler): Set an actual start date.
16
- export const endDate = new Date ( '2022-01-01 ' ) ; // TODO(rstambler): Set an actual end date.
15
+ export const startDate = new Date ( '2021-10-27 ' ) ;
16
+ export const endDate = new Date ( '2021-11-16 ' ) ;
17
17
18
18
// DeveloperSurveyConfig is the set of global properties used to determine if
19
19
// we should prompt a user to take the gopls survey.
@@ -81,11 +81,14 @@ export function shouldPromptForSurvey(now: Date, cfg: DeveloperSurveyConfig): De
81
81
if ( cfg . datePromptComputed && ! inDateRange ( startDate , endDate , cfg . datePromptComputed ) ) {
82
82
cfg = { } ;
83
83
}
84
- // If the prompt value is not set, assume we haven't prompted the user
85
- // and should do so.
84
+ // If the prompt value is undefined, then this is the first activation
85
+ // for this survey period, so decide if we should prompt the user. This
86
+ // is done by generating a random number in the range [0, 1) and checking
87
+ // if it is < probability.
86
88
if ( cfg . prompt === undefined ) {
87
- cfg . prompt = true ;
89
+ const probability = 0.2 ;
88
90
cfg . datePromptComputed = now ;
91
+ cfg . prompt = Math . random ( ) < probability ;
89
92
}
90
93
flushSurveyConfig ( developerSurveyConfig , cfg ) ;
91
94
if ( ! cfg . prompt ) {
@@ -103,29 +106,26 @@ export function shouldPromptForSurvey(now: Date, cfg: DeveloperSurveyConfig): De
103
106
// Check if the user has been prompted for the survey in the last 5 days.
104
107
// Don't prompt them if they have been.
105
108
if ( cfg . lastDatePrompted ) {
106
- // If the survey will end in 5 days, prompt the next day.
109
+ const daysSinceLastPrompt = daysBetween ( now , cfg . lastDatePrompted ) ;
110
+ // Don't prompt twice on the same day, even if it's the last day of the
111
+ // survey.
112
+ if ( daysSinceLastPrompt < 1 ) {
113
+ return ;
114
+ }
115
+ // If the survey will end in 5 days, prompt on the next day.
107
116
// Otherwise, wait for 5 days.
108
- if ( daysBetween ( now , endDate ) > 5 && daysBetween ( now , cfg . lastDatePrompted ) < 5 ) {
117
+ if ( daysBetween ( now , endDate ) > 5 ) {
109
118
return ;
110
119
}
111
- return cfg ;
112
120
}
113
-
114
- // This is the first activation this month (or ever), so decide if we
115
- // should prompt the user. This is done by generating a random number in
116
- // the range [0, 1) and checking if it is < probability.
117
- const probability = 0.2 ;
118
- cfg . datePromptComputed = now ;
119
- cfg . prompt = Math . random ( ) < probability ;
120
- flushSurveyConfig ( developerSurveyConfig , cfg ) ;
121
121
return cfg ;
122
122
}
123
123
124
124
export async function promptForDeveloperSurvey ( cfg : DeveloperSurveyConfig , now : Date ) : Promise < DeveloperSurveyConfig > {
125
125
let selected = await vscode . window . showInformationMessage (
126
126
// TODO(rstambler): Figure out how to phrase this.
127
- `Looks like you are coding in Go! Help ensure Go is meeting your needs
128
- by participating in this 10-minute survey by ${ endDate . toDateString ( ) } ?` ,
127
+ `Looks like you are coding in Go! Would you like to help ensure that Go is meeting your needs
128
+ by participating in this 10-minute survey before ${ endDate . toDateString ( ) } ?` ,
129
129
'Yes' ,
130
130
'Remind me later' ,
131
131
'Never'
@@ -140,7 +140,7 @@ by participating in this 10-minute survey by ${endDate.toDateString()}?`,
140
140
{
141
141
cfg . lastDateAccepted = now ;
142
142
cfg . prompt = true ;
143
- const surveyURL = 'https://google.com?utm_source=vscode-go' ; // set source to vscode-go
143
+ const surveyURL = 'https://google.qualtrics. com/jfe/form/SV_0BwHwKSaeE9Cx2S?s=p' ;
144
144
await vscode . env . openExternal ( vscode . Uri . parse ( surveyURL ) ) ;
145
145
}
146
146
break ;
@@ -154,7 +154,7 @@ by participating in this 10-minute survey by ${endDate.toDateString()}?`,
154
154
155
155
selected = await vscode . window . showInformationMessage (
156
156
`No problem! We won't ask again.
157
- To opt-out of all survey prompts, please set 'go.survey.prompt' to false.`,
157
+ If you'd like to opt-out of all survey prompts, you can set 'go.survey.prompt' to false.`,
158
158
'Open Settings'
159
159
) ;
160
160
switch ( selected ) {
0 commit comments