feat(archive): capture all PostHog resource modules to DB + MinIO

Extends archival beyond events/persons/cohorts. New generic resource
archiver (posthog-resource-archive@*/6h) snapshots surveys, feature flags,
experiments, dashboards, insights, annotations, and actions into
posthog_resource_snapshots — change-detected (hash over non-volatile config),
lossless `data` payload — and dumps a full per-type daily copy to MinIO
(resources/<type>/<date>.json.gz). listResource() pages any PostHog REST
resource. Survey responses + flag calls are already captured as events.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Semih
2026-06-10 20:31:19 +03:00
parent a9e0d93aa1
commit dd54f4983b
4 changed files with 156 additions and 1 deletions

View File

@@ -538,6 +538,29 @@ model PosthogCohortSnapshot {
@@map("posthog_cohort_snapshots")
}
// Generic change-history of every PostHog "resource" module beyond events:
// surveys, feature_flags, experiments, dashboards, insights, annotations,
// actions. One row is appended only when a resource's config changed
// (stateHash compare); the full payload is kept lossless in `data`, and a full
// per-type daily snapshot is also dumped to MinIO. Survey responses + flag
// calls are events (already in posthog_events) — this captures the definitions.
model PosthogResourceSnapshot {
id String @id @default(cuid())
projectKey String
resourceType String // survey | feature_flag | experiment | dashboard | insight | annotation | action
resourceId String // PostHog resource id (stringified)
name String?
stateHash String // change-detection over the non-volatile config
data Json // full resource payload, lossless
capturedAt DateTime @default(now())
dumpedAt DateTime?
@@index([projectKey, resourceType, capturedAt])
@@index([resourceType, resourceId, capturedAt])
@@index([dumpedAt])
@@map("posthog_resource_snapshots")
}
// ---------- Phase C: Sentry archive ----------
// Sentry issue (group) aggregate state. Upserted to the latest snapshot — the