/** * Data module — privacy-first analytics dashboard. * * Lightweight module that shows analytics stats from the * self-hosted Umami instance. No database — proxies to Umami API. */ import { Hono } from "hono"; import { renderShell } from "../../server/shell"; import { getModuleInfoList } from "../../shared/module"; import type { RSpaceModule } from "../../shared/module"; const routes = new Hono(); const UMAMI_URL = process.env.UMAMI_URL || "https://analytics.rspace.online"; // ── API routes ── // GET /api/info — module info routes.get("/api/info", (c) => { return c.json({ module: "data", name: "rData", umamiUrl: UMAMI_URL, features: ["privacy-first", "cookieless", "self-hosted"], trackedApps: 17, }); }); // GET /api/health routes.get("/api/health", (c) => c.json({ ok: true })); // GET /api/stats — summary stats (placeholder until Umami API is wired) routes.get("/api/stats", (c) => { return c.json({ trackedApps: 17, cookiesSet: 0, scriptSize: "~2KB", selfHosted: true, dashboardUrl: UMAMI_URL, apps: [ "rSpace", "rNotes", "rVote", "rFunds", "rCart", "rWallet", "rPubs", "rChoices", "rCal", "rForum", "rInbox", "rFiles", "rTrips", "rTube", "rWork", "rNetwork", "rData", ], }); }); // ── Page route ── routes.get("/", (c) => { const space = c.req.param("space") || "demo"; return c.html(renderShell({ title: `${space} — Data | rSpace`, moduleId: "data", spaceSlug: space, modules: getModuleInfoList(), theme: "light", styles: ``, body: ``, scripts: ``, })); }); export const dataModule: RSpaceModule = { id: "data", name: "rData", icon: "\u{1F4CA}", description: "Privacy-first analytics for the r* ecosystem", routes, standaloneDomain: "rdata.online", };