fix: Adjust telemetry from canvas (no-changelog) (#8252)

This commit is contained in:
Tomi Turtiainen 2024-01-08 13:56:16 +02:00 committed by GitHub
parent 90c065e999
commit 7899f7aca5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 30 additions and 12 deletions

View file

@ -5,9 +5,13 @@ import { useI18n } from '@/composables/useI18n';
import N8nHeading from 'n8n-design-system/components/N8nHeading'; import N8nHeading from 'n8n-design-system/components/N8nHeading';
import AppsRequiringCredsNotice from '@/views/SetupWorkflowFromTemplateView/AppsRequiringCredsNotice.vue'; import AppsRequiringCredsNotice from '@/views/SetupWorkflowFromTemplateView/AppsRequiringCredsNotice.vue';
import SetupTemplateFormStep from '@/views/SetupWorkflowFromTemplateView/SetupTemplateFormStep.vue'; import SetupTemplateFormStep from '@/views/SetupWorkflowFromTemplateView/SetupTemplateFormStep.vue';
import { onMounted } from 'vue'; import { onMounted, onUnmounted } from 'vue';
import { useTelemetry } from '@/composables/useTelemetry';
import { useWorkflowsStore } from '@/stores/workflows.store';
const i18n = useI18n(); const i18n = useI18n();
const telemetry = useTelemetry();
const workflowStore = useWorkflowsStore();
const props = defineProps<{ const props = defineProps<{
modalName: string; modalName: string;
@ -17,6 +21,7 @@ const props = defineProps<{
const { const {
appCredentials, appCredentials,
credentialUsages, credentialUsages,
numFilledCredentials,
selectedCredentialIdByKey, selectedCredentialIdByKey,
setInitialCredentialSelection, setInitialCredentialSelection,
setCredential, setCredential,
@ -25,6 +30,17 @@ const {
onMounted(() => { onMounted(() => {
setInitialCredentialSelection(); setInitialCredentialSelection();
telemetry.track('User opened cred setup', { source: 'canvas' }, { withPostHog: true });
});
onUnmounted(() => {
telemetry.track('User closed cred setup', {
completed: numFilledCredentials.value === credentialUsages.value.length,
creds_filled: numFilledCredentials.value,
creds_needed: credentialUsages.value.length,
workflow_id: workflowStore.workflowId,
});
}); });
</script> </script>

View file

@ -407,11 +407,11 @@ export const listenForCredentialChanges = (opts: {
onCredentialCreated?: (credential: ICredentialsResponse) => void; onCredentialCreated?: (credential: ICredentialsResponse) => void;
onCredentialUpdated?: (credential: ICredentialsResponse) => void; onCredentialUpdated?: (credential: ICredentialsResponse) => void;
onCredentialDeleted?: (credentialId: string) => void; onCredentialDeleted?: (credentialId: string) => void;
}): void => { }) => {
const { store, onCredentialCreated, onCredentialDeleted, onCredentialUpdated } = opts; const { store, onCredentialCreated, onCredentialDeleted, onCredentialUpdated } = opts;
const listeningForActions = ['createNewCredential', 'updateCredential', 'deleteCredential']; const listeningForActions = ['createNewCredential', 'updateCredential', 'deleteCredential'];
store.$onAction((result) => { return store.$onAction((result) => {
const { name, after, args } = result; const { name, after, args } = result;
after(async (returnValue) => { after(async (returnValue) => {
if (!listeningForActions.includes(name)) { if (!listeningForActions.includes(name)) {

View file

@ -629,11 +629,11 @@ export const listenForModalChanges = (opts: {
store: UiStore; store: UiStore;
onModalOpened?: (name: keyof Modals) => void; onModalOpened?: (name: keyof Modals) => void;
onModalClosed?: (name: keyof Modals) => void; onModalClosed?: (name: keyof Modals) => void;
}): void => { }) => {
const { store, onModalClosed, onModalOpened } = opts; const { store, onModalClosed, onModalOpened } = opts;
const listeningForActions = ['openModal', 'openModalWithData', 'closeModal']; const listeningForActions = ['openModal', 'openModalWithData', 'closeModal'];
store.$onAction((result) => { return store.$onAction((result) => {
const { name, after, args } = result; const { name, after, args } = result;
after(async () => { after(async () => {
if (!listeningForActions.includes(name)) { if (!listeningForActions.includes(name)) {

View file

@ -68,8 +68,12 @@ async function openTemplateCredentialSetup(opts: {
templateId: string; templateId: string;
router: Router; router: Router;
inNewBrowserTab?: boolean; inNewBrowserTab?: boolean;
telemetry: Telemetry;
source: string;
}) { }) {
const { router, templateId, inNewBrowserTab = false } = opts; const { router, templateId, inNewBrowserTab = false, telemetry, source } = opts;
telemetry.track('User opened cred setup', { source }, { withPostHog: true });
const routeLocation: RouteLocationRaw = { const routeLocation: RouteLocationRaw = {
name: VIEWS.TEMPLATE_SETUP, name: VIEWS.TEMPLATE_SETUP,
@ -152,6 +156,7 @@ export async function useTemplateWorkflow(opts: {
router: Router; router: Router;
inNewBrowserTab?: boolean; inNewBrowserTab?: boolean;
telemetry: Telemetry; telemetry: Telemetry;
source: string;
}) { }) {
const { nodeTypesStore, posthogStore, templateId, templatesStore } = opts; const { nodeTypesStore, posthogStore, templateId, templatesStore } = opts;

View file

@ -81,12 +81,7 @@ setupTemplateStore.setTemplateId(templateId.value);
onMounted(async () => { onMounted(async () => {
await setupTemplateStore.init(); await setupTemplateStore.init();
const wasSkipped = await skipIfTemplateHasNoCreds(); await skipIfTemplateHasNoCreds();
if (!wasSkipped) {
telemetry.track('User opened cred setup', undefined, {
withPostHog: true,
});
}
}); });
//#endregion Lifecycle hooks //#endregion Lifecycle hooks

View file

@ -162,6 +162,7 @@ export default defineComponent({
externalHooks: this.externalHooks, externalHooks: this.externalHooks,
nodeTypesStore: useNodeTypesStore(), nodeTypesStore: useNodeTypesStore(),
telemetry: this.$telemetry, telemetry: this.$telemetry,
source: 'template_list',
}); });
}, },
navigateTo(e: MouseEvent, page: string, id: string) { navigateTo(e: MouseEvent, page: string, id: string) {

View file

@ -141,6 +141,7 @@ export default defineComponent({
nodeTypesStore: useNodeTypesStore(), nodeTypesStore: useNodeTypesStore(),
telemetry: this.$telemetry, telemetry: this.$telemetry,
templatesStore: useTemplatesStore(), templatesStore: useTemplatesStore(),
source: 'template_preview',
}); });
}, },
onHidePreview() { onHidePreview() {