Skip to content

Commit ef872de

Browse files
authored
Fixing survey logic (#18295)
1 parent a47b9fb commit ef872de

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/nps/userSurvey.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const SESSION_COUNT_KEY = "nps/sessionCount";
2525
const LAST_SESSION_DATE_KEY = "nps/lastSessionDate";
2626
const SKIP_VERSION_KEY = "nps/skipVersion";
2727
const IS_CANDIDATE_KEY = "nps/isCandidate";
28+
const NEVER_KEY = "nps/never";
2829

2930
export class UserSurvey {
3031
private static _instance: UserSurvey;
@@ -39,8 +40,19 @@ export class UserSurvey {
3940

4041
public async promptUserForNPSFeedback(): Promise<void> {
4142
const globalState = this._context.globalState;
43+
44+
// If the user has opted out of the survey, don't prompt for feedback
45+
const isNeverUser = globalState.get(NEVER_KEY, false);
46+
if (isNeverUser) {
47+
return;
48+
}
49+
50+
// If the user has already been prompted for feedback in this version, don't prompt again
51+
const extensionVersion =
52+
vscode.extensions.getExtension(constants.extensionId).packageJSON
53+
.version || "unknown";
4254
const skipVersion = globalState.get(SKIP_VERSION_KEY, "");
43-
if (skipVersion) {
55+
if (skipVersion === extensionVersion) {
4456
return;
4557
}
4658

@@ -69,9 +81,6 @@ export class UserSurvey {
6981

7082
await globalState.update(IS_CANDIDATE_KEY, isCandidate);
7183

72-
const extensionVersion =
73-
vscode.extensions.getExtension(constants.extensionId).packageJSON
74-
.version || "unknown";
7584
if (!isCandidate) {
7685
await globalState.update(SKIP_VERSION_KEY, extensionVersion);
7786
return;
@@ -118,8 +127,7 @@ export class UserSurvey {
118127
title: locConstants.UserSurvey.dontShowAgain,
119128
isSecondary: true,
120129
run: async () => {
121-
await globalState.update(IS_CANDIDATE_KEY, false);
122-
await globalState.update(SKIP_VERSION_KEY, extensionVersion);
130+
await globalState.update(NEVER_KEY, true);
123131
},
124132
};
125133

0 commit comments

Comments
 (0)