Skip to content

Commit

Permalink
add mutation and trackEvent to saveResumeButton
Browse files Browse the repository at this point in the history
  • Loading branch information
RODO94 committed Nov 19, 2024
1 parent 8bb6ad3 commit 6481933
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ const SaveResumeButton: React.FC = () => {
const saveToEmail = useStore((state) => state.saveToEmail);
const { trackEvent } = useAnalyticsTracking();

const handleClick = () => {
const handleClick = async () => {
if (saveToEmail) {
trackEvent({ event: "saveClick", metadata: {} });
trackEvent({
event: "flowDirectionChange",
metadata: null,
Expand Down
12 changes: 12 additions & 0 deletions editor.planx.uk/src/pages/FlowEditor/lib/analytics/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ export const UPDATE_HAS_CLICKED_HELP = gql`
}
`;

export const UPDATE_HAS_USER_CLICKED_SAVE = gql`
mutation UpdateHasClickedSave($id: bigint!, $metadata: jsonb = {}) {
update_analytics_logs_by_pk(
pk_columns: { id: $id }
_set: { has_user_clicked_save: true }
_append: { metadata: $metadata }
) {
id
}
}
`;

export const UPDATE_ANALYTICS_LOG_METADATA = gql`
mutation UpdateAnalyticsLogMetadata($id: bigint!, $metadata: jsonb = {}) {
update_analytics_logs_by_pk(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
UPDATE_ANALYTICS_LOG_METADATA,
UPDATE_FLOW_DIRECTION,
UPDATE_HAS_CLICKED_HELP,
UPDATE_HAS_USER_CLICKED_SAVE,
UPDATE_NEXT_LOG_CREATED_AT,
} from "./mutations";
import {
Expand Down Expand Up @@ -270,6 +271,9 @@ export const AnalyticsProvider: React.FC<{ children: React.ReactNode }> = ({
case "helpClick":
updateMetadata(UPDATE_HAS_CLICKED_HELP, metadata);
return;
case "saveClick":
updateMetadata(UPDATE_HAS_USER_CLICKED_SAVE, metadata);
return;
case "nextStepsClick":
case "helpTextFeedback":
updateMetadata(UPDATE_ANALYTICS_LOG_METADATA, metadata);
Expand Down

0 comments on commit 6481933

Please sign in to comment.