apps/product-analytics: a standalone Node 22 service (hono, pg, fflate, jose)
that speaks the public SDK capture protocol (/e/, /i/v0/e/, /batch/,
/capture/, /engage/, /groups/, /flags/?v=2, /decide/, /array/:token/config)
over JSON, gzip, base64 and form data, stores into Postgres (monthly
partitions, RLS on pa.project_id plus a bound project_id), resolves people
with identify/alias/merge semantics ported from the upstream persons code
(MIT, cbb1e9253027), applies the console caps (byte copy, drift-tested),
meters scribase.analytics.events behind RAILYARD_LIVE, drops IPs, runs
privacy deletions as visible jobs and trims to each plan's window.
Hand-offs created now (empty on purpose):
- src/routes.ts mounts src/insights/routes.ts -> A2
- src/routes.ts mounts src/{replay,heatmaps,surveys,experiments,exports}/routes.ts -> A3
- src/remote-config/sections.ts (replay, heatmaps, surveys providers) -> A3
- src/flags/variants.ts (returns null) -> A3
- src/replay/gdpr.ts and src/surveys/gdpr.ts privacy hooks -> A3
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
22 lines
1001 B
SQL
22 lines
1001 B
SQL
-- Group analytics: up to five group types per project, each with keyed groups.
|
|
|
|
create table if not exists pa.group_types (
|
|
project_id uuid not null,
|
|
group_type text not null check (length(group_type) between 1 and 100),
|
|
group_type_index smallint not null check (group_type_index between 0 and 4),
|
|
created_at timestamptz not null default now(),
|
|
primary key (project_id, group_type),
|
|
unique (project_id, group_type_index)
|
|
);
|
|
|
|
create table if not exists pa.groups (
|
|
project_id uuid not null,
|
|
group_type_index smallint not null check (group_type_index between 0 and 4),
|
|
group_key text not null check (length(group_key) between 1 and 400),
|
|
properties jsonb not null default '{}'::jsonb,
|
|
created_at timestamptz not null default now(),
|
|
updated_at timestamptz not null default now(),
|
|
version bigint not null default 0,
|
|
primary key (project_id, group_type_index, group_key)
|
|
);
|