Skip to content

Commit

Permalink
fix: added more telemetry and log telemetry to console in dev
Browse files Browse the repository at this point in the history
  • Loading branch information
olensmar committed May 10, 2023
1 parent 45e8f36 commit 77757bc
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
2 changes: 2 additions & 0 deletions electron/app/ipc/ipcListeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ ipcMain.on('track-event', async (event: any, {eventName, payload}: any) => {
userId: machineId,
properties,
});
} else if (process.env.NODE_ENV === `development`) {
console.log(`telemetry event ${eventName}`, payload);
}
});

Expand Down
7 changes: 0 additions & 7 deletions src/components/molecules/FormEditor/FormEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import {parseYamlDocument, stringifyK8sResource} from '@utils/yaml';
import {isHelmChartFile} from '@shared/utils/helm';
import {isEqual} from '@shared/utils/isEqual';
import {isInClusterModeSelector, isInPreviewModeSelector} from '@shared/utils/selectors';
import {trackEvent} from '@shared/utils/telemetry';

import {FormArrayFieldTemplate} from './FormArrayFieldTemplate';
import * as S from './FormEditor.styled';
Expand Down Expand Up @@ -123,12 +122,6 @@ const FormEditor: React.FC<IProps> = props => {
}
};
loadResourceFile();

return () => {
if (selectedResource || selectedFilePath) {
trackEvent('edit/form_editor', {resourceKind: selectedResource?.kind});
}
};
}, [dispatch, selectedResource, selectedFilePath, setFormData]);

useEffect(() => {
Expand Down
8 changes: 7 additions & 1 deletion src/components/organisms/ActionsPane/ActionsPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,13 @@ const ActionsPane: React.FC = () => {
onChange={k => {
dispatch(setActiveEditorTab(k as ActionPaneTab));
if (k === 'graph') {
trackEvent('edit/graphview');
trackEvent('edit/graphview', {resourceKind: selectedResource?.kind});
}
if (k === 'form') {
trackEvent('edit/form_editor', {resourceKind: selectedResource?.kind});
}
if (k === 'source') {
trackEvent('edit/source', {resourceKind: selectedResource?.kind});
}
}}
tabBarExtraContent={
Expand Down
7 changes: 7 additions & 0 deletions src/editor/enhancers/k8sResource/refs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {createGlyphDecoration, createMarkdownString} from '@editor/editor.utils'
import {RefPosition, ResourceRef, ResourceRefType, areRefPosEqual} from '@monokle/validation';
import {AppDispatch} from '@shared/models/appDispatch';
import {ResourceMeta, isLocalResourceMeta} from '@shared/models/k8sResource';
import {trackEvent} from '@shared/utils';

import {createEditorEnhancer} from '../createEnhancer';

Expand Down Expand Up @@ -205,6 +206,7 @@ const addEditorCommandForRef = (args: {resourceMeta: ResourceMeta; ref: Resource
dispatch(
selectResource({resourceIdentifier: {id: (ref.target as any).resourceId, storage: resourceMeta.storage}})
);
trackEvent('edit/select_hover_link', {type: 'resource'});
}
},
},
Expand All @@ -218,6 +220,7 @@ const addEditorCommandForRef = (args: {resourceMeta: ResourceMeta; ref: Resource
handler: () => {
if (ref.target?.type === 'file') {
dispatch(selectFile({filePath: ref.target.filePath}));
trackEvent('edit/select_hover_link', {type: 'file'});
}
},
},
Expand All @@ -231,6 +234,7 @@ const addEditorCommandForRef = (args: {resourceMeta: ResourceMeta; ref: Resource
handler: () => {
if (ref.target?.type === 'image') {
dispatch(selectImage({imageId: `${ref.name}:${ref.target?.tag}`}));
trackEvent('edit/select_hover_link', {type: 'image'});
}
},
},
Expand All @@ -248,9 +252,12 @@ const onClickRefLink = (args: {resourceMeta: ResourceMeta; ref: ResourceRef; dis
if (ref.target?.type === 'resource' && ref.target.resourceId) {
// is the storage of the target resource the same as the current resource?
dispatch(selectResource({resourceIdentifier: {id: ref.target.resourceId, storage: resourceMeta.storage}}));
trackEvent('edit/select_hover_link', {type: 'resource'});
} else if (ref.target?.type === 'file' && ref.target.filePath) {
dispatch(selectFile({filePath: ref.target.filePath}));
trackEvent('edit/select_hover_link', {type: 'file'});
} else if (ref.target?.type === 'image') {
dispatch(selectImage({imageId: `${ref.name}:${ref.target?.tag}`}));
trackEvent('edit/select_hover_link', {type: 'image'});
}
};
4 changes: 3 additions & 1 deletion src/shared/models/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ export type EventMap = {
'graph/select_image': undefined;
'edit/template_use': {templateID: string};
'edit/form_editor': {resourceKind?: string};
'edit/source': {resourceKind?: string};
'edit/side_by_side_editor': {resourceKind: string};
'edit/graphview': {kind: string};
'edit/select_hover_link': {type: 'resource' | 'image' | 'file'};
'edit/graphview': {resourceKind?: string};
'create/file': undefined;
'create/folder': undefined;
'create/resource': {resourceKind: string};
Expand Down

0 comments on commit 77757bc

Please sign in to comment.