Skip to content

Commit

Permalink
feat(editor): Add more telemetry for workflow inputs (no-changelog) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
MiloradFilipovic authored Jan 27, 2025
1 parent eabf160 commit 6dd90c8
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
33 changes: 32 additions & 1 deletion packages/editor-ui/src/components/FixedCollectionParameter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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');
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 = {
Expand All @@ -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>
Expand Down Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions packages/editor-ui/src/components/ParameterInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 6dd90c8

Please sign in to comment.