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>
21 lines
1022 B
SQL
21 lines
1022 B
SQL
-- Privacy jobs: one row per person deletion, visible in the console until done.
|
|
|
|
create table if not exists pa.gdpr_jobs (
|
|
id uuid primary key default gen_random_uuid(),
|
|
project_id uuid not null,
|
|
kind text not null default 'delete' check (kind in ('delete')),
|
|
distinct_id text not null check (length(distinct_id) between 1 and 200),
|
|
requested_by text not null check (length(requested_by) between 1 and 200),
|
|
requested_at timestamptz not null,
|
|
due_at timestamptz not null,
|
|
status text not null default 'queued' check (status in ('queued', 'running', 'done', 'failed')),
|
|
started_at timestamptz,
|
|
finished_at timestamptz,
|
|
attempts integer not null default 0,
|
|
result jsonb,
|
|
error text,
|
|
check (due_at > requested_at)
|
|
);
|
|
create index if not exists gdpr_jobs_status_idx on pa.gdpr_jobs (status, due_at);
|
|
create index if not exists gdpr_jobs_project_idx on pa.gdpr_jobs (project_id, requested_at desc);
|