Ghost/ghost/tinybird/pipes/analytics_sessions.pipe
Hannah Wolfe 4c5704bfa6 Added audience handling to stats
closes https://linear.app/tryghost/issue/ANAL-23/filtering-by-logged-out-logged-in-traffic

- Updated all of our tinybird datasources and pipes to handle member status
- Added member_status as an array query param to the API endpoints
- Added a really dodgy power select multiple to the stats page to demonstrate it works (needs styling)
- Added all of the wiring so each chart updates
- This was done pretty fast, and may not be 100% right yet
2024-09-02 12:56:37 +01:00

26 lines
742 B
Plaintext

NODE analytics_sessions_1
DESCRIPTION >
Aggregate by session_id and calculate session metrics
SQL >
SELECT
site_uuid,
toDate(timestamp) AS date,
session_id,
maxIf(
member_status,
member_status IN ('paid', 'free', 'undefined')
) AS member_status,
anySimpleState(post_uuid) AS post_uuid,
anySimpleState(device) AS device,
anySimpleState(browser) AS browser,
anySimpleState(location) AS location,
minSimpleState(timestamp) AS first_hit,
maxSimpleState(timestamp) AS latest_hit,
countState() AS hits
FROM analytics_hits
GROUP BY date, session_id, site_uuid
TYPE MATERIALIZED
DATASOURCE analytics_sessions_mv