mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
feat(AI Transform Node): Telemetry (no-changelog) (#10398)
This commit is contained in:
parent
4d222ac19d
commit
4dc34ba745
|
@ -10,6 +10,7 @@ import { getSchemas, getParentNodes } from './utils';
|
|||
import { ASK_AI_EXPERIMENT } from '@/constants';
|
||||
import { usePostHog } from '@/stores/posthog.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useTelemetry } from '@/composables/useTelemetry';
|
||||
import { generateCodeForPrompt } from '@/api/ai';
|
||||
|
||||
import { format } from 'prettier';
|
||||
|
@ -144,6 +145,11 @@ async function onSubmit() {
|
|||
};
|
||||
|
||||
emit('valueChanged', updateInformation);
|
||||
|
||||
useTelemetry().trackAiTransform('generationFinished', {
|
||||
prompt: prompt.value,
|
||||
code: formattedCode,
|
||||
});
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
|
@ -156,6 +162,11 @@ async function onSubmit() {
|
|||
|
||||
stopLoading();
|
||||
} catch (error) {
|
||||
useTelemetry().trackAiTransform('generationFinished', {
|
||||
prompt: prompt.value,
|
||||
code: '',
|
||||
hasError: true,
|
||||
});
|
||||
showMessage({
|
||||
type: 'error',
|
||||
title: i18n.baseText('codeNodeEditor.askAi.generationFailed'),
|
||||
|
|
|
@ -167,6 +167,20 @@ export class Telemetry {
|
|||
}
|
||||
}
|
||||
|
||||
trackAiTransform(event: string, properties: IDataObject = {}) {
|
||||
if (this.rudderStack) {
|
||||
properties.session_id = useRootStore().pushRef;
|
||||
properties.ndv_session_id = useNDVStore().pushRef;
|
||||
|
||||
switch (event) {
|
||||
case 'generationFinished':
|
||||
this.track('Ai Transform code generation finished', properties, { withPostHog: true });
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
trackNodesPanel(event: string, properties: IDataObject = {}) {
|
||||
if (this.rudderStack) {
|
||||
properties.nodes_panel_session_id = this.userNodesPanelSession.pushRef;
|
||||
|
|
|
@ -32,7 +32,7 @@ export class AiTransform implements INodeType {
|
|||
properties: [
|
||||
{
|
||||
displayName: 'Instructions',
|
||||
name: 'generate',
|
||||
name: 'instructions',
|
||||
type: 'button',
|
||||
default: '',
|
||||
description:
|
||||
|
@ -92,7 +92,7 @@ export class AiTransform implements INodeType {
|
|||
code = this.getNodeParameter(codeParameterName, index) as string;
|
||||
|
||||
if (!code) {
|
||||
const instructions = this.getNodeParameter('generate', index) as string;
|
||||
const instructions = this.getNodeParameter('instructions', index) as string;
|
||||
if (!instructions) {
|
||||
throw new NodeOperationError(node, 'Missing instructions to generate code', {
|
||||
description:
|
||||
|
|
|
@ -13,6 +13,7 @@ import type {
|
|||
import { ApplicationError } from './errors/application.error';
|
||||
import {
|
||||
AGENT_LANGCHAIN_NODE_TYPE,
|
||||
AI_TRANSFORM_NODE_TYPE,
|
||||
CHAIN_LLM_LANGCHAIN_NODE_TYPE,
|
||||
CHAIN_SUMMARIZATION_LANGCHAIN_NODE_TYPE,
|
||||
EXECUTE_WORKFLOW_NODE_TYPE,
|
||||
|
@ -207,7 +208,9 @@ export function generateNodesGraph(
|
|||
nodeItem.src_node_id = options.nodeIdMap[node.id];
|
||||
}
|
||||
|
||||
if (node.type === AGENT_LANGCHAIN_NODE_TYPE) {
|
||||
if (node.type === AI_TRANSFORM_NODE_TYPE && options?.isCloudDeployment) {
|
||||
nodeItem.prompts = { instructions: node.parameters.instructions as string };
|
||||
} else if (node.type === AGENT_LANGCHAIN_NODE_TYPE) {
|
||||
nodeItem.agent = (node.parameters.agent as string) ?? 'conversationalAgent';
|
||||
} else if (node.type === MERGE_NODE_TYPE) {
|
||||
nodeItem.operation = node.parameters.mode as string;
|
||||
|
|
Loading…
Reference in a new issue