Use async version of machineId + refactoring

Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
Lauri Nevala committed 2021-02-03 22:07:46 +02:00
1 parent 795b490d70
commit 24f6aabc49
2 files changed
+3 -3

No files matched your search

+1 -1
View File
@@ -12,7 +12,7 @@ export class SurveyPreferenceInput extends React.Component<{survey: SurveyPrefer
<Component.Checkbox <Component.Checkbox
label="Allow in-app surveys" label="Allow in-app surveys"
value={survey.enabled} value={survey.enabled}
onChange={v => { survey.enabled = v; }} onChange={v => survey.enabled = v }
/> />
); );
} }
+2 -2
View File
@@ -1,5 +1,5 @@
import { Util } from "@k8slens/extensions"; import { Util } from "@k8slens/extensions";
import { machineIdSync } from "node-machine-id"; import { machineId } from "node-machine-id";
import Refiner from "refiner-js"; import Refiner from "refiner-js";
import got from "got"; import got from "got";
import { surveyPreferencesStore } from "./survey-preferences-store"; import { surveyPreferencesStore } from "./survey-preferences-store";
@@ -32,7 +32,7 @@ export class Survey extends Util.Singleton {
async fetchSurveyId() { async fetchSurveyId() {
try { try {
const surveyApi = process.env.SURVEY_API_URL || "https://survey.k8slens.dev"; const surveyApi = process.env.SURVEY_API_URL || "https://survey.k8slens.dev";
const anonymousId = machineIdSync(); const anonymousId = await machineId();
const { body } = await got(`${surveyApi}/api/survey-id?anonymousId=${anonymousId}`, { responseType: "json"}); const { body } = await got(`${surveyApi}/api/survey-id?anonymousId=${anonymousId}`, { responseType: "json"});
return (body as SurveyIdResponse).surveyId; return (body as SurveyIdResponse).surveyId;