From 18f6e0ef01d815184fb2cf3458256dc2de58bf67 Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Mon, 18 Nov 2024 15:30:56 +0000 Subject: [PATCH 1/9] add user_clicked_save to analytics views --- .../down.sql | 57 ++++++++++++++++++ .../up.sql | 59 +++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 hasura.planx.uk/migrations/1731943657237_add_user_click_save_to_analytics_summary/down.sql create mode 100644 hasura.planx.uk/migrations/1731943657237_add_user_click_save_to_analytics_summary/up.sql diff --git a/hasura.planx.uk/migrations/1731943657237_add_user_click_save_to_analytics_summary/down.sql b/hasura.planx.uk/migrations/1731943657237_add_user_click_save_to_analytics_summary/down.sql new file mode 100644 index 0000000000..c5fcce5e81 --- /dev/null +++ b/hasura.planx.uk/migrations/1731943657237_add_user_click_save_to_analytics_summary/down.sql @@ -0,0 +1,57 @@ +CREATE OR REPLACE VIEW "public"."analytics_summary" AS + SELECT a.id AS analytics_id, + al.id AS analytics_log_id, + f.slug AS service_slug, + t.slug AS team_slug, + a.type AS analytics_type, + al.created_at AS analytics_log_created_at, + a.created_at AS analytics_created_at, + ((a.user_agent -> 'os'::text) ->> 'name'::text) AS operating_system, + ((a.user_agent -> 'browser'::text) ->> 'name'::text) AS browser, + ((a.user_agent -> 'platform'::text) ->> 'type'::text) AS platform, + a.referrer, + al.flow_direction, + (al.metadata ->> 'change'::text) AS change_metadata, + (al.metadata ->> 'back'::text) AS back_metadata, + (al.metadata ->> 'selectedUrls'::text) AS selected_urls, + (al.metadata ->> 'flag'::text) AS result_flag, + ((al.metadata -> 'flagSet'::text))::text AS result_flagset, + ((al.metadata -> 'displayText'::text) ->> 'heading'::text) AS result_heading, + ((al.metadata -> 'displayText'::text) ->> 'description'::text) AS result_description, + ((al.metadata -> 'helpTextUseful'::text))::text AS help_text_useful, + CASE + WHEN al.has_clicked_help THEN al.metadata + ELSE NULL::jsonb + END AS help_metadata, + al.user_exit AS is_user_exit, + al.node_type, + al.node_title, + al.has_clicked_help, + al.input_errors, + (date_part('epoch'::text, (al.next_log_created_at - al.created_at)))::numeric(10,1) AS time_spent_on_node_seconds, + a.ended_at AS analytics_ended_at, + ((date_part('epoch'::text, (a.ended_at - a.created_at)) / (60)::double precision))::numeric(10,1) AS time_spent_on_analytics_session_minutes, + al.node_id, + al.allow_list_answers, + ((al.allow_list_answers -> 'proposal.projectType'::text))::text AS proposal_project_type, + ((al.allow_list_answers -> 'application.declaration.connection'::text))::text AS application_declaration_connection, + ((al.allow_list_answers -> 'property.type'::text))::text AS property_type, + ((al.allow_list_answers -> 'drawBoundary.action'::text))::text AS draw_boundary_action, + ((al.allow_list_answers -> 'user.role'::text))::text AS user_role, + ((al.allow_list_answers -> 'property.constraints.planning'::text))::text AS property_constraints_planning, + ((al.allow_list_answers -> 'findProperty.action'::text))::text AS find_property_action, + ((al.allow_list_answers -> 'usedFOIYNPP'::text))::text AS used_foiynpp, + ((al.allow_list_answers -> 'propertyInformation.action'::text))::text AS property_information_action, + ((al.allow_list_answers -> 'planningConstraints.action'::text))::text AS planning_constraints_action, + ((al.allow_list_answers -> '_overrides'::text))::text AS overrides, + ((al.allow_list_answers -> 'rab.exitReason'::text))::text AS rab_exit_reason, + ((al.allow_list_answers -> 'service.type'::text))::text AS pre_app_service_type, + ((al.allow_list_answers -> 'application.information.harmful'::text))::text AS pre_app_harmful_info, + ((al.allow_list_answers -> 'application.information.sensitive'::text))::text AS pre_app_sensitive_info, + (((al.allow_list_answers -> 'application.type'::text) -> 0))::text AS application_type, + FROM (((analytics a + LEFT JOIN analytics_logs al ON ((a.id = al.analytics_id))) + LEFT JOIN flows f ON ((a.flow_id = f.id))) + LEFT JOIN teams t ON ((t.id = f.team_id))); + + GRANT SELECT ON "public"."analytics_summary" TO metabase_read_only; diff --git a/hasura.planx.uk/migrations/1731943657237_add_user_click_save_to_analytics_summary/up.sql b/hasura.planx.uk/migrations/1731943657237_add_user_click_save_to_analytics_summary/up.sql new file mode 100644 index 0000000000..c1d8e585f9 --- /dev/null +++ b/hasura.planx.uk/migrations/1731943657237_add_user_click_save_to_analytics_summary/up.sql @@ -0,0 +1,59 @@ +CREATE OR REPLACE VIEW "public"."analytics_summary" AS + SELECT a.id AS analytics_id, + al.id AS analytics_log_id, + f.slug AS service_slug, + t.slug AS team_slug, + a.type AS analytics_type, + al.created_at AS analytics_log_created_at, + a.created_at AS analytics_created_at, + ((a.user_agent -> 'os'::text) ->> 'name'::text) AS operating_system, + ((a.user_agent -> 'browser'::text) ->> 'name'::text) AS browser, + ((a.user_agent -> 'platform'::text) ->> 'type'::text) AS platform, + a.referrer, + al.flow_direction, + (al.metadata ->> 'change'::text) AS change_metadata, + (al.metadata ->> 'back'::text) AS back_metadata, + (al.metadata ->> 'selectedUrls'::text) AS selected_urls, + (al.metadata ->> 'flag'::text) AS result_flag, + ((al.metadata -> 'flagSet'::text))::text AS result_flagset, + ((al.metadata -> 'displayText'::text) ->> 'heading'::text) AS result_heading, + ((al.metadata -> 'displayText'::text) ->> 'description'::text) AS result_description, + ((al.metadata -> 'helpTextUseful'::text))::text AS help_text_useful, + CASE + WHEN al.has_clicked_help THEN al.metadata + ELSE NULL::jsonb + END AS help_metadata, + al.user_exit AS is_user_exit, + al.node_type, + al.node_title, + al.has_clicked_help, + al.input_errors, + (date_part('epoch'::text, (al.next_log_created_at - al.created_at)))::numeric(10,1) AS time_spent_on_node_seconds, + a.ended_at AS analytics_ended_at, + ((date_part('epoch'::text, (a.ended_at - a.created_at)) / (60)::double precision))::numeric(10,1) AS time_spent_on_analytics_session_minutes, + al.node_id, + al.allow_list_answers, + ((al.allow_list_answers -> 'proposal.projectType'::text))::text AS proposal_project_type, + ((al.allow_list_answers -> 'application.declaration.connection'::text))::text AS application_declaration_connection, + ((al.allow_list_answers -> 'property.type'::text))::text AS property_type, + ((al.allow_list_answers -> 'drawBoundary.action'::text))::text AS draw_boundary_action, + ((al.allow_list_answers -> 'user.role'::text))::text AS user_role, + ((al.allow_list_answers -> 'property.constraints.planning'::text))::text AS property_constraints_planning, + ((al.allow_list_answers -> 'findProperty.action'::text))::text AS find_property_action, + ((al.allow_list_answers -> 'usedFOIYNPP'::text))::text AS used_foiynpp, + ((al.allow_list_answers -> 'propertyInformation.action'::text))::text AS property_information_action, + ((al.allow_list_answers -> 'planningConstraints.action'::text))::text AS planning_constraints_action, + ((al.allow_list_answers -> '_overrides'::text))::text AS overrides, + ((al.allow_list_answers -> 'rab.exitReason'::text))::text AS rab_exit_reason, + ((al.allow_list_answers -> 'service.type'::text))::text AS pre_app_service_type, + ((al.allow_list_answers -> 'application.information.harmful'::text))::text AS pre_app_harmful_info, + ((al.allow_list_answers -> 'application.information.sensitive'::text))::text AS pre_app_sensitive_info, + (((al.allow_list_answers -> 'application.type'::text) -> 0))::text AS application_type, + ls.has_user_saved AS user_clicked_save + FROM (((analytics a + LEFT JOIN analytics_logs al ON ((a.id = al.analytics_id))) + LEFT JOIN flows f ON ((a.flow_id = f.id))) + LEFT JOIN teams t ON ((t.id = f.team_id))) + LEFT JOIN lowcal_sessions ls ON ((ls.flow_id = a.flow_id)); + + GRANT SELECT ON "public"."analytics_summary" TO metabase_read_only; From 004661daf890c88dfb0fdaf25e44ec0da97f69bf Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Tue, 19 Nov 2024 11:50:39 +0000 Subject: [PATCH 2/9] init work to setup db for new track event --- .../pages/FlowEditor/lib/analytics/types.ts | 10 +++- hasura.planx.uk/metadata/tables.yaml | 2 + .../down.sql | 57 ------------------ .../up.sql | 59 ------------------- .../down.sql | 1 + .../up.sql | 2 + 6 files changed, 14 insertions(+), 117 deletions(-) delete mode 100644 hasura.planx.uk/migrations/1731943657237_add_user_click_save_to_analytics_summary/down.sql delete mode 100644 hasura.planx.uk/migrations/1731943657237_add_user_click_save_to_analytics_summary/up.sql create mode 100644 hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/down.sql create mode 100644 hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/up.sql diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/analytics/types.ts b/editor.planx.uk/src/pages/FlowEditor/lib/analytics/types.ts index fda09035d2..bd9a435443 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/analytics/types.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/analytics/types.ts @@ -32,6 +32,8 @@ export type AllowListKey = (typeof ALLOW_LIST)[number]; */ export type HelpClickMetadata = Record; +export type SaveClickMetadata = Record; + export type SelectedUrlsMetadata = Record<"selectedUrls", string[]>; export type BackwardsNavigationInitiatorType = "change" | "back"; @@ -95,7 +97,8 @@ export type EventData = | BackwardsNavigation | FlowDirectionChange | InputErrors - | HelpTextFeedback; + | HelpTextFeedback + | SaveClick; /** * Capture when a user clicks on the `More Information` i.e. the help on a @@ -108,6 +111,11 @@ type HelpClick = { metadata: HelpClickMetadata; }; +type SaveClick = { + event: "saveClick"; + metadata: SaveClickMetadata; +}; + /** * A user gets to a `NextSteps` component. Track every time a user selects a * link and appends it to the array. diff --git a/hasura.planx.uk/metadata/tables.yaml b/hasura.planx.uk/metadata/tables.yaml index fcf2b0f3ea..f7532e7fc4 100644 --- a/hasura.planx.uk/metadata/tables.yaml +++ b/hasura.planx.uk/metadata/tables.yaml @@ -55,6 +55,7 @@ - created_at - flow_direction - has_clicked_help + - has_user_clicked_save - id - input_errors - metadata @@ -79,6 +80,7 @@ - allow_list_answers - flow_direction - has_clicked_help + - has_user_clicked_save - input_errors - metadata - next_log_created_at diff --git a/hasura.planx.uk/migrations/1731943657237_add_user_click_save_to_analytics_summary/down.sql b/hasura.planx.uk/migrations/1731943657237_add_user_click_save_to_analytics_summary/down.sql deleted file mode 100644 index c5fcce5e81..0000000000 --- a/hasura.planx.uk/migrations/1731943657237_add_user_click_save_to_analytics_summary/down.sql +++ /dev/null @@ -1,57 +0,0 @@ -CREATE OR REPLACE VIEW "public"."analytics_summary" AS - SELECT a.id AS analytics_id, - al.id AS analytics_log_id, - f.slug AS service_slug, - t.slug AS team_slug, - a.type AS analytics_type, - al.created_at AS analytics_log_created_at, - a.created_at AS analytics_created_at, - ((a.user_agent -> 'os'::text) ->> 'name'::text) AS operating_system, - ((a.user_agent -> 'browser'::text) ->> 'name'::text) AS browser, - ((a.user_agent -> 'platform'::text) ->> 'type'::text) AS platform, - a.referrer, - al.flow_direction, - (al.metadata ->> 'change'::text) AS change_metadata, - (al.metadata ->> 'back'::text) AS back_metadata, - (al.metadata ->> 'selectedUrls'::text) AS selected_urls, - (al.metadata ->> 'flag'::text) AS result_flag, - ((al.metadata -> 'flagSet'::text))::text AS result_flagset, - ((al.metadata -> 'displayText'::text) ->> 'heading'::text) AS result_heading, - ((al.metadata -> 'displayText'::text) ->> 'description'::text) AS result_description, - ((al.metadata -> 'helpTextUseful'::text))::text AS help_text_useful, - CASE - WHEN al.has_clicked_help THEN al.metadata - ELSE NULL::jsonb - END AS help_metadata, - al.user_exit AS is_user_exit, - al.node_type, - al.node_title, - al.has_clicked_help, - al.input_errors, - (date_part('epoch'::text, (al.next_log_created_at - al.created_at)))::numeric(10,1) AS time_spent_on_node_seconds, - a.ended_at AS analytics_ended_at, - ((date_part('epoch'::text, (a.ended_at - a.created_at)) / (60)::double precision))::numeric(10,1) AS time_spent_on_analytics_session_minutes, - al.node_id, - al.allow_list_answers, - ((al.allow_list_answers -> 'proposal.projectType'::text))::text AS proposal_project_type, - ((al.allow_list_answers -> 'application.declaration.connection'::text))::text AS application_declaration_connection, - ((al.allow_list_answers -> 'property.type'::text))::text AS property_type, - ((al.allow_list_answers -> 'drawBoundary.action'::text))::text AS draw_boundary_action, - ((al.allow_list_answers -> 'user.role'::text))::text AS user_role, - ((al.allow_list_answers -> 'property.constraints.planning'::text))::text AS property_constraints_planning, - ((al.allow_list_answers -> 'findProperty.action'::text))::text AS find_property_action, - ((al.allow_list_answers -> 'usedFOIYNPP'::text))::text AS used_foiynpp, - ((al.allow_list_answers -> 'propertyInformation.action'::text))::text AS property_information_action, - ((al.allow_list_answers -> 'planningConstraints.action'::text))::text AS planning_constraints_action, - ((al.allow_list_answers -> '_overrides'::text))::text AS overrides, - ((al.allow_list_answers -> 'rab.exitReason'::text))::text AS rab_exit_reason, - ((al.allow_list_answers -> 'service.type'::text))::text AS pre_app_service_type, - ((al.allow_list_answers -> 'application.information.harmful'::text))::text AS pre_app_harmful_info, - ((al.allow_list_answers -> 'application.information.sensitive'::text))::text AS pre_app_sensitive_info, - (((al.allow_list_answers -> 'application.type'::text) -> 0))::text AS application_type, - FROM (((analytics a - LEFT JOIN analytics_logs al ON ((a.id = al.analytics_id))) - LEFT JOIN flows f ON ((a.flow_id = f.id))) - LEFT JOIN teams t ON ((t.id = f.team_id))); - - GRANT SELECT ON "public"."analytics_summary" TO metabase_read_only; diff --git a/hasura.planx.uk/migrations/1731943657237_add_user_click_save_to_analytics_summary/up.sql b/hasura.planx.uk/migrations/1731943657237_add_user_click_save_to_analytics_summary/up.sql deleted file mode 100644 index c1d8e585f9..0000000000 --- a/hasura.planx.uk/migrations/1731943657237_add_user_click_save_to_analytics_summary/up.sql +++ /dev/null @@ -1,59 +0,0 @@ -CREATE OR REPLACE VIEW "public"."analytics_summary" AS - SELECT a.id AS analytics_id, - al.id AS analytics_log_id, - f.slug AS service_slug, - t.slug AS team_slug, - a.type AS analytics_type, - al.created_at AS analytics_log_created_at, - a.created_at AS analytics_created_at, - ((a.user_agent -> 'os'::text) ->> 'name'::text) AS operating_system, - ((a.user_agent -> 'browser'::text) ->> 'name'::text) AS browser, - ((a.user_agent -> 'platform'::text) ->> 'type'::text) AS platform, - a.referrer, - al.flow_direction, - (al.metadata ->> 'change'::text) AS change_metadata, - (al.metadata ->> 'back'::text) AS back_metadata, - (al.metadata ->> 'selectedUrls'::text) AS selected_urls, - (al.metadata ->> 'flag'::text) AS result_flag, - ((al.metadata -> 'flagSet'::text))::text AS result_flagset, - ((al.metadata -> 'displayText'::text) ->> 'heading'::text) AS result_heading, - ((al.metadata -> 'displayText'::text) ->> 'description'::text) AS result_description, - ((al.metadata -> 'helpTextUseful'::text))::text AS help_text_useful, - CASE - WHEN al.has_clicked_help THEN al.metadata - ELSE NULL::jsonb - END AS help_metadata, - al.user_exit AS is_user_exit, - al.node_type, - al.node_title, - al.has_clicked_help, - al.input_errors, - (date_part('epoch'::text, (al.next_log_created_at - al.created_at)))::numeric(10,1) AS time_spent_on_node_seconds, - a.ended_at AS analytics_ended_at, - ((date_part('epoch'::text, (a.ended_at - a.created_at)) / (60)::double precision))::numeric(10,1) AS time_spent_on_analytics_session_minutes, - al.node_id, - al.allow_list_answers, - ((al.allow_list_answers -> 'proposal.projectType'::text))::text AS proposal_project_type, - ((al.allow_list_answers -> 'application.declaration.connection'::text))::text AS application_declaration_connection, - ((al.allow_list_answers -> 'property.type'::text))::text AS property_type, - ((al.allow_list_answers -> 'drawBoundary.action'::text))::text AS draw_boundary_action, - ((al.allow_list_answers -> 'user.role'::text))::text AS user_role, - ((al.allow_list_answers -> 'property.constraints.planning'::text))::text AS property_constraints_planning, - ((al.allow_list_answers -> 'findProperty.action'::text))::text AS find_property_action, - ((al.allow_list_answers -> 'usedFOIYNPP'::text))::text AS used_foiynpp, - ((al.allow_list_answers -> 'propertyInformation.action'::text))::text AS property_information_action, - ((al.allow_list_answers -> 'planningConstraints.action'::text))::text AS planning_constraints_action, - ((al.allow_list_answers -> '_overrides'::text))::text AS overrides, - ((al.allow_list_answers -> 'rab.exitReason'::text))::text AS rab_exit_reason, - ((al.allow_list_answers -> 'service.type'::text))::text AS pre_app_service_type, - ((al.allow_list_answers -> 'application.information.harmful'::text))::text AS pre_app_harmful_info, - ((al.allow_list_answers -> 'application.information.sensitive'::text))::text AS pre_app_sensitive_info, - (((al.allow_list_answers -> 'application.type'::text) -> 0))::text AS application_type, - ls.has_user_saved AS user_clicked_save - FROM (((analytics a - LEFT JOIN analytics_logs al ON ((a.id = al.analytics_id))) - LEFT JOIN flows f ON ((a.flow_id = f.id))) - LEFT JOIN teams t ON ((t.id = f.team_id))) - LEFT JOIN lowcal_sessions ls ON ((ls.flow_id = a.flow_id)); - - GRANT SELECT ON "public"."analytics_summary" TO metabase_read_only; diff --git a/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/down.sql b/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/down.sql new file mode 100644 index 0000000000..340894dd90 --- /dev/null +++ b/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/down.sql @@ -0,0 +1 @@ +alter table "public"."analytics_logs" drop column "has_user_clicked_save" \ No newline at end of file diff --git a/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/up.sql b/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/up.sql new file mode 100644 index 0000000000..06f5b05253 --- /dev/null +++ b/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/up.sql @@ -0,0 +1,2 @@ +alter table "public"."analytics_logs" add column "has_user_clicked_save" boolean + null default 'false'; From 696e19e4e95380a6b344727b5483056e23a1e91e Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Tue, 19 Nov 2024 12:34:34 +0000 Subject: [PATCH 3/9] add mutation and trackEvent to saveResumeButton add new view migration squash migrations alter order of down file remove async fix down sql --- .../shared/Preview/SaveResumeButton.tsx | 1 + .../FlowEditor/lib/analytics/mutations.ts | 12 ++++ .../FlowEditor/lib/analytics/provider.tsx | 4 ++ .../down.sql | 61 ++++++++++++++++++- .../up.sql | 59 ++++++++++++++++++ 5 files changed, 136 insertions(+), 1 deletion(-) diff --git a/editor.planx.uk/src/@planx/components/shared/Preview/SaveResumeButton.tsx b/editor.planx.uk/src/@planx/components/shared/Preview/SaveResumeButton.tsx index e5bcb896bd..840a7666e8 100644 --- a/editor.planx.uk/src/@planx/components/shared/Preview/SaveResumeButton.tsx +++ b/editor.planx.uk/src/@planx/components/shared/Preview/SaveResumeButton.tsx @@ -21,6 +21,7 @@ const SaveResumeButton: React.FC = () => { const handleClick = () => { if (saveToEmail) { + trackEvent({ event: "saveClick", metadata: {} }); trackEvent({ event: "flowDirectionChange", metadata: null, diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/analytics/mutations.ts b/editor.planx.uk/src/pages/FlowEditor/lib/analytics/mutations.ts index fcaead276f..8f6f3178d3 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/analytics/mutations.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/analytics/mutations.ts @@ -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( diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/analytics/provider.tsx b/editor.planx.uk/src/pages/FlowEditor/lib/analytics/provider.tsx index 6d979cfb7f..9c945e18b2 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/analytics/provider.tsx +++ b/editor.planx.uk/src/pages/FlowEditor/lib/analytics/provider.tsx @@ -15,6 +15,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 { @@ -273,6 +274,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); diff --git a/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/down.sql b/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/down.sql index 340894dd90..32740eb8b1 100644 --- a/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/down.sql +++ b/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/down.sql @@ -1 +1,60 @@ -alter table "public"."analytics_logs" drop column "has_user_clicked_save" \ No newline at end of file +alter table "public"."analytics_logs" drop column "has_user_clicked_save"; + + +CREATE OR REPLACE VIEW "public"."analytics_summary" AS + SELECT a.id AS analytics_id, + al.id AS analytics_log_id, + f.slug AS service_slug, + t.slug AS team_slug, + a.type AS analytics_type, + al.created_at AS analytics_log_created_at, + a.created_at AS analytics_created_at, + ((a.user_agent -> 'os'::text) ->> 'name'::text) AS operating_system, + ((a.user_agent -> 'browser'::text) ->> 'name'::text) AS browser, + ((a.user_agent -> 'platform'::text) ->> 'type'::text) AS platform, + a.referrer, + al.flow_direction, + (al.metadata ->> 'change'::text) AS change_metadata, + (al.metadata ->> 'back'::text) AS back_metadata, + (al.metadata ->> 'selectedUrls'::text) AS selected_urls, + (al.metadata ->> 'flag'::text) AS result_flag, + ((al.metadata -> 'flagSet'::text))::text AS result_flagset, + ((al.metadata -> 'displayText'::text) ->> 'heading'::text) AS result_heading, + ((al.metadata -> 'displayText'::text) ->> 'description'::text) AS result_description, + ((al.metadata -> 'helpTextUseful'::text))::text AS help_text_useful, + CASE + WHEN al.has_clicked_help THEN al.metadata + ELSE NULL::jsonb + END AS help_metadata, + al.user_exit AS is_user_exit, + al.node_type, + al.node_title, + al.has_clicked_help, + al.input_errors, + (date_part('epoch'::text, (al.next_log_created_at - al.created_at)))::numeric(10,1) AS time_spent_on_node_seconds, + a.ended_at AS analytics_ended_at, + ((date_part('epoch'::text, (a.ended_at - a.created_at)) / (60)::double precision))::numeric(10,1) AS time_spent_on_analytics_session_minutes, + al.node_id, + al.allow_list_answers, + ((al.allow_list_answers -> 'proposal.projectType'::text))::text AS proposal_project_type, + ((al.allow_list_answers -> 'application.declaration.connection'::text))::text AS application_declaration_connection, + ((al.allow_list_answers -> 'property.type'::text))::text AS property_type, + ((al.allow_list_answers -> 'drawBoundary.action'::text))::text AS draw_boundary_action, + ((al.allow_list_answers -> 'user.role'::text))::text AS user_role, + ((al.allow_list_answers -> 'property.constraints.planning'::text))::text AS property_constraints_planning, + ((al.allow_list_answers -> 'findProperty.action'::text))::text AS find_property_action, + ((al.allow_list_answers -> 'usedFOIYNPP'::text))::text AS used_foiynpp, + ((al.allow_list_answers -> 'propertyInformation.action'::text))::text AS property_information_action, + ((al.allow_list_answers -> 'planningConstraints.action'::text))::text AS planning_constraints_action, + ((al.allow_list_answers -> '_overrides'::text))::text AS overrides, + ((al.allow_list_answers -> 'rab.exitReason'::text))::text AS rab_exit_reason, + ((al.allow_list_answers -> 'service.type'::text))::text AS pre_app_service_type, + ((al.allow_list_answers -> 'application.information.harmful'::text))::text AS pre_app_harmful_info, + ((al.allow_list_answers -> 'application.information.sensitive'::text))::text AS pre_app_sensitive_info, + (((al.allow_list_answers -> 'application.type'::text) -> 0))::text AS application_type, + FROM (((analytics a + LEFT JOIN analytics_logs al ON ((a.id = al.analytics_id))) + LEFT JOIN flows f ON ((a.flow_id = f.id))) + LEFT JOIN teams t ON ((t.id = f.team_id))); + + GRANT SELECT ON "public"."analytics_summary" TO metabase_read_only; diff --git a/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/up.sql b/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/up.sql index 06f5b05253..8b08cca965 100644 --- a/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/up.sql +++ b/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/up.sql @@ -1,2 +1,61 @@ alter table "public"."analytics_logs" add column "has_user_clicked_save" boolean null default 'false'; + +CREATE OR REPLACE VIEW "public"."analytics_summary" AS + SELECT a.id AS analytics_id, + al.id AS analytics_log_id, + f.slug AS service_slug, + t.slug AS team_slug, + a.type AS analytics_type, + al.created_at AS analytics_log_created_at, + a.created_at AS analytics_created_at, + ((a.user_agent -> 'os'::text) ->> 'name'::text) AS operating_system, + ((a.user_agent -> 'browser'::text) ->> 'name'::text) AS browser, + ((a.user_agent -> 'platform'::text) ->> 'type'::text) AS platform, + a.referrer, + al.flow_direction, + (al.metadata ->> 'change'::text) AS change_metadata, + (al.metadata ->> 'back'::text) AS back_metadata, + (al.metadata ->> 'selectedUrls'::text) AS selected_urls, + (al.metadata ->> 'flag'::text) AS result_flag, + ((al.metadata -> 'flagSet'::text))::text AS result_flagset, + ((al.metadata -> 'displayText'::text) ->> 'heading'::text) AS result_heading, + ((al.metadata -> 'displayText'::text) ->> 'description'::text) AS result_description, + ((al.metadata -> 'helpTextUseful'::text))::text AS help_text_useful, + CASE + WHEN al.has_clicked_help THEN al.metadata + ELSE NULL::jsonb + END AS help_metadata, + al.user_exit AS is_user_exit, + al.node_type, + al.node_title, + al.has_clicked_help, + al.input_errors, + (date_part('epoch'::text, (al.next_log_created_at - al.created_at)))::numeric(10,1) AS time_spent_on_node_seconds, + a.ended_at AS analytics_ended_at, + ((date_part('epoch'::text, (a.ended_at - a.created_at)) / (60)::double precision))::numeric(10,1) AS time_spent_on_analytics_session_minutes, + al.node_id, + al.allow_list_answers, + ((al.allow_list_answers -> 'proposal.projectType'::text))::text AS proposal_project_type, + ((al.allow_list_answers -> 'application.declaration.connection'::text))::text AS application_declaration_connection, + ((al.allow_list_answers -> 'property.type'::text))::text AS property_type, + ((al.allow_list_answers -> 'drawBoundary.action'::text))::text AS draw_boundary_action, + ((al.allow_list_answers -> 'user.role'::text))::text AS user_role, + ((al.allow_list_answers -> 'property.constraints.planning'::text))::text AS property_constraints_planning, + ((al.allow_list_answers -> 'findProperty.action'::text))::text AS find_property_action, + ((al.allow_list_answers -> 'usedFOIYNPP'::text))::text AS used_foiynpp, + ((al.allow_list_answers -> 'propertyInformation.action'::text))::text AS property_information_action, + ((al.allow_list_answers -> 'planningConstraints.action'::text))::text AS planning_constraints_action, + ((al.allow_list_answers -> '_overrides'::text))::text AS overrides, + ((al.allow_list_answers -> 'rab.exitReason'::text))::text AS rab_exit_reason, + ((al.allow_list_answers -> 'service.type'::text))::text AS pre_app_service_type, + ((al.allow_list_answers -> 'application.information.harmful'::text))::text AS pre_app_harmful_info, + ((al.allow_list_answers -> 'application.information.sensitive'::text))::text AS pre_app_sensitive_info, + (((al.allow_list_answers -> 'application.type'::text) -> 0))::text AS application_type, + al.has_user_clicked_save + FROM (((analytics a + LEFT JOIN analytics_logs al ON ((a.id = al.analytics_id))) + LEFT JOIN flows f ON ((a.flow_id = f.id))) + LEFT JOIN teams t ON ((t.id = f.team_id))); + + GRANT SELECT ON "public"."analytics_summary" TO metabase_read_only; \ No newline at end of file From 0d0ec1afea410bb3b5ba5d81e916a7c4441623a9 Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Tue, 19 Nov 2024 15:29:34 +0000 Subject: [PATCH 4/9] add changes --- .../components/shared/Preview/SaveResumeButton.tsx | 2 +- .../src/pages/FlowEditor/lib/analytics/mutations.ts | 4 ++-- .../src/pages/FlowEditor/lib/analytics/provider.tsx | 12 ++++++------ .../src/pages/FlowEditor/lib/analytics/types.ts | 9 ++++++--- .../up.sql | 4 ++-- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/editor.planx.uk/src/@planx/components/shared/Preview/SaveResumeButton.tsx b/editor.planx.uk/src/@planx/components/shared/Preview/SaveResumeButton.tsx index 840a7666e8..4dc35d8c4e 100644 --- a/editor.planx.uk/src/@planx/components/shared/Preview/SaveResumeButton.tsx +++ b/editor.planx.uk/src/@planx/components/shared/Preview/SaveResumeButton.tsx @@ -21,7 +21,7 @@ const SaveResumeButton: React.FC = () => { const handleClick = () => { if (saveToEmail) { - trackEvent({ event: "saveClick", metadata: {} }); + trackEvent({ event: "saveClick" }); trackEvent({ event: "flowDirectionChange", metadata: null, diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/analytics/mutations.ts b/editor.planx.uk/src/pages/FlowEditor/lib/analytics/mutations.ts index 8f6f3178d3..22eb5a966f 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/analytics/mutations.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/analytics/mutations.ts @@ -52,11 +52,11 @@ export const UPDATE_HAS_CLICKED_HELP = gql` } `; -export const UPDATE_HAS_USER_CLICKED_SAVE = gql` +export const UPDATE_HAS_CLICKED_SAVE = gql` mutation UpdateHasClickedSave($id: bigint!, $metadata: jsonb = {}) { update_analytics_logs_by_pk( pk_columns: { id: $id } - _set: { has_user_clicked_save: true } + _set: { has_clicked_save: true } _append: { metadata: $metadata } ) { id diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/analytics/provider.tsx b/editor.planx.uk/src/pages/FlowEditor/lib/analytics/provider.tsx index 9c945e18b2..f6c3d46b72 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/analytics/provider.tsx +++ b/editor.planx.uk/src/pages/FlowEditor/lib/analytics/provider.tsx @@ -15,7 +15,7 @@ import { UPDATE_ANALYTICS_LOG_METADATA, UPDATE_FLOW_DIRECTION, UPDATE_HAS_CLICKED_HELP, - UPDATE_HAS_USER_CLICKED_SAVE, + UPDATE_HAS_CLICKED_SAVE, UPDATE_NEXT_LOG_CREATED_AT, } from "./mutations"; import { @@ -257,7 +257,7 @@ export const AnalyticsProvider: React.FC<{ children: React.ReactNode }> = ({ return !shouldTrackAnalytics || !lastVisibleNodeAnalyticsLogId; } - async function updateMetadata(mutation: DocumentNode, metadata: Metadata) { + async function updateMetadata(mutation: DocumentNode, metadata?: Metadata) { await publicClient.mutate({ mutation: mutation, variables: { @@ -269,17 +269,17 @@ export const AnalyticsProvider: React.FC<{ children: React.ReactNode }> = ({ async function trackEvent(eventData: EventData) { if (shouldSkipTracking()) return; - const { event, metadata } = eventData; + const { event } = eventData; switch (event) { case "helpClick": - updateMetadata(UPDATE_HAS_CLICKED_HELP, metadata); + updateMetadata(UPDATE_HAS_CLICKED_HELP, eventData.metadata); return; case "saveClick": - updateMetadata(UPDATE_HAS_USER_CLICKED_SAVE, metadata); + updateMetadata(UPDATE_HAS_CLICKED_SAVE); return; case "nextStepsClick": case "helpTextFeedback": - updateMetadata(UPDATE_ANALYTICS_LOG_METADATA, metadata); + updateMetadata(UPDATE_ANALYTICS_LOG_METADATA, eventData.metadata); return; case "backwardsNavigation": { const { initiator, nodeId } = eventData; diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/analytics/types.ts b/editor.planx.uk/src/pages/FlowEditor/lib/analytics/types.ts index bd9a435443..9d6e3c9b5a 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/analytics/types.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/analytics/types.ts @@ -32,8 +32,6 @@ export type AllowListKey = (typeof ALLOW_LIST)[number]; */ export type HelpClickMetadata = Record; -export type SaveClickMetadata = Record; - export type SelectedUrlsMetadata = Record<"selectedUrls", string[]>; export type BackwardsNavigationInitiatorType = "change" | "back"; @@ -111,9 +109,14 @@ type HelpClick = { metadata: HelpClickMetadata; }; +/** + * Captured when a user clicks Save and Return. + * The mutation sets the "has_clicked_help: true" when Save and + * Return button is clicked + */ + type SaveClick = { event: "saveClick"; - metadata: SaveClickMetadata; }; /** diff --git a/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/up.sql b/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/up.sql index 8b08cca965..e03de6c548 100644 --- a/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/up.sql +++ b/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/up.sql @@ -1,4 +1,4 @@ -alter table "public"."analytics_logs" add column "has_user_clicked_save" boolean +alter table "public"."analytics_logs" add column "has_clicked_save" boolean null default 'false'; CREATE OR REPLACE VIEW "public"."analytics_summary" AS @@ -52,7 +52,7 @@ CREATE OR REPLACE VIEW "public"."analytics_summary" AS ((al.allow_list_answers -> 'application.information.harmful'::text))::text AS pre_app_harmful_info, ((al.allow_list_answers -> 'application.information.sensitive'::text))::text AS pre_app_sensitive_info, (((al.allow_list_answers -> 'application.type'::text) -> 0))::text AS application_type, - al.has_user_clicked_save + al.has_clicked_save FROM (((analytics a LEFT JOIN analytics_logs al ON ((a.id = al.analytics_id))) LEFT JOIN flows f ON ((a.flow_id = f.id))) From 94eeb1ee13037777e4341e0ee41591172cd54b4b Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Tue, 19 Nov 2024 15:46:31 +0000 Subject: [PATCH 5/9] update permissions --- hasura.planx.uk/metadata/tables.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hasura.planx.uk/metadata/tables.yaml b/hasura.planx.uk/metadata/tables.yaml index f7532e7fc4..ea03c776ed 100644 --- a/hasura.planx.uk/metadata/tables.yaml +++ b/hasura.planx.uk/metadata/tables.yaml @@ -55,7 +55,7 @@ - created_at - flow_direction - has_clicked_help - - has_user_clicked_save + - has_clicked_save - id - input_errors - metadata @@ -80,7 +80,7 @@ - allow_list_answers - flow_direction - has_clicked_help - - has_user_clicked_save + - has_clicked_save - input_errors - metadata - next_log_created_at From 24ce3e4ad1c173e0c83e01ddd844f42223091a80 Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Tue, 19 Nov 2024 16:12:16 +0000 Subject: [PATCH 6/9] bug fix on down file --- .../down.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/down.sql b/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/down.sql index 32740eb8b1..3a91c28957 100644 --- a/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/down.sql +++ b/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/down.sql @@ -1,4 +1,4 @@ -alter table "public"."analytics_logs" drop column "has_user_clicked_save"; +alter table "public"."analytics_logs" drop column "has_clicked_save"; CREATE OR REPLACE VIEW "public"."analytics_summary" AS From c45dd197937c8607f08b417152425911e700b2bb Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Tue, 19 Nov 2024 16:54:07 +0000 Subject: [PATCH 7/9] incorporate feedback changes --- .../down.sql | 4 ++-- .../up.sql | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/down.sql b/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/down.sql index 3a91c28957..3205618e04 100644 --- a/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/down.sql +++ b/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/down.sql @@ -1,6 +1,5 @@ alter table "public"."analytics_logs" drop column "has_clicked_save"; - CREATE OR REPLACE VIEW "public"."analytics_summary" AS SELECT a.id AS analytics_id, al.id AS analytics_log_id, @@ -52,9 +51,10 @@ CREATE OR REPLACE VIEW "public"."analytics_summary" AS ((al.allow_list_answers -> 'application.information.harmful'::text))::text AS pre_app_harmful_info, ((al.allow_list_answers -> 'application.information.sensitive'::text))::text AS pre_app_sensitive_info, (((al.allow_list_answers -> 'application.type'::text) -> 0))::text AS application_type, + ((al.allow_list_answers -> '_feedback') ->> 'feedbackScore'::text)::int AS feedback_score FROM (((analytics a LEFT JOIN analytics_logs al ON ((a.id = al.analytics_id))) LEFT JOIN flows f ON ((a.flow_id = f.id))) LEFT JOIN teams t ON ((t.id = f.team_id))); - GRANT SELECT ON "public"."analytics_summary" TO metabase_read_only; +GRANT SELECT ON "public"."analytics_summary" TO metabase_read_only; \ No newline at end of file diff --git a/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/up.sql b/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/up.sql index e03de6c548..2e249c7ad6 100644 --- a/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/up.sql +++ b/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/up.sql @@ -52,6 +52,7 @@ CREATE OR REPLACE VIEW "public"."analytics_summary" AS ((al.allow_list_answers -> 'application.information.harmful'::text))::text AS pre_app_harmful_info, ((al.allow_list_answers -> 'application.information.sensitive'::text))::text AS pre_app_sensitive_info, (((al.allow_list_answers -> 'application.type'::text) -> 0))::text AS application_type, + ((al.allow_list_answers -> '_feedback') ->> 'feedbackScore'::text)::int AS feedback_score, al.has_clicked_save FROM (((analytics a LEFT JOIN analytics_logs al ON ((a.id = al.analytics_id))) From ac9c46fb7505f6e309689cfc712e74d31f995c5a Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Tue, 19 Nov 2024 17:29:34 +0000 Subject: [PATCH 8/9] incorporate new view variables --- .../down.sql | 5 +++-- .../up.sql | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/down.sql b/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/down.sql index 3205618e04..a18398fd07 100644 --- a/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/down.sql +++ b/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/down.sql @@ -50,8 +50,9 @@ CREATE OR REPLACE VIEW "public"."analytics_summary" AS ((al.allow_list_answers -> 'service.type'::text))::text AS pre_app_service_type, ((al.allow_list_answers -> 'application.information.harmful'::text))::text AS pre_app_harmful_info, ((al.allow_list_answers -> 'application.information.sensitive'::text))::text AS pre_app_sensitive_info, - (((al.allow_list_answers -> 'application.type'::text) -> 0))::text AS application_type, - ((al.allow_list_answers -> '_feedback') ->> 'feedbackScore'::text)::int AS feedback_score + al.allow_list_answers -> 'application.type' ->> 0 AS application_type, + ((al.allow_list_answers -> '_feedback') ->> 'feedbackScore'::text)::int AS feedback_score, + al.allow_list_answers -> 'applicant.researchOptIn' ->> 0 AS applicant_research_opt_in FROM (((analytics a LEFT JOIN analytics_logs al ON ((a.id = al.analytics_id))) LEFT JOIN flows f ON ((a.flow_id = f.id))) diff --git a/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/up.sql b/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/up.sql index 2e249c7ad6..bdbcb67b69 100644 --- a/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/up.sql +++ b/hasura.planx.uk/migrations/1732016907414_alter_table_public_analytics_logs_add_column_has_user_clicked_save/up.sql @@ -51,8 +51,9 @@ CREATE OR REPLACE VIEW "public"."analytics_summary" AS ((al.allow_list_answers -> 'service.type'::text))::text AS pre_app_service_type, ((al.allow_list_answers -> 'application.information.harmful'::text))::text AS pre_app_harmful_info, ((al.allow_list_answers -> 'application.information.sensitive'::text))::text AS pre_app_sensitive_info, - (((al.allow_list_answers -> 'application.type'::text) -> 0))::text AS application_type, + al.allow_list_answers -> 'application.type' ->> 0 AS application_type, ((al.allow_list_answers -> '_feedback') ->> 'feedbackScore'::text)::int AS feedback_score, + al.allow_list_answers -> 'applicant.researchOptIn' ->> 0 AS applicant_research_opt_in, al.has_clicked_save FROM (((analytics a LEFT JOIN analytics_logs al ON ((a.id = al.analytics_id))) From 13b8544be26e7cfc7628c2bec5054a5101199f9b Mon Sep 17 00:00:00 2001 From: Rory Doak Date: Wed, 20 Nov 2024 11:36:28 +0000 Subject: [PATCH 9/9] add null field for save click metadata --- .../src/@planx/components/shared/Preview/SaveResumeButton.tsx | 2 +- editor.planx.uk/src/pages/FlowEditor/lib/analytics/types.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/editor.planx.uk/src/@planx/components/shared/Preview/SaveResumeButton.tsx b/editor.planx.uk/src/@planx/components/shared/Preview/SaveResumeButton.tsx index 4dc35d8c4e..96bb8cd30c 100644 --- a/editor.planx.uk/src/@planx/components/shared/Preview/SaveResumeButton.tsx +++ b/editor.planx.uk/src/@planx/components/shared/Preview/SaveResumeButton.tsx @@ -21,7 +21,7 @@ const SaveResumeButton: React.FC = () => { const handleClick = () => { if (saveToEmail) { - trackEvent({ event: "saveClick" }); + trackEvent({ event: "saveClick", metadata: null }); trackEvent({ event: "flowDirectionChange", metadata: null, diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/analytics/types.ts b/editor.planx.uk/src/pages/FlowEditor/lib/analytics/types.ts index 9d6e3c9b5a..611e5b0c6f 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/analytics/types.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/analytics/types.ts @@ -117,6 +117,7 @@ type HelpClick = { type SaveClick = { event: "saveClick"; + metadata: null; }; /**