feat: Add new tracking events for flow and data load executions (#6492)

* add new events

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
Mike Fortman 2025-02-13 17:14:51 -06:00 committed by GitHub
commit 0fbe1b0d09
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 53 additions and 2 deletions

View file

@ -5,3 +5,20 @@ export const track = async (
): Promise<void> => {
return;
};
export const trackFlowBuild = async (
flowName: string,
isError?: boolean,
properties?: Record<string, any>,
): Promise<void> => {
return;
};
export const trackDataLoaded = async (
flowId?: string,
flowName?: string,
component?: string,
componentId?: string,
): Promise<void> => {
return;
};

View file

@ -2,7 +2,12 @@ import {
BROKEN_EDGES_WARNING,
componentsToIgnoreUpdate,
} from "@/constants/constants";
import { track } from "@/customization/utils/analytics";
import { ENABLE_DATASTAX_LANGFLOW } from "@/customization/feature-flags";
import {
track,
trackDataLoaded,
trackFlowBuild,
} from "@/customization/utils/analytics";
import { brokenEdgeMessage } from "@/utils/utils";
import {
EdgeChange,
@ -19,7 +24,7 @@ import {
MISSED_ERROR_ALERT,
} from "../constants/alerts_constants";
import { BuildStatus } from "../constants/enums";
import { VertexBuildTypeAPI } from "../types/api";
import { LogsLogType, VertexBuildTypeAPI } from "../types/api";
import { ChatInputType, ChatOutputType } from "../types/chat";
import {
AllNodeType,
@ -699,6 +704,28 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
...get().verticesBuild!.verticesIds,
...next_vertices_ids,
];
if (
ENABLE_DATASTAX_LANGFLOW &&
vertexBuildData?.id?.includes("AstraDB")
) {
const search_results: LogsLogType[] = Object.values(
vertexBuildData?.data?.logs?.search_results,
);
search_results.forEach((log) => {
if (
log.message.includes("Adding") &&
log.message.includes("documents") &&
log.message.includes("Vector Store")
) {
trackDataLoaded(
get().currentFlow?.id,
get().currentFlow?.name,
"AstraDB Vector Store",
vertexBuildData?.id,
);
}
});
}
get().updateVerticesBuild({
verticesIds: newIds,
verticesLayers: newLayers,
@ -747,6 +774,9 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
false,
);
get().setIsBuilding(false);
trackFlowBuild(get().currentFlow?.name ?? "Unknown", false, {
flowId: get().currentFlow?.id,
});
},
onBuildUpdate: handleBuildUpdate,
onBuildError: (title: string, list: string[], elementList) => {
@ -767,6 +797,10 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
setErrorData({ list, title });
get().setIsBuilding(false);
get().buildController.abort();
trackFlowBuild(get().currentFlow?.name ?? "Unknown", true, {
flowId: get().currentFlow?.id,
error: list,
});
},
onBuildStart: (elementList) => {
const idList = elementList