8000 Add survey and banner by DonJayamanne · Pull Request #7 · microsoft/vscode-python · GitHub
[go: up one dir, main page]

Skip to content

Add survey and banner #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Nov 6, 2017
Prev Previous commit
Next Next commit
track whether user responded to feedback
  • Loading branch information
DonJayamanne committed Nov 6, 2017
commit e2cb83203c2bbd56a92146f2f4082d53a800a988
29 changes: 18 additions & 11 deletions src/client/feedback/feedbackService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,14 @@ const FEEDBACK_URL = 'https://aka.ms/egv4z1';
export class FeedbackService implements Disposable {
private counters?: FeedbackCounters;
private showFeedback: PersistentState<boolean>;
private userResponded: PersistentState<boolean>;
private promptDisplayed: boolean;
private disposables: Disposable[] = [];
constructor(persistentStateFactory: IPersistentStateFactor) {
this.showFeedback = persistentStateFactory.createGlobalPersistentState('SHOW_FEEDBACK', true);
// tslint:disable-next-line:no-void-expression
let commandDisable = commands.registerCommand('python.updateFeedbackCounter', (telemetryEventName: string) => this.updateFeedbackCounter(telemetryEventName));
this.disposables.push(commandDisable);
// tslint:disable-next-line:no-void-expression
commandDisable = workspace.onDidChangeTextDocument(changeEvent => this.handleChangesToTextDocument(changeEvent.document), this, this.disposables);
this.disposables.push(commandDisable);

this.userResponded = persistentStateFactory.createGlobalPersistentState('RESPONDED_TO_FEEDBACK', false);
if (this.showFeedback.value) {
this.counters = new FeedbackCounters();
this.counters.on('thresholdReached', () => {
this.thresholdHandler();
});
this.initialize();
}
}
public dispose() {
Expand All @@ -44,6 +36,19 @@ export class FeedbackService implements Disposable {
});
this.disposables = [];
}
private initialize() {
// tslint:disable-next-line:no-void-expression
let commandDisable = commands.registerCommand('python.updateFeedbackCounter', (telemetryEventName: string) => this.updateFeedbackCounter(telemetryEventName));
this.disposables.push(commandDisable);
// tslint:disable-next-line:no-void-expression
commandDisable = workspace.onDidChangeTextDocument(changeEvent => this.handleChangesToTextDocument(changeEvent.document), this, this.disposables);
this.disposables.push(commandDisable);

this.counters = new FeedbackCounters();
this.counters.on('thresholdReached', () => {
this.thresholdHandler();
});
}
private handleChangesToTextDocument(textDocument: TextDocument) {
if (textDocument.languageId !== PythonLanguage.language) {
return;
Expand Down Expand Up @@ -97,6 +102,7 @@ export class FeedbackService implements Disposable {
@captureTelemetry(FEEDBACK, { action: 'accepted' })
private displaySurvey() {
this.showFeedback.value = false;
this.userResponded.value = true;

let openCommand: string | undefined;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this code common between here and the banner? Should it be factored out?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but the banner would go out (removed), hence didn't want to share any code.

if (os.platform() === 'win32') {
Expand All @@ -114,5 +120,6 @@ export class FeedbackService implements Disposable {
@captureTelemetry(FEEDBACK, { action: 'doNotShowAgain' })
private doNotShowFeedbackAgain() {
this.showFeedback.value = false;
this.userResponded.value = false;
}
}
0