Skip to content

feat: local pg analytics#3561

Merged
isTravis merged 48 commits intomainfrom
tr/analytics-local2
Apr 15, 2026
Merged

feat: local pg analytics#3561
isTravis merged 48 commits intomainfrom
tr/analytics-local2

Conversation

@isTravis
Copy link
Copy Markdown
Member

@isTravis isTravis commented Apr 7, 2026

Riffing on #3560 - this simplifies the approach to bypass metabase altogether. Functions to get Redshift data into our app's PG database, and then serves historical analytics straight from PG (using a few materialized views for performance). See server/analytics/README.md for full break down and steps for testing up locally.

Materialized views do a lot. Comparison of queries on raw table vs materialized views:

Query Raw table (with indexes) Materialized views Speedup
Daily summary 13.9s 0.7ms 19,800×
Countries 11.1s 11ms 1,010×
Referrers 12.3s 91ms 135×
Pages ~13s 259ms ~50×
Campaigns ~11s 1ms ~11,000×
Pubs ~12s 33ms ~360×
Collections ~11s 3ms ~3,700×

@isTravis isTravis changed the title Local Analytics sans-metabase feat: local Analytics sans-metabase Apr 7, 2026
Comment thread server/analytics/api.ts Outdated
Comment on lines 50 to 53
const record = toEventRecord(payload, { country, countryCode });

await sendToStitch({ country, countryCode: id, ...payload });
enqueue(record);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clever!

@isTravis isTravis changed the title feat: local Analytics sans-metabase feat: local pg analytics Apr 8, 2026
@isTravis isTravis mentioned this pull request Apr 13, 2026
@isTravis isTravis merged commit 8b240ea into main Apr 15, 2026
1 of 2 checks passed
@isTravis isTravis deleted the tr/analytics-local2 branch April 15, 2026 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants