Skip to content

Commit

Permalink
feat: Add new tracking events for flow and data load executions (#6492)
Browse files Browse the repository at this point in the history
* add new events

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
mfortman11 and autofix-ci[bot] authored Feb 13, 2025
1 parent 79f91e3 commit 0fbe1b0
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
17 changes: 17 additions & 0 deletions src/frontend/src/customization/utils/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
38 changes: 36 additions & 2 deletions src/frontend/src/stores/flowStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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) => {
Expand All @@ -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
Expand Down

0 comments on commit 0fbe1b0

Please sign in to comment.