From 0d8c7436f728e8c6c163b63ad38718b526f0daed Mon Sep 17 00:00:00 2001 From: "Wei-Chun, Chang" Date: Fri, 20 Dec 2024 17:48:08 +0800 Subject: [PATCH 1/6] Add telemetry for preview change Signed-off-by: Wei-Chun, Chang --- js/src/components/lineage/NodeView.tsx | 3 +++ js/src/components/lineage/PreviewChangeView.tsx | 2 ++ js/src/lib/api/track.ts | 16 ++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/js/src/components/lineage/NodeView.tsx b/js/src/components/lineage/NodeView.tsx index 4ccbd74a..9a56f794 100644 --- a/js/src/components/lineage/NodeView.tsx +++ b/js/src/components/lineage/NodeView.tsx @@ -46,6 +46,7 @@ import { is } from "date-fns/locale"; import { run } from "node:test"; import { DisableTooltipMessages } from "@/constants/tooltipMessage"; import { PreviewChangeView } from "./PreviewChangeView"; +import { trackPreviewChange } from "@/lib/api/track"; interface NodeViewProps { node: LineageGraphNode; @@ -154,6 +155,8 @@ export function NodeView({ node, onCloseNode }: NodeViewProps) { ); } onPreviewChangeOpen(); + onPreviewChangeOpen(); + trackPreviewChange({ action: "explore" }); }} > Preview Change (Experiment) diff --git a/js/src/components/lineage/PreviewChangeView.tsx b/js/src/components/lineage/PreviewChangeView.tsx index f8209af4..20a0ec75 100644 --- a/js/src/components/lineage/PreviewChangeView.tsx +++ b/js/src/components/lineage/PreviewChangeView.tsx @@ -33,6 +33,7 @@ import { useFeedbackCollectionToast } from "@/lib/hooks/useFeedbackCollectionToa import { VscFeedback } from "react-icons/vsc"; import { localStorageKeys } from "@/lib/api/localStorageKeys"; import { useRecceQueryContext } from "@/lib/hooks/RecceQueryContext"; +import { trackPreviewChange } from "@/lib/api/track"; interface PreviewChangeViewProps { isOpen: boolean; @@ -92,6 +93,7 @@ function PreviewChangeTopBar({ onRunResultOpen(); runQuery(); setTimeout(() => feedbackToast(), 3000); + trackPreviewChange({ action: "run" }); }} colorScheme="blue" isLoading={isPending} diff --git a/js/src/lib/api/track.ts b/js/src/lib/api/track.ts index 5e5d0cea..727761be 100644 --- a/js/src/lib/api/track.ts +++ b/js/src/lib/api/track.ts @@ -39,3 +39,19 @@ interface HistoryActionProps { export function trackHistoryAction(props: HistoryActionProps) { amplitude.track("[Web] history_action", props); } + +interface PreviewChangeProps { + action: "explore" | "run"; +} + +export function trackPreviewChange(props: PreviewChangeProps) { + amplitude.track("[Experiment] preview_change", props); +} + +interface PreviewChangeFeedbackProps { + feedback: "like" | "dislike"; +} + +export function trackPreviewChangeFeedback(props: PreviewChangeFeedbackProps) { + amplitude.track("[Experiment] preview_change", props); +} From 7754cbbefb78154f97c613dd7eb035045c592a44 Mon Sep 17 00:00:00 2001 From: "Wei-Chun, Chang" Date: Mon, 23 Dec 2024 16:11:52 +0800 Subject: [PATCH 2/6] Incloud node name in preview change event Signed-off-by: Wei-Chun, Chang --- js/src/components/lineage/NodeView.tsx | 2 +- js/src/components/lineage/PreviewChangeView.tsx | 2 +- js/src/lib/api/track.ts | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/js/src/components/lineage/NodeView.tsx b/js/src/components/lineage/NodeView.tsx index 9a56f794..be212e05 100644 --- a/js/src/components/lineage/NodeView.tsx +++ b/js/src/components/lineage/NodeView.tsx @@ -156,7 +156,7 @@ export function NodeView({ node, onCloseNode }: NodeViewProps) { } onPreviewChangeOpen(); onPreviewChangeOpen(); - trackPreviewChange({ action: "explore" }); + trackPreviewChange({ action: "explore", node: node.name }); }} > Preview Change (Experiment) diff --git a/js/src/components/lineage/PreviewChangeView.tsx b/js/src/components/lineage/PreviewChangeView.tsx index 20a0ec75..b2473523 100644 --- a/js/src/components/lineage/PreviewChangeView.tsx +++ b/js/src/components/lineage/PreviewChangeView.tsx @@ -93,7 +93,7 @@ function PreviewChangeTopBar({ onRunResultOpen(); runQuery(); setTimeout(() => feedbackToast(), 3000); - trackPreviewChange({ action: "run" }); + trackPreviewChange({ action: "run", node: current?.name }); }} colorScheme="blue" isLoading={isPending} diff --git a/js/src/lib/api/track.ts b/js/src/lib/api/track.ts index 727761be..a1cd7a88 100644 --- a/js/src/lib/api/track.ts +++ b/js/src/lib/api/track.ts @@ -42,6 +42,7 @@ export function trackHistoryAction(props: HistoryActionProps) { interface PreviewChangeProps { action: "explore" | "run"; + node?: string; } export function trackPreviewChange(props: PreviewChangeProps) { From 938646d09a417ddf0f632ffc4fe8a2478e55e615 Mon Sep 17 00:00:00 2001 From: "Wei-Chun, Chang" Date: Mon, 23 Dec 2024 18:39:40 +0800 Subject: [PATCH 3/6] Include close preview change modal event Signed-off-by: Wei-Chun, Chang --- js/src/components/lineage/PreviewChangeView.tsx | 1 + js/src/lib/api/track.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/js/src/components/lineage/PreviewChangeView.tsx b/js/src/components/lineage/PreviewChangeView.tsx index b2473523..9e9344ed 100644 --- a/js/src/components/lineage/PreviewChangeView.tsx +++ b/js/src/components/lineage/PreviewChangeView.tsx @@ -198,6 +198,7 @@ export function PreviewChangeView({ onRunResultClose(); clearRunResult(); closeToast(); + trackPreviewChange({ action: "close" }); }} > {/* */} diff --git a/js/src/lib/api/track.ts b/js/src/lib/api/track.ts index a1cd7a88..d6c5bae0 100644 --- a/js/src/lib/api/track.ts +++ b/js/src/lib/api/track.ts @@ -41,7 +41,7 @@ export function trackHistoryAction(props: HistoryActionProps) { } interface PreviewChangeProps { - action: "explore" | "run"; + action: "explore" | "run" | "close"; node?: string; } From acf5270ad895b8928af3ade98bc4b31f72ee2b36 Mon Sep 17 00:00:00 2001 From: "Wei-Chun, Chang" Date: Tue, 24 Dec 2024 07:42:02 +0800 Subject: [PATCH 4/6] Add feedback track Signed-off-by: Wei-Chun, Chang --- js/src/components/lineage/PreviewChangeView.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/js/src/components/lineage/PreviewChangeView.tsx b/js/src/components/lineage/PreviewChangeView.tsx index 9e9344ed..3f63cef6 100644 --- a/js/src/components/lineage/PreviewChangeView.tsx +++ b/js/src/components/lineage/PreviewChangeView.tsx @@ -33,7 +33,10 @@ import { useFeedbackCollectionToast } from "@/lib/hooks/useFeedbackCollectionToa import { VscFeedback } from "react-icons/vsc"; import { localStorageKeys } from "@/lib/api/localStorageKeys"; import { useRecceQueryContext } from "@/lib/hooks/RecceQueryContext"; -import { trackPreviewChange } from "@/lib/api/track"; +import { + trackPreviewChange, + trackPreviewChangeFeedback, +} from "@/lib/api/track"; interface PreviewChangeViewProps { isOpen: boolean; @@ -150,7 +153,6 @@ export function PreviewChangeView({ const queryFn = async () => { const sqlTemplate = modifiedCode; const runFn = submitQueryDiff; - console.log(primaryKeys); const params: QueryParams = { current_model: current?.name || "", primary_keys: primaryKeys, @@ -173,12 +175,10 @@ export function PreviewChangeView({ onFeedbackSubmit: (feedback: string) => { switch (feedback) { case "like": - console.log("Like"); - // TODO: track feedback result + trackPreviewChangeFeedback({ feedback: "like" }); break; case "dislike": - console.log("Dislike"); - // TODO: track feedback result + trackPreviewChangeFeedback({ feedback: "dislike" }); break; default: console.log("Not support feedback type"); From 54922e76f01395fe41e4b237189ce287e332ee35 Mon Sep 17 00:00:00 2001 From: "Wei-Chun, Chang" Date: Tue, 24 Dec 2024 07:46:39 +0800 Subject: [PATCH 5/6] Fix typo Signed-off-by: Wei-Chun, Chang --- js/src/components/lineage/NodeView.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/js/src/components/lineage/NodeView.tsx b/js/src/components/lineage/NodeView.tsx index be212e05..45b1f9ce 100644 --- a/js/src/components/lineage/NodeView.tsx +++ b/js/src/components/lineage/NodeView.tsx @@ -155,7 +155,6 @@ export function NodeView({ node, onCloseNode }: NodeViewProps) { ); } onPreviewChangeOpen(); - onPreviewChangeOpen(); trackPreviewChange({ action: "explore", node: node.name }); }} > From e03c98da46280382bc647ad385437a6f1615d0f7 Mon Sep 17 00:00:00 2001 From: "Wei-Chun, Chang" Date: Tue, 24 Dec 2024 16:33:54 +0800 Subject: [PATCH 6/6] Refine track event and props Signed-off-by: Wei-Chun, Chang --- .../components/lineage/PreviewChangeView.tsx | 29 ++++++++++++++++--- js/src/lib/api/track.ts | 4 ++- .../lib/hooks/useFeedbackCollectionToast.tsx | 12 +++++++- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/js/src/components/lineage/PreviewChangeView.tsx b/js/src/components/lineage/PreviewChangeView.tsx index 3f63cef6..4f790c12 100644 --- a/js/src/components/lineage/PreviewChangeView.tsx +++ b/js/src/components/lineage/PreviewChangeView.tsx @@ -96,7 +96,6 @@ function PreviewChangeTopBar({ onRunResultOpen(); runQuery(); setTimeout(() => feedbackToast(), 3000); - trackPreviewChange({ action: "run", node: current?.name }); }} colorScheme="blue" isLoading={isPending} @@ -168,17 +167,39 @@ export function PreviewChangeView({ }; const { mutate: runQuery, isPending } = useMutation({ mutationFn: queryFn, + onSuccess(data, variables) { + if (data.error) { + trackPreviewChange({ + action: "run", + node: current?.name, + status: "failure", + }); + } else { + trackPreviewChange({ + action: "run", + node: current?.name, + status: "success", + }); + } + }, }); const { feedbackToast, closeToast } = useFeedbackCollectionToast({ feedbackId: localStorageKeys.previewChangeFeedbackID, description: "Enjoy preview change?", + onFeedbackSubmit: (feedback: string) => { switch (feedback) { case "like": - trackPreviewChangeFeedback({ feedback: "like" }); + trackPreviewChangeFeedback({ feedback: "like", node: current?.name }); break; case "dislike": - trackPreviewChangeFeedback({ feedback: "dislike" }); + trackPreviewChangeFeedback({ + feedback: "dislike", + node: current?.name, + }); + break; + case "link": + trackPreviewChangeFeedback({ feedback: "form", node: current?.name }); break; default: console.log("Not support feedback type"); @@ -198,7 +219,7 @@ export function PreviewChangeView({ onRunResultClose(); clearRunResult(); closeToast(); - trackPreviewChange({ action: "close" }); + trackPreviewChange({ action: "close", node: current?.name }); }} > {/* */} diff --git a/js/src/lib/api/track.ts b/js/src/lib/api/track.ts index d6c5bae0..b8d07fe7 100644 --- a/js/src/lib/api/track.ts +++ b/js/src/lib/api/track.ts @@ -43,6 +43,7 @@ export function trackHistoryAction(props: HistoryActionProps) { interface PreviewChangeProps { action: "explore" | "run" | "close"; node?: string; + status?: "success" | "failure"; } export function trackPreviewChange(props: PreviewChangeProps) { @@ -50,7 +51,8 @@ export function trackPreviewChange(props: PreviewChangeProps) { } interface PreviewChangeFeedbackProps { - feedback: "like" | "dislike"; + feedback: "like" | "dislike" | "form"; + node?: string; } export function trackPreviewChangeFeedback(props: PreviewChangeFeedbackProps) { diff --git a/js/src/lib/hooks/useFeedbackCollectionToast.tsx b/js/src/lib/hooks/useFeedbackCollectionToast.tsx index 2d0578e3..4ab3ea02 100644 --- a/js/src/lib/hooks/useFeedbackCollectionToast.tsx +++ b/js/src/lib/hooks/useFeedbackCollectionToast.tsx @@ -14,12 +14,14 @@ function ReactionFeedback({ description, onLike, onDislike, + onClickLink, externalLink, externalLinkText, }: { description: string; onLike: () => void; onDislike: () => void; + onClickLink: () => void; externalLink?: string; externalLinkText?: string; }) { @@ -48,7 +50,12 @@ function ReactionFeedback({ onClick={onDislike} /> {externalLink && externalLinkText && ( - + {externalLinkText} )} @@ -113,6 +120,9 @@ export function useFeedbackCollectionToast(options: { }} externalLink={externalLink} externalLinkText={externalLinkText} + onClickLink={() => { + onFeedbackSubmit("link"); + }} />