Skip to content

Commit

Permalink
feature: add analytics session ended_at to view
Browse files Browse the repository at this point in the history
- Found that it wasn't possible to replicate the ["Average time spent"](https://metabase.editor.planx.uk/question/15-average-time-spent?flow_id=0e9d79ec-9cf3-497d-a1a1-8e70469bb52d) card without analytics session ended at
- Added this to the view
  • Loading branch information
Mike-Heneghan committed Dec 11, 2023
1 parent 751d1dd commit 138facc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP VIEW public.analytics_summary CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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,
a.created_at AS analytics_created_at,
a.user_agent,
a.referrer,
al.flow_direction,
al.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
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)));

0 comments on commit 138facc

Please sign in to comment.