mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
Lands five integrated branches: pipeline templates (#355), analytics opt-out (#354), 83 conversion presets bringing the catalog to 240 tools (#356), self-hosted positioning (#353), and e2e modernization (#351). Integration fixes: aligned stale web analytics tests with the opt-out/allow-list model, closed 3 CodeQL incomplete-sanitization alerts in the i18n generator, resolved settings/index/docs/format-matrix conflicts, and corrected tool counts to 240.
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
import { ANALYTICS_BAKED } from "@snapotter/shared";
|
|
import { eq } from "drizzle-orm";
|
|
import type { FastifyInstance } from "fastify";
|
|
import { db, schema } from "../db/index.js";
|
|
import { analyticsEnabled } from "../lib/analytics-gate.js";
|
|
|
|
export async function analyticsRoutes(app: FastifyInstance): Promise<void> {
|
|
app.get("/api/v1/config/analytics", async () => {
|
|
// Effective state: compile-time bake AND the runtime instance opt-out.
|
|
if (!analyticsEnabled()) {
|
|
return {
|
|
enabled: false,
|
|
posthogApiKey: "",
|
|
posthogHost: "",
|
|
sentryDsn: "",
|
|
sampleRate: 0,
|
|
instanceId: "",
|
|
};
|
|
}
|
|
|
|
const [row] = await db
|
|
.select()
|
|
.from(schema.settings)
|
|
.where(eq(schema.settings.key, "instance_id"));
|
|
|
|
return {
|
|
enabled: true,
|
|
posthogApiKey: ANALYTICS_BAKED.posthogApiKey,
|
|
posthogHost: ANALYTICS_BAKED.posthogHost,
|
|
sentryDsn: ANALYTICS_BAKED.sentryDsn,
|
|
sampleRate: ANALYTICS_BAKED.sampleRate,
|
|
instanceId: row?.value ?? "",
|
|
};
|
|
});
|
|
}
|