From aa1f3f5da10aa538a502b452c03f197d32ed9221 Mon Sep 17 00:00:00 2001 From: Mohamed Khelif Date: Thu, 27 Jun 2024 10:32:56 -0400 Subject: [PATCH] DEVPROD-8367 Update analytics event names for annotation actions (#206) --- .../analytics/task/useAnnotationAnalytics.ts | 28 ++++++++----------- .../AddIssueModal/index.tsx | 8 +++--- .../AnnotationNote.tsx | 2 +- .../AnnotationTicketRow/index.tsx | 3 +- .../AnnotationTicketsList/index.tsx | 14 ++++------ .../FileTicketButton.tsx | 2 +- .../Issues/AnnotationTickets.tsx | 9 +++--- .../JiraTicketRow_Default.storyshot | 2 +- .../JiraTicketList/JiraTicketRow/index.tsx | 7 +++-- 9 files changed, 36 insertions(+), 39 deletions(-) diff --git a/apps/spruce/src/analytics/task/useAnnotationAnalytics.ts b/apps/spruce/src/analytics/task/useAnnotationAnalytics.ts index 97d250e81..916779dae 100644 --- a/apps/spruce/src/analytics/task/useAnnotationAnalytics.ts +++ b/apps/spruce/src/analytics/task/useAnnotationAnalytics.ts @@ -13,18 +13,16 @@ import { useQueryParam } from "hooks/useQueryParam"; import { RequiredQueryParams } from "types/task"; type Action = - | { name: "Click Jira Summary Link" } - | { name: "Build Baron File Ticket" } - | { name: "Save Annotation Note" } - | { name: "Click Annotation Ticket Link" } - | { name: "Remove Annotation Issue" } - | { name: "Remove Annotation Suspected Issue" } - | { name: "Move Annotation Issue" } - | { name: "Move Annotation Suspected Issue" } - | { name: "Click Add Annotation Issue Button" } - | { name: "Click Add Annotation Suspected Issue Button" } - | { name: "Add Task Annotation Issue" } - | { name: "Add Task Annotation Suspected Issue" }; + | { name: "Clicked Jira ticket summary link" } + | { name: "Filed Build Baron ticket" } + | { name: "Saved annotation note" } + | { name: "Moved annotation"; type: "Issue" | "Suspected Issue" } + | { + name: "Clicked annotation link"; + target: "Jira ticket link"; + } + | { name: "Removed annotation"; type: "Issue" | "Suspected Issue" } + | { name: "Add task annotation"; type: "Issue" | "Suspected Issue" }; export const useAnnotationAnalytics = () => { const { [slugs.taskId]: taskId } = useParams(); @@ -34,16 +32,14 @@ export const useAnnotationAnalytics = () => { AnnotationEventDataQuery, AnnotationEventDataQueryVariables >(ANNOTATION_EVENT_DATA, { - // @ts-expect-error: FIXME. This comment was added by an automated script. - variables: { taskId, execution }, + variables: { taskId: taskId || "", execution }, fetchPolicy: "cache-first", }); const { data: bbData } = useQuery( BUILD_BARON, { - // @ts-expect-error: FIXME. This comment was added by an automated script. - variables: { taskId, execution }, + variables: { taskId: taskId || "", execution }, fetchPolicy: "cache-first", }, ); diff --git a/apps/spruce/src/pages/task/taskTabs/buildBaronAndAnnotations/AddIssueModal/index.tsx b/apps/spruce/src/pages/task/taskTabs/buildBaronAndAnnotations/AddIssueModal/index.tsx index f3ceb1bf4..db7be18e0 100644 --- a/apps/spruce/src/pages/task/taskTabs/buildBaronAndAnnotations/AddIssueModal/index.tsx +++ b/apps/spruce/src/pages/task/taskTabs/buildBaronAndAnnotations/AddIssueModal/index.tsx @@ -40,9 +40,6 @@ export const AddIssueModal: React.FC = ({ const dispatchToast = useToastContext(); const title = isIssue ? "Add Issue" : "Add Suspected Issue"; const issueString = isIssue ? "issue" : "suspected issue"; - const analyticsType = isIssue - ? "Add Task Annotation Issue" - : "Add Task Annotation Suspected Issue"; const [canSubmit, setCanSubmit] = useState(false); const [formState, setFormState] = useState({ @@ -62,7 +59,10 @@ export const AddIssueModal: React.FC = ({ // @ts-expect-error: FIXME. This comment was added by an automated script. setSelectedRowKey(issueKey); closeModal(); - annotationAnalytics.sendEvent({ name: analyticsType }); + annotationAnalytics.sendEvent({ + name: "Add task annotation", + type: isIssue ? "Issue" : "Suspected Issue", + }); }, onError(error) { closeModal(); diff --git a/apps/spruce/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationNote.tsx b/apps/spruce/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationNote.tsx index 040334b6f..dd962f69f 100644 --- a/apps/spruce/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationNote.tsx +++ b/apps/spruce/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationNote.tsx @@ -59,7 +59,7 @@ const AnnotationNote: React.FC = ({ newMessage, }, }); - annotationAnalytics.sendEvent({ name: "Save Annotation Note" }); + annotationAnalytics.sendEvent({ name: "Saved annotation note" }); }; return ( diff --git a/apps/spruce/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsList/AnnotationTicketRow/index.tsx b/apps/spruce/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsList/AnnotationTicketRow/index.tsx index 697a5bcb1..2436bf200 100644 --- a/apps/spruce/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsList/AnnotationTicketRow/index.tsx +++ b/apps/spruce/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsList/AnnotationTicketRow/index.tsx @@ -45,7 +45,8 @@ const AnnotationTicketRow: React.FC = ({ data-cy={issueKey} onClick={() => annotationAnalytics.sendEvent({ - name: "Click Annotation Ticket Link", + name: "Clicked annotation link", + target: "Jira ticket link", }) } > diff --git a/apps/spruce/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsList/index.tsx b/apps/spruce/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsList/index.tsx index 7574c03bd..ac5ba4932 100644 --- a/apps/spruce/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsList/index.tsx +++ b/apps/spruce/src/pages/task/taskTabs/buildBaronAndAnnotations/AnnotationTicketsList/index.tsx @@ -77,11 +77,10 @@ const AnnotationTicketsList: React.FC = ({ issueKey, }; removeAnnotation({ variables: { taskId, execution, apiIssue, isIssue } }); - const analyticsType = isIssue - ? "Remove Annotation Issue" - : "Remove Annotation Suspected Issue"; + annotationAnalytics.sendEvent({ - name: analyticsType, + name: "Removed annotation", + type: isIssue ? "Issue" : "Suspected Issue", }); }; @@ -91,12 +90,11 @@ const AnnotationTicketsList: React.FC = ({ confidenceScore: number; }): void => { moveAnnotation({ variables: { taskId, execution, apiIssue, isIssue } }); - const analyticsType = isIssue - ? "Move Annotation Issue" - : "Move Annotation Suspected Issue"; + setSelectedRowKey(apiIssue.issueKey); annotationAnalytics.sendEvent({ - name: analyticsType, + name: "Moved annotation", + type: isIssue ? "Issue" : "Suspected Issue", }); }; diff --git a/apps/spruce/src/pages/task/taskTabs/buildBaronAndAnnotations/FileTicketButton.tsx b/apps/spruce/src/pages/task/taskTabs/buildBaronAndAnnotations/FileTicketButton.tsx index 656dfdc26..d4d0df2bb 100644 --- a/apps/spruce/src/pages/task/taskTabs/buildBaronAndAnnotations/FileTicketButton.tsx +++ b/apps/spruce/src/pages/task/taskTabs/buildBaronAndAnnotations/FileTicketButton.tsx @@ -40,7 +40,7 @@ const FileTicketButton: React.FC = ({ execution, taskId }) => { const [buttonText, setButtonText] = useState("File ticket"); const annotationAnalytics = useAnnotationAnalytics(); const onClickFile = () => { - annotationAnalytics.sendEvent({ name: "Build Baron File Ticket" }); + annotationAnalytics.sendEvent({ name: "Filed Build Baron ticket" }); fileJiraTicket({ variables: { taskId, execution } }); }; diff --git a/apps/spruce/src/pages/task/taskTabs/buildBaronAndAnnotations/Issues/AnnotationTickets.tsx b/apps/spruce/src/pages/task/taskTabs/buildBaronAndAnnotations/Issues/AnnotationTickets.tsx index fab3c5219..d282222bb 100644 --- a/apps/spruce/src/pages/task/taskTabs/buildBaronAndAnnotations/Issues/AnnotationTickets.tsx +++ b/apps/spruce/src/pages/task/taskTabs/buildBaronAndAnnotations/Issues/AnnotationTickets.tsx @@ -38,10 +38,11 @@ const AnnotationTickets: React.FC = ({ const handleAdd = () => { setIsAddAnnotationModalVisible(true); - const analyticsType = isIssue - ? "Click Add Annotation Issue Button" - : "Click Add Annotation Suspected Issue Button"; - annotationAnalytics.sendEvent({ name: analyticsType }); + + annotationAnalytics.sendEvent({ + name: "Add task annotation", + type: isIssue ? "Issue" : "Suspected Issue", + }); }; return ( <> diff --git a/apps/spruce/src/pages/task/taskTabs/buildBaronAndAnnotations/JiraTicketList/JiraTicketRow/__snapshots__/JiraTicketRow_Default.storyshot b/apps/spruce/src/pages/task/taskTabs/buildBaronAndAnnotations/JiraTicketList/JiraTicketRow/__snapshots__/JiraTicketRow_Default.storyshot index 7e98081d8..9a81ce9fc 100644 --- a/apps/spruce/src/pages/task/taskTabs/buildBaronAndAnnotations/JiraTicketList/JiraTicketRow/__snapshots__/JiraTicketRow_Default.storyshot +++ b/apps/spruce/src/pages/task/taskTabs/buildBaronAndAnnotations/JiraTicketList/JiraTicketRow/__snapshots__/JiraTicketRow_Default.storyshot @@ -6,7 +6,7 @@ = ({ fields, jiraKey }) => { const getDateCopy = useDateFormat(); const spruceConfig = useSpruceConfig(); const jiraHost = spruceConfig?.jira?.host; - // @ts-expect-error: FIXME. This comment was added by an automated script. - const url = getJiraTicketUrl(jiraHost, jiraKey); + const url = getJiraTicketUrl(jiraHost || "", jiraKey); const { assigneeDisplayName, created, status, summary, updated } = fields ?? {}; return ( @@ -28,7 +27,9 @@ const JiraTicketRow: React.FC = ({ fields, jiraKey }) => { href={url} data-cy={jiraKey} onClick={() => - annotationAnalytics.sendEvent({ name: "Click Jira Summary Link" }) + annotationAnalytics.sendEvent({ + name: "Clicked Jira ticket summary link", + }) } title={summary} >