Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add tracking and custom param label #3902

Merged
merged 3 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import useHandleNodeClass from "@/CustomNodes/hooks/use-handle-node-class";
import { usePostTemplateValue } from "@/controllers/API/queries/nodes/use-post-template-value";
import {
CustomParameterComponent,
CustomParameterLabel,
getCustomParameterTitle,
} from "@/customization/components/custom-parameter";
import { useEffect, useRef } from "react";
Expand Down Expand Up @@ -104,42 +105,50 @@ export default function NodeInputField({
>
{displayHandle && Handle}
<div className="flex w-full flex-col gap-2">
<div className="flex w-full items-center truncate text-sm">
{proxy ? (
<ShadTooltip content={<span>{proxy.id}</span>}>
{
<span>
{getCustomParameterTitle({ title, nodeId: data.id })}
</span>
}
</ShadTooltip>
) : (
<div className="flex gap-2">
<span>
<div className="flex w-full items-center justify-between text-sm">
<div className="flex w-full items-center truncate">
{proxy ? (
<ShadTooltip content={<span>{proxy.id}</span>}>
{
<span>
{getCustomParameterTitle({ title, nodeId: data.id })}
</span>
}
</span>
</div>
)}
<span className={(required ? "ml-2 " : "") + "text-status-red"}>
{required ? "*" : ""}
</span>
<div className="">
{info !== "" && (
<ShadTooltip content={<NodeInputInfo info={info} />}>
{/* put div to avoid bug that does not display tooltip */}
<div className="cursor-help">
<IconComponent
name="Info"
className="relative bottom-px ml-1.5 h-3 w-4"
/>
</div>
</ShadTooltip>
) : (
<div className="flex gap-2">
<span>
{
<span>
{getCustomParameterTitle({ title, nodeId: data.id })}
</span>
}
</span>
</div>
)}
<span className={(required ? "ml-2 " : "") + "text-status-red"}>
{required ? "*" : ""}
</span>
<div className="">
{info !== "" && (
<ShadTooltip content={<NodeInputInfo info={info} />}>
{/* put div to avoid bug that does not display tooltip */}
<div className="cursor-help">
<IconComponent
name="Info"
className="relative bottom-px ml-1.5 h-3 w-4"
/>
</div>
</ShadTooltip>
)}
</div>
</div>
<CustomParameterLabel
name={name}
nodeId={data.id}
templateValue={data.node?.template[name]}
nodeClass={data.node!}
/>
</div>

{data.node?.template[name] !== undefined && (
Expand Down
3 changes: 3 additions & 0 deletions src/frontend/src/CustomNodes/hooks/use-handle-new-value.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { usePostTemplateValue } from "@/controllers/API/queries/nodes/use-post-template-value";
import { track } from "@/customization/utils/analytics";
import useAlertStore from "@/stores/alertStore";
import useFlowStore from "@/stores/flowStore";
import useFlowsManagerStore from "@/stores/flowsManagerStore";
Expand Down Expand Up @@ -45,6 +46,8 @@ const useHandleOnNewValue = ({
const newNode = cloneDeep(node);
const template = newNode.template;

track("Component Edited", { nodeId });

if (!template) {
setErrorData({ title: "Template not found in the component" });
return;
Expand Down
14 changes: 14 additions & 0 deletions src/frontend/src/customization/components/custom-parameter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,17 @@ export function getCustomParameterTitle({
}) {
return title;
}

export function CustomParameterLabel({
name,
nodeId,
templateValue,
nodeClass,
}: {
name: string;
nodeId: string;
templateValue: any;
nodeClass: APIClassType;
}) {
return <></>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function NewFlowCardComponent() {
addFlow().then((id) => {
navigate(`/flow/${id}${folderId ? `/folder/${folderId}` : ""}`);
});
track("New Flow Created: Blank Flow");
track("New Flow Created", { template: "Blank Flow" });
}}
className="h-64 w-80 cursor-pointer bg-background pt-4"
data-testid="blank-flow"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export default function UndrawCardComponent({
addFlow({ flow }).then((id) => {
navigate(`/flow/${id}/folder/${folderIdUrl}`);
});
track(`New Flow Created: ${flow.name} Template`);
track("New Flow Created", { template: `${flow.name} Template` });
}}
className="h-64 w-80 cursor-pointer bg-background pt-4"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@ export default function Page({ view }: { view?: boolean }): JSX.Element {
e.preventDefault();
(e as unknown as Event).stopImmediatePropagation();
takeSnapshot();
if (lastSelection.edges?.length) {
track("Component Connection Deleted");
}
if (lastSelection.nodes?.length) {
track("Component Deleted");
}
deleteNode(lastSelection.nodes.map((node) => node.id));
deleteEdge(lastSelection.edges.map((edge) => edge.id));
}
Expand Down Expand Up @@ -341,7 +347,7 @@ export default function Page({ view }: { view?: boolean }): JSX.Element {
event.dataTransfer.getData(datakey!),
);

track(`Component Added: ${data.node?.display_name}`);
track("Component Added", { componentType: data.node?.display_name });

const newId = getNodeId(data.type);

Expand Down
3 changes: 3 additions & 0 deletions src/frontend/src/stores/flowStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
BROKEN_EDGES_WARNING,
componentsToIgnoreUpdate,
} from "@/constants/constants";
import { track } from "@/customization/utils/analytics";
import { brokenEdgeMessage } from "@/utils/utils";
import { cloneDeep, zip } from "lodash";
import {
Expand Down Expand Up @@ -271,6 +272,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
: !nodeId.includes(node.id),
),
);
track("Component Deleted", { nodeId });
},
deleteEdge: (edgeId) => {
get().setEdges(
Expand All @@ -280,6 +282,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
: !edgeId.includes(edge.id),
),
);
track("Component Connection Deleted", { edgeId });
},
paste: (selection, position) => {
if (
Expand Down
Loading