Skip to content

Commit 0fbe1b0

Browse files
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>
1 parent 79f91e3 commit 0fbe1b0

File tree

2 files changed

+53
-2
lines changed

2 files changed

+53
-2
lines changed

src/frontend/src/customization/utils/analytics.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,20 @@ export const track = async (
55
): Promise<void> => {
66
return;
77
};
8+
9+
export const trackFlowBuild = async (
10+
flowName: string,
11+
isError?: boolean,
12+
properties?: Record<string, any>,
13+
): Promise<void> => {
14+
return;
15+
};
16+
17+
export const trackDataLoaded = async (
18+
flowId?: string,
19+
flowName?: string,
20+
component?: string,
21+
componentId?: string,
22+
): Promise<void> => {
23+
return;
24+
};

src/frontend/src/stores/flowStore.ts

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ import {
22
BROKEN_EDGES_WARNING,
33
componentsToIgnoreUpdate,
44
} from "@/constants/constants";
5-
import { track } from "@/customization/utils/analytics";
5+
import { ENABLE_DATASTAX_LANGFLOW } from "@/customization/feature-flags";
6+
import {
7+
track,
8+
trackDataLoaded,
9+
trackFlowBuild,
10+
} from "@/customization/utils/analytics";
611
import { brokenEdgeMessage } from "@/utils/utils";
712
import {
813
EdgeChange,
@@ -19,7 +24,7 @@ import {
1924
MISSED_ERROR_ALERT,
2025
} from "../constants/alerts_constants";
2126
import { BuildStatus } from "../constants/enums";
22-
import { VertexBuildTypeAPI } from "../types/api";
27+
import { LogsLogType, VertexBuildTypeAPI } from "../types/api";
2328
import { ChatInputType, ChatOutputType } from "../types/chat";
2429
import {
2530
AllNodeType,
@@ -699,6 +704,28 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
699704
...get().verticesBuild!.verticesIds,
700705
...next_vertices_ids,
701706
];
707+
if (
708+
ENABLE_DATASTAX_LANGFLOW &&
709+
vertexBuildData?.id?.includes("AstraDB")
710+
) {
711+
const search_results: LogsLogType[] = Object.values(
712+
vertexBuildData?.data?.logs?.search_results,
713+
);
714+
search_results.forEach((log) => {
715+
if (
716+
log.message.includes("Adding") &&
717+
log.message.includes("documents") &&
718+
log.message.includes("Vector Store")
719+
) {
720+
trackDataLoaded(
721+
get().currentFlow?.id,
722+
get().currentFlow?.name,
723+
"AstraDB Vector Store",
724+
vertexBuildData?.id,
725+
);
726+
}
727+
});
728+
}
702729
get().updateVerticesBuild({
703730
verticesIds: newIds,
704731
verticesLayers: newLayers,
@@ -747,6 +774,9 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
747774
false,
748775
);
749776
get().setIsBuilding(false);
777+
trackFlowBuild(get().currentFlow?.name ?? "Unknown", false, {
778+
flowId: get().currentFlow?.id,
779+
});
750780
},
751781
onBuildUpdate: handleBuildUpdate,
752782
onBuildError: (title: string, list: string[], elementList) => {
@@ -767,6 +797,10 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
767797
setErrorData({ list, title });
768798
get().setIsBuilding(false);
769799
get().buildController.abort();
800+
trackFlowBuild(get().currentFlow?.name ?? "Unknown", true, {
801+
flowId: get().currentFlow?.id,
802+
error: list,
803+
});
770804
},
771805
onBuildStart: (elementList) => {
772806
const idList = elementList

0 commit comments

Comments
 (0)