feat(analytics): build-time bake + telemetry depth (#336)

Bake PostHog + Sentry into the published Docker image (SNAPOTTER_ANALYTICS
build arg, codegen script). Delete entire consent system. Move event emission
to BullMQ worker. Add cross-tier identity stitching, Sentry performance
tracing on both tiers, frontend funnel events. Fix stateful regex bug.

86 files changed, 1593 insertions(+), 3747 deletions(-)
This commit is contained in:
SnapOtter
2026-06-24 11:05:39 +08:00
committed by GitHub
parent a53038ed96
commit 5d36ac06d8
86 changed files with 1594 additions and 3748 deletions
+29
View File
@@ -0,0 +1,29 @@
import { writeFileSync } from "node:fs";
import { resolve, dirname } from "node:path";
import { fileURLToPath } from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url));
const outPath = resolve(__dirname, "../packages/shared/src/analytics/baked.ts");
const mode = process.argv[2] || "on";
const enabled = mode === "on";
const posthogApiKey = enabled ? "phc_REPLACE_WITH_REAL_KEY" : "";
const posthogHost = enabled ? "https://us.i.posthog.com" : "";
const sentryDsn = enabled
? "https://REPLACE_WITH_REAL_DSN@o0.ingest.us.sentry.io/0"
: "";
const sampleRate = enabled ? 1 : 0;
const content = `// AUTO-GENERATED by scripts/bake-analytics.mjs -- do not edit manually
export const ANALYTICS_BAKED = {
enabled: ${enabled},
posthogApiKey: "${posthogApiKey}",
posthogHost: "${posthogHost}",
sentryDsn: "${sentryDsn}",
sampleRate: ${sampleRate},
} as const;
`;
writeFileSync(outPath, content, "utf-8");
console.log(`bake-analytics: wrote ${outPath} (mode=${mode}, enabled=${enabled})`);