feat(editor): Add more telemetry for workflow inputs (no-changelog) (#12862)

This commit is contained in:
Milorad FIlipović 2025-01-27 15:36:59 +01:00 committed by GitHub
parent eabf160957
commit 6dd90c8764
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 51 additions and 1 deletions

View file

@ -18,6 +18,9 @@ import {
} from 'n8n-design-system';
import ParameterInputList from './ParameterInputList.vue';
import Draggable from 'vuedraggable';
import { useWorkflowsStore } from '@/stores/workflows.store';
import { useNDVStore } from '@/stores/ndv.store';
import { telemetry } from '@/plugins/telemetry';
const locale = useI18n();
@ -44,6 +47,9 @@ const emit = defineEmits<{
valueChanged: [value: ValueChangedEvent];
}>();
const workflowsStore = useWorkflowsStore();
const ndvStore = useNDVStore();
const getPlaceholderText = computed(() => {
const placeholder = locale.nodeText().placeholder(props.parameter, props.path);
return placeholder ? placeholder : locale.baseText('fixedCollectionParameter.choose');
@ -127,6 +133,13 @@ const getOptionProperties = (optionName: string) => {
return undefined;
};
const onAddButtonClick = (optionName: string) => {
optionSelected(optionName);
if (props.parameter.name === 'workflowInputs') {
trackWorkflowInputFieldAdded();
}
};
const optionSelected = (optionName: string) => {
const option = getOptionProperties(optionName);
if (option === undefined) {
@ -183,6 +196,9 @@ const optionSelected = (optionName: string) => {
const valueChanged = (parameterData: IUpdateInformation) => {
emit('valueChanged', parameterData);
if (props.parameter.name === 'workflowInputs') {
trackWorkflowInputFieldTypeChange(parameterData);
}
};
const onDragChange = (optionName: string) => {
const parameterData: ValueChangedEvent = {
@ -193,6 +209,21 @@ const onDragChange = (optionName: string) => {
emit('valueChanged', parameterData);
};
const trackWorkflowInputFieldTypeChange = (parameterData: IUpdateInformation) => {
telemetry.track('User changed workflow input field type', {
type: parameterData.value,
workflow_id: workflowsStore.workflow.id,
node_id: ndvStore.activeNode?.id,
});
};
const trackWorkflowInputFieldAdded = () => {
telemetry.track('User added workflow input field', {
workflow_id: workflowsStore.workflow.id,
node_id: ndvStore.activeNode?.id,
});
};
</script>
<template>
@ -305,7 +336,7 @@ const onDragChange = (optionName: string) => {
block
data-test-id="fixed-collection-add"
:label="getPlaceholderText"
@click="optionSelected(parameter.options[0].name)"
@click="onAddButtonClick(parameter.options[0].name)"
/>
<div v-else class="add-option">
<N8nSelect

View file

@ -837,6 +837,25 @@ function valueChanged(value: NodeParameterValueType | {} | Date) {
parameter: props.parameter.name,
});
}
// Track workflow input data mode change
const isWorkflowInputParameter =
props.parameter.name === 'inputSource' && props.parameter.default === 'workflowInputs';
if (isWorkflowInputParameter) {
trackWorkflowInputModeEvent(value as string);
}
}
function trackWorkflowInputModeEvent(value: string) {
const telemetryValuesMap: Record<string, string> = {
workflowInputs: 'fields',
jsonExample: 'json',
passthrough: 'all',
};
telemetry.track('User chose input data mode', {
option: telemetryValuesMap[value],
workflow_id: workflowsStore.workflowId,
node_id: node.value?.id,
});
}
async function optionSelected(command: string) {