Skip to content

Commit 52c1221

Browse files
survey implementation improvements
1 parent 8c07ca1 commit 52c1221

File tree

3 files changed

+29
-43
lines changed

3 files changed

+29
-43
lines changed

Diff for: arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts

-3
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ import { SaveSketch } from './contributions/save-sketch';
122122
import { VerifySketch } from './contributions/verify-sketch';
123123
import { UploadSketch } from './contributions/upload-sketch';
124124
import { SurveyNotification } from './contributions/survey-notification';
125-
import { SurveyRetriever } from './survey/survey-retriever';
126125
import { CommonFrontendContribution } from './theia/core/common-frontend-contribution';
127126
import { EditContributions } from './contributions/edit-contributions';
128127
import { OpenSketchExternal } from './contributions/open-sketch-external';
@@ -478,8 +477,6 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
478477
bind(FrontendApplicationContribution).toService(EditorMode);
479478

480479
// Survey notification
481-
bind(SurveyRetriever).toSelf().inSingletonScope();
482-
483480
bind(SurveyNotification).toSelf().inSingletonScope();
484481
bind(FrontendApplicationContribution).toService(SurveyNotification);
485482

Diff for: arduino-ide-extension/src/browser/contributions/survey-notification.ts

+29-20
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import { MessageService } from '@theia/core';
22
import { FrontendApplicationContribution } from '@theia/core/lib/browser';
33
import { inject, injectable } from '@theia/core/shared/inversify';
4-
import { shell } from '@theia/electron/shared/electron';
54
import { LocalStorageService } from '@theia/core/lib/browser';
6-
import { SurveyRetriever } from '../survey/survey-retriever';
75
import { nls } from '@theia/core/lib/common';
6+
import { WindowService } from '@theia/core/lib/browser/window/window-service';
7+
8+
export type Survey = {
9+
url: URL;
10+
id: string;
11+
};
812

913
const SURVEY_MESSAGE = nls.localize(
1014
'arduino/survey/surveyMessage',
@@ -19,6 +23,9 @@ const GO_TO_SURVEY = nls.localize(
1923
'ANSWER SURVEY'
2024
);
2125

26+
const SURVEY_BASE_URL = 'https://surveys.hotjar.com/';
27+
const surveyId = '17887b40-e1f0-4bd6-b9f0-a37f229ccd8b';
28+
2229
@injectable()
2330
export class SurveyNotification implements FrontendApplicationContribution {
2431
@inject(MessageService)
@@ -27,30 +34,32 @@ export class SurveyNotification implements FrontendApplicationContribution {
2734
@inject(LocalStorageService)
2835
protected readonly localStorageService: LocalStorageService;
2936

30-
@inject(SurveyRetriever)
31-
protected readonly surveyRetriever: SurveyRetriever;
37+
@inject(WindowService)
38+
protected readonly windowService: WindowService;
3239

3340
async onStart(): Promise<void> {
34-
const survey = await this.surveyRetriever.getSurvey();
35-
const surveyAnswered = await this.localStorageService.getData(
36-
this.surveyKey(survey.id),
37-
'notAnswered'
38-
);
39-
40-
if (surveyAnswered !== 'notAnswered') {
41-
return;
42-
}
43-
44-
this.messageService
45-
.info(SURVEY_MESSAGE, DO_NOT_SHOW_AGAIN, GO_TO_SURVEY)
46-
.then(async (answer) => {
41+
this.localStorageService
42+
.getData(this.surveyKey(surveyId), undefined)
43+
.then((surveyAnswered) => {
44+
if (surveyAnswered !== undefined) {
45+
return;
46+
}
47+
return this.messageService.info(
48+
SURVEY_MESSAGE,
49+
DO_NOT_SHOW_AGAIN,
50+
GO_TO_SURVEY
51+
);
52+
})
53+
.then((answer) => {
4754
switch (answer) {
4855
case GO_TO_SURVEY:
49-
shell.openExternal(survey.url.href);
50-
this.localStorageService.setData(this.surveyKey(survey.id), true);
56+
this.windowService.openNewWindow(SURVEY_BASE_URL + surveyId, {
57+
external: true,
58+
});
59+
this.localStorageService.setData(this.surveyKey(surveyId), true);
5160
break;
5261
case DO_NOT_SHOW_AGAIN:
53-
this.localStorageService.setData(this.surveyKey(survey.id), false);
62+
this.localStorageService.setData(this.surveyKey(surveyId), false);
5463
break;
5564
}
5665
});

Diff for: arduino-ide-extension/src/browser/survey/survey-retriever.ts

-20
This file was deleted.

0 commit comments

Comments
 (0)