diff --git a/electron/main.ts b/electron/main.ts
index 3ae344a43d..1dc1b00de8 100644
--- a/electron/main.ts
+++ b/electron/main.ts
@@ -90,11 +90,9 @@ const templatesDir = path.join(userDataDir, 'monokleTemplates');
const templatePacksDir = path.join(userDataDir, 'monokleTemplatePacks');
const APP_DEPENDENCIES = ['kubectl', 'helm', 'kustomize'];
-
let {disableErrorReports,disableTracking} = initNucleus(isDev, app);
unhandled({
logger: (error) => {
- console.error(error);
if (!disableErrorReports) {
Nucleus.trackError((error && error.name) || 'Unnamed error', error);
}
diff --git a/electron/utils.ts b/electron/utils.ts
index c8ac560125..92ba1eb17f 100644
--- a/electron/utils.ts
+++ b/electron/utils.ts
@@ -154,7 +154,7 @@ export function askActionConfirmation({
}
export const initNucleus = (isDev: boolean, app: any) => {
- Nucleus.init('6218cf3ef5e5d2023724d89b', {
+ Nucleus.init(PROCESS_ENV.NUCLEUS_SH_APP_ID || '6218cf3ef5e5d2023724d89b', {
disableInDev: false,
disableTracking: Boolean(electronStore.get('appConfig.disableEventTracking')),
disableErrorReports: true,
diff --git a/src/components/organisms/CreateProjectModal/CreateProjectModal.tsx b/src/components/organisms/CreateProjectModal/CreateProjectModal.tsx
index c6abfc8cd5..2a74cdf697 100644
--- a/src/components/organisms/CreateProjectModal/CreateProjectModal.tsx
+++ b/src/components/organisms/CreateProjectModal/CreateProjectModal.tsx
@@ -18,7 +18,7 @@ import FileExplorer from '@components/atoms/FileExplorer';
import {useFileExplorer} from '@hooks/useFileExplorer';
import {useFocus} from '@utils/hooks';
-import {trackEvent} from '@utils/telemetry';
+import {CREATE_EMPTY_PROJECT, trackEvent} from '@utils/telemetry';
import Colors from '@styles/Colors';
@@ -105,7 +105,7 @@ const CreateProjectModal: React.FC = () => {
setFormStep(FormSteps.STEP_TWO);
}
if (!uiState.fromTemplate && values.rootFolder && values.name) {
- trackEvent('CREATE_EMPTY_PROJECT');
+ trackEvent(CREATE_EMPTY_PROJECT);
dispatch(setCreateProject({...values}));
closeModal();
}
@@ -267,20 +267,19 @@ const CreateProjectModal: React.FC = () => {
)}
- {Object.values(templateMap).sort((a,b) =>{
- if(favoriteTemplates.includes(a.id))
- return -1;
- if(favoriteTemplates.includes(b.id))
- return 1;
- return 0;
- }).map(template => (
- onClickOpenTemplate(template)}
- />
- ))}
-
+ {Object.values(templateMap)
+ .sort((a, b) => {
+ if (favoriteTemplates.includes(a.id)) return -1;
+ if (favoriteTemplates.includes(b.id)) return 1;
+ return 0;
+ })
+ .map(template => (
+ onClickOpenTemplate(template)}
+ />
+ ))}
)}
diff --git a/src/components/organisms/PaneManager/PaneManagerLeftMenu.tsx b/src/components/organisms/PaneManager/PaneManagerLeftMenu.tsx
index ba29b7c846..1ba6001c6d 100644
--- a/src/components/organisms/PaneManager/PaneManagerLeftMenu.tsx
+++ b/src/components/organisms/PaneManager/PaneManagerLeftMenu.tsx
@@ -12,7 +12,7 @@ import {useAppDispatch, useAppSelector} from '@redux/hooks';
import {setLeftMenuSelection, toggleLeftMenu, toggleStartProjectPane} from '@redux/reducers/ui';
import {activeProjectSelector, kustomizationsSelector} from '@redux/selectors';
-import {trackEvent} from '@utils/telemetry';
+import {SELECT_LEFT_TOOL_PANEL, trackEvent} from '@utils/telemetry';
import Colors from '@styles/Colors';
@@ -52,7 +52,7 @@ const PaneManagerLeftMenu: React.FC = () => {
if (isStartProjectPaneVisible) {
dispatch(toggleStartProjectPane());
}
- trackEvent('SELECT_LEFT_TOOL_PANEL', {panelID: selectedMenu});
+ trackEvent(SELECT_LEFT_TOOL_PANEL, {panelID: selectedMenu});
dispatch(setLeftMenuSelection(selectedMenu));
if (!leftActive) {
diff --git a/src/components/organisms/TemplateModal/TemplateModal.tsx b/src/components/organisms/TemplateModal/TemplateModal.tsx
index d38e296ccb..f72128d2f7 100644
--- a/src/components/organisms/TemplateModal/TemplateModal.tsx
+++ b/src/components/organisms/TemplateModal/TemplateModal.tsx
@@ -20,7 +20,7 @@ import {createUnsavedResourcesFromVanillaTemplate} from '@redux/services/templat
import {TemplateFormRenderer} from '@components/molecules';
-import {trackEvent} from '@utils/telemetry';
+import {START_FROM_A_TEMPLATE, USE_TEMPLATE, trackEvent} from '@utils/telemetry';
import * as S from './styled';
@@ -53,7 +53,7 @@ const TemplateModal: React.FC = props => {
const onClickSubmit = useCallback(
(formDataList: Record[]) => {
if (projectToCreate) {
- trackEvent('START_FROM_A_TEMPLATE', {templateID: template.id});
+ trackEvent(START_FROM_A_TEMPLATE, {templateID: template.id});
dispatch(setCreateProject({...projectToCreate}));
onClose('PREVIEW');
}
@@ -62,7 +62,7 @@ const TemplateModal: React.FC = props => {
formDataList.shift();
if (isVanillaTemplate(template)) {
- trackEvent('USE_TEMPLATE', {templateID: template.id});
+ trackEvent(USE_TEMPLATE, {templateID: template.id});
setIsLoading(true);
createUnsavedResourcesFromVanillaTemplate(template, formDataList, dispatch)
.then(({message, resources}) => {
@@ -81,7 +81,7 @@ const TemplateModal: React.FC = props => {
return;
}
setIsLoading(true);
- trackEvent('USE_TEMPLATE', {templateID: template.id});
+ trackEvent(USE_TEMPLATE, {templateID: template.id});
previewReferencedHelmChart(
template.chartName,
template.chartVersion,
diff --git a/src/redux/thunks/previewCluster.ts b/src/redux/thunks/previewCluster.ts
index 455fceda91..af4f191452 100644
--- a/src/redux/thunks/previewCluster.ts
+++ b/src/redux/thunks/previewCluster.ts
@@ -17,7 +17,7 @@ import {extractK8sResources, processParsedResources} from '@redux/services/resou
import {createPreviewResult, createRejectionWithAlert, getK8sObjectsAsYaml} from '@redux/thunks/utils';
import {createKubeClient} from '@utils/kubeclient';
-import {trackEvent} from '@utils/telemetry';
+import {CLUSTER_VIEW, trackEvent} from '@utils/telemetry';
import {getRegisteredKindHandlers, getResourceKindHandler} from '@src/kindhandlers';
@@ -82,7 +82,7 @@ const previewClusterHandler = async (context: string, thunkAPI: any) => {
resourceIds: customResources.map(r => r.id),
});
- trackEvent('CLUSTER_VIEW', {numberOfResourcesInCluster: Object.keys(previewResult.previewResources).length});
+ trackEvent(CLUSTER_VIEW, {numberOfResourcesInCluster: Object.keys(previewResult.previewResources).length});
previewResult.alert.message = `Previewing ${Object.keys(previewResult.previewResources).length} resources`;
}
diff --git a/src/redux/thunks/previewHelmValuesFile.ts b/src/redux/thunks/previewHelmValuesFile.ts
index bc268df813..c1602d605f 100644
--- a/src/redux/thunks/previewHelmValuesFile.ts
+++ b/src/redux/thunks/previewHelmValuesFile.ts
@@ -14,7 +14,7 @@ import {currentConfigSelector} from '@redux/selectors';
import {createPreviewResult, createRejectionWithAlert} from '@redux/thunks/utils';
import {runHelm} from '@utils/helm';
-import {trackEvent} from '@utils/telemetry';
+import {DO_HELM_PREVIEW, trackEvent} from '@utils/telemetry';
/**
* Thunk to preview a Helm Chart
@@ -60,7 +60,7 @@ export const previewHelmValuesFile = createAsyncThunk<
const result = await runHelm(args);
- trackEvent('DO_HELM_PREVIEW');
+ trackEvent(DO_HELM_PREVIEW);
if (result.error) {
return createRejectionWithAlert(thunkAPI, 'Helm Error', result.error);
diff --git a/src/redux/thunks/previewKustomization.ts b/src/redux/thunks/previewKustomization.ts
index 2642907546..ece6ff2a23 100644
--- a/src/redux/thunks/previewKustomization.ts
+++ b/src/redux/thunks/previewKustomization.ts
@@ -16,7 +16,7 @@ import {SetPreviewDataPayload} from '@redux/reducers/main';
import {currentConfigSelector} from '@redux/selectors';
import {createPreviewResult, createRejectionWithAlert} from '@redux/thunks/utils';
-import {trackEvent} from '@utils/telemetry';
+import {DO_KUSTOMIZE_PREVIEW, trackEvent} from '@utils/telemetry';
export type KustomizeCommandOptions = {
folder: string;
@@ -48,7 +48,7 @@ export const previewKustomization = createAsyncThunk<
log.info(`previewing ${resource.id} in folder ${folder}`);
const result = await runKustomize(folder, projectConfig);
- trackEvent('DO_KUSTOMIZE_PREVIEW');
+ trackEvent(DO_KUSTOMIZE_PREVIEW);
if (result.error) {
return createRejectionWithAlert(thunkAPI, 'Kustomize Error', result.error);
diff --git a/src/redux/thunks/saveUnsavedResources.ts b/src/redux/thunks/saveUnsavedResources.ts
index 6cd6560c9a..a53834fc0f 100644
--- a/src/redux/thunks/saveUnsavedResources.ts
+++ b/src/redux/thunks/saveUnsavedResources.ts
@@ -12,7 +12,7 @@ import {K8sResource} from '@models/k8sresource';
import {RootState} from '@models/rootstate';
import {getFileTimestamp} from '@utils/files';
-import {trackEvent} from '@utils/telemetry';
+import {ADD_NEW_RESOURCE, trackEvent} from '@utils/telemetry';
import {createRejectionWithAlert} from './utils';
@@ -47,7 +47,7 @@ const performSaveUnsavedResource = async (
throw new Error('Could not find the root folder.');
}
- trackEvent('ADD_NEW_RESOURCE', {resourceKind: resource.kind});
+ trackEvent(ADD_NEW_RESOURCE, {resourceKind: resource.kind});
if (saveMode === 'saveToFolder') {
await writeFilePromise(absolutePath, resource.text);
diff --git a/src/redux/thunks/setRootFolder.ts b/src/redux/thunks/setRootFolder.ts
index 8cdb2f9a01..b7e98264b8 100644
--- a/src/redux/thunks/setRootFolder.ts
+++ b/src/redux/thunks/setRootFolder.ts
@@ -14,7 +14,7 @@ import {processParsedResources} from '@redux/services/resource';
import {createRejectionWithAlert} from '@redux/thunks/utils';
import {getFileStats} from '@utils/files';
-import {trackEvent} from '@utils/telemetry';
+import {OPEN_EXISTING_PROJECT, trackEvent} from '@utils/telemetry';
/**
* Thunk to set the specified root folder
@@ -83,7 +83,7 @@ export const setRootFolder = createAsyncThunk<
type: AlertEnum.Success,
};
- trackEvent('OPEN_EXISTING_PROJECT', {
+ trackEvent(OPEN_EXISTING_PROJECT, {
numberOfFiles: Object.values(fileMap).filter(f => !f.children).length,
numberOfResources: Object.values(resourceMap).length,
});
diff --git a/src/utils/shell.ts b/src/utils/shell.ts
index 7f8ab0e904..8cc14deea8 100644
--- a/src/utils/shell.ts
+++ b/src/utils/shell.ts
@@ -4,7 +4,7 @@ import * as os from 'os';
// @ts-ignore
import shellPath from 'shell-path';
-import {trackEvent} from './telemetry';
+import {WINDOW_HELP_LINK, trackEvent} from './telemetry';
let cachedShellPath: string | undefined;
@@ -21,12 +21,12 @@ export function showItemInFolder(fullPath: string) {
}
export function openGitHub() {
- trackEvent('WINDOW_HELP_LINK', {linkID: 'github'});
+ trackEvent(WINDOW_HELP_LINK, {linkID: 'github'});
shell.openExternal('https://github.com/kubeshop/monokle');
}
export function openDiscord() {
- trackEvent('WINDOW_HELP_LINK', {linkID: 'discord'});
+ trackEvent(WINDOW_HELP_LINK, {linkID: 'discord'});
shell.openExternal('https://discord.gg/kMJxmuYTMu');
}
@@ -37,12 +37,12 @@ export function openUrlInExternalBrowser(url?: string) {
}
export function openDocumentation() {
- trackEvent('WINDOW_HELP_LINK', {linkID: 'documentation', osType: os.type});
+ trackEvent(WINDOW_HELP_LINK, {linkID: 'documentation'});
shell.openExternal(`https://kubeshop.github.io/monokle?os=${os.type}`);
}
export function openKeyboardShortcuts() {
- trackEvent('WINDOW_HELP_LINK', {linkID: 'shortcuts', osType: os.type});
+ trackEvent(WINDOW_HELP_LINK, {linkID: 'shortcuts'});
shell.openExternal(`https://kubeshop.github.io/monokle/hotkeys?os=${os.type}`);
}
diff --git a/src/utils/telemetry.ts b/src/utils/telemetry.ts
index 61fd441b93..ab36b8d2e1 100644
--- a/src/utils/telemetry.ts
+++ b/src/utils/telemetry.ts
@@ -6,3 +6,14 @@ export const trackEvent = (eventName: string, payload?: any) => {
export const trackError = (error: any) => {
ipcRenderer.send('track-event', {error});
};
+
+export const CREATE_EMPTY_PROJECT = 'CREATE_EMPTY_PROJECT';
+export const SELECT_LEFT_TOOL_PANEL = 'SELECT_LEFT_TOOL_PANEL';
+export const START_FROM_A_TEMPLATE = 'START_FROM_A_TEMPLATE';
+export const WINDOW_HELP_LINK = 'WINDOW_HELP_LINK';
+export const USE_TEMPLATE = 'USE_TEMPLATE';
+export const DO_HELM_PREVIEW = 'DO_HELM_PREVIEW';
+export const CLUSTER_VIEW = 'CLUSTER_VIEW';
+export const DO_KUSTOMIZE_PREVIEW = 'DO_KUSTOMIZE_PREVIEW';
+export const OPEN_EXISTING_PROJECT = 'OPEN_EXISTING_PROJECT';
+export const ADD_NEW_RESOURCE = 'ADD_NEW_RESOURCE';