Skip to content

Commit

Permalink
DEVPROD-8367 Update analytics event names for annotation actions (#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
khelif96 authored Jun 27, 2024
1 parent afd1d71 commit aa1f3f5
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 39 deletions.
28 changes: 12 additions & 16 deletions apps/spruce/src/analytics/task/useAnnotationAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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<BuildBaronQuery, BuildBaronQueryVariables>(
BUILD_BARON,
{
// @ts-expect-error: FIXME. This comment was added by an automated script.
variables: { taskId, execution },
variables: { taskId: taskId || "", execution },
fetchPolicy: "cache-first",
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ export const AddIssueModal: React.FC<Props> = ({
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({
Expand All @@ -62,7 +59,10 @@ export const AddIssueModal: React.FC<Props> = ({
// @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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const AnnotationNote: React.FC<Props> = ({
newMessage,
},
});
annotationAnalytics.sendEvent({ name: "Save Annotation Note" });
annotationAnalytics.sendEvent({ name: "Saved annotation note" });
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ const AnnotationTicketRow: React.FC<AnnotationTicketRowProps> = ({
data-cy={issueKey}
onClick={() =>
annotationAnalytics.sendEvent({
name: "Click Annotation Ticket Link",
name: "Clicked annotation link",
target: "Jira ticket link",
})
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,10 @@ const AnnotationTicketsList: React.FC<AnnotationTicketsListProps> = ({
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",
});
};

Expand All @@ -91,12 +90,11 @@ const AnnotationTicketsList: React.FC<AnnotationTicketsListProps> = ({
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",
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const FileTicketButton: React.FC<FileTicketProps> = ({ execution, taskId }) => {
const [buttonText, setButtonText] = useState<string>("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 } });
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ const AnnotationTickets: React.FC<AnnotationTicketsProps> = ({

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 (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<a
class="lg-ui-0001 e1fnmnn30 css-1a8dqbm-StyledLink-JiraSummaryLink leafygreen-ui-sv8tvj"
data-cy="DEVPROD-123"
href="https://undefined/browse/DEVPROD-123"
href="https:///browse/DEVPROD-123"
rel="noopener noreferrer"
target="_blank"
title="Create the JiraTicketRow component"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ const JiraTicketRow: React.FC<JiraTicketRowProps> = ({ 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 (
Expand All @@ -28,7 +27,9 @@ const JiraTicketRow: React.FC<JiraTicketRowProps> = ({ 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}
>
Expand Down

0 comments on commit aa1f3f5

Please sign in to comment.