Files
SnapOtter/apps/api/src/routes/analytics.ts
T

23 lines
731 B
TypeScript
Raw Normal View History

import { ANALYTICS_BAKED } from "@snapotter/shared";
import { eq } from "drizzle-orm";
import type { FastifyInstance } from "fastify";
import { db, schema } from "../db/index.js";
export async function analyticsRoutes(app: FastifyInstance): Promise<void> {
app.get("/api/v1/config/analytics", async () => {
const [row] = await db
.select()
.from(schema.settings)
.where(eq(schema.settings.key, "instance_id"));
return {
enabled: ANALYTICS_BAKED.enabled,
posthogApiKey: ANALYTICS_BAKED.posthogApiKey,
posthogHost: ANALYTICS_BAKED.posthogHost,
sentryDsn: ANALYTICS_BAKED.sentryDsn,
sampleRate: ANALYTICS_BAKED.sampleRate,
instanceId: row?.value ?? "",
};
});
}