Product Usage Analytics
Kartorium collects first-party product usage analytics in Postgres. This data answers operational questions such as how many unique users were active recently, which organizations used the app, how many sessions were created, how long sessions lasted, and which routes users visited.
The /admin/org-settings admin page includes a Product Analytics tab for Kartorium super admins. The tab shows summary metrics for the selected time window and a recent-session table.
Data Flow
flowchart LR Browser["Angular app"] --> API["Analytics API"] API --> Sessions["user_sessions"] API --> Events["user_session_events"] Admin["Admin Product Analytics tab"] --> API API --> Admin
Tables
| Table | Purpose |
|---|---|
user_sessions | One row per browser app session. Stores user, organization, entry route, exit route, start time, last-seen time, end time, viewport, environment, app version, and duration. |
user_session_events | Event rows attached to a session. Page views are stored as event_name = 'page_view' with the route and optional entity context. |
Admin Metrics
The admin summary reads from get_product_analytics_summary and shows:
- Unique active users
- Active organizations
- Total sessions
- Page views
- Average session duration
- Median session duration
- Last-seen timestamp
Recent sessions read from get_product_analytics_recent_sessions and include the user, organization, session start, last seen time, duration, entry route, exit route, page-view count, and event count.
Related Code
- Tables:
database/sql_scripts/tables/user_product_analytics.sql - Functions:
database/sql_scripts/functions/product_analytics.sql - Backend endpoint:
backend/endpoints/productAnalytics.ts - Frontend session tracker:
frontend/src/app/services/product-analytics.service.ts - Admin UI:
frontend/src/app/modules/admin/org-settings/