Skip to content

Commit

Permalink
Refine track event and props
Browse files Browse the repository at this point in the history
Signed-off-by: Wei-Chun, Chang <[email protected]>
  • Loading branch information
wcchang1115 committed Dec 24, 2024
1 parent 54922e7 commit e03c98d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
29 changes: 25 additions & 4 deletions js/src/components/lineage/PreviewChangeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ function PreviewChangeTopBar({
onRunResultOpen();
runQuery();
setTimeout(() => feedbackToast(), 3000);
trackPreviewChange({ action: "run", node: current?.name });
}}
colorScheme="blue"
isLoading={isPending}
Expand Down Expand Up @@ -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");
Expand All @@ -198,7 +219,7 @@ export function PreviewChangeView({
onRunResultClose();
clearRunResult();
closeToast();
trackPreviewChange({ action: "close" });
trackPreviewChange({ action: "close", node: current?.name });
}}
>
{/* <ModalOverlay /> */}
Expand Down
4 changes: 3 additions & 1 deletion js/src/lib/api/track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,16 @@ export function trackHistoryAction(props: HistoryActionProps) {
interface PreviewChangeProps {
action: "explore" | "run" | "close";
node?: string;
status?: "success" | "failure";
}

export function trackPreviewChange(props: PreviewChangeProps) {
amplitude.track("[Experiment] preview_change", props);
}

interface PreviewChangeFeedbackProps {
feedback: "like" | "dislike";
feedback: "like" | "dislike" | "form";
node?: string;
}

export function trackPreviewChangeFeedback(props: PreviewChangeFeedbackProps) {
Expand Down
12 changes: 11 additions & 1 deletion js/src/lib/hooks/useFeedbackCollectionToast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ function ReactionFeedback({
description,
onLike,
onDislike,
onClickLink,
externalLink,
externalLinkText,
}: {
description: string;
onLike: () => void;
onDislike: () => void;
onClickLink: () => void;
externalLink?: string;
externalLinkText?: string;
}) {
Expand Down Expand Up @@ -48,7 +50,12 @@ function ReactionFeedback({
onClick={onDislike}
/>
{externalLink && externalLinkText && (
<Link href={externalLink} isExternal textDecoration="underline">
<Link
href={externalLink}
isExternal
textDecoration="underline"
onClick={onClickLink}
>
{externalLinkText}
</Link>
)}
Expand Down Expand Up @@ -113,6 +120,9 @@ export function useFeedbackCollectionToast(options: {
}}
externalLink={externalLink}
externalLinkText={externalLinkText}
onClickLink={() => {
onFeedbackSubmit("link");
}}
/>
<CloseButton onClick={onClose} />
</HStack>
Expand Down

0 comments on commit e03c98d

Please sign in to comment.