feat: add telemetry

This commit is contained in:
Mutasem Aldmour 2024-11-11 10:12:01 +01:00
parent cc97c6c026
commit 80ae58f2af
No known key found for this signature in database
GPG key ID: 3DFA8122BB7FD6B8
3 changed files with 42 additions and 2 deletions

View file

@ -1210,6 +1210,23 @@ function onSearchClear() {
document.dispatchEvent(new KeyboardEvent('keyup', { key: '/' }));
}
function onOpenRelatedExecution(executionId: string, workflowId?: string) {
if (!nodeType.value) {
return;
}
openExecutionInNewTab(executionId, workflowId);
// todo better distinguish these two
const isTrigger = nodeType.value.group.includes('trigger');
telemetry.track(
isTrigger ? 'User clicked parent execution button' : 'User clicked inspect sub-workflow',
{
view: displayMode.value,
},
);
}
defineExpose({ enterEditMode });
</script>
@ -1390,7 +1407,9 @@ defineExpose({ enterEditMode });
:class="$style.parentExecutionInfo"
>
<a
@click.stop="openExecutionInNewTab(subWorkflowData.executionId, subWorkflowData.workflowId)"
@click.stop="
onOpenRelatedExecution(subWorkflowData.executionId, subWorkflowData.workflowId)
"
>
<N8nIcon icon="external-link-alt" size="xsmall" />
{{

View file

@ -12,6 +12,7 @@ import { computed } from 'vue';
import NodeIcon from '@/components/NodeIcon.vue';
import AiRunContentBlock from './AiRunContentBlock.vue';
import { useExecutionHelpers } from '@/composables/useExecutionHelpers';
import { useTelemetry } from '@/composables/useTelemetry';
interface RunMeta {
startTimeMs: number;
@ -29,6 +30,8 @@ const props = defineProps<{
const nodeTypesStore = useNodeTypesStore();
const workflowsStore = useWorkflowsStore();
const telemetry = useTelemetry();
const { openExecutionInNewTab } = useExecutionHelpers();
type TokenUsageData = {
@ -105,6 +108,20 @@ const outputError = computed(() => {
| NodeError
| undefined;
});
// todo unify function across components
function openExecution({ executionId }: RunMeta) {
if (!executionId) {
return;
}
// todo add workflow id
openExecutionInNewTab(executionId);
telemetry.track('User clicked inspect sub-workflow', {
view: 'ai',
});
}
</script>
<template>
@ -137,7 +154,7 @@ const outputError = computed(() => {
</n8n-tooltip>
</li>
<li v-if="runMeta?.executionId">
<a @click.stop="openExecutionInNewTab(runMeta?.executionId)">
<a @click.stop="openExecution(runMeta)">
<N8nIcon icon="external-link-alt" size="xsmall" />
{{ $locale.baseText('runData.openSubExecution') }}
</a>

View file

@ -412,6 +412,10 @@ function switchToJsonView() {
function openExecution({ executionId, workflowId }: SubworkflowExecutionInfo) {
openExecutionInNewTab(executionId, workflowId);
telemetry.track('User clicked inspect sub-workflow', {
view: 'table',
});
}
watch(focusedMappableInput, (curr) => {