Support telemetry page (#2756)

* support telemetry page events

* add log level to FE settings

* add debug logging

* fix types

* state fix

* move call
This commit is contained in:
Mutasem Aldmour
2022-02-04 00:24:01 +02:00
committed by GitHub
parent 0bf554394a
commit 7bdb7e2a25
9 changed files with 51 additions and 23 deletions

View File

@@ -1,5 +1,6 @@
import { ActionContext, Module } from 'vuex';
import {
ILogLevel,
IN8nPrompts,
IN8nUISettings,
IN8nValueSurveyData,
@@ -11,6 +12,7 @@ import { getPromptsData, getSettings, submitValueSurvey, submitPersonalizationSu
import Vue from 'vue';
import { getPersonalizedNodeTypes } from './helper';
import { CONTACT_PROMPT_MODAL_KEY, PERSONALIZATION_MODAL_KEY, VALUE_SURVEY_MODAL_KEY } from '@/constants';
import { ITelemetrySettings } from 'n8n-workflow';
const module: Module<ISettingsState, IRootState> = {
namespaced: true,
@@ -30,6 +32,15 @@ const module: Module<ISettingsState, IRootState> = {
getPromptsData(state: ISettingsState) {
return state.promptsData;
},
telemetry: (state): ITelemetrySettings => {
return state.settings.telemetry;
},
logLevel: (state): ILogLevel => {
return state.settings.logLevel;
},
isTelemetryEnabled: (state) => {
return state.settings.telemetry && state.settings.telemetry.enabled;
},
},
mutations: {
setSettings(state: ISettingsState, settings: IN8nUISettings) {
@@ -66,7 +77,6 @@ const module: Module<ISettingsState, IRootState> = {
context.commit('setN8nMetadata', settings.n8nMetadata || {}, {root: true});
context.commit('setDefaultLocale', settings.defaultLocale, {root: true});
context.commit('versions/setVersionNotificationSettings', settings.versionNotifications, {root: true});
context.commit('setTelemetry', settings.telemetry, {root: true});
const showPersonalizationsModal = settings.personalizationSurvey && settings.personalizationSurvey.shouldShow && !settings.personalizationSurvey.answers;
@@ -81,7 +91,7 @@ const module: Module<ISettingsState, IRootState> = {
context.commit('setPersonalizationAnswers', results);
},
async fetchPromptsData(context: ActionContext<ISettingsState, IRootState>) {
if (!context.rootGetters.isTelemetryEnabled) {
if (!context.getters.isTelemetryEnabled) {
return;
}