Skip to content

Your favorite shift management application!

feat(telemetry): opt-in anonymous instance telemetry with a swappable receiver (#217)

panteL9b9fff71ff6a
diff --git a/.dockerignore b/.dockerignore
index 1fe69c9..c1f2e25 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -53,6 +53,9 @@ data/
.claude
.LOCAL
+# Cloudflare Worker: separate TS project, never part of the Next.js image
+telemetry-hub
+
# IDE
.vscode
.idea
diff --git a/.env.example b/.env.example
index d20e35e..45c34d4 100644
--- a/.env.example
+++ b/.env.example
@@ -262,3 +262,16 @@ ALLOW_USER_REGISTRATION=true # Enable/disable new user signups
# port-forwarding tunnel, or a device on the network. Next.js logs the
# blocked origin in its warning; put that value here.
# DEV_ALLOWED_ORIGINS=192.168.1.1
+
+
+# ==============================================================================
+# 12. TELEMETRY (opt-in, anonymous)
+# ==============================================================================
+
+# Unset: the instance admin decides in the app.
+# false: hard off, no dialog, no requests. true: hard on, no dialog.
+# Only the literal "true" and "false" are recognised; anything else (1, yes,
+# TRUE) fails closed, i.e. behaves like "false" and locks the admin toggle.
+# See docs/TELEMETRY.md for every field that is sent.
+# TELEMETRY_ENABLED=
+# TELEMETRY_ENDPOINT=https://telemetry-bettershift.pantelx.com
diff --git a/README.md b/README.md
index b7dbbaf..734ec65 100644
--- a/README.md
+++ b/README.md
@@ -105,6 +105,7 @@ npm run dev
| [Authentication Setup](docs/AUTH_SETUP.md) | Email/password, OAuth, OIDC configuration |
| [Admin Panel](docs/ADMIN_PANEL.md) | User management, calendar administration |
| [Permissions](docs/PERMISSIONS.md) | Sharing, access tokens, guest access |
+| [Telemetry](docs/TELEMETRY.md) | What data is collected and how to disable it |
| [Enabling Auth on an Existing Instance](docs/ENABLING_AUTH.md) | Turn on accounts for an instance that ran with `AUTH_ENABLED=false` |
| [Upgrade Guide](docs/UPGRADING.md) | Breaking changes between versions and the steps to get through them |
diff --git a/app/admin/page.tsx b/app/admin/page.tsx
index 5cc68a5..97a45bc 100644
--- a/app/admin/page.tsx
+++ b/app/admin/page.tsx
@@ -1,11 +1,12 @@
"use client";
-import { ReactNode } from "react";
+import { ReactNode, useState } from "react";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { useLocale, useTranslations } from "next-intl";
import { format, formatDistanceToNow } from "date-fns";
import { ArrowUpCircle, ChevronRight, FolderClosed } from "lucide-react";
+import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { ChoiceChips, Field, Pill, ToggleRow } from "@/components/form-kit";
import { StatusBanner } from "@/components/status-banner";
@@ -15,11 +16,19 @@ import { useAuditDescription } from "@/components/admin/audit-describe";
import { useAdminStats } from "@/hooks/useAdminStats";
import { useVersionUpdateCheck } from "@/hooks/useVersionUpdate";
import { useSystemSettings } from "@/hooks/useSystemSettings";
+import { useTelemetryPayload } from "@/hooks/useTelemetryPayload";
+import { useTelemetrySend } from "@/hooks/useTelemetrySend";
import type { UpdateBannerVisibility } from "@/lib/system-settings";
+import type { DiagnosticsPayload } from "@/lib/telemetry/schema";
import { getDateLocale } from "@/lib/locales";
import { cn } from "@/lib/utils";
import { useClientValue } from "@/hooks/useMediaQuery";
+// Upstream repo for prefilled issue links; a self-hosted fork's GITHUB_REPO_OWNER/NAME
+// override isn't available client-side, so this always points at the canonical project.
+const GITHUB_ISSUE_URL = "https://github.com/panteLx/BetterShift/issues/new";
+// GitHub truncates query strings past roughly this length.
+const MAX_ISSUE_URL_LENGTH = 6000;
function ScaleValue({ value }: { value: number | undefined }) {
return (
@@ -56,6 +65,42 @@ export default function AdminDashboardPage() {
const { settings, updateSettings, isUpdating } = useSystemSettings();
const [, usersArea, calendarsArea, logsArea] = useAdminSections();
+ // Resolved server-side: an env override wins over the stored value here too.
+ const telemetryEnabled = settings?.telemetryResolved === true;
+ const { data: telemetryPreview } = useTelemetryPayload("telemetry", true);
+ const { sendNow, isSending } = useTelemetrySend();
+ const [diagnosticsOpen, setDiagnosticsOpen] = useState(false);
+ const { data: diagnostics } = useTelemetryPayload("diagnostics", diagnosticsOpen) as {
+ data: DiagnosticsPayload | undefined;
+ };
+ const [includeInstanceId, setIncludeInstanceId] = useState(true);
+ // No instance id exists unless telemetry is actually on, regardless of stale server data.
+ const diagnosticsBody: DiagnosticsPayload | null = diagnostics
+ ? { ...diagnostics, instanceId: telemetryEnabled && includeInstanceId ? diagnostics.instanceId : null }
+ : null;
+
+ const copyDiagnostics = async () => {
+ if (!diagnosticsBody) return;
+ try {
+ await navigator.clipboard.writeText(
+ "```json\n" + JSON.stringify(diagnosticsBody, null, 2) + "\n```"
+ );
+ toast.success(t("admin.telemetry.copied"));
+ } catch (error) {
+ console.error("Failed to copy diagnostics:", error);
+ toast.error(t("common.error"));
+ }
+ };
+
+ const issueHref = diagnosticsBody
+ ? `${GITHUB_ISSUE_URL}?body=${encodeURIComponent(
+ "\n\n<details><summary>Diagnostics</summary>\n\n```json\n" +
+ JSON.stringify(diagnosticsBody, null, 2) +
+ "\n```\n\n</details>"
+ )}`
+ : null;
+ const issueHrefTooLong = (issueHref?.length ?? 0) > MAX_ISSUE_URL_LENGTH;
+
// Admin actions plus security events, delivered with the stats
const activity = stats?.activity.logs ?? [];
const activityTotal = stats?.activity.total ?? 0;
@@ -206,46 +251,6 @@ export default function AdminDashboardPage() {
</StatusBanner>
)}
- <section className="flex flex-col gap-2 lg:gap-0 lg:overflow-hidden lg:rounded-[12px] lg:border lg:border-line lg:bg-surface-card">
- <div className="lg:border-b lg:border-line lg:px-4 lg:py-[13px]">
- <h2 className="eyebrow lg:hidden">{t("admin.systemSettings.title")}</h2>
- <span className="hidden text-[14px] font-semibold text-fg-strong lg:inline">
- {t("admin.systemSettings.title")}
- </span>
- <p className="mt-0.5 text-[12.5px] text-fg-tertiary">{t("admin.systemSettings.description")}</p>
- </div>
- <div className="flex flex-col gap-4 rounded-[11px] border border-line bg-surface-card p-3 lg:rounded-none lg:border-0 lg:p-4">
- <ToggleRow
- id="update-check-enabled"
- title={t("admin.systemSettings.checkEnabled")}
- description={t("admin.systemSettings.checkEnabledHint")}
- checked={settings?.updateCheckEnabled ?? true}
- onCheckedChange={(checked) => updateSettings({ updateCheckEnabled: checked })}
- disabled={!settings || isUpdating}
- />
- <Field label={t("admin.systemSettings.visibility")}>
- <ChoiceChips<UpdateBannerVisibility>
- value={settings?.updateBannerVisibility ?? "all"}
- onChange={(updateBannerVisibility) => updateSettings({ updateBannerVisibility })}
- disabled={!settings || isUpdating || !settings.updateCheckEnabled}
- options={[
- { value: "all", label: t("admin.systemSettings.visibilityAll") },
- { value: "admins", label: t("admin.systemSettings.visibilityAdmins") },
- ]}
- />
- </Field>
- <div className="h-px bg-line-subtle" />
- <ToggleRow
- id="allow-guest-access"
- title={t("admin.systemSettings.guestAccess")}
- description={t("admin.systemSettings.guestAccessHint")}
- checked={settings?.allowGuestAccess ?? false}
- onCheckedChange={(checked) => updateSettings({ allowGuestAccess: checked })}
- disabled={!settings || isUpdating}
- />
- </div>
- </section>
-
<div className="grid gap-[14px] lg:grid-cols-[minmax(0,1fr)_320px] lg:gap-[18px]">
{/* Recent activity */}
<section className="flex min-w-0 flex-col gap-2 lg:gap-0 lg:overflow-hidden lg:rounded-[12px] lg:border lg:border-line lg:bg-surface-card">
@@ -363,6 +368,157 @@ export default function AdminDashboardPage() {
</section>
</div>
</div>
+
+ <section className="flex flex-col gap-2 lg:gap-0 lg:overflow-hidden lg:rounded-[12px] lg:border lg:border-line lg:bg-surface-card">
+ <div className="lg:border-b lg:border-line lg:px-4 lg:py-[13px]">
+ <h2 className="eyebrow lg:hidden">{t("admin.guestAccess.title")}</h2>
+ <span className="hidden text-[14px] font-semibold text-fg-strong lg:inline">
+ {t("admin.guestAccess.title")}
+ </span>
+ <p className="mt-0.5 text-[12.5px] text-fg-tertiary">{t("admin.guestAccess.description")}</p>
+ </div>
+ <div className="flex flex-col gap-4 rounded-[11px] border border-line bg-surface-card p-3 lg:rounded-none lg:border-0 lg:p-4">
+ <ToggleRow
+ id="allow-guest-access"
+ title={t("admin.guestAccess.toggleLabel")}
+ description={t("admin.guestAccess.toggleHint")}
+ checked={settings?.allowGuestAccess ?? false}
+ onCheckedChange={(checked) => updateSettings({ allowGuestAccess: checked })}
+ disabled={!settings || isUpdating}
+ />
+ </div>
+ </section>
+
+ <section className="flex flex-col gap-2 lg:gap-0 lg:overflow-hidden lg:rounded-[12px] lg:border lg:border-line lg:bg-surface-card">
+ <div className="lg:border-b lg:border-line lg:px-4 lg:py-[13px]">
+ <h2 className="eyebrow lg:hidden">{t("admin.systemSettings.title")}</h2>
+ <span className="hidden text-[14px] font-semibold text-fg-strong lg:inline">
+ {t("admin.systemSettings.title")}
+ </span>
+ <p className="mt-0.5 text-[12.5px] text-fg-tertiary">{t("admin.systemSettings.description")}</p>
+ </div>
+ <div className="flex flex-col gap-4 rounded-[11px] border border-line bg-surface-card p-3 lg:rounded-none lg:border-0 lg:p-4">
+ <ToggleRow
+ id="update-check-enabled"
+ title={t("admin.systemSettings.checkEnabled")}
+ description={t("admin.systemSettings.checkEnabledHint")}
+ checked={settings?.updateCheckEnabled ?? true}
+ onCheckedChange={(checked) => updateSettings({ updateCheckEnabled: checked })}
+ disabled={!settings || isUpdating}
+ />
+ <Field label={t("admin.systemSettings.visibility")}>
+ <ChoiceChips<UpdateBannerVisibility>
+ value={settings?.updateBannerVisibility ?? "all"}
+ onChange={(updateBannerVisibility) => updateSettings({ updateBannerVisibility })}
+ disabled={!settings || isUpdating || !settings.updateCheckEnabled}
+ options={[
+ { value: "all", label: t("admin.systemSettings.visibilityAll") },
+ { value: "admins", label: t("admin.systemSettings.visibilityAdmins") },
+ ]}
+ />
+ </Field>
+ </div>
+ </section>
+
+ <section className="flex flex-col gap-2 lg:gap-0 lg:overflow-hidden lg:rounded-[12px] lg:border lg:border-line lg:bg-surface-card">
+ <div className="lg:border-b lg:border-line lg:px-4 lg:py-[13px]">
+ <h2 className="eyebrow lg:hidden">{t("admin.telemetry.title")}</h2>
+ <span className="hidden text-[14px] font-semibold text-fg-strong lg:inline">
+ {t("admin.telemetry.title")}
+ </span>
+ <p className="mt-0.5 text-[12.5px] text-fg-tertiary">{t("admin.telemetry.description")}</p>
+ </div>
+ <div className="flex flex-col gap-4 rounded-[11px] border border-line bg-surface-card p-3 lg:rounded-none lg:border-0 lg:p-4">
+ <ToggleRow
+ id="telemetry-enabled"
+ title={t("admin.telemetry.toggleLabel")}
+ description={
+ settings?.telemetryEnvManaged
+ ? t("admin.telemetry.envManaged")
+ : settings?.telemetryEnabled === null
+ ? t("admin.telemetry.notDecided")
+ : undefined
+ }
+ checked={telemetryEnabled}
+ onCheckedChange={(checked) => updateSettings({ telemetryEnabled: checked })}
+ disabled={!settings || isUpdating || settings.telemetryEnvManaged}
+ />
+
+ <details className="rounded-lg border border-line">
+ <summary className="cursor-pointer select-none px-3 py-2 text-[13px] font-medium text-fg-secondary">
+ {t("admin.telemetry.previewTitle")}
+ </summary>
+ <pre className="max-h-[240px] overflow-auto rounded-b-lg border-t border-line bg-surface-panel px-3 py-2.5 text-[11.5px] leading-relaxed text-fg-tertiary">
+ {telemetryPreview ? JSON.stringify(telemetryPreview, null, 2) : t("common.loading")}
+ </pre>
+ </details>
+
+ <div className="flex flex-wrap items-center gap-x-3 gap-y-1.5">
+ <Button
+ variant="outline"
+ size="sm"
+ className="h-8 rounded-lg font-semibold"
+ disabled={!telemetryEnabled || isSending}
+ onClick={() => sendNow()}
+ >
+ {t("admin.telemetry.sendNow")}
+ </Button>
+ {!telemetryEnabled && (
+ <span className="text-[12.5px] text-fg-tertiary">{t("admin.telemetry.sendNowHint")}</span>
+ )}
+ </div>
+
+ <div className="h-px bg-line-subtle" />
+
+ <div className="flex flex-col gap-1">
+ <span className="block text-[14px] font-semibold text-fg-strong">
+ {t("admin.telemetry.diagnosticsTitle")}
+ </span>
+ <p className="text-[12.5px] text-fg-secondary">{t("admin.telemetry.diagnosticsDescription")}</p>
+ </div>
+
+ {telemetryEnabled && (
+ <ToggleRow
+ id="telemetry-include-instance-id"
+ title={t("admin.telemetry.includeInstanceId")}
+ description={t("admin.telemetry.includeInstanceIdHint")}
+ checked={includeInstanceId}
+ onCheckedChange={setIncludeInstanceId}
+ />
+ )}
+
+ <details
+ className="rounded-lg border border-line"
+ onToggle={(event) => setDiagnosticsOpen(event.currentTarget.open)}
+ >
+ <summary className="cursor-pointer select-none px-3 py-2 text-[13px] font-medium text-fg-secondary">
+ {t("admin.telemetry.diagnosticsPreviewTitle")}
+ </summary>
+ <pre className="max-h-[240px] overflow-auto rounded-b-lg border-t border-line bg-surface-panel px-3 py-2.5 text-[11.5px] leading-relaxed text-fg-tertiary">
+ {diagnosticsBody ? JSON.stringify(diagnosticsBody, null, 2) : t("common.loading")}
+ </pre>
+ </details>
+
+ <div className="flex flex-wrap items-center gap-2">
+ <Button
+ variant="outline"
+ size="sm"
+ className="h-8 rounded-lg font-semibold"
+ disabled={!diagnosticsBody}
+ onClick={copyDiagnostics}
+ >
+ {t("admin.telemetry.copy")}
+ </Button>
+ {issueHref && !issueHrefTooLong && (
+ <Button variant="outline" size="sm" asChild className="h-8 rounded-lg font-semibold">
+ <a href={issueHref} target="_blank" rel="noopener noreferrer">
+ {t("admin.telemetry.openIssue")}
+ </a>
+ </Button>
+ )}
+ </div>
+ </div>
+ </section>
</div>
);
}
diff --git a/app/api/admin/system-settings/route.ts b/app/api/admin/system-settings/route.ts
index 9782d5c..fcfa6fc 100644
--- a/app/api/admin/system-settings/route.ts
+++ b/app/api/admin/system-settings/route.ts
@@ -4,12 +4,34 @@ import { canManageSystemSettings } from "@/lib/auth/admin";
import {
getSystemSettings,
updateSystemSettings,
+ type SystemSettings,
type UpdateBannerVisibility,
} from "@/lib/system-settings";
-import { logAdminAction } from "@/lib/audit-log";
+import {
+ logAdminAction,
+ type AdminSystemSettingsUpdatedMetadata,
+ type AdminTelemetryConsentMetadata,
+} from "@/lib/audit-log";
+import {
+ isTelemetryForcedByEnv,
+ resolveTelemetryEnabled,
+} from "@/lib/telemetry/config";
+import { TELEMETRY_SCHEMA_VERSION } from "@/lib/telemetry/schema";
const VISIBILITY_VALUES: UpdateBannerVisibility[] = ["all", "admins"];
+/** Enumerated, not spread: an audit log is exportable and must never carry the instance id. */
+function forAudit(settings: SystemSettings): AdminSystemSettingsUpdatedMetadata["before"] {
+ return {
+ updateCheckEnabled: settings.updateCheckEnabled,
+ updateBannerVisibility: settings.updateBannerVisibility,
+ allowGuestAccess: settings.allowGuestAccess,
+ telemetryEnabled: settings.telemetryEnabled,
+ telemetryConsentedSchema: settings.telemetryConsentedSchema,
+ telemetryDecidedAt: settings.telemetryDecidedAt,
+ };
+}
+
/**
* Admin System Settings API
*
@@ -37,7 +59,13 @@ export async function GET(request: NextRequest) {
if (error) return error;
const settings = await getSystemSettings();
- return NextResponse.json(settings);
+ // Derived, never stored: the client can't read process.env itself, so the
+ // panel would otherwise show the stored value while the env override sends.
+ return NextResponse.json({
+ ...settings,
+ telemetryEnvManaged: isTelemetryForcedByEnv(),
+ telemetryResolved: resolveTelemetryEnabled(settings.telemetryEnabled),
+ });
} catch (error) {
console.error("Failed to fetch system settings:", error);
return NextResponse.json(
@@ -61,6 +89,10 @@ export async function PATCH(request: NextRequest) {
updateCheckEnabled?: boolean;
updateBannerVisibility?: UpdateBannerVisibility;
allowGuestAccess?: boolean;
+ telemetryEnabled?: boolean;
+ telemetryDecidedAt?: Date;
+ telemetryConsentedSchema?: number;
+ telemetryInstanceId?: string;
} = {};
if ("updateCheckEnabled" in body) {
@@ -87,15 +119,49 @@ export async function PATCH(request: NextRequest) {
patch.allowGuestAccess = body.allowGuestAccess;
}
+ if ("telemetryEnabled" in body) {
+ if (typeof body.telemetryEnabled !== "boolean") {
+ return NextResponse.json({ error: "telemetryEnabled must be a boolean" }, { status: 400 });
+ }
+ if (isTelemetryForcedByEnv()) {
+ return NextResponse.json(
+ { error: "telemetryEnabled is managed by the TELEMETRY_ENABLED environment variable and cannot be changed here" },
+ { status: 400 }
+ );
+ }
+ patch.telemetryEnabled = body.telemetryEnabled;
+ patch.telemetryDecidedAt = new Date();
+ patch.telemetryConsentedSchema = TELEMETRY_SCHEMA_VERSION;
+ if (body.telemetryEnabled) {
+ const current = await getSystemSettings();
+ // Created on first opt-in only, never at install time.
+ patch.telemetryInstanceId = current.telemetryInstanceId ?? crypto.randomUUID();
+ }
+ }
+
const { before, after } = await updateSystemSettings(patch);
- await logAdminAction({
+ await logAdminAction<AdminSystemSettingsUpdatedMetadata>({
action: "admin.system_settings.update",
userId: currentUser!.id,
request,
- metadata: { before, after },
+ metadata: { before: forAudit(before), after: forAudit(after) },
});
+ if ("telemetryEnabled" in patch) {
+ await logAdminAction<AdminTelemetryConsentMetadata>({
+ action: "admin.telemetry_consent",
+ userId: currentUser!.id,
+ resourceType: "system_settings",
+ request,
+ metadata: {
+ before: before.telemetryEnabled,
+ after: after.telemetryEnabled === true,
+ schemaVersion: TELEMETRY_SCHEMA_VERSION,
+ },
+ });
+ }
+
return NextResponse.json(after);
} catch (error) {
console.error("Failed to update system settings:", error);
diff --git a/app/api/admin/telemetry/payload/route.ts b/app/api/admin/telemetry/payload/route.ts
new file mode 100644
index 0000000..3577116
--- /dev/null
+++ b/app/api/admin/telemetry/payload/route.ts
@@ -0,0 +1,47 @@
+import { NextRequest, NextResponse } from "next/server";
+import { getValidatedAdminUser, isErrorResponse } from "@/lib/auth/admin-helpers";
+import { canManageSystemSettings } from "@/lib/auth/admin";
+import { rateLimit } from "@/lib/rate-limiter";
+import { collectTelemetryPayload } from "@/lib/telemetry/collect";
+import { ensureTelemetryInstanceId } from "@/lib/telemetry/instance-id";
+
+/**
+ * Admin preview of the telemetry payload.
+ *
+ * GET /api/admin/telemetry/payload?profile=telemetry|diagnostics
+ *
+ * Permission: Admin or Superadmin only
+ */
+export async function GET(request: NextRequest) {
+ const currentUser = await getValidatedAdminUser(request);
+ if (isErrorResponse(currentUser)) return currentUser;
+
+ if (!canManageSystemSettings(currentUser)) {
+ return NextResponse.json({ error: "Admin access required" }, { status: 403 });
+ }
+
+ const limited = rateLimit(request, currentUser.id, "telemetry-payload");
+ if (limited) return limited;
+
+ const profile =
+ request.nextUrl.searchParams.get("profile") === "diagnostics"
+ ? "diagnostics"
+ : "telemetry";
+
+ try {
+ await ensureTelemetryInstanceId();
+ const payload =
+ profile === "diagnostics"
+ ? await collectTelemetryPayload("diagnostics")
+ : await collectTelemetryPayload("telemetry");
+ return NextResponse.json(payload, {
+ headers: { "Cache-Control": "private, no-store" },
+ });
+ } catch (error) {
+ console.error("Failed to collect telemetry payload:", error);
+ return NextResponse.json(
+ { error: "Failed to collect telemetry payload" },
+ { status: 500 }
+ );
+ }
+}
diff --git a/app/api/admin/telemetry/send/route.ts b/app/api/admin/telemetry/send/route.ts
new file mode 100644
index 0000000..a9e7436
--- /dev/null
+++ b/app/api/admin/telemetry/send/route.ts
@@ -0,0 +1,59 @@
+import { NextRequest, NextResponse } from "next/server";
+import { getValidatedAdminUser, isErrorResponse } from "@/lib/auth/admin-helpers";
+import { canManageSystemSettings } from "@/lib/auth/admin";
+import { rateLimit } from "@/lib/rate-limiter";
+import { logAdminAction, type TelemetrySendMetadata } from "@/lib/audit-log";
+import { sendTelemetryNow, toSendAuditMetadata } from "@/lib/telemetry/sender";
+
+/**
+ * Sends the telemetry payload right away instead of waiting for the daily timer.
+ *
+ * POST /api/admin/telemetry/send
+ *
+ * Same guards as the daily send: nothing is sent unless telemetry is on, the
+ * consent covers the current schema.
+ *
+ * Permission: Admin or Superadmin only
+ */
+export async function POST(request: NextRequest) {
+ const currentUser = await getValidatedAdminUser(request);
+ if (isErrorResponse(currentUser)) return currentUser;
+
+ if (!canManageSystemSettings(currentUser)) {
+ return NextResponse.json({ error: "Admin access required" }, { status: 403 });
+ }
+
+ const limited = rateLimit(request, currentUser.id, "telemetry-send");
+ if (limited) return limited;
+
+ try {
+ const result = await sendTelemetryNow();
+
+ if (result.status === "sent" || result.status === "failed") {
+ await logAdminAction<TelemetrySendMetadata>({
+ action: "admin.telemetry_send",
+ userId: currentUser.id,
+ resourceType: "system_settings",
+ request,
+ metadata: toSendAuditMetadata(result),
+ });
+ }
+
+ if (result.status === "sent") {
+ return NextResponse.json({ ok: true });
+ }
+ if (result.status === "failed") {
+ return NextResponse.json(
+ { error: "Telemetry endpoint did not accept the request", reason: result.reason },
+ { status: 502 }
+ );
+ }
+ return NextResponse.json(
+ { error: "Telemetry is not sendable", reason: result.status },
+ { status: 409 }
+ );
+ } catch (error) {
+ console.error("Failed to send telemetry:", error);
+ return NextResponse.json({ error: "Failed to send telemetry" }, { status: 500 });
+ }
+}
diff --git a/app/api/version/route.ts b/app/api/version/route.ts
index 2caf029..8e74886 100644
--- a/app/api/version/route.ts
+++ b/app/api/version/route.ts
@@ -3,6 +3,8 @@ import { getBuildInfo, buildGitHubUrl } from "@/lib/version";
import { getAdminUser } from "@/lib/auth/admin-helpers";
import { isAdmin } from "@/lib/auth/admin";
import { getSystemSettings } from "@/lib/system-settings";
+import { TELEMETRY_SCHEMA_VERSION } from "@/lib/telemetry/schema";
+import { isTelemetryForcedByEnv } from "@/lib/telemetry/config";
/**
* Cache Strategy: 15 minutes for the GitHub release lookup.
@@ -24,6 +26,8 @@ interface VersionResponse {
latestVersion?: string;
latestUrl?: string;
hasUpdate?: boolean;
+ /** Admins only: the consent dialog must be shown. */
+ telemetryPrompt?: boolean;
}
// Cache latest release info
@@ -109,14 +113,14 @@ function isDevVersion(version: string): boolean {
}
/** Whether the given requester's role is included in the configured banner audience. */
-async function isVisibleToRequester(
- request: NextRequest,
+function isVisibleToRequester(
+ requesterIsAdmin: boolean,
visibility: "all" | "admins"
-): Promise<boolean> {
+): boolean {
if (visibility === "all") return true;
// "admins": only requesters with an admin/superadmin role qualify
- return isAdmin(await getAdminUser(request.headers));
+ return requesterIsAdmin;
}
export async function GET(request: NextRequest) {
@@ -125,6 +129,20 @@ export async function GET(request: NextRequest) {
getSystemSettings(),
]);
+ // Once an instance has answered for the current schema no prompt is possible,
+ // so the session lookup is skipped unless a role-specific answer needs it.
+ const telemetryPromptPossible =
+ !isTelemetryForcedByEnv() &&
+ (settings.telemetryEnabled === null ||
+ (settings.telemetryEnabled === true &&
+ (settings.telemetryConsentedSchema ?? 0) < TELEMETRY_SCHEMA_VERSION));
+ const needsRequesterRole =
+ settings.updateBannerVisibility === "admins" || telemetryPromptPossible;
+ // Resolved once and reused below, so the admin lookup only runs once per request.
+ const requesterIsAdmin = needsRequesterRole
+ ? isAdmin(await getAdminUser(request.headers))
+ : false;
+
// Build GitHub URL based on version and commit
const githubUrl = buildGitHubUrl(buildInfo.version, buildInfo.commitSha);
@@ -141,7 +159,11 @@ export async function GET(request: NextRequest) {
const showUpdateInfo =
!!latestRelease &&
- (await isVisibleToRequester(request, settings.updateBannerVisibility));
+ isVisibleToRequester(requesterIsAdmin, settings.updateBannerVisibility);
+
+ // Admin-only and never cached across roles: the response is already
+ // Cache-Control: private for exactly this reason.
+ const telemetryPrompt = telemetryPromptPossible && requesterIsAdmin;
const response: VersionResponse = {
version: buildInfo.version,
@@ -158,12 +180,19 @@ export async function GET(request: NextRequest) {
latestUrl: latestRelease.url,
hasUpdate,
}),
+ telemetryPrompt,
};
return NextResponse.json(response, {
headers: {
- // "private": the response varies by requester role, so shared/CDN caches must not reuse it
- "Cache-Control": `private, max-age=${CACHE_SECONDS}`,
+ // "private": the response varies by requester role, so shared/CDN caches must not reuse it.
+ // While a prompt is pending, no-store: a cached response would let an admin's browser keep
+ // re-showing the consent dialog after they already answered it, until the max-age expired.
+ "Cache-Control": telemetryPrompt
+ ? "private, no-store"
+ : `private, max-age=${CACHE_SECONDS}`,
+ // Without this the browser reuses a logged-out response after login and the admin never sees the prompt.
+ Vary: "Cookie",
},
});
}
diff --git a/app/page.tsx b/app/page.tsx
index 9251628..dbd450b 100644
--- a/app/page.tsx
+++ b/app/page.tsx
@@ -21,6 +21,7 @@ import { useDialogStates } from "@/hooks/useDialogStates";
import { useAuth } from "@/hooks/useAuth";
import { useConnectionStatus } from "@/hooks/useConnectionStatus";
import { useCalendarPermission } from "@/hooks/useCalendarPermission";
+import { useVersionUpdateCheck } from "@/hooks/useVersionUpdate";
import { DESKTOP_QUERY, useMediaQuery } from "@/hooks/useMediaQuery";
import { CalendarViewMode, useCalendarViewMode } from "@/hooks/useCalendarViewMode";
import { EmptyCalendarState } from "@/components/empty-calendar-state";
@@ -56,6 +57,11 @@ function HomeContent() {
const { isGuest } = useAuth();
+ const { versionInfo } = useVersionUpdateCheck();
+ const telemetryPrompt = versionInfo?.telemetryPrompt;
+ // Local flag so the dialog closes right after an answer, without waiting for the next poll.
+ const [telemetryDecided, setTelemetryDecided] = useState(false);
+
const {
calendars,
selectedCalendar,
@@ -395,6 +401,8 @@ function HomeContent() {
onMonthStatsDialogChange={dialogStates.setShowMonthStatsDialog}
showPresetManageDialog={dialogStates.showPresetManageDialog}
onPresetManageDialogChange={dialogStates.setShowPresetManageDialog}
+ showTelemetryConsent={Boolean(telemetryPrompt) && !telemetryDecided}
+ onTelemetryDecide={() => setTelemetryDecided(true)}
/>
);
diff --git a/components/admin/audit-describe.ts b/components/admin/audit-describe.ts
index 0633ebe..2c328a6 100644
--- a/components/admin/audit-describe.ts
+++ b/components/admin/audit-describe.ts
@@ -77,6 +77,18 @@ export function useAuditDescription() {
return t("adminAudit.describe.logsDeleted", { count: count(m, "deletedCount") });
case "admin.system_settings.update":
return t("adminAudit.describe.systemSettingsUpdated");
+ case "admin.telemetry_consent":
+ return field(m, "after") === true
+ ? t("adminAudit.describe.telemetryEnabled")
+ : t("adminAudit.describe.telemetryDisabled");
+ case "admin.telemetry_send":
+ return field(m, "result") === "failed"
+ ? t("adminAudit.describe.telemetrySendFailed")
+ : t("adminAudit.describe.telemetrySent");
+ case "system.telemetry_send":
+ return field(m, "result") === "failed"
+ ? t("adminAudit.describe.telemetryAutoSendFailed")
+ : t("adminAudit.describe.telemetryAutoSent");
case "admin.calendar.update":
case "calendar.updated":
if (calendar) return t("adminAudit.describe.calendarUpdated", { calendar });
diff --git a/components/dialog-manager.tsx b/components/dialog-manager.tsx
index 0a42875..1d39cab 100644
--- a/components/dialog-manager.tsx
+++ b/components/dialog-manager.tsx
@@ -9,6 +9,7 @@ import { NoteSheet } from "@/components/note-sheet";
import { NotesListDialog } from "@/components/notes-list-dialog";
import { PresetManageSheet } from "@/components/preset-manage-sheet";
import { MonthStatsDialog } from "@/components/month-dialogs";
+import { TelemetryConsentDialog } from "@/components/telemetry-consent-dialog";
import { DESKTOP_QUERY, useMediaQuery } from "@/hooks/useMediaQuery";
import { ShiftWithCalendar } from "@/lib/types";
import { CalendarNote } from "@/lib/db/schema";
@@ -86,6 +87,10 @@ interface DialogManagerProps {
// Preset management opened from the stamp dock
showPresetManageDialog: boolean;
onPresetManageDialogChange: (open: boolean) => void;
+
+ // Telemetry consent gate, shown once to an admin whose instance has not decided yet
+ showTelemetryConsent: boolean;
+ onTelemetryDecide: (accepted: boolean) => void;
}
export function DialogManager(props: DialogManagerProps) {
@@ -190,6 +195,11 @@ export function DialogManager(props: DialogManagerProps) {
note={props.selectedNote}
calendarId={props.noteCalendarId ?? (props.selectedCalendar || undefined)}
/>
+
+ {/* Mounted only while relevant, so a non-admin session never fires the admin-only fetches it needs. */}
+ {props.showTelemetryConsent && (
+ <TelemetryConsentDialog open onDecide={props.onTelemetryDecide} />
+ )}
</>
);
}
diff --git a/components/telemetry-consent-dialog.tsx b/components/telemetry-consent-dialog.tsx
new file mode 100644
index 0000000..1d0b32e
--- /dev/null
+++ b/components/telemetry-consent-dialog.tsx
@@ -0,0 +1,118 @@
+"use client";
+
+import { useTranslations } from "next-intl";
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from "@/components/ui/dialog";
+import { Button } from "@/components/ui/button";
+import { useTelemetryPayload } from "@/hooks/useTelemetryPayload";
+import { useSystemSettings } from "@/hooks/useSystemSettings";
+
+// Default upstream repo; a self-hosted fork's GITHUB_REPO_OWNER/NAME override isn't
+// available client-side, so this doc link always points at the canonical project.
+const TELEMETRY_DOCS_URL =
+ "https://github.com/panteLx/BetterShift/blob/main/docs/TELEMETRY.md";
+
+interface TelemetryConsentDialogProps {
+ open: boolean;
+ onDecide: (accepted: boolean) => void;
+}
+
+/**
+ * One-time, non-dismissible consent gate shown to an admin whose instance has not
+ * yet decided on telemetry. Only the two buttons resolve it — no other way out.
+ */
+export function TelemetryConsentDialog({ open, onDecide }: TelemetryConsentDialogProps) {
+ const t = useTranslations();
+ const { updateSettings, isUpdating } = useSystemSettings();
+ // Real payload of this instance, not a mock — fetched only while the dialog is open.
+ const { data: payload } = useTelemetryPayload("telemetry", open);
+
+ const decide = (accepted: boolean) => {
+ updateSettings({ telemetryEnabled: accepted });
+ onDecide(accepted);
+ };
+
+ return (
+ <Dialog open={open}>
+ <DialogContent
+ showCloseButton={false}
+ className="gap-0 overflow-hidden rounded-2xl border-control p-0 shadow-window sm:max-w-[480px]"
+ onEscapeKeyDown={(event) => event.preventDefault()}
+ onPointerDownOutside={(event) => event.preventDefault()}
+ onInteractOutside={(event) => event.preventDefault()}
+ >
+ <DialogHeader className="gap-1.5 border-b border-line px-[22px] pb-4 pt-5 text-left">
+ <DialogTitle className="text-[19px] font-semibold leading-tight tracking-[-0.01em] text-fg-strong">
+ {t("telemetry.consent.title")}
+ </DialogTitle>
+ <DialogDescription className="mt-1 text-[13.5px] text-fg-secondary">
+ {t("telemetry.consent.description")}
+ </DialogDescription>
+ </DialogHeader>
+
+ <div className="flex max-h-[min(60vh,480px)] flex-col gap-3.5 overflow-y-auto px-[22px] py-[18px]">
+ <ul className="flex flex-col gap-1.5 text-[13px] text-fg-secondary">
+ <li className="flex gap-2">
+ <span aria-hidden>•</span>
+ {t("telemetry.consent.pointAnonymous")}
+ </li>
+ <li className="flex gap-2">
+ <span aria-hidden>•</span>
+ {t("telemetry.consent.pointBuckets")}
+ </li>
+ <li className="flex gap-2">
+ <span aria-hidden>•</span>
+ {t("telemetry.consent.pointRevocable")}
+ </li>
+ </ul>
+
+ <details className="rounded-lg border border-line">
+ <summary className="cursor-pointer select-none px-3 py-2 text-[13px] font-medium text-fg-secondary">
+ {t("telemetry.consent.previewToggle")}
+ </summary>
+ <pre className="max-h-[240px] overflow-auto rounded-b-lg border-t border-line bg-surface-panel px-3 py-2.5 text-[11.5px] leading-relaxed text-fg-tertiary">
+ {payload ? JSON.stringify(payload, null, 2) : t("common.loading")}
+ </pre>
+ </details>
+
+ <a
+ href={TELEMETRY_DOCS_URL}
+ target="_blank"
+ rel="noreferrer"
+ className="text-[13px] font-medium text-brand-ink underline underline-offset-2"
+ >
+ {t("telemetry.consent.docsLink")}
+ </a>
+ </div>
+
+ <DialogFooter className="flex-row gap-2.5 border-t border-line px-[22px] pb-[max(16px,env(safe-area-inset-bottom))] pt-4">
+ {/* Equal variant on both sides on purpose — a highlighted accept would be a dark pattern. */}
+ <Button
+ type="button"
+ variant="outline"
+ className="h-10 flex-1 font-semibold"
+ disabled={isUpdating}
+ onClick={() => decide(true)}
+ >
+ {t("telemetry.consent.accept")}
+ </Button>
+ <Button
+ type="button"
+ variant="outline"
+ className="h-10 flex-1 font-semibold"
+ disabled={isUpdating}
+ onClick={() => decide(false)}
+ >
+ {t("telemetry.consent.decline")}
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ );
+}
diff --git a/docs/TELEMETRY.md b/docs/TELEMETRY.md
new file mode 100644
index 0000000..070f62f
--- /dev/null
+++ b/docs/TELEMETRY.md
@@ -0,0 +1,145 @@
+# Telemetry Guide
+
+This guide documents the anonymous usage telemetry BetterShift can send, field by field, so a self-hoster can decide whether to turn it on without reading the source. It also covers the diagnostics export and every other outbound request the app makes on its own.
+
+## Table of Contents
+
+1. [What This Is](#what-this-is)
+2. [Every Field](#every-field)
+3. [What Is Never Collected](#what-is-never-collected)
+4. [Buckets](#buckets)
+5. [Turning It Off](#turning-it-off)
+6. [Where It Goes](#where-it-goes)
+7. [Other Outbound Requests](#other-outbound-requests)
+8. [The Diagnostics Export](#the-diagnostics-export)
+
+---
+
+## What This Is
+
+Telemetry is **opt-in and off by default**. A fresh instance sends nothing until an admin explicitly agrees to it in a one-time consent dialog; declining is a permanent, equally valid answer. When enabled, one payload is sent roughly once a day (with a random 5–30 minute startup delay so a fleet of instances restarting together doesn't all report at the same moment). There is no per-request tracking, no analytics script in the page, and no cookie tied to this — the payload is a single, independently generated snapshot of the instance's own state.
+
+The payload is anonymous in the sense that it carries no names, emails, URLs, or IP addresses (see [What Is Never Collected](#what-is-never-collected)) — it is not anonymous in the sense of being unlinkable to itself: a stable `instanceId` lets repeated pings from the same instance be grouped over time.
+
+Admins can also send the payload right away with the **Send now** button in Admin → System Settings instead of waiting for the daily timer. It follows the same rules as the daily send — it only works while telemetry is on, and the consent covers the current `schemaVersion` — and it does not reset the daily schedule. It is rate limited (default 5 per hour, `RATE_LIMIT_TELEMETRY_SEND_REQUESTS` / `RATE_LIMIT_TELEMETRY_SEND_WINDOW`) and leaves an audit-log entry with only the outcome, never the endpoint URL. Every automatic send leaves the same kind of entry (`system.telemetry_send`), so the last outcome is visible in the audit log even though the timer itself stays silent.
+
+If a future release changes what is collected in a way that needs fresh consent, an instance that previously accepted is asked again once (governed by `schemaVersion` — see the field table below); an instance that declined is never re-prompted.
+
+---
+
+## Every Field
+
+This table is generated from `TelemetryPayload` in [`lib/telemetry/schema.ts`](../lib/telemetry/schema.ts) — every field the type defines appears below, and nothing else does. Fields under `scale` are size buckets, not exact counts (see [Buckets](#buckets)); the [diagnostics export](#the-diagnostics-export) is the only path that ever carries exact numbers, and only on admin request.
+
+| Field | Example | Answers |
+| -------------------------------- | -------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `schemaVersion` | `1` | Which version of this payload's shape was used, so a schema change can be handled or ignored correctly. |
+| `instanceId` | `"3f2a9c11-8b7d-4e2a-9c31-7a5e6d2b9f01"` or `null` | A random id generated once, the first time telemetry is turned on, so repeated pings from the same instance can be grouped. `null` before an instance has ever opted in. |
+| `sentAt` | `"2026-09-19T14:32:07.512Z"` | When this specific payload was generated. |
+| `app.version` | `"3.2.0"` | Which release is running. |
+| `app.isDev` | `false` | Is this a development build. Dev builds send like any other; the flag only lets the receiving side tell them apart. |
+| `app.migrations` | `42` | How many database migrations have been applied — a rough signal of how current the schema is. |
+| `runtime.node` | `"24.4.0"` | Which Node.js version the process is running on. |
+| `runtime.arch` | `"x64"` | Which CPU architecture (`x64`, `arm64`, …). |
+| `runtime.platform` | `"linux"` | Which OS family the process runs on. |
+| `runtime.sqlite` | `"3.45.1"` | Which SQLite version the database driver reports. |
+| `runtime.timezone` | `"Europe/Berlin"` or `"unknown"` | The value of the `TZ` environment variable, if set. |
+| `config.authEnabled` | `true` | Is authentication turned on for this instance. |
+| `config.guestAccess` | `false` | Is guest (no-login) access allowed. |
+| `config.registrationOpen` | `true` | Can new users self-register. |
+| `config.defaultLocale` | `"de"` | Which locale the instance defaults to. This is the instance-wide default only — there is deliberately no per-user locale field, because nothing in the app stores one per account. |
+| `config.updateCheckEnabled` | `true` | Has this admin turned off the update check described in [Other Outbound Requests](#other-outbound-requests). |
+| `config.rateLimitOverrides` | `2` | How many `RATE_LIMIT_*` environment variables are set — a count only, never which ones or what values. |
+| `scale.users` | `"6-20"` | Roughly how many user accounts exist. |
+| `scale.calendars` | `"1-5"` | Roughly how many calendars exist. |
+| `scale.shifts` | `"101-500"` | Roughly how many shifts exist. |
+| `scale.presets` | `"6-20"` | Roughly how many shift presets exist. |
+| `scale.notes` | `"1-5"` | Roughly how many calendar notes/events exist. |
+| `scale.bundles` | `"6-20"` | Roughly how many permission bundles exist across all calendars. |
+| `scale.shares` | `"1-5"` | Roughly how many calendar shares (invited users) exist. |
+| `scale.accessTokens` | `"0"` | Roughly how many share links (access tokens) exist. |
+| `scale.signups` | `"1-5"` | Roughly how many shift signups exist. |
+| `features.externalSyncs` | `"0"` | Roughly how many external calendar subscriptions are configured — never which calendars they sync to or their URLs. |
+| `features.calendarViewOverrides` | `"1-5"` | Roughly how many calendars pin their own view settings instead of using each viewer's personal one. |
+| `features.customFields.count` | `"1-5"` | Roughly how many custom field definitions exist across all calendars. |
+| `features.customFields.types` | `["text", "select"]` | Which custom field _types_ are in use — never a field's key or label (see [What Is Never Collected](#what-is-never-collected)). |
+| `features.archivedPresets` | `true` | Does at least one archived preset exist. |
+| `features.splitShifts` | `false` | Does at least one calendar have split shifts enabled. |
+| `health.uptimeHours` | `168` | How many hours since the Node process last (re)started. |
+| `health.syncRuns24h` | `12` | How many external sync runs completed in the last 24 hours. |
+| `health.syncFailures24h` | `0` | How many of those runs failed. |
+
+---
+
+## What Is Never Collected
+
+Regardless of what's enabled, the payload never contains:
+
+- External sync URLs — they can reveal an employer or organization.
+- Calendar, shift, or note names/content.
+- Custom field keys or labels — only the field _types_ (see `features.customFields.types` above).
+- User names.
+- Email addresses.
+- IP addresses.
+- The instance's hostname or domain.
+
+---
+
+## Buckets
+
+Every count under `scale` and `features.externalSyncs` / `features.calendarViewOverrides` / `features.customFields.count` is reported as one of six size buckets instead of an exact number, via `toBucket()` in `lib/telemetry/schema.ts`:
+
+| Bucket | Range |
+| --------- | -------------- |
+| `0` | Exactly zero. |
+| `1-5` | 1 to 5. |
+| `6-20` | 6 to 20. |
+| `21-100` | 21 to 100. |
+| `101-500` | 101 to 500. |
+| `500+` | More than 500. |
+
+The comment in the source is explicit about why: an exact count can make a small instance recognisable (e.g. "exactly 3 users"); a bucket answers the same scale question without doing so.
+
+---
+
+## Turning It Off
+
+Three independent controls, in order of precedence:
+
+1. **`TELEMETRY_ENABLED=false`** in `.env` — a hard off. It wins over any stored answer, including a previous "yes": no consent dialog is shown, no daily send ever fires, and the admin toggle described below is disabled (shown as environment-managed). This is the setting for an unattended or scripted deployment where telemetry must never be a question.
+2. **`TELEMETRY_ENABLED=true`** — the mirror image: a hard on. It also skips the dialog and disables the admin toggle, and wins over a stored "no".
+3. **The admin toggle** (Admin → System Settings) — only reachable when `TELEMETRY_ENABLED` is unset in the environment. This is what the one-time consent dialog writes to, and it can be flipped again at any time afterwards.
+
+Only the literal values `true` and `false` are recognised. Anything else (`1`, `yes`, `TRUE`, …) is treated as `false` — a hard off that also disables the admin toggle — so a typo fails closed rather than silently turning telemetry on.
+
+`TELEMETRY_ENDPOINT` (default `https://telemetry-bettershift.pantelx.com`) lets you point the daily send at your own receiver instead — useful if you'd rather run [`telemetry-hub/`](../telemetry-hub/) yourself, or something else entirely that accepts the same JSON body.
+
+---
+
+## Where It Goes
+
+The default endpoint is a small Cloudflare Worker; its source lives in this repository at [`telemetry-hub/`](../telemetry-hub/) (excluded from the Docker image — it's deployed separately, not run alongside the app). It:
+
+- Accepts only `POST` requests up to 16 KB.
+- Validates the payload against the current schema version (`telemetry-hub/src/schemas/v1.ts`). A body that isn't valid JSON is answered with `400` and one larger than 16 KB with `413`; a payload that parses but fails validation, or carries an unknown/retired `schemaVersion`, is answered with `200` and discarded. Either way the fire-and-forget sender ignores the status and never retries.
+- Forwards a valid payload to [PostHog](https://posthog.com/) (`telemetry-hub/src/targets/posthog.ts`), explicitly enumerating each field it passes on rather than forwarding the request body as-is, so an unexpected extra field can never leak through.
+- Sends `$ip: null` and `$geoip_disable: true` with every event, so PostHog neither stores the request IP nor derives a country or city from it — without this, the Cloudflare PoP nearest the sending instance would approximate its location.
+- **Stores nothing itself.** There is no database, no request log, and no persistence layer in the Worker — a payload it can't forward to PostHog is simply lost, not queued or written anywhere.
+
+---
+
+## Other Outbound Requests
+
+Telemetry is not the only request BetterShift makes on its own. Independently of telemetry — and regardless of whether telemetry is enabled — `/api/version` (and the release list behind `/api/releases`) polls the public GitHub releases API for this project on a 15-minute server-side cache, to show admins whether a newer version is available.
+
+This has existed before telemetry was added and is controlled separately: the **"Check for updates"** switch in Admin → System Settings (`updateCheckEnabled`) turns it off. With it off, no request to GitHub is made. Note that `config.updateCheckEnabled` in the telemetry payload only reports whether this switch is on — it does not send anything from the GitHub response itself.
+
+---
+
+## The Diagnostics Export
+
+Separately from the daily telemetry send, Admin → System Settings has a **diagnostics export**: an admin-triggered preview that can be copied or used to pre-fill a GitHub issue.
+
+- It carries the same shape as the telemetry payload, but with **exact numbers** instead of buckets (`scale` and the numeric parts of `features` are plain counts), plus two fields the telemetry payload never has: `envFlags`, the values of a fixed allowlist of environment variables (`AUTH_ENABLED`, `ALLOW_GUEST_ACCESS`, `ALLOW_USER_REGISTRATION`, `DEFAULT_LOCALE`, `TZ`, `TELEMETRY_ENABLED` — see `REPORTABLE_ENV` in `lib/telemetry/collect.ts`, never `process.env` as a whole), plus `TELEMETRY_ENDPOINT`, which is reported as `"custom"` or `"default"` and never as its actual value — a self-hosted receiver URL can be private and carry a token, and this export is meant for public issues, and `migrationList`, the list of applied migration hashes.
+- It works **whether or not telemetry is enabled** — it's a local, on-demand preview, never sent anywhere automatically. Only pressing "copy" or "open issue" puts it anywhere, and that's the admin's own action, to their own clipboard or their own browser tab to GitHub.
+- `instanceId` is included in the exported/copied diagnostics only when telemetry is enabled **and** the admin leaves the separate "include instance id" switch on next to the export. With telemetry off, or that switch off, `instanceId` is reported as `null` in the export regardless of what's stored.
diff --git a/docs/UPGRADING.md b/docs/UPGRADING.md
index 680b1a9..d7c68f5 100644
--- a/docs/UPGRADING.md
+++ b/docs/UPGRADING.md
@@ -25,11 +25,26 @@ Breaking changes between BetterShift releases and the steps to get through them.
## Versions
+- [3.3.0](#330-from-320) — from `3.2.0`
- [3.1.0](#310-from-300) — from `3.0.0`
- [3.0.0](#300-from-22x) — from `2.2.x`
---
+## 3.3.0 (from 3.2.0)
+
+BetterShift 3.3.0 adds optional, anonymous telemetry — see the [Telemetry Guide](TELEMETRY.md) for exactly what is collected and how to control it. There's no schema change requiring action, but there is a one-time interaction every admin will hit after upgrading.
+
+### What to expect (3.3.0)
+
+The first time an admin opens the app after upgrading, a non-dismissible dialog asks whether to enable telemetry. It has no close button and can't be dismissed by pressing Escape or clicking outside — only the "Accept" or "Decline" button resolves it. Declining is stored the same way accepting is: it's a permanent, valid answer, and the dialog does not come back. Non-admin users never see it.
+
+For unattended or scripted deployments where nobody is around to answer, set `TELEMETRY_ENABLED=false` (or `=true`) in `.env` before starting the instance — either value skips the dialog entirely, since an explicit environment setting always overrides the stored database answer. See [Turning It Off](TELEMETRY.md#turning-it-off).
+
+No database backup or manual migration step is needed for this release.
+
+---
+
## 3.1.0 (from 3.0.0)
BetterShift 3.1.0 replaces the fixed calendar read/write/admin permission ladder with per-calendar **permission bundles** — an owner defines named bundles by ticking individual capabilities instead of the app hard-coding what "write" means. See the [Permissions and Sharing Guide](PERMISSIONS.md) for the full picture. The upgrade itself needs no configuration changes; there's a single deliberate behavior change to be aware of, described below.
diff --git a/drizzle/0029_red_night_thrasher.sql b/drizzle/0029_red_night_thrasher.sql
new file mode 100644
index 0000000..e70d5e7
--- /dev/null
+++ b/drizzle/0029_red_night_thrasher.sql
@@ -0,0 +1,4 @@
+ALTER TABLE `system_settings` ADD `telemetry_enabled` integer;--> statement-breakpoint
+ALTER TABLE `system_settings` ADD `telemetry_instance_id` text;--> statement-breakpoint
+ALTER TABLE `system_settings` ADD `telemetry_consented_schema` integer;--> statement-breakpoint
+ALTER TABLE `system_settings` ADD `telemetry_decided_at` integer;
\ No newline at end of file
diff --git a/drizzle/meta/0029_snapshot.json b/drizzle/meta/0029_snapshot.json
new file mode 100644
index 0000000..09d0cfc
--- /dev/null
+++ b/drizzle/meta/0029_snapshot.json
@@ -0,0 +1,2547 @@
+{
+ "version": "6",
+ "dialect": "sqlite",
+ "id": "a11e9068-3b63-4179-9a3e-955658e05445",
+ "prevId": "c88eee0a-2374-4827-8143-61807b963512",
+ "tables": {
+ "account": {
+ "name": "account",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "password": {
+ "name": "password",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "account_userId_idx": {
+ "name": "account_userId_idx",
+ "columns": [
+ "user_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "account_user_id_user_id_fk": {
+ "name": "account_user_id_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "audit_logs": {
+ "name": "audit_logs",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "resource_type": {
+ "name": "resource_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "resource_id": {
+ "name": "resource_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "severity": {
+ "name": "severity",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'info'"
+ },
+ "is_user_visible": {
+ "name": "is_user_visible",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "timestamp": {
+ "name": "timestamp",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "audit_logs_userId_timestamp_idx": {
+ "name": "audit_logs_userId_timestamp_idx",
+ "columns": [
+ "user_id",
+ "timestamp"
+ ],
+ "isUnique": false
+ },
+ "audit_logs_action_timestamp_idx": {
+ "name": "audit_logs_action_timestamp_idx",
+ "columns": [
+ "action",
+ "timestamp"
+ ],
+ "isUnique": false
+ },
+ "audit_logs_userVisible_userId_timestamp_idx": {
+ "name": "audit_logs_userVisible_userId_timestamp_idx",
+ "columns": [
+ "is_user_visible",
+ "user_id",
+ "timestamp"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "audit_logs_user_id_user_id_fk": {
+ "name": "audit_logs_user_id_user_id_fk",
+ "tableFrom": "audit_logs",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "calendar_access_tokens": {
+ "name": "calendar_access_tokens",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "calendar_id": {
+ "name": "calendar_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "bundle_id": {
+ "name": "bundle_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "last_used_at": {
+ "name": "last_used_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "usage_count": {
+ "name": "usage_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ }
+ },
+ "indexes": {
+ "calendar_access_tokens_token_unique": {
+ "name": "calendar_access_tokens_token_unique",
+ "columns": [
+ "token"
+ ],
+ "isUnique": true
+ },
+ "calendar_access_tokens_token_idx": {
+ "name": "calendar_access_tokens_token_idx",
+ "columns": [
+ "token"
+ ],
+ "isUnique": false
+ },
+ "calendar_access_tokens_calendarId_isActive_idx": {
+ "name": "calendar_access_tokens_calendarId_isActive_idx",
+ "columns": [
+ "calendar_id",
+ "is_active"
+ ],
+ "isUnique": false
+ },
+ "calendar_access_tokens_createdBy_idx": {
+ "name": "calendar_access_tokens_createdBy_idx",
+ "columns": [
+ "created_by"
+ ],
+ "isUnique": false
+ },
+ "calendar_access_tokens_bundleId_idx": {
+ "name": "calendar_access_tokens_bundleId_idx",
+ "columns": [
+ "bundle_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "calendar_access_tokens_calendar_id_calendars_id_fk": {
+ "name": "calendar_access_tokens_calendar_id_calendars_id_fk",
+ "tableFrom": "calendar_access_tokens",
+ "tableTo": "calendars",
+ "columnsFrom": [
+ "calendar_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "calendar_access_tokens_bundle_id_calendar_permission_bundles_id_fk": {
+ "name": "calendar_access_tokens_bundle_id_calendar_permission_bundles_id_fk",
+ "tableFrom": "calendar_access_tokens",
+ "tableTo": "calendar_permission_bundles",
+ "columnsFrom": [
+ "bundle_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "calendar_access_tokens_created_by_user_id_fk": {
+ "name": "calendar_access_tokens_created_by_user_id_fk",
+ "tableFrom": "calendar_access_tokens",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "calendar_custom_fields": {
+ "name": "calendar_custom_fields",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "calendar_id": {
+ "name": "calendar_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "label": {
+ "name": "label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "options": {
+ "name": "options",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "required": {
+ "name": "required",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "show_in_calendar": {
+ "name": "show_in_calendar",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "order": {
+ "name": "order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "calendar_custom_fields_calendarId_idx": {
+ "name": "calendar_custom_fields_calendarId_idx",
+ "columns": [
+ "calendar_id"
+ ],
+ "isUnique": false
+ },
+ "calendar_custom_fields_calendarId_key_idx": {
+ "name": "calendar_custom_fields_calendarId_key_idx",
+ "columns": [
+ "calendar_id",
+ "key"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "calendar_custom_fields_calendar_id_calendars_id_fk": {
+ "name": "calendar_custom_fields_calendar_id_calendars_id_fk",
+ "tableFrom": "calendar_custom_fields",
+ "tableTo": "calendars",
+ "columnsFrom": [
+ "calendar_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "calendar_custom_fields_created_by_user_id_fk": {
+ "name": "calendar_custom_fields_created_by_user_id_fk",
+ "tableFrom": "calendar_custom_fields",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "calendar_notes": {
+ "name": "calendar_notes",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "calendar_id": {
+ "name": "calendar_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "date": {
+ "name": "date",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "note": {
+ "name": "note",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'note'"
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "recurring_pattern": {
+ "name": "recurring_pattern",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'none'"
+ },
+ "recurring_interval": {
+ "name": "recurring_interval",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "calendar_notes_calendar_id_calendars_id_fk": {
+ "name": "calendar_notes_calendar_id_calendars_id_fk",
+ "tableFrom": "calendar_notes",
+ "tableTo": "calendars",
+ "columnsFrom": [
+ "calendar_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "calendar_notes_created_by_user_id_fk": {
+ "name": "calendar_notes_created_by_user_id_fk",
+ "tableFrom": "calendar_notes",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "calendar_permission_bundles": {
+ "name": "calendar_permission_bundles",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "calendar_id": {
+ "name": "calendar_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "seed_key": {
+ "name": "seed_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "capabilities": {
+ "name": "capabilities",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "calendar_permission_bundles_calendarId_idx": {
+ "name": "calendar_permission_bundles_calendarId_idx",
+ "columns": [
+ "calendar_id"
+ ],
+ "isUnique": false
+ },
+ "calendar_permission_bundles_calendarId_seedKey_idx": {
+ "name": "calendar_permission_bundles_calendarId_seedKey_idx",
+ "columns": [
+ "calendar_id",
+ "seed_key"
+ ],
+ "isUnique": true,
+ "where": "\"calendar_permission_bundles\".\"seed_key\" is not null"
+ }
+ },
+ "foreignKeys": {
+ "calendar_permission_bundles_calendar_id_calendars_id_fk": {
+ "name": "calendar_permission_bundles_calendar_id_calendars_id_fk",
+ "tableFrom": "calendar_permission_bundles",
+ "tableTo": "calendars",
+ "columnsFrom": [
+ "calendar_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "calendar_shares": {
+ "name": "calendar_shares",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "calendar_id": {
+ "name": "calendar_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "bundle_id": {
+ "name": "bundle_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "shared_by": {
+ "name": "shared_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "calendar_shares_calendarId_idx": {
+ "name": "calendar_shares_calendarId_idx",
+ "columns": [
+ "calendar_id"
+ ],
+ "isUnique": false
+ },
+ "calendar_shares_userId_idx": {
+ "name": "calendar_shares_userId_idx",
+ "columns": [
+ "user_id"
+ ],
+ "isUnique": false
+ },
+ "calendar_shares_bundleId_idx": {
+ "name": "calendar_shares_bundleId_idx",
+ "columns": [
+ "bundle_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "calendar_shares_calendar_id_calendars_id_fk": {
+ "name": "calendar_shares_calendar_id_calendars_id_fk",
+ "tableFrom": "calendar_shares",
+ "tableTo": "calendars",
+ "columnsFrom": [
+ "calendar_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "calendar_shares_user_id_user_id_fk": {
+ "name": "calendar_shares_user_id_user_id_fk",
+ "tableFrom": "calendar_shares",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "calendar_shares_bundle_id_calendar_permission_bundles_id_fk": {
+ "name": "calendar_shares_bundle_id_calendar_permission_bundles_id_fk",
+ "tableFrom": "calendar_shares",
+ "tableTo": "calendar_permission_bundles",
+ "columnsFrom": [
+ "bundle_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "calendar_shares_shared_by_user_id_fk": {
+ "name": "calendar_shares_shared_by_user_id_fk",
+ "tableFrom": "calendar_shares",
+ "tableTo": "user",
+ "columnsFrom": [
+ "shared_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "calendars": {
+ "name": "calendars",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'#3b82f6'"
+ },
+ "owner_id": {
+ "name": "owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "guest_bundle_id": {
+ "name": "guest_bundle_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "signups_enabled": {
+ "name": "signups_enabled",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "split_shifts_enabled": {
+ "name": "split_shifts_enabled",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "view_settings": {
+ "name": "view_settings",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "calendars_ownerId_idx": {
+ "name": "calendars_ownerId_idx",
+ "columns": [
+ "owner_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "calendars_owner_id_user_id_fk": {
+ "name": "calendars_owner_id_user_id_fk",
+ "tableFrom": "calendars",
+ "tableTo": "user",
+ "columnsFrom": [
+ "owner_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "external_syncs": {
+ "name": "external_syncs",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "calendar_id": {
+ "name": "calendar_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "sync_type": {
+ "name": "sync_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'icloud'"
+ },
+ "calendar_url": {
+ "name": "calendar_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'#3b82f6'"
+ },
+ "display_mode": {
+ "name": "display_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'normal'"
+ },
+ "is_hidden": {
+ "name": "is_hidden",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "hide_from_stats": {
+ "name": "hide_from_stats",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "auto_sync_interval": {
+ "name": "auto_sync_interval",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "is_one_time_import": {
+ "name": "is_one_time_import",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "last_synced_at": {
+ "name": "last_synced_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "external_syncs_calendar_id_calendars_id_fk": {
+ "name": "external_syncs_calendar_id_calendars_id_fk",
+ "tableFrom": "external_syncs",
+ "tableTo": "calendars",
+ "columnsFrom": [
+ "calendar_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "preset_custom_field_values": {
+ "name": "preset_custom_field_values",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "preset_id": {
+ "name": "preset_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "field_id": {
+ "name": "field_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "preset_custom_field_values_presetId_idx": {
+ "name": "preset_custom_field_values_presetId_idx",
+ "columns": [
+ "preset_id"
+ ],
+ "isUnique": false
+ },
+ "preset_custom_field_values_presetId_fieldId_idx": {
+ "name": "preset_custom_field_values_presetId_fieldId_idx",
+ "columns": [
+ "preset_id",
+ "field_id"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "preset_custom_field_values_preset_id_shift_presets_id_fk": {
+ "name": "preset_custom_field_values_preset_id_shift_presets_id_fk",
+ "tableFrom": "preset_custom_field_values",
+ "tableTo": "shift_presets",
+ "columnsFrom": [
+ "preset_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "preset_custom_field_values_field_id_calendar_custom_fields_id_fk": {
+ "name": "preset_custom_field_values_field_id_calendar_custom_fields_id_fk",
+ "tableFrom": "preset_custom_field_values",
+ "tableTo": "calendar_custom_fields",
+ "columnsFrom": [
+ "field_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "preset_time_segments": {
+ "name": "preset_time_segments",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "preset_id": {
+ "name": "preset_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "start_time": {
+ "name": "start_time",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "end_time": {
+ "name": "end_time",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "preset_time_segments_presetId_idx": {
+ "name": "preset_time_segments_presetId_idx",
+ "columns": [
+ "preset_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "preset_time_segments_preset_id_shift_presets_id_fk": {
+ "name": "preset_time_segments_preset_id_shift_presets_id_fk",
+ "tableFrom": "preset_time_segments",
+ "tableTo": "shift_presets",
+ "columnsFrom": [
+ "preset_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "session": {
+ "name": "session",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "impersonated_by": {
+ "name": "impersonated_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "session_token_unique": {
+ "name": "session_token_unique",
+ "columns": [
+ "token"
+ ],
+ "isUnique": true
+ },
+ "session_userId_idx": {
+ "name": "session_userId_idx",
+ "columns": [
+ "user_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "session_user_id_user_id_fk": {
+ "name": "session_user_id_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "shift_custom_field_values": {
+ "name": "shift_custom_field_values",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "shift_id": {
+ "name": "shift_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "field_id": {
+ "name": "field_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "shift_custom_field_values_shiftId_idx": {
+ "name": "shift_custom_field_values_shiftId_idx",
+ "columns": [
+ "shift_id"
+ ],
+ "isUnique": false
+ },
+ "shift_custom_field_values_shiftId_fieldId_idx": {
+ "name": "shift_custom_field_values_shiftId_fieldId_idx",
+ "columns": [
+ "shift_id",
+ "field_id"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "shift_custom_field_values_shift_id_shifts_id_fk": {
+ "name": "shift_custom_field_values_shift_id_shifts_id_fk",
+ "tableFrom": "shift_custom_field_values",
+ "tableTo": "shifts",
+ "columnsFrom": [
+ "shift_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shift_custom_field_values_field_id_calendar_custom_fields_id_fk": {
+ "name": "shift_custom_field_values_field_id_calendar_custom_fields_id_fk",
+ "tableFrom": "shift_custom_field_values",
+ "tableTo": "calendar_custom_fields",
+ "columnsFrom": [
+ "field_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "shift_presets": {
+ "name": "shift_presets",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "calendar_id": {
+ "name": "calendar_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "start_time": {
+ "name": "start_time",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "end_time": {
+ "name": "end_time",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'#3b82f6'"
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "group_name": {
+ "name": "group_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "is_secondary": {
+ "name": "is_secondary",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "is_all_day": {
+ "name": "is_all_day",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "hide_from_stats": {
+ "name": "hide_from_stats",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "default_signup_capacity": {
+ "name": "default_signup_capacity",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "order": {
+ "name": "order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "shift_presets_calendar_id_calendars_id_fk": {
+ "name": "shift_presets_calendar_id_calendars_id_fk",
+ "tableFrom": "shift_presets",
+ "tableTo": "calendars",
+ "columnsFrom": [
+ "calendar_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shift_presets_created_by_user_id_fk": {
+ "name": "shift_presets_created_by_user_id_fk",
+ "tableFrom": "shift_presets",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "shift_signups": {
+ "name": "shift_signups",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "shift_id": {
+ "name": "shift_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "signed_up_by": {
+ "name": "signed_up_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "shift_signups_shiftId_idx": {
+ "name": "shift_signups_shiftId_idx",
+ "columns": [
+ "shift_id"
+ ],
+ "isUnique": false
+ },
+ "shift_signups_userId_idx": {
+ "name": "shift_signups_userId_idx",
+ "columns": [
+ "user_id"
+ ],
+ "isUnique": false
+ },
+ "shift_signups_shiftId_userId_idx": {
+ "name": "shift_signups_shiftId_userId_idx",
+ "columns": [
+ "shift_id",
+ "user_id"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "shift_signups_shift_id_shifts_id_fk": {
+ "name": "shift_signups_shift_id_shifts_id_fk",
+ "tableFrom": "shift_signups",
+ "tableTo": "shifts",
+ "columnsFrom": [
+ "shift_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shift_signups_user_id_user_id_fk": {
+ "name": "shift_signups_user_id_user_id_fk",
+ "tableFrom": "shift_signups",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shift_signups_signed_up_by_user_id_fk": {
+ "name": "shift_signups_signed_up_by_user_id_fk",
+ "tableFrom": "shift_signups",
+ "tableTo": "user",
+ "columnsFrom": [
+ "signed_up_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "shift_time_segments": {
+ "name": "shift_time_segments",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "shift_id": {
+ "name": "shift_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "start_time": {
+ "name": "start_time",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "end_time": {
+ "name": "end_time",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "shift_time_segments_shiftId_idx": {
+ "name": "shift_time_segments_shiftId_idx",
+ "columns": [
+ "shift_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "shift_time_segments_shift_id_shifts_id_fk": {
+ "name": "shift_time_segments_shift_id_shifts_id_fk",
+ "tableFrom": "shift_time_segments",
+ "tableTo": "shifts",
+ "columnsFrom": [
+ "shift_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "shifts": {
+ "name": "shifts",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "calendar_id": {
+ "name": "calendar_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "preset_id": {
+ "name": "preset_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "date": {
+ "name": "date",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "start_time": {
+ "name": "start_time",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "end_time": {
+ "name": "end_time",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'#3b82f6'"
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "is_all_day": {
+ "name": "is_all_day",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "is_secondary": {
+ "name": "is_secondary",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "signup_capacity": {
+ "name": "signup_capacity",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "external_event_id": {
+ "name": "external_event_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "external_sync_id": {
+ "name": "external_sync_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "synced_from_external": {
+ "name": "synced_from_external",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "shifts_calendar_id_calendars_id_fk": {
+ "name": "shifts_calendar_id_calendars_id_fk",
+ "tableFrom": "shifts",
+ "tableTo": "calendars",
+ "columnsFrom": [
+ "calendar_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shifts_preset_id_shift_presets_id_fk": {
+ "name": "shifts_preset_id_shift_presets_id_fk",
+ "tableFrom": "shifts",
+ "tableTo": "shift_presets",
+ "columnsFrom": [
+ "preset_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "shifts_external_sync_id_external_syncs_id_fk": {
+ "name": "shifts_external_sync_id_external_syncs_id_fk",
+ "tableFrom": "shifts",
+ "tableTo": "external_syncs",
+ "columnsFrom": [
+ "external_sync_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shifts_created_by_user_id_fk": {
+ "name": "shifts_created_by_user_id_fk",
+ "tableFrom": "shifts",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "sync_logs": {
+ "name": "sync_logs",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "calendar_id": {
+ "name": "calendar_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "external_sync_id": {
+ "name": "external_sync_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "external_sync_name": {
+ "name": "external_sync_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "shifts_created": {
+ "name": "shifts_created",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "shifts_updated": {
+ "name": "shifts_updated",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "shifts_deleted": {
+ "name": "shifts_deleted",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "sync_type": {
+ "name": "sync_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'auto'"
+ },
+ "is_read": {
+ "name": "is_read",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "synced_at": {
+ "name": "synced_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "sync_logs_calendar_id_calendars_id_fk": {
+ "name": "sync_logs_calendar_id_calendars_id_fk",
+ "tableFrom": "sync_logs",
+ "tableTo": "calendars",
+ "columnsFrom": [
+ "calendar_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "sync_logs_external_sync_id_external_syncs_id_fk": {
+ "name": "sync_logs_external_sync_id_external_syncs_id_fk",
+ "tableFrom": "sync_logs",
+ "tableTo": "external_syncs",
+ "columnsFrom": [
+ "external_sync_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "system_settings": {
+ "name": "system_settings",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'default'"
+ },
+ "update_check_enabled": {
+ "name": "update_check_enabled",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "update_banner_visibility": {
+ "name": "update_banner_visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'all'"
+ },
+ "allow_guest_access": {
+ "name": "allow_guest_access",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "telemetry_enabled": {
+ "name": "telemetry_enabled",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "telemetry_instance_id": {
+ "name": "telemetry_instance_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "telemetry_consented_schema": {
+ "name": "telemetry_consented_schema",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "telemetry_decided_at": {
+ "name": "telemetry_decided_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "user": {
+ "name": "user",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "email_verified": {
+ "name": "email_verified",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "banned": {
+ "name": "banned",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": false
+ },
+ "ban_reason": {
+ "name": "ban_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "ban_expires": {
+ "name": "ban_expires",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "must_change_password": {
+ "name": "must_change_password",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ }
+ },
+ "indexes": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "columns": [
+ "email"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "user_calendar_subscriptions": {
+ "name": "user_calendar_subscriptions",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "calendar_id": {
+ "name": "calendar_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'subscribed'"
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'guest'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "user_calendar_subscriptions_userId_idx": {
+ "name": "user_calendar_subscriptions_userId_idx",
+ "columns": [
+ "user_id"
+ ],
+ "isUnique": false
+ },
+ "user_calendar_subscriptions_calendarId_idx": {
+ "name": "user_calendar_subscriptions_calendarId_idx",
+ "columns": [
+ "calendar_id"
+ ],
+ "isUnique": false
+ },
+ "user_calendar_subscriptions_status_idx": {
+ "name": "user_calendar_subscriptions_status_idx",
+ "columns": [
+ "status"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "user_calendar_subscriptions_user_id_user_id_fk": {
+ "name": "user_calendar_subscriptions_user_id_user_id_fk",
+ "tableFrom": "user_calendar_subscriptions",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_calendar_subscriptions_calendar_id_calendars_id_fk": {
+ "name": "user_calendar_subscriptions_calendar_id_calendars_id_fk",
+ "tableFrom": "user_calendar_subscriptions",
+ "tableTo": "calendars",
+ "columnsFrom": [
+ "calendar_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "user_preferences": {
+ "name": "user_preferences",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "view_settings": {
+ "name": "view_settings",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_preferences_user_id_user_id_fk": {
+ "name": "user_preferences_user_id_user_id_fk",
+ "tableFrom": "user_preferences",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "verification": {
+ "name": "verification",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ }
+ },
+ "views": {},
+ "enums": {},
+ "_meta": {
+ "schemas": {},
+ "tables": {},
+ "columns": {}
+ },
+ "internal": {
+ "indexes": {}
+ }
+}
\ No newline at end of file
diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json
index 3285b10..dd96c6e 100644
--- a/drizzle/meta/_journal.json
+++ b/drizzle/meta/_journal.json
@@ -204,6 +204,13 @@
"when": 1789823233140,
"tag": "0028_dapper_karnak",
"breakpoints": true
+ },
+ {
+ "idx": 29,
+ "version": "6",
+ "when": 1789845766565,
+ "tag": "0029_red_night_thrasher",
+ "breakpoints": true
}
]
}
\ No newline at end of file
diff --git a/eslint.config.mjs b/eslint.config.mjs
index fb7d519..8173d2b 100644
--- a/eslint.config.mjs
+++ b/eslint.config.mjs
@@ -17,6 +17,8 @@ const eslintConfig = defineConfig([
// Gitignored scratch space (design handoffs, local scripts). CI never sees
// it, so linting it only ever breaks `npm test` on a working copy.
".LOCAL/**",
+ // Separate Cloudflare Worker project with its own tsconfig and globals.
+ "telemetry-hub/**",
]),
]);
diff --git a/hooks/useSystemSettings.ts b/hooks/useSystemSettings.ts
index 14c604b..673a60e 100644
--- a/hooks/useSystemSettings.ts
+++ b/hooks/useSystemSettings.ts
@@ -6,7 +6,14 @@ import { useTranslations } from "next-intl";
import { queryKeys } from "@/lib/query-keys";
import type { SystemSettings } from "@/lib/system-settings";
-async function fetchSystemSettings(): Promise<SystemSettings> {
+// GET-only fields: whether TELEMETRY_ENABLED overrides the stored value, and
+// the effective on/off state after that override is applied.
+export interface SystemSettingsResponse extends SystemSettings {
+ telemetryEnvManaged: boolean;
+ telemetryResolved: boolean;
+}
+
+async function fetchSystemSettings(): Promise<SystemSettingsResponse> {
const response = await fetch("/api/admin/system-settings");
if (!response.ok) throw new Error(`Failed to fetch system settings: ${response.status}`);
return response.json();
@@ -25,7 +32,7 @@ async function updateSystemSettingsApi(
}
interface UpdateSettingsContext {
- previous: SystemSettings | undefined;
+ previous: SystemSettingsResponse | undefined;
}
/** Instance-wide toggles for the update-check banner, admin-only. */
@@ -42,9 +49,17 @@ export function useSystemSettings() {
mutationFn: updateSystemSettingsApi,
onMutate: async (patch) => {
await queryClient.cancelQueries({ queryKey: queryKeys.admin.systemSettings });
- const previous = queryClient.getQueryData<SystemSettings>(queryKeys.admin.systemSettings);
+ const previous = queryClient.getQueryData<SystemSettingsResponse>(queryKeys.admin.systemSettings);
if (previous) {
- queryClient.setQueryData<SystemSettings>(queryKeys.admin.systemSettings, { ...previous, ...patch });
+ queryClient.setQueryData<SystemSettingsResponse>(queryKeys.admin.systemSettings, {
+ ...previous,
+ ...patch,
+ // Derived server-side; without it the toggle would snap back until the refetch.
+ telemetryResolved:
+ !previous.telemetryEnvManaged && typeof patch.telemetryEnabled === "boolean"
+ ? patch.telemetryEnabled
+ : previous.telemetryResolved,
+ });
}
return { previous };
},
@@ -55,8 +70,13 @@ export function useSystemSettings() {
console.error("Failed to update system settings:", err);
toast.error(t("admin.systemSettings.updateError"));
},
- onSettled: () => {
+ onSettled: (_data, _error, patch) => {
queryClient.invalidateQueries({ queryKey: queryKeys.admin.systemSettings });
+ if ("telemetryEnabled" in patch) {
+ // The preview carries the instance id, which only exists once telemetry is on.
+ queryClient.invalidateQueries({ queryKey: queryKeys.admin.telemetryPayload("telemetry") });
+ queryClient.invalidateQueries({ queryKey: queryKeys.admin.telemetryPayload("diagnostics") });
+ }
},
});
diff --git a/hooks/useTelemetryPayload.ts b/hooks/useTelemetryPayload.ts
new file mode 100644
index 0000000..ee65938
--- /dev/null
+++ b/hooks/useTelemetryPayload.ts
@@ -0,0 +1,24 @@
+"use client";
+
+import { useQuery } from "@tanstack/react-query";
+import { queryKeys } from "@/lib/query-keys";
+import type { DiagnosticsPayload, TelemetryPayload } from "@/lib/telemetry/schema";
+
+async function fetchPayload(profile: string) {
+ const response = await fetch(`/api/admin/telemetry/payload?profile=${profile}`);
+ if (!response.ok) throw new Error(`Failed to fetch telemetry payload: ${response.status}`);
+ return response.json();
+}
+
+/** Admin-only preview of the payload this instance would send; gate `enabled` to the caller's need. */
+export function useTelemetryPayload(
+ profile: "telemetry" | "diagnostics",
+ enabled: boolean
+) {
+ return useQuery<TelemetryPayload | DiagnosticsPayload>({
+ queryKey: queryKeys.admin.telemetryPayload(profile),
+ queryFn: () => fetchPayload(profile),
+ enabled,
+ staleTime: 60_000,
+ });
+}
diff --git a/hooks/useTelemetrySend.ts b/hooks/useTelemetrySend.ts
new file mode 100644
index 0000000..139bc12
--- /dev/null
+++ b/hooks/useTelemetrySend.ts
@@ -0,0 +1,41 @@
+"use client";
+
+import { useMutation } from "@tanstack/react-query";
+import { toast } from "sonner";
+import { useTranslations } from "next-intl";
+import { isRateLimitError, handleRateLimitError } from "@/lib/rate-limit-client";
+
+class SendError extends Error {
+ constructor(
+ readonly kind: "rate-limited" | "unavailable" | "failed",
+ ) {
+ super(`Telemetry send failed: ${kind}`);
+ }
+}
+
+/** Admin "send now": the same guarded send the daily timer does, on demand. */
+export function useTelemetrySend() {
+ const t = useTranslations();
+
+ const mutation = useMutation<void, SendError>({
+ mutationFn: async () => {
+ const response = await fetch("/api/admin/telemetry/send", { method: "POST" });
+ if (response.ok) return;
+ if (isRateLimitError(response)) {
+ await handleRateLimitError(response, t);
+ throw new SendError("rate-limited");
+ }
+ // 409: off or outdated consent -- nothing was attempted.
+ throw new SendError(response.status === 409 ? "unavailable" : "failed");
+ },
+ onSuccess: () => toast.success(t("admin.telemetry.sendSuccess")),
+ onError: (error) => {
+ // The rate-limit helper already showed its own toast.
+ if (error.kind === "rate-limited") return;
+ if (error.kind === "unavailable") toast.error(t("admin.telemetry.sendUnavailable"));
+ else toast.error(t("admin.telemetry.sendFailed"));
+ },
+ });
+
+ return { sendNow: mutation.mutate, isSending: mutation.isPending };
+}
diff --git a/hooks/useVersionUpdate.ts b/hooks/useVersionUpdate.ts
index 4b37c93..cd2576c 100644
--- a/hooks/useVersionUpdate.ts
+++ b/hooks/useVersionUpdate.ts
@@ -14,6 +14,8 @@ interface VersionInfo {
latestVersion?: string;
latestUrl?: string;
hasUpdate?: boolean;
+ /** Admins only: the consent dialog must be shown. */
+ telemetryPrompt?: boolean;
}
// Dismissing is per-version: the banner reappears once a newer release ships
diff --git a/instrumentation.ts b/instrumentation.ts
index 66dcd6b..0a2f62a 100644
--- a/instrumentation.ts
+++ b/instrumentation.ts
@@ -11,12 +11,14 @@ export async function register() {
// (bad version lookup, sync scheduler error) logs instead of taking the
// whole server down.
const { autoSyncService } = await import("@/lib/auto-sync-service");
+ const { telemetryService } = await import("@/lib/telemetry/sender");
try {
// Preload version during startup to avoid blocking on first request
const { initializeVersion } = await import("@/lib/version");
await initializeVersion();
await autoSyncService.start();
+ telemetryService.start();
} catch (error) {
console.error("[Instrumentation] Startup task failed:", error);
}
@@ -38,6 +40,7 @@ export async function register() {
shuttingDown = true;
console.log(`Received ${signal}, shutting down auto-sync service...`);
autoSyncService.stop();
+ telemetryService.stop();
};
process.once("SIGTERM", shutdown);
process.once("SIGINT", shutdown);
diff --git a/lib/audit-log.ts b/lib/audit-log.ts
index 8f859d9..f30e7ba 100644
--- a/lib/audit-log.ts
+++ b/lib/audit-log.ts
@@ -157,9 +157,33 @@ export interface AdminPasswordResetMetadata {
targetUser: string;
}
+// Mirrors SystemSettings minus telemetryInstanceId: the instance id must never
+// reach an audit log, which admins can export.
+interface AuditedSystemSettings {
+ updateCheckEnabled: boolean;
+ updateBannerVisibility: string;
+ allowGuestAccess: boolean;
+ telemetryEnabled: boolean | null;
+ telemetryConsentedSchema: number | null;
+ telemetryDecidedAt: Date | null;
+}
+
export interface AdminSystemSettingsUpdatedMetadata {
- before: { updateCheckEnabled: boolean; updateBannerVisibility: string; allowGuestAccess: boolean };
- after: { updateCheckEnabled: boolean; updateBannerVisibility: string; allowGuestAccess: boolean };
+ before: AuditedSystemSettings;
+ after: AuditedSystemSettings;
+}
+
+export interface AdminTelemetryConsentMetadata {
+ before: boolean | null;
+ after: boolean;
+ schemaVersion: number;
+}
+
+// Outcome only: the endpoint URL can be private and must not reach an exportable log.
+// Shared by the admin button and the daily timer.
+export interface TelemetrySendMetadata {
+ result: "sent" | "failed";
+ reason?: "timeout" | "network" | "http";
}
export interface AdminUserCreateMetadata {
@@ -241,6 +265,8 @@ export type AuditLogMetadata =
| AdminCalendarTransferMetadata
| AdminPasswordResetMetadata
| AdminSystemSettingsUpdatedMetadata
+ | AdminTelemetryConsentMetadata
+ | TelemetrySendMetadata
| CalendarBundleCreatedMetadata
| CalendarBundleUpdatedMetadata
| CalendarBundleClonedMetadata
diff --git a/lib/db/schema.ts b/lib/db/schema.ts
index b41457e..033a917 100644
--- a/lib/db/schema.ts
+++ b/lib/db/schema.ts
@@ -287,6 +287,12 @@ export const systemSettings = sqliteTable("system_settings", {
// to ALLOW_GUEST_ACCESS (see lib/system-settings.ts), not silently to
// false -- a NOT NULL DEFAULT would force that on every upgrade.
allowGuestAccess: integer("allow_guest_access", { mode: "boolean" }),
+ // Nullable without default: telemetryEnabled null means "not decided yet",
+ // and no instance id exists until telemetry is actually on.
+ telemetryEnabled: integer("telemetry_enabled", { mode: "boolean" }),
+ telemetryInstanceId: text("telemetry_instance_id"),
+ telemetryConsentedSchema: integer("telemetry_consented_schema"),
+ telemetryDecidedAt: integer("telemetry_decided_at", { mode: "timestamp" }),
updatedAt: integer("updated_at", { mode: "timestamp" })
.notNull()
.default(sql`CURRENT_TIMESTAMP`)
diff --git a/lib/query-keys.ts b/lib/query-keys.ts
index d5550c4..7d663f5 100644
--- a/lib/query-keys.ts
+++ b/lib/query-keys.ts
@@ -65,6 +65,8 @@ export const queryKeys = {
auditLogsAll: ["admin", "audit-logs"] as const,
auditLogs: (filters?: object) => ["admin", "audit-logs", filters] as const,
systemSettings: ["admin", "system-settings"] as const,
+ telemetryPayload: (profile: string) =>
+ ["admin", "telemetry-payload", profile] as const,
},
// Calendar Features
diff --git a/lib/rate-limiter.ts b/lib/rate-limiter.ts
index d6bc2fe..d0bee22 100644
--- a/lib/rate-limiter.ts
+++ b/lib/rate-limiter.ts
@@ -29,6 +29,10 @@
* - RATE_LIMIT_USER_SEARCH_WINDOW
* - RATE_LIMIT_BUNDLE_MUTATIONS_REQUESTS - Permission bundle create/update/delete/clone (per calendar)
* - RATE_LIMIT_BUNDLE_MUTATIONS_WINDOW
+ * - RATE_LIMIT_TELEMETRY_PAYLOAD_REQUESTS - Admin telemetry payload preview
+ * - RATE_LIMIT_TELEMETRY_PAYLOAD_WINDOW
+ * - RATE_LIMIT_TELEMETRY_SEND_REQUESTS - Admin "send telemetry now" button
+ * - RATE_LIMIT_TELEMETRY_SEND_WINDOW
*/
import { NextRequest, NextResponse } from "next/server";
@@ -202,6 +206,19 @@ const config = {
parseInt(process.env.RATE_LIMIT_CUSTOM_FIELD_MUTATIONS_WINDOW || "3600", 10) *
1000, // 1 hour
},
+ // Admin telemetry payload preview; the collector's own cache keeps repeat
+ // calls cheap, this just bounds the burst.
+ telemetryPayload: {
+ requests: parseInt(process.env.RATE_LIMIT_TELEMETRY_PAYLOAD_REQUESTS || "20", 10),
+ windowMs:
+ parseInt(process.env.RATE_LIMIT_TELEMETRY_PAYLOAD_WINDOW || "60", 10) * 1000,
+ },
+ // Each call is an outbound request to the telemetry endpoint.
+ telemetrySend: {
+ requests: parseInt(process.env.RATE_LIMIT_TELEMETRY_SEND_REQUESTS || "5", 10),
+ windowMs:
+ parseInt(process.env.RATE_LIMIT_TELEMETRY_SEND_WINDOW || "3600", 10) * 1000,
+ },
};
/**
@@ -230,6 +247,8 @@ const limitsByType = {
"admin-calendar-mutations": config.adminCalendarMutations,
"bundle-mutations": config.bundleMutations,
"custom-field-mutations": config.customFieldMutations,
+ "telemetry-payload": config.telemetryPayload,
+ "telemetry-send": config.telemetrySend,
} as const;
export type RateLimitType = keyof typeof limitsByType;
diff --git a/lib/system-settings.ts b/lib/system-settings.ts
index 625311d..49452c1 100644
--- a/lib/system-settings.ts
+++ b/lib/system-settings.ts
@@ -11,6 +11,10 @@ export interface SystemSettings {
updateCheckEnabled: boolean;
updateBannerVisibility: UpdateBannerVisibility;
allowGuestAccess: boolean;
+ telemetryEnabled: boolean | null;
+ telemetryInstanceId: string | null;
+ telemetryConsentedSchema: number | null;
+ telemetryDecidedAt: Date | null;
}
// Neither the row nor (on upgrade) this specific column may exist yet, so
@@ -21,6 +25,10 @@ export const DEFAULT_SYSTEM_SETTINGS: SystemSettings = {
updateCheckEnabled: true,
updateBannerVisibility: "all",
allowGuestAccess: ALLOW_GUEST_ACCESS,
+ telemetryEnabled: null,
+ telemetryInstanceId: null,
+ telemetryConsentedSchema: null,
+ telemetryDecidedAt: null,
};
// Settings are read on every /api/version request; a short cache avoids a DB
@@ -40,6 +48,10 @@ export async function getSystemSettings(): Promise<SystemSettings> {
updateCheckEnabled: systemSettings.updateCheckEnabled,
updateBannerVisibility: systemSettings.updateBannerVisibility,
allowGuestAccess: systemSettings.allowGuestAccess,
+ telemetryEnabled: systemSettings.telemetryEnabled,
+ telemetryInstanceId: systemSettings.telemetryInstanceId,
+ telemetryConsentedSchema: systemSettings.telemetryConsentedSchema,
+ telemetryDecidedAt: systemSettings.telemetryDecidedAt,
})
.from(systemSettings)
.where(eq(systemSettings.id, SETTINGS_ID))
diff --git a/lib/telemetry/collect.ts b/lib/telemetry/collect.ts
new file mode 100644
index 0000000..ee9f32f
--- /dev/null
+++ b/lib/telemetry/collect.ts
@@ -0,0 +1,226 @@
+import { and, eq, gte, ne, sql } from "drizzle-orm";
+import { db } from "@/lib/db";
+import {
+ calendarAccessTokens,
+ calendarCustomFields,
+ calendarNotes,
+ calendarPermissionBundles,
+ calendarShares,
+ calendars,
+ externalSyncs,
+ shiftPresets,
+ shiftSignups,
+ shifts,
+ syncLogs,
+ user,
+} from "@/lib/db/schema";
+import { getSystemSettings } from "@/lib/system-settings";
+import { getBuildInfo } from "@/lib/version";
+import {
+ isAuthEnabled,
+ allowGuestAccess,
+ allowUserRegistration,
+} from "@/lib/auth/feature-flags";
+import { DEFAULT_TELEMETRY_ENDPOINT } from "@/lib/telemetry/config";
+import {
+ TELEMETRY_SCHEMA_VERSION,
+ toBucket,
+ type DiagnosticsPayload,
+ type TelemetryPayload,
+ type TelemetryProfile,
+} from "@/lib/telemetry/schema";
+
+const startedAt = Date.now();
+
+// Only these keys ever leave the instance; never iterate process.env itself.
+const REPORTABLE_ENV = [
+ "AUTH_ENABLED",
+ "ALLOW_GUEST_ACCESS",
+ "ALLOW_USER_REGISTRATION",
+ "DEFAULT_LOCALE",
+ "TZ",
+ "TELEMETRY_ENABLED",
+ "TELEMETRY_ENDPOINT",
+] as const;
+
+function collectEnvFlags(): Record<string, string> {
+ const flags: Record<string, string> = {};
+ for (const key of REPORTABLE_ENV) {
+ const value = process.env[key];
+ if (value !== undefined) flags[key] = value;
+ }
+ // A self-hosted receiver URL can be private and carry a token, and this export
+ // is pasted into public issues -- report only whether it differs from the default.
+ const endpoint = process.env.TELEMETRY_ENDPOINT;
+ flags.TELEMETRY_ENDPOINT =
+ endpoint && endpoint !== DEFAULT_TELEMETRY_ENDPOINT ? "custom" : "default";
+ return flags;
+}
+
+function collectMigrationList(): string[] {
+ const rows = db.all<{ hash: string }>(
+ sql`select hash from __drizzle_migrations order by created_at`
+ );
+ return rows.map((row) => row.hash);
+}
+
+function countMigrations(): number {
+ const [row] = db.all<{ value: number }>(
+ sql`select count(*) as value from __drizzle_migrations`
+ );
+ return row?.value ?? 0;
+}
+
+export async function collectTelemetryPayload(
+ profile: "telemetry"
+): Promise<TelemetryPayload>;
+export async function collectTelemetryPayload(
+ profile: "diagnostics"
+): Promise<DiagnosticsPayload>;
+export async function collectTelemetryPayload(
+ profile: TelemetryProfile
+): Promise<TelemetryPayload | DiagnosticsPayload> {
+ const [settings, buildInfo] = await Promise.all([
+ getSystemSettings(),
+ getBuildInfo(),
+ ]);
+
+ const since = new Date(Date.now() - 24 * 60 * 60 * 1000);
+
+ const [
+ users,
+ calendarCount,
+ shiftCount,
+ presetCount,
+ noteCount,
+ bundleCount,
+ shareCount,
+ tokenCount,
+ signupCount,
+ syncCount,
+ customFieldCount,
+ viewOverrideCount,
+ archivedPresetCount,
+ splitShiftCalendarCount,
+ syncRuns24h,
+ syncFailures24h,
+ migrations,
+ ] = await Promise.all([
+ db.$count(user),
+ db.$count(calendars),
+ db.$count(shifts),
+ db.$count(shiftPresets),
+ db.$count(calendarNotes),
+ db.$count(calendarPermissionBundles),
+ db.$count(calendarShares),
+ db.$count(calendarAccessTokens),
+ db.$count(shiftSignups),
+ db.$count(externalSyncs),
+ db.$count(calendarCustomFields),
+ db.$count(calendars, sql`${calendars.viewSettings} is not null`),
+ db.$count(shiftPresets, sql`${shiftPresets.archivedAt} is not null`),
+ db.$count(calendars, eq(calendars.splitShiftsEnabled, true)),
+ db.$count(syncLogs, gte(syncLogs.syncedAt, since)),
+ db.$count(
+ syncLogs,
+ and(gte(syncLogs.syncedAt, since), ne(syncLogs.status, "success"))
+ ),
+ countMigrations(),
+ ]);
+
+ const fieldTypeRows = await db
+ .selectDistinct({ type: calendarCustomFields.type })
+ .from(calendarCustomFields);
+ const types = fieldTypeRows.map((row) => row.type).sort();
+
+ const sqliteVersion =
+ db.all<{ v: string }>(sql`select sqlite_version() as v`)[0]?.v ??
+ "unknown";
+
+ const rateLimitOverrides = Object.keys(process.env).filter((key) =>
+ key.startsWith("RATE_LIMIT_")
+ ).length;
+
+ const base = {
+ schemaVersion: TELEMETRY_SCHEMA_VERSION,
+ instanceId: settings.telemetryInstanceId,
+ sentAt: new Date().toISOString(),
+ app: {
+ version: buildInfo.version,
+ isDev: buildInfo.version.includes("dev"),
+ migrations,
+ },
+ runtime: {
+ node: process.versions.node,
+ arch: process.arch,
+ platform: process.platform,
+ sqlite: sqliteVersion,
+ timezone: process.env.TZ ?? "unknown",
+ },
+ config: {
+ authEnabled: isAuthEnabled(),
+ guestAccess: await allowGuestAccess(),
+ registrationOpen: allowUserRegistration(),
+ defaultLocale: process.env.DEFAULT_LOCALE ?? "en",
+ updateCheckEnabled: settings.updateCheckEnabled,
+ rateLimitOverrides,
+ },
+ health: {
+ uptimeHours: Math.round((Date.now() - startedAt) / 3_600_000),
+ syncRuns24h,
+ syncFailures24h,
+ },
+ };
+
+ const archivedPresets = archivedPresetCount > 0;
+ const splitShifts = splitShiftCalendarCount > 0;
+
+ const value: TelemetryPayload | DiagnosticsPayload =
+ profile === "telemetry"
+ ? {
+ ...base,
+ scale: {
+ users: toBucket(users),
+ calendars: toBucket(calendarCount),
+ shifts: toBucket(shiftCount),
+ presets: toBucket(presetCount),
+ notes: toBucket(noteCount),
+ bundles: toBucket(bundleCount),
+ shares: toBucket(shareCount),
+ accessTokens: toBucket(tokenCount),
+ signups: toBucket(signupCount),
+ },
+ features: {
+ externalSyncs: toBucket(syncCount),
+ calendarViewOverrides: toBucket(viewOverrideCount),
+ customFields: { count: toBucket(customFieldCount), types },
+ archivedPresets,
+ splitShifts,
+ },
+ }
+ : {
+ ...base,
+ scale: {
+ users,
+ calendars: calendarCount,
+ shifts: shiftCount,
+ presets: presetCount,
+ notes: noteCount,
+ bundles: bundleCount,
+ shares: shareCount,
+ accessTokens: tokenCount,
+ signups: signupCount,
+ },
+ features: {
+ externalSyncs: syncCount,
+ calendarViewOverrides: viewOverrideCount,
+ customFields: { count: customFieldCount, types },
+ archivedPresets,
+ splitShifts,
+ },
+ envFlags: collectEnvFlags(),
+ migrationList: collectMigrationList(),
+ };
+
+ return value;
+}
diff --git a/lib/telemetry/config.ts b/lib/telemetry/config.ts
new file mode 100644
index 0000000..62037bd
--- /dev/null
+++ b/lib/telemetry/config.ts
@@ -0,0 +1,24 @@
+export const DEFAULT_TELEMETRY_ENDPOINT =
+ "https://telemetry-bettershift.pantelx.com";
+
+/** Tri-state, mirroring the nullable column: unset means the instance decides. */
+function envOverride(): boolean | null {
+ const raw = process.env.TELEMETRY_ENABLED;
+ if (raw === undefined || raw === "") return null;
+ // Only the literal "true" enables: anything else ("1", "yes", "TRUE") is a
+ // forced off, so a typo fails closed instead of silently opting an instance in.
+ return raw === "true";
+}
+
+export function isTelemetryForcedByEnv(): boolean {
+ return envOverride() !== null;
+}
+
+/** A set env var always wins over the database, in both directions. */
+export function resolveTelemetryEnabled(stored: boolean | null): boolean {
+ return envOverride() ?? stored === true;
+}
+
+export function getTelemetryEndpoint(): string {
+ return process.env.TELEMETRY_ENDPOINT || DEFAULT_TELEMETRY_ENDPOINT;
+}
diff --git a/lib/telemetry/instance-id.ts b/lib/telemetry/instance-id.ts
new file mode 100644
index 0000000..2812c1b
--- /dev/null
+++ b/lib/telemetry/instance-id.ts
@@ -0,0 +1,18 @@
+import { getSystemSettings, updateSystemSettings } from "@/lib/system-settings";
+import { resolveTelemetryEnabled } from "@/lib/telemetry/config";
+
+/**
+ * Mints the instance id on first use when telemetry resolves to on, including
+ * when it is forced by env. Never mints while off: a declining instance must
+ * hold no identifier at all.
+ */
+export async function ensureTelemetryInstanceId(): Promise<string | null> {
+ const settings = await getSystemSettings();
+ if (!resolveTelemetryEnabled(settings.telemetryEnabled)) return null;
+ if (settings.telemetryInstanceId) return settings.telemetryInstanceId;
+
+ const { after } = await updateSystemSettings({
+ telemetryInstanceId: crypto.randomUUID(),
+ });
+ return after.telemetryInstanceId;
+}
diff --git a/lib/telemetry/schema.ts b/lib/telemetry/schema.ts
new file mode 100644
index 0000000..a37fafa
--- /dev/null
+++ b/lib/telemetry/schema.ts
@@ -0,0 +1,76 @@
+// Wire format version. Bump only for removed fields or changed meanings —
+// adding a field is backwards compatible and needs no bump.
+export const TELEMETRY_SCHEMA_VERSION = 1;
+
+export const BUCKETS = ["0", "1-5", "6-20", "21-100", "101-500", "500+"] as const;
+export type Bucket = (typeof BUCKETS)[number];
+
+// Exact counts make a small instance recognisable; buckets answer the same
+// questions without doing so.
+export function toBucket(count: number): Bucket {
+ if (count <= 0) return "0";
+ if (count <= 5) return "1-5";
+ if (count <= 20) return "6-20";
+ if (count <= 100) return "21-100";
+ if (count <= 500) return "101-500";
+ return "500+";
+}
+
+export type TelemetryProfile = "telemetry" | "diagnostics";
+
+export interface TelemetryPayload {
+ schemaVersion: number;
+ instanceId: string | null;
+ sentAt: string;
+ app: { version: string; isDev: boolean; migrations: number };
+ runtime: {
+ node: string;
+ arch: string;
+ platform: string;
+ sqlite: string;
+ timezone: string;
+ };
+ config: {
+ authEnabled: boolean;
+ guestAccess: boolean;
+ registrationOpen: boolean;
+ defaultLocale: string;
+ updateCheckEnabled: boolean;
+ rateLimitOverrides: number;
+ };
+ scale: {
+ users: Bucket;
+ calendars: Bucket;
+ shifts: Bucket;
+ presets: Bucket;
+ notes: Bucket;
+ bundles: Bucket;
+ shares: Bucket;
+ accessTokens: Bucket;
+ signups: Bucket;
+ };
+ features: {
+ externalSyncs: Bucket;
+ calendarViewOverrides: Bucket;
+ customFields: { count: Bucket; types: string[] };
+ archivedPresets: boolean;
+ splitShifts: boolean;
+ };
+ health: { uptimeHours: number; syncRuns24h: number; syncFailures24h: number };
+}
+
+// Admin-triggered export for GitHub issues. Exact counts are acceptable here
+// because the admin actively presses copy and chooses what to paste.
+export interface DiagnosticsPayload
+ extends Omit<TelemetryPayload, "scale" | "features"> {
+ scale: Record<keyof TelemetryPayload["scale"], number>;
+ features: {
+ externalSyncs: number;
+ calendarViewOverrides: number;
+ customFields: { count: number; types: string[] };
+ archivedPresets: boolean;
+ splitShifts: boolean;
+ };
+ envFlags: Record<string, string>;
+ migrationList: string[];
+}
diff --git a/lib/telemetry/sender.ts b/lib/telemetry/sender.ts
new file mode 100644
index 0000000..ec1735c
--- /dev/null
+++ b/lib/telemetry/sender.ts
@@ -0,0 +1,123 @@
+import { logSystemEvent, type TelemetrySendMetadata } from "@/lib/audit-log";
+import { getSystemSettings } from "@/lib/system-settings";
+import { collectTelemetryPayload } from "@/lib/telemetry/collect";
+import {
+ getTelemetryEndpoint,
+ isTelemetryForcedByEnv,
+ resolveTelemetryEnabled,
+} from "@/lib/telemetry/config";
+import { ensureTelemetryInstanceId } from "@/lib/telemetry/instance-id";
+import { TELEMETRY_SCHEMA_VERSION } from "@/lib/telemetry/schema";
+
+const DAY_MS = 24 * 60 * 60 * 1000;
+const REQUEST_TIMEOUT_MS = 5000;
+
+// Without a random first delay every instance restarting after a release tag
+// would fire at the same moment.
+const MIN_START_DELAY_MS = 5 * 60 * 1000;
+const MAX_START_DELAY_MS = 30 * 60 * 1000;
+
+let timer: NodeJS.Timeout | null = null;
+let stopped = false;
+
+export type TelemetrySendResult =
+ | { status: "sent" }
+ | { status: "disabled" }
+ | { status: "consent-outdated" }
+ | { status: "failed"; reason: "timeout" | "network" | "http" };
+
+// Shared by the daily timer and the admin "send now" button. Throws on DB
+// errors; only the network leg is turned into a result.
+export async function sendTelemetryNow(): Promise<TelemetrySendResult> {
+ const settings = await getSystemSettings();
+ if (!resolveTelemetryEnabled(settings.telemetryEnabled)) {
+ return { status: "disabled" };
+ }
+ // A consent given for an older schema does not cover new data categories;
+ // the env override is the operator's own standing decision and needs none.
+ if (
+ !isTelemetryForcedByEnv() &&
+ (settings.telemetryConsentedSchema ?? 0) < TELEMETRY_SCHEMA_VERSION
+ ) {
+ return { status: "consent-outdated" };
+ }
+
+ await ensureTelemetryInstanceId();
+ const payload = await collectTelemetryPayload("telemetry");
+
+ const controller = new AbortController();
+ const abort = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
+ try {
+ const response = await fetch(getTelemetryEndpoint(), {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify(payload),
+ signal: controller.signal,
+ });
+ return response.ok
+ ? { status: "sent" }
+ : { status: "failed", reason: "http" };
+ } catch (error) {
+ const timedOut = error instanceof Error && error.name === "AbortError";
+ return { status: "failed", reason: timedOut ? "timeout" : "network" };
+ } finally {
+ clearTimeout(abort);
+ }
+}
+
+/** Outcome for the audit log; never the endpoint URL, which can be private. */
+export function toSendAuditMetadata(
+ result: Extract<TelemetrySendResult, { status: "sent" | "failed" }>
+): TelemetrySendMetadata {
+ return result.status === "sent"
+ ? { result: "sent" }
+ : { result: "failed", reason: result.reason };
+}
+
+// Fire-and-forget on purpose: no retry, no backoff, no console output. An
+// instance whose logs fill with telemetry errors is worse than a missing data
+// point; the one audit entry per attempt is what shows the last outcome.
+// The whole body is one try/catch -- sendTelemetryNow can throw too (DB lock,
+// query error), not just fetch.
+async function sendOnce(): Promise<void> {
+ try {
+ const result = await sendTelemetryNow();
+ if (result.status === "sent" || result.status === "failed") {
+ await logSystemEvent<TelemetrySendMetadata>({
+ action: "system.telemetry_send",
+ resourceType: "system_settings",
+ metadata: toSendAuditMetadata(result),
+ });
+ }
+ } catch {
+ // ignored on purpose
+ }
+}
+
+function schedule(delay: number): void {
+ if (stopped) return;
+ timer = setTimeout(() => {
+ // .catch() belt-and-braces alongside sendOnce()'s own try/catch: a throw
+ // here must never become an unhandled rejection that kills the process.
+ void sendOnce()
+ .catch(() => {})
+ .finally(() => schedule(DAY_MS));
+ }, delay);
+}
+
+export const telemetryService = {
+ start(): void {
+ if (timer) return;
+ stopped = false;
+ const jitter =
+ MIN_START_DELAY_MS +
+ Math.random() * (MAX_START_DELAY_MS - MIN_START_DELAY_MS);
+ schedule(jitter);
+ },
+ stop(): void {
+ // An in-flight send's .finally() would otherwise re-arm a 24h timer.
+ stopped = true;
+ if (timer) clearTimeout(timer);
+ timer = null;
+ },
+};
diff --git a/messages/cs.json b/messages/cs.json
index ba4914f..073d0f5 100644
--- a/messages/cs.json
+++ b/messages/cs.json
@@ -527,9 +527,13 @@
"visibility": "Banner viditelný pro",
"visibilityAll": "Všechny",
"visibilityAdmins": "Pouze administrátory",
- "updateError": "Nastavení se nepodařilo uložit",
- "guestAccess": "Přístup pro hosty",
- "guestAccessHint": "Umožňuje zobrazit kalendáře bez přihlášení, pokud to kalendář povoluje."
+ "updateError": "Nastavení se nepodařilo uložit"
+ },
+ "guestAccess": {
+ "title": "Přístup pro hosty",
+ "description": "Určuje, zda lze kalendáře zobrazit bez přihlášení.",
+ "toggleLabel": "Povolit přístup pro hosty",
+ "toggleHint": "Umožňuje zobrazit kalendáře bez přihlášení, pokud to kalendář povoluje."
},
"orphanedCalendarsWarning": "Zjištěny osiřelé kalendáře",
"orphanedCalendarsWarningDescription": "{count, plural, =1 {Existuje 1 kalendář bez vlastníka} few {Existují # kalendáře bez vlastníka} other {Existuje # kalendářů bez vlastníka}}. Přiřaďte je prosím uživatelům.",
@@ -662,7 +666,28 @@
"createUser": "Vytvořit uživatele",
"createUserSubtitle": "Vytvoří nový účet i při vypnuté registraci.",
"mustChangePasswordHint": "Uživatel bude muset toto heslo změnit při prvním přihlášení.",
- "emailAlreadyExists": "Uživatel s touto e-mailovou adresou již existuje"
+ "emailAlreadyExists": "Uživatel s touto e-mailovou adresou již existuje",
+ "telemetry": {
+ "title": "Telemetrie a diagnostika",
+ "description": "Odesílat anonymní data o používání projektu.",
+ "toggleLabel": "Odesílat telemetrii",
+ "notDecided": "Zatím nerozhodnuto",
+ "envManaged": "Nastaveno proměnnou prostředí TELEMETRY_ENABLED",
+ "previewTitle": "Náhled dat k odeslání",
+ "diagnosticsPreviewTitle": "Exportovaná data",
+ "diagnosticsTitle": "Diagnostická data pro hlášení chyb",
+ "diagnosticsDescription": "Obsahuje přesná čísla a nastavené konfigurační přepínače. Určeno pouze pro hlášení chyb.",
+ "includeInstanceId": "Přidat identifikátor instance",
+ "includeInstanceIdHint": "Propojí hlášení chyby s telemetrickými daty této instance.",
+ "copy": "Kopírovat jako Markdown",
+ "copied": "Zkopírováno do schránky",
+ "openIssue": "Otevřít hlášení chyby na GitHubu",
+ "sendNow": "Odeslat nyní",
+ "sendNowHint": "K dispozici pouze při zapnuté telemetrii.",
+ "sendSuccess": "Telemetrie odeslána",
+ "sendFailed": "Odeslání se nezdařilo. Telemetrický server je nedostupný nebo požadavek odmítl.",
+ "sendUnavailable": "Odeslání není možné: telemetrie je vypnutá, souhlas je zastaralý nebo jde o vývojové sestavení."
+ }
},
"appearance": {
"title": "Vzhled",
@@ -1060,7 +1085,13 @@
"profileUpdated": "Profil upraven",
"passwordChanged": "Heslo změněno",
"accountDeleted": "Vlastní účet smazán",
- "sessionsRevoked": "{count, plural, one {# relace ukončena} few {# relace ukončeny} other {# relací ukončeno}}"
+ "sessionsRevoked": "{count, plural, one {# relace ukončena} few {# relace ukončeny} other {# relací ukončeno}}",
+ "telemetryEnabled": "Telemetrie zapnuta",
+ "telemetryDisabled": "Telemetrie vypnuta",
+ "telemetrySent": "Telemetrie odeslána ručně",
+ "telemetrySendFailed": "Ruční odeslání telemetrie se nezdařilo",
+ "telemetryAutoSent": "Telemetrie odeslána automaticky",
+ "telemetryAutoSendFailed": "Automatické odeslání telemetrie se nezdařilo"
}
},
"adminUsers": {
@@ -1248,5 +1279,18 @@
"deleteConfirm": "Toto pole bude smazáno. Hodnoty v {shifts} směnách a {presets} předlohách budou ztraceny.",
"saveFailed": "Pole se nepodařilo uložit",
"deleteFailed": "Pole se nepodařilo smazat"
+ },
+ "telemetry": {
+ "consent": {
+ "title": "Odeslat anonymní diagnostická data?",
+ "description": "BetterShift může jednou denně odeslat projektu anonymní data o používání. Pomáhá to rozhodnout, které funkce udržovat a která prostředí podporovat.",
+ "pointAnonymous": "Žádná jména, adresy, e-maily ani obsah kalendářů",
+ "pointBuckets": "Velikosti se uvádějí pouze jako rozsah, například „6-20 uživatelů“",
+ "pointRevocable": "Kdykoli odvolatelné v panelu správce",
+ "previewToggle": "Zobrazit náhled dat k odeslání",
+ "docsLink": "Úplná dokumentace",
+ "accept": "Odeslat",
+ "decline": "Neodesílat"
+ }
}
}
diff --git a/messages/de.json b/messages/de.json
index 491dba8..f87de65 100644
--- a/messages/de.json
+++ b/messages/de.json
@@ -527,9 +527,13 @@
"visibility": "Banner sichtbar für",
"visibilityAll": "Alle",
"visibilityAdmins": "Nur Admins",
- "updateError": "Einstellungen konnten nicht gespeichert werden",
- "guestAccess": "Gastzugang",
- "guestAccessHint": "Erlaubt das Ansehen von Kalendern ohne Anmeldung, sofern der Kalender das zulässt."
+ "updateError": "Einstellungen konnten nicht gespeichert werden"
+ },
+ "guestAccess": {
+ "title": "Gastzugang",
+ "description": "Steuert, ob Kalender ohne Anmeldung angesehen werden können.",
+ "toggleLabel": "Gastzugang erlauben",
+ "toggleHint": "Erlaubt das Ansehen von Kalendern ohne Anmeldung, sofern der Kalender das zulässt."
},
"orphanedCalendarsWarning": "Verwaiste Kalender erkannt",
"orphanedCalendarsWarningDescription": "{count, plural, =1 {Es gibt 1 Kalender ohne Besitzer} other {Es gibt # Kalender ohne Besitzer}}. Bitte weise diese(n) Benutzern zu.",
@@ -662,7 +666,28 @@
"createUser": "Benutzer erstellen",
"createUserSubtitle": "Legt ein neues Konto an, auch wenn die Registrierung deaktiviert ist.",
"mustChangePasswordHint": "Der Benutzer muss dieses Passwort beim ersten Login ändern.",
- "emailAlreadyExists": "Ein Benutzer mit dieser E-Mail-Adresse existiert bereits"
+ "emailAlreadyExists": "Ein Benutzer mit dieser E-Mail-Adresse existiert bereits",
+ "telemetry": {
+ "title": "Telemetrie & Diagnose",
+ "description": "Anonyme Nutzungsdaten an das Projekt senden.",
+ "toggleLabel": "Telemetrie senden",
+ "notDecided": "Noch nicht entschieden",
+ "envManaged": "Durch die Umgebungsvariable TELEMETRY_ENABLED festgelegt",
+ "previewTitle": "Vorschau der zu sendenden Daten",
+ "diagnosticsPreviewTitle": "Exportierte Daten",
+ "diagnosticsTitle": "Diagnosedaten für Fehlerberichte",
+ "diagnosticsDescription": "Enthält genaue Zahlen und gesetzte Konfigurationsschalter. Nur für Fehlerberichte gedacht.",
+ "includeInstanceId": "Instanz-Kennung mitgeben",
+ "includeInstanceIdHint": "Verknüpft den Fehlerbericht mit den Telemetriedaten dieser Instanz.",
+ "copy": "Als Markdown kopieren",
+ "copied": "In die Zwischenablage kopiert",
+ "openIssue": "Fehlerbericht auf GitHub öffnen",
+ "sendNow": "Jetzt senden",
+ "sendNowHint": "Nur verfügbar, wenn Telemetrie aktiv ist.",
+ "sendSuccess": "Telemetriedaten gesendet",
+ "sendFailed": "Senden fehlgeschlagen. Der Telemetrie-Server ist nicht erreichbar oder hat die Anfrage abgelehnt.",
+ "sendUnavailable": "Senden nicht möglich: Telemetrie ist aus, die Zustimmung ist veraltet oder dies ist ein Entwicklungs-Build."
+ }
},
"appearance": {
"title": "Erscheinungsbild",
@@ -1060,7 +1085,13 @@
"profileUpdated": "Profil bearbeitet",
"passwordChanged": "Passwort geändert",
"accountDeleted": "Eigenes Konto gelöscht",
- "sessionsRevoked": "{count, plural, one {# Sitzung} other {# Sitzungen}} beendet"
+ "sessionsRevoked": "{count, plural, one {# Sitzung} other {# Sitzungen}} beendet",
+ "telemetryEnabled": "Telemetrie aktiviert",
+ "telemetryDisabled": "Telemetrie deaktiviert",
+ "telemetrySent": "Telemetriedaten manuell gesendet",
+ "telemetrySendFailed": "Manuelles Senden der Telemetriedaten fehlgeschlagen",
+ "telemetryAutoSent": "Telemetriedaten automatisch gesendet",
+ "telemetryAutoSendFailed": "Automatisches Senden der Telemetriedaten fehlgeschlagen"
}
},
"adminUsers": {
@@ -1248,5 +1279,18 @@
"deleteConfirm": "Dieses Feld wird gelöscht. Werte in {shifts} Schichten und {presets} Presets gehen dabei verloren.",
"saveFailed": "Feld konnte nicht gespeichert werden",
"deleteFailed": "Feld konnte nicht gelöscht werden"
+ },
+ "telemetry": {
+ "consent": {
+ "title": "Anonyme Diagnosedaten senden?",
+ "description": "BetterShift kann einmal täglich anonyme Nutzungsdaten an das Projekt senden. Das hilft dabei zu entscheiden, welche Funktionen gepflegt werden und welche Umgebungen unterstützt werden müssen.",
+ "pointAnonymous": "Keine Namen, Adressen, E-Mails oder Kalenderinhalte",
+ "pointBuckets": "Größenangaben nur als Bereich, etwa „6-20 Nutzer“",
+ "pointRevocable": "Jederzeit im Admin-Bereich widerrufbar",
+ "previewToggle": "Vorschau der zu sendenden Daten anzeigen",
+ "docsLink": "Vollständige Dokumentation",
+ "accept": "Senden",
+ "decline": "Nicht senden"
+ }
}
}
diff --git a/messages/en.json b/messages/en.json
index c9b5b62..642ad21 100644
--- a/messages/en.json
+++ b/messages/en.json
@@ -527,9 +527,13 @@
"visibility": "Banner visible to",
"visibilityAll": "Everyone",
"visibilityAdmins": "Admins only",
- "updateError": "Failed to save settings",
- "guestAccess": "Guest access",
- "guestAccessHint": "Allows viewing calendars without logging in, where the calendar permits it."
+ "updateError": "Failed to save settings"
+ },
+ "guestAccess": {
+ "title": "Guest access",
+ "description": "Controls whether calendars can be viewed without logging in.",
+ "toggleLabel": "Allow guest access",
+ "toggleHint": "Allows viewing calendars without logging in, where the calendar permits it."
},
"orphanedCalendarsWarning": "Orphaned Calendars Detected",
"orphanedCalendarsWarningDescription": "{count, plural, =1 {There is 1 calendar without an owner} other {There are # calendars without an owner}}. Please assign them to users.",
@@ -662,7 +666,28 @@
"createUser": "Create user",
"createUserSubtitle": "Creates a new account, even while registration is disabled.",
"mustChangePasswordHint": "The user will be required to change this password on first login.",
- "emailAlreadyExists": "A user with this email address already exists"
+ "emailAlreadyExists": "A user with this email address already exists",
+ "telemetry": {
+ "title": "Telemetry & Diagnostics",
+ "description": "Send anonymous usage data to the project.",
+ "toggleLabel": "Send telemetry",
+ "notDecided": "Not decided yet",
+ "envManaged": "Set by the TELEMETRY_ENABLED environment variable",
+ "previewTitle": "Preview of data to be sent",
+ "diagnosticsPreviewTitle": "Exported data",
+ "diagnosticsTitle": "Diagnostic data for bug reports",
+ "diagnosticsDescription": "Includes exact figures and enabled configuration switches. Intended only for bug reports.",
+ "includeInstanceId": "Include instance ID",
+ "includeInstanceIdHint": "Links the bug report to this instance's telemetry data.",
+ "copy": "Copy as Markdown",
+ "copied": "Copied to clipboard",
+ "openIssue": "Open bug report on GitHub",
+ "sendNow": "Send now",
+ "sendNowHint": "Only available while telemetry is on.",
+ "sendSuccess": "Telemetry sent",
+ "sendFailed": "Sending failed. The telemetry server is unreachable or rejected the request.",
+ "sendUnavailable": "Cannot send: telemetry is off, the consent is outdated, or this is a development build."
+ }
},
"appearance": {
"title": "Appearance",
@@ -1060,7 +1085,13 @@
"profileUpdated": "Profile edited",
"passwordChanged": "Password changed",
"accountDeleted": "Own account deleted",
- "sessionsRevoked": "{count, plural, one {# session} other {# sessions}} ended"
+ "sessionsRevoked": "{count, plural, one {# session} other {# sessions}} ended",
+ "telemetryEnabled": "Telemetry enabled",
+ "telemetryDisabled": "Telemetry disabled",
+ "telemetrySent": "Telemetry sent manually",
+ "telemetrySendFailed": "Sending telemetry manually failed",
+ "telemetryAutoSent": "Telemetry sent automatically",
+ "telemetryAutoSendFailed": "Sending telemetry automatically failed"
}
},
"adminUsers": {
@@ -1248,5 +1279,18 @@
"deleteConfirm": "This field will be deleted. Values in {shifts} shifts and {presets} presets will be lost.",
"saveFailed": "Failed to save field",
"deleteFailed": "Failed to delete field"
+ },
+ "telemetry": {
+ "consent": {
+ "title": "Send anonymous diagnostic data?",
+ "description": "BetterShift can send anonymous usage data to the project once a day. This helps decide which features to maintain and which environments need support.",
+ "pointAnonymous": "No names, addresses, emails, or calendar content",
+ "pointBuckets": "Size figures only as a range, e.g. “6-20 users”",
+ "pointRevocable": "Revocable at any time in the admin area",
+ "previewToggle": "Show preview of data to be sent",
+ "docsLink": "Full documentation",
+ "accept": "Send",
+ "decline": "Don't send"
+ }
}
}
diff --git a/messages/es.json b/messages/es.json
index 98cc11b..3b031b0 100644
--- a/messages/es.json
+++ b/messages/es.json
@@ -527,9 +527,13 @@
"visibility": "Banner visible para",
"visibilityAll": "Todos",
"visibilityAdmins": "Solo administradores",
- "updateError": "No se pudieron guardar los ajustes",
- "guestAccess": "Acceso de invitado",
- "guestAccessHint": "Permite ver calendarios sin iniciar sesión, si el calendario lo permite."
+ "updateError": "No se pudieron guardar los ajustes"
+ },
+ "guestAccess": {
+ "title": "Acceso de invitado",
+ "description": "Controla si los calendarios se pueden ver sin iniciar sesión.",
+ "toggleLabel": "Permitir acceso de invitado",
+ "toggleHint": "Permite ver calendarios sin iniciar sesión, si el calendario lo permite."
},
"orphanedCalendarsWarning": "Se han detectado calendarios huérfanos",
"orphanedCalendarsWarningDescription": "{count, plural, =1 {Hay 1 calendario sin propietario} other {Hay # calendarios sin propietario}}. Por favor, asígnalos a usuarios.",
@@ -662,7 +666,28 @@
"createUser": "Crear usuario",
"createUserSubtitle": "Crea una nueva cuenta, incluso con el registro desactivado.",
"mustChangePasswordHint": "El usuario deberá cambiar esta contraseña en el primer inicio de sesión.",
- "emailAlreadyExists": "Ya existe un usuario con esta dirección de correo electrónico"
+ "emailAlreadyExists": "Ya existe un usuario con esta dirección de correo electrónico",
+ "telemetry": {
+ "title": "Telemetría y diagnóstico",
+ "description": "Enviar datos de uso anónimos al proyecto.",
+ "toggleLabel": "Enviar telemetría",
+ "notDecided": "Aún sin decidir",
+ "envManaged": "Definido por la variable de entorno TELEMETRY_ENABLED",
+ "previewTitle": "Vista previa de los datos a enviar",
+ "diagnosticsPreviewTitle": "Datos exportados",
+ "diagnosticsTitle": "Datos de diagnóstico para informes de error",
+ "diagnosticsDescription": "Incluye cifras exactas y los interruptores de configuración activados. Pensado solo para informes de error.",
+ "includeInstanceId": "Incluir identificador de instancia",
+ "includeInstanceIdHint": "Vincula el informe de error con los datos de telemetría de esta instancia.",
+ "copy": "Copiar como Markdown",
+ "copied": "Copiado al portapapeles",
+ "openIssue": "Abrir informe de error en GitHub",
+ "sendNow": "Enviar ahora",
+ "sendNowHint": "Solo disponible mientras la telemetría esté activada.",
+ "sendSuccess": "Telemetría enviada",
+ "sendFailed": "Error al enviar. El servidor de telemetría no está accesible o rechazó la solicitud.",
+ "sendUnavailable": "No se puede enviar: la telemetría está desactivada, el consentimiento está desactualizado o es una compilación de desarrollo."
+ }
},
"appearance": {
"title": "Apariencia",
@@ -1060,7 +1085,13 @@
"profileUpdated": "Perfil editado",
"passwordChanged": "Contraseña cambiada",
"accountDeleted": "Cuenta propia eliminada",
- "sessionsRevoked": "{count, plural, one {# sesión cerrada} other {# sesiones cerradas}}"
+ "sessionsRevoked": "{count, plural, one {# sesión cerrada} other {# sesiones cerradas}}",
+ "telemetryEnabled": "Telemetría activada",
+ "telemetryDisabled": "Telemetría desactivada",
+ "telemetrySent": "Telemetría enviada manualmente",
+ "telemetrySendFailed": "Error al enviar la telemetría manualmente",
+ "telemetryAutoSent": "Telemetría enviada automáticamente",
+ "telemetryAutoSendFailed": "Error al enviar la telemetría automáticamente"
}
},
"adminUsers": {
@@ -1248,5 +1279,18 @@
"deleteConfirm": "Este campo se eliminará. Se perderán los valores en {shifts} turnos y {presets} plantillas.",
"saveFailed": "No se pudo guardar el campo",
"deleteFailed": "No se pudo eliminar el campo"
+ },
+ "telemetry": {
+ "consent": {
+ "title": "¿Enviar datos de diagnóstico anónimos?",
+ "description": "BetterShift puede enviar datos de uso anónimos al proyecto una vez al día. Esto ayuda a decidir qué funciones mantener y qué entornos necesitan compatibilidad.",
+ "pointAnonymous": "Sin nombres, direcciones, correos electrónicos ni contenido de calendarios",
+ "pointBuckets": "Los tamaños solo se indican como rango, por ejemplo «6-20 usuarios»",
+ "pointRevocable": "Revocable en cualquier momento desde el panel de administración",
+ "previewToggle": "Mostrar vista previa de los datos a enviar",
+ "docsLink": "Documentación completa",
+ "accept": "Enviar",
+ "decline": "No enviar"
+ }
}
}
diff --git a/messages/fr.json b/messages/fr.json
index 3fd906c..8440380 100755
--- a/messages/fr.json
+++ b/messages/fr.json
@@ -527,9 +527,13 @@
"visibility": "Bannière visible pour",
"visibilityAll": "Tout le monde",
"visibilityAdmins": "Administrateurs uniquement",
- "updateError": "Échec de l'enregistrement des paramètres",
- "guestAccess": "Accès invité",
- "guestAccessHint": "Permet de consulter les calendriers sans connexion, si le calendrier l'autorise."
+ "updateError": "Échec de l'enregistrement des paramètres"
+ },
+ "guestAccess": {
+ "title": "Accès invité",
+ "description": "Détermine si les calendriers peuvent être consultés sans connexion.",
+ "toggleLabel": "Autoriser l'accès invité",
+ "toggleHint": "Permet de consulter les calendriers sans connexion, si le calendrier l'autorise."
},
"orphanedCalendarsWarning": "Calendriers orphelins détectés",
"orphanedCalendarsWarningDescription": "{count, plural, =1 {1 calendrier n'a pas de propriétaire} other {# calendriers n'ont pas de propriétaire}}. Veuillez les attribuer à des utilisateurs.",
@@ -662,7 +666,28 @@
"createUser": "Créer un utilisateur",
"createUserSubtitle": "Crée un nouveau compte, même si l'inscription est désactivée.",
"mustChangePasswordHint": "L'utilisateur devra changer ce mot de passe lors de sa première connexion.",
- "emailAlreadyExists": "Un utilisateur avec cette adresse e-mail existe déjà"
+ "emailAlreadyExists": "Un utilisateur avec cette adresse e-mail existe déjà",
+ "telemetry": {
+ "title": "Télémétrie et diagnostic",
+ "description": "Envoyer des données d'utilisation anonymes au projet.",
+ "toggleLabel": "Envoyer la télémétrie",
+ "notDecided": "Pas encore décidé",
+ "envManaged": "Défini par la variable d'environnement TELEMETRY_ENABLED",
+ "previewTitle": "Aperçu des données à envoyer",
+ "diagnosticsPreviewTitle": "Données exportées",
+ "diagnosticsTitle": "Données de diagnostic pour les rapports de bug",
+ "diagnosticsDescription": "Comprend des chiffres exacts et les options de configuration activées. Destiné uniquement aux rapports de bug.",
+ "includeInstanceId": "Inclure l'identifiant de l'instance",
+ "includeInstanceIdHint": "Associe le rapport de bug aux données de télémétrie de cette instance.",
+ "copy": "Copier au format Markdown",
+ "copied": "Copié dans le presse-papiers",
+ "openIssue": "Ouvrir un rapport de bug sur GitHub",
+ "sendNow": "Envoyer maintenant",
+ "sendNowHint": "Disponible uniquement lorsque la télémétrie est activée.",
+ "sendSuccess": "Télémétrie envoyée",
+ "sendFailed": "Échec de l'envoi. Le serveur de télémétrie est injoignable ou a refusé la requête.",
+ "sendUnavailable": "Envoi impossible : la télémétrie est désactivée, le consentement est obsolète ou il s'agit d'une version de développement."
+ }
},
"appearance": {
"title": "Apparence",
@@ -1060,7 +1085,13 @@
"profileUpdated": "Profil modifié",
"passwordChanged": "Mot de passe modifié",
"accountDeleted": "Compte personnel supprimé",
- "sessionsRevoked": "{count, plural, one {# session fermée} other {# sessions fermées}}"
+ "sessionsRevoked": "{count, plural, one {# session fermée} other {# sessions fermées}}",
+ "telemetryEnabled": "Télémétrie activée",
+ "telemetryDisabled": "Télémétrie désactivée",
+ "telemetrySent": "Télémétrie envoyée manuellement",
+ "telemetrySendFailed": "Échec de l'envoi manuel de la télémétrie",
+ "telemetryAutoSent": "Télémétrie envoyée automatiquement",
+ "telemetryAutoSendFailed": "Échec de l'envoi automatique de la télémétrie"
}
},
"adminUsers": {
@@ -1248,5 +1279,18 @@
"deleteConfirm": "Ce champ va être supprimé. Les valeurs de {shifts} créneaux et {presets} modèles seront perdues.",
"saveFailed": "Impossible d'enregistrer le champ",
"deleteFailed": "Impossible de supprimer le champ"
+ },
+ "telemetry": {
+ "consent": {
+ "title": "Envoyer des données de diagnostic anonymes ?",
+ "description": "BetterShift peut envoyer une fois par jour des données d'utilisation anonymes au projet. Cela aide à décider quelles fonctionnalités maintenir et quels environnements prendre en charge.",
+ "pointAnonymous": "Aucun nom, adresse, e-mail ni contenu de calendrier",
+ "pointBuckets": "Les tailles ne sont indiquées que sous forme de plage, par exemple « 6-20 utilisateurs »",
+ "pointRevocable": "Révocable à tout moment depuis le panneau d'administration",
+ "previewToggle": "Afficher l'aperçu des données à envoyer",
+ "docsLink": "Documentation complète",
+ "accept": "Envoyer",
+ "decline": "Ne pas envoyer"
+ }
}
}
diff --git a/messages/it.json b/messages/it.json
index e59eb78..51f9779 100644
--- a/messages/it.json
+++ b/messages/it.json
@@ -527,9 +527,13 @@
"visibility": "Banner visibile a",
"visibilityAll": "Tutti",
"visibilityAdmins": "Solo amministratori",
- "updateError": "Impossibile salvare le impostazioni",
- "guestAccess": "Accesso ospite",
- "guestAccessHint": "Consente di visualizzare i calendari senza accedere, se il calendario lo consente."
+ "updateError": "Impossibile salvare le impostazioni"
+ },
+ "guestAccess": {
+ "title": "Accesso ospite",
+ "description": "Controlla se i calendari possono essere visualizzati senza accedere.",
+ "toggleLabel": "Consenti accesso ospite",
+ "toggleHint": "Consente di visualizzare i calendari senza accedere, se il calendario lo consente."
},
"orphanedCalendarsWarning": "Calendari Orfani Rilevati",
"orphanedCalendarsWarningDescription": "{count, plural, =1 {C'è 1 calendario senza proprietario} other {Ci sono # calendari senza proprietario}}. Si prega di assegnarli agli utenti.",
@@ -662,7 +666,28 @@
"createUser": "Crea utente",
"createUserSubtitle": "Crea un nuovo account, anche con la registrazione disattivata.",
"mustChangePasswordHint": "L'utente dovrà cambiare questa password al primo accesso.",
- "emailAlreadyExists": "Esiste già un utente con questo indirizzo email"
+ "emailAlreadyExists": "Esiste già un utente con questo indirizzo email",
+ "telemetry": {
+ "title": "Telemetria e diagnostica",
+ "description": "Invia dati di utilizzo anonimi al progetto.",
+ "toggleLabel": "Invia telemetria",
+ "notDecided": "Non ancora deciso",
+ "envManaged": "Impostato dalla variabile d'ambiente TELEMETRY_ENABLED",
+ "previewTitle": "Anteprima dei dati da inviare",
+ "diagnosticsPreviewTitle": "Dati esportati",
+ "diagnosticsTitle": "Dati di diagnostica per le segnalazioni di bug",
+ "diagnosticsDescription": "Include cifre esatte e le opzioni di configurazione attive. Pensato solo per le segnalazioni di bug.",
+ "includeInstanceId": "Includi ID istanza",
+ "includeInstanceIdHint": "Collega la segnalazione di bug ai dati di telemetria di questa istanza.",
+ "copy": "Copia come Markdown",
+ "copied": "Copiato negli appunti",
+ "openIssue": "Apri una segnalazione di bug su GitHub",
+ "sendNow": "Invia ora",
+ "sendNowHint": "Disponibile solo quando la telemetria è attiva.",
+ "sendSuccess": "Telemetria inviata",
+ "sendFailed": "Invio non riuscito. Il server di telemetria non è raggiungibile o ha rifiutato la richiesta.",
+ "sendUnavailable": "Impossibile inviare: la telemetria è disattivata, il consenso non è aggiornato oppure si tratta di una build di sviluppo."
+ }
},
"appearance": {
"title": "Aspetto",
@@ -1060,7 +1085,13 @@
"profileUpdated": "Profilo modificato",
"passwordChanged": "Password cambiata",
"accountDeleted": "Account personale eliminato",
- "sessionsRevoked": "{count, plural, one {# sessione terminata} other {# sessioni terminate}}"
+ "sessionsRevoked": "{count, plural, one {# sessione terminata} other {# sessioni terminate}}",
+ "telemetryEnabled": "Telemetria attivata",
+ "telemetryDisabled": "Telemetria disattivata",
+ "telemetrySent": "Telemetria inviata manualmente",
+ "telemetrySendFailed": "Invio manuale della telemetria non riuscito",
+ "telemetryAutoSent": "Telemetria inviata automaticamente",
+ "telemetryAutoSendFailed": "Invio automatico della telemetria non riuscito"
}
},
"adminUsers": {
@@ -1248,5 +1279,18 @@
"deleteConfirm": "Questo campo verrà eliminato. I valori in {shifts} turni e {presets} modelli andranno persi.",
"saveFailed": "Impossibile salvare il campo",
"deleteFailed": "Impossibile eliminare il campo"
+ },
+ "telemetry": {
+ "consent": {
+ "title": "Inviare dati di diagnostica anonimi?",
+ "description": "BetterShift può inviare una volta al giorno dati di utilizzo anonimi al progetto. Questo aiuta a decidere quali funzionalità mantenere e quali ambienti supportare.",
+ "pointAnonymous": "Nessun nome, indirizzo, email o contenuto dei calendari",
+ "pointBuckets": "Le dimensioni sono indicate solo come intervallo, ad esempio «6-20 utenti»",
+ "pointRevocable": "Revocabile in qualsiasi momento dal Pannello Admin",
+ "previewToggle": "Mostra l'anteprima dei dati da inviare",
+ "docsLink": "Documentazione completa",
+ "accept": "Invia",
+ "decline": "Non inviare"
+ }
}
}
diff --git a/telemetry-hub/.env.example b/telemetry-hub/.env.example
new file mode 100644
index 0000000..f41e038
--- /dev/null
+++ b/telemetry-hub/.env.example
@@ -0,0 +1,16 @@
+# Settings for scripts/create-posthog-dashboard.mjs — copy to .env (gitignored), then `npm run dashboard`.
+# Not the Worker's config: that lives in wrangler.toml and .dev.vars.
+
+# Personal key (phx_...) with the dashboard:write, insight:write and project:read scopes.
+POSTHOG_PERSONAL_API_KEY=
+
+# Optional. Only needed if the key can see more than one project.
+# POSTHOG_PROJECT_ID=
+
+# Optional. App host, not the eu.i.posthog.com ingest host.
+# POSTHOG_HOST=https://eu.posthog.com
+
+# Optional. Instance ids to leave out of the "ohne Test-Instanzen" dashboard (comma-separated).
+# EXCLUDE_INSTANCE_IDS=
+
+# Optional. DASHBOARD_NAME, and DASHBOARD_VARIANTS=all,no-dev,dev-only,no-ids
diff --git a/telemetry-hub/.gitignore b/telemetry-hub/.gitignore
new file mode 100644
index 0000000..073e02d
--- /dev/null
+++ b/telemetry-hub/.gitignore
@@ -0,0 +1,3 @@
+node_modules
+.wrangler
+.dev.vars
diff --git a/telemetry-hub/README.md b/telemetry-hub/README.md
new file mode 100644
index 0000000..42f724e
--- /dev/null
+++ b/telemetry-hub/README.md
@@ -0,0 +1,158 @@
+# BetterShift Telemetry Hub
+
+A small Cloudflare Worker that receives the opt-in, anonymous instance pings of BetterShift and forwards them to [PostHog](https://posthog.com/). It stores nothing itself.
+
+You only need this if you want to **run your own receiver**. By default, instances send to the maintainer's hub, and an admin can opt out completely. What is sent is documented field by field in [`docs/TELEMETRY.md`](../docs/TELEMETRY.md).
+
+The hub is deployed on its own and is not part of the Docker image.
+
+## Table of Contents
+
+1. [What You Need](#what-you-need)
+2. [Set It Up](#set-it-up)
+3. [Point Your Instances at It](#point-your-instances-at-it)
+4. [Test It Locally](#test-it-locally)
+5. [What the Worker Does](#what-the-worker-does)
+6. [The PostHog Dashboards](#the-posthog-dashboards)
+7. [Operating It](#operating-it)
+8. [Project Layout](#project-layout)
+
+---
+
+## What You Need
+
+- A **Cloudflare account** (the free plan is enough).
+- A **PostHog project**, cloud EU or US. Use the _project API key_ (`phc_...`), not a personal key.
+- **Node.js 20.12 or newer** on the machine you deploy from.
+- Optional: a domain on Cloudflare, if you want a URL like `telemetry.example.com`. Without one, the Worker is served from a free `*.workers.dev` address.
+
+## Set It Up
+
+All commands run in this directory (`telemetry-hub/`).
+
+### 1. Install
+
+```bash
+npm install
+npx wrangler login
+```
+
+### 2. Adjust `wrangler.toml`
+
+The committed file describes the maintainer's deployment. Change it before your first deploy:
+
+| Setting | What to do |
+| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `name` | Any unique Worker name. |
+| `routes` | Replace `pattern` and `zone_name` with your own hostname and the Cloudflare zone it belongs to. Cloudflare creates the DNS record and certificate for you. |
+| `POSTHOG_HOST` | The **ingest** host of your PostHog region: `https://eu.i.posthog.com` or `https://us.i.posthog.com`. It must match the region of the project key (see below). |
+
+No domain? Delete the whole `routes` block and add `workers_dev = true` instead. After the deploy, Wrangler prints the `https://<name>.<your-subdomain>.workers.dev` URL.
+
+### 3. Store the PostHog key as a secret
+
+```bash
+npx wrangler secret put POSTHOG_API_KEY
+```
+
+Paste the project API key (PostHog → Project settings → Project API key). It is stored encrypted in Cloudflare and is never written to `wrangler.toml` or the repository.
+
+A key only works against its own region. An EU project used with `us.i.posthog.com` (or the other way round) is rejected, and because the Worker always answers `200`, you would see no error on the sender's side. See [Operating It](#operating-it) for where to look.
+
+### 4. Deploy
+
+```bash
+npm run deploy
+```
+
+### 5. Check that it arrived
+
+Send one valid ping with an id you can recognise later:
+
+```bash
+curl -i -X POST https://YOUR-HUB-URL \
+ -H 'Content-Type: application/json' \
+ -d '{"schemaVersion":1,"instanceId":"smoke-test","sentAt":"2026-01-01T00:00:00.000Z","app":{"version":"0.0.0","isDev":true,"migrations":0},"runtime":{"node":"24.0.0","arch":"x64","platform":"linux","sqlite":"3.45.1","timezone":"UTC"},"config":{"authEnabled":true,"guestAccess":false,"registrationOpen":false,"defaultLocale":"en","updateCheckEnabled":true,"rateLimitOverrides":0},"scale":{"users":"1-5","calendars":"1-5","shifts":"1-5","presets":"0","notes":"0","bundles":"0","shares":"0","accessTokens":"0","signups":"0"},"features":{"externalSyncs":"0","calendarViewOverrides":"0","customFields":{"count":"0","types":[]},"archivedPresets":false,"splitShifts":false},"health":{"uptimeHours":1,"syncRuns24h":0,"syncFailures24h":0}}'
+```
+
+You should get `HTTP/2 200`, and an `instance_ping` event for `smoke-test` should show up in PostHog → Activity within a minute.
+
+**A `200` alone proves nothing.** The Worker also answers `200` to payloads it discards and to failed forwards, on purpose (see [What the Worker Does](#what-the-worker-does)). The event in PostHog is the real confirmation.
+
+## Point Your Instances at It
+
+Set this in the `.env` of every BetterShift instance that should report to you:
+
+```env
+TELEMETRY_ENDPOINT=https://YOUR-HUB-URL
+```
+
+Use the bare URL without a path. Telemetry itself stays opt-in: the instance admin still has to agree in the app, or you set `TELEMETRY_ENABLED=true` to switch it on for a deployment you control. Details are in [`docs/TELEMETRY.md`](../docs/TELEMETRY.md#turning-it-off).
+
+## Test It Locally
+
+Create `.dev.vars` in this directory:
+
+```env
+POSTHOG_API_KEY=phc_your_key
+POSTHOG_HOST=https://eu.i.posthog.com
+```
+
+Then start the dev server:
+
+```bash
+npm run dev
+```
+
+The Worker then listens on `http://localhost:8787`. Use the `curl` command from step 5 against that URL. `.dev.vars` is gitignored and only read by `wrangler dev`.
+
+Use a throwaway PostHog project for this. Local test pings otherwise mix into your real data.
+
+`npm run typecheck` checks the types.
+
+## What the Worker Does
+
+| Request | Answer |
+| ---------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
+| Any method except `POST` | `405` |
+| Body larger than 16 KB | `413` |
+| Body is not valid JSON | `400` |
+| Valid JSON that fails validation, or unknown version | `200`, discarded |
+| Valid v1 payload | `200`, forwarded to PostHog. If PostHog rejects it, still `200`; the error message is logged. |
+
+The senders are fire-and-forget and never retry, so a payload the Worker cannot forward is lost. That is by design: the Worker has no database, queue or request log.
+
+Every event is sent to PostHog with `$ip: null` and `$geoip_disable: true`, so PostHog stores neither the sender's IP nor a location derived from it. Person profiles are switched off as well, since an instance is not a person. Each field is passed on explicitly; nothing is spread from the request body.
+
+Cloudflare itself still sees the connecting IP in its own edge logs, like for any hosted Worker. The Worker code never reads or stores it.
+
+## The PostHog Dashboards
+
+`scripts/create-posthog-dashboard.mjs` builds ready-made dashboards (growth, versions, environment, sizes, configuration, features, health) from the `instance_ping` events. It uses a **personal** API key, not the project key of the Worker.
+
+```bash
+cp .env.example .env # then fill in POSTHOG_PERSONAL_API_KEY
+npm run dashboard -- --dry-run
+npm run dashboard
+```
+
+The script also creates variants without dev builds, with dev builds only, and without your own test instances (`EXCLUDE_INSTANCE_IDS`, for example `smoke-test`). Run it again at any time: existing dashboards are matched by name and updated in place. All options are described in `.env.example` and in the header of the script.
+
+If your PostHog project is in the US region, set `POSTHOG_HOST=https://us.posthog.com` in `.env` (the app host, not the `i.` ingest host).
+
+## Operating It
+
+- **Live logs:** `npx wrangler tail`. A failed forward appears as one line with the PostHog status, never the payload.
+- **Nothing shows up in PostHog:** check, in this order, that the ping reached the Worker (`wrangler tail` while sending), that the key belongs to the region set in `POSTHOG_HOST`, and that the sender is a real v1 payload (an invalid one is discarded silently).
+- **Rotating the key:** run `npx wrangler secret put POSTHOG_API_KEY` again. No redeploy is needed.
+## Project Layout
+
+```text
+src/index.ts request handling: method, size, JSON, validation, forward
+src/schemas/v1.ts payload type and validator for schemaVersion 1
+src/targets/posthog.ts maps a payload to a PostHog event
+scripts/ create-posthog-dashboard.mjs
+wrangler.toml Worker name, route and the PostHog host
+```
+
+This project is self-contained and does not import from the main app. `src/schemas/v1.ts` mirrors `TelemetryPayload` in [`lib/telemetry/schema.ts`](../lib/telemetry/schema.ts) by value, so a change to the payload has to be made in both places. Until a new `schemaVersion` exists, anything that is not a valid v1 payload is discarded.
diff --git a/telemetry-hub/package-lock.json b/telemetry-hub/package-lock.json
new file mode 100644
index 0000000..5f90695
--- /dev/null
+++ b/telemetry-hub/package-lock.json
@@ -0,0 +1,1613 @@
+{
+ "name": "bettershift-telemetry-hub",
+ "lockfileVersion": 3,
+ "requires": true,
+ "packages": {
+ "": {
+ "name": "bettershift-telemetry-hub",
+ "devDependencies": {
+ "@cloudflare/workers-types": "^5.20260919.1",
+ "typescript": "^6.0.3",
+ "wrangler": "^4.135.0"
+ }
+ },
+ "node_modules/@cloudflare/kv-asset-handler": {
+ "version": "0.5.0",
+ "resolved": "https://registry.npmjs.org/@cloudflare/kv-asset-handler/-/kv-asset-handler-0.5.0.tgz",
+ "integrity": "sha512-jxQYkj8dSIzc0cD6cMMNdOc1UVjqSqu8BZdor5s8cGjW2I8BjODt/kWPVdY+u9zj3ms75Q5qaZgnxUad83+eAg==",
+ "dev": true,
+ "license": "MIT OR Apache-2.0",
+ "engines": {
+ "node": ">=22.0.0"
+ }
+ },
+ "node_modules/@cloudflare/unenv-preset": {
+ "version": "2.16.1",
+ "resolved": "https://registry.npmjs.org/@cloudflare/unenv-preset/-/unenv-preset-2.16.1.tgz",
+ "integrity": "sha512-ECxObrMfyTl5bhQf/lZCXwo5G6xX9IAUo+nDMKK4SZ8m4Jvvxp52vilxyySSWh2YTZz8+HQ07qGH/2rEom1vDw==",
+ "dev": true,
+ "license": "MIT OR Apache-2.0",
+ "peerDependencies": {
+ "unenv": "2.0.0-rc.24",
+ "workerd": ">1.20260305.0 <2.0.0-0"
+ },
+ "peerDependenciesMeta": {
+ "workerd": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@cloudflare/workerd-darwin-64": {
+ "version": "1.20260918.1",
+ "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-64/-/workerd-darwin-64-1.20260918.1.tgz",
+ "integrity": "sha512-H5Em6Wd0jjxaloYh2rp+WLBl2eWbkk7nSP1svGt6K1RSv/rNVqmKdpjZPJTBSavOmeYGa88qvtOWwS+33OHTqQ==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": ">=16"
+ }
+ },
+ "node_modules/@cloudflare/workerd-darwin-arm64": {
+ "version": "1.20260918.1",
+ "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-arm64/-/workerd-darwin-arm64-1.20260918.1.tgz",
+ "integrity": "sha512-CR9JRZEQo93fNgBVF4Df2H2/VYO4n7rxSseSwCVv3bJQEb0huADUSCj2FK4ipxar8ToOEB4wawyw0vJo5U/rQQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": ">=16"
+ }
+ },
+ "node_modules/@cloudflare/workerd-linux-64": {
+ "version": "1.20260918.1",
+ "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-64/-/workerd-linux-64-1.20260918.1.tgz",
+ "integrity": "sha512-UQ2nnY3qpXLzQ80frmWO+8HvtqyWaQILe8QYZwpemdjT+sqwCz4Dz+0/WVkFco0v/04kIIqikVeLTY/7gEhmkw==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=16"
+ }
+ },
+ "node_modules/@cloudflare/workerd-linux-arm64": {
+ "version": "1.20260918.1",
+ "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-arm64/-/workerd-linux-arm64-1.20260918.1.tgz",
+ "integrity": "sha512-4rib51MaLNWweUIUxM/Xj558M5QmyZoBSf0ffv+lYah5VTrvwnez3XGxX72pElnBKHROvAPOi5msQ5Ts8JSI0A==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=16"
+ }
+ },
+ "node_modules/@cloudflare/workerd-windows-64": {
+ "version": "1.20260918.1",
+ "resolved": "https://registry.npmjs.org/@cloudflare/workerd-windows-64/-/workerd-windows-64-1.20260918.1.tgz",
+ "integrity": "sha512-sATrMx5ShYYgmgUGrcTmvsFSJBFuN95NEkX3xwb1qk8w1A6h5N11sea7yN2IeibwPyPmXKjWNjXOno0hZAM71Q==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">=16"
+ }
+ },
+ "node_modules/@cloudflare/workers-types": {
+ "version": "5.20260919.1",
+ "resolved": "https://registry.npmjs.org/@cloudflare/workers-types/-/workers-types-5.20260919.1.tgz",
+ "integrity": "sha512-xUdKJoTHhNcXwnBrfrM1STkzm3oSUc9cRVzP8fO5NyJZ/UtnDnWZHDk9z8IkTnbC2WRWFAS87HICmqZhbHDvQw==",
+ "dev": true,
+ "license": "MIT OR Apache-2.0"
+ },
+ "node_modules/@cspotcode/source-map-support": {
+ "version": "0.8.1",
+ "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz",
+ "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@jridgewell/trace-mapping": "0.3.9"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/@emnapi/runtime": {
+ "version": "1.11.3",
+ "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.3.tgz",
+ "integrity": "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==",
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "dependencies": {
+ "tslib": "^2.4.0"
+ }
+ },
+ "node_modules/@esbuild/aix-ppc64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.1.tgz",
+ "integrity": "sha512-Svl7tq8k/08+p6CXPpRjQ1fKX+1odH/BQbb48fV6fj3CWHhsoIOoY87w1oHXm0qEpkIK3ZfVgp0hed3XBXzXMQ==",
+ "cpu": [
+ "ppc64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "aix"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/android-arm": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.1.tgz",
+ "integrity": "sha512-0k2F129Xdio1TdJfzJ8sy1Q47vUD2NnwdhiAf7drUN1EBTfPf4hsFCtmMgu/6m8JSzsBrlmVjudMBQqOfG8usQ==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "android"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/android-arm64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.1.tgz",
+ "integrity": "sha512-34EGEbCIAgosYz6goLcopX6Mo7NyGv9tfwEM2/7Ce2VcVRk568iSvniGWcUXIy7wEDR1wzolcxcriFVrWYcwBg==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "android"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/android-x64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.1.tgz",
+ "integrity": "sha512-dbwY7ltSMDWsRatcRpCnES4F+im88OCUgGZjy52shC7GqHRE/cYlxNbB4Z4UpJswpcc4Qxd2oE/ufM0p61IKng==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "android"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/darwin-arm64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.1.tgz",
+ "integrity": "sha512-TZbWkQY7kvTAXbXUT7uVACR5cMHsDiSz9z7ZKAX/RTq/WJEk3QyRr0wZpNhBDX+/0CtdqUIJlOiodQcta6tY3Q==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/darwin-x64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.1.tgz",
+ "integrity": "sha512-zfdzgK9ACBNZLI/CyHTOx81SyNbM6YXn7rxSgX97VjyiPl9W1i4Ka4fgKECEoFCKGpvBj5qArWIGgQjOwkgskQ==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/freebsd-arm64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.1.tgz",
+ "integrity": "sha512-wG2EA8ENdEI0qhkSZMjfqrdY+ziCYCPMmtZjjIwOmXFjmyzEHn+UUxk5of+SYsjtfs3VpnlC7QLzSI5hY/rOAw==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "freebsd"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/freebsd-x64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.1.tgz",
+ "integrity": "sha512-i7dZ9vQgnvSCzi/rYCXNgtF/U+eKZNJBzu3eTQbRgHnM7tNSizLOkRFAl3qzVc/Op/u5YkHHa4pf/3DOYHthLQ==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "freebsd"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-arm": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.1.tgz",
+ "integrity": "sha512-qVXBOHQS+d5Y722GwJzJUtOLlX7km3CraOaGormF1pDtPd2C/l1SHRPgjLunLGe51Sh5YYWKMFDyV4SxgMQYTQ==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-arm64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.1.tgz",
+ "integrity": "sha512-yHs+0uc8+nvEAfAfxrWQKK5peSNzBc4PegcMO0EJ2hT71uA7vB8Ihg2e77R2P7SG5uYjPbHlLLmve4LLLRCf0g==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-ia32": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.1.tgz",
+ "integrity": "sha512-d1z4ZuP0ajrfz/FhGT4vv278rX8KnPPJx8i5+AtK7TYbx9Le9F1hyzurZpkEyjkGa9dUGhQow4C1NmeGvqxN2w==",
+ "cpu": [
+ "ia32"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-loong64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.1.tgz",
+ "integrity": "sha512-M5sRjUVZrkm1OAPR3dlOYzNmN+loZKGVi1VUQGrwuqLcbR6qeAz+famMhjASeH3YVKvZz+zT1jlh/keC3Rj/lg==",
+ "cpu": [
+ "loong64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-mips64el": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.1.tgz",
+ "integrity": "sha512-mRObBZeHh2OxcBFPWE/FjylkRgZdYuiTR3vaTozquCGOH14iP9oN4x4Ge81CoIDYQrXmIxpFumJBu5MtZpnQJQ==",
+ "cpu": [
+ "mips64el"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-ppc64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.1.tgz",
+ "integrity": "sha512-slScBsMAb3GFDcdrCgLwZtPYRoH2H/youv10QiZyRjmsP48fznoveWytSgCI/R0ZcUgpc0ZhIUEx6LHts8yrfQ==",
+ "cpu": [
+ "ppc64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-riscv64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.1.tgz",
+ "integrity": "sha512-kw0owk1o0GFETUJyW0jc0G4Yzs0BHZn0JDZ8JRT088vjJYX777BAs1fDGxAC+q831qOs2DTC96mNsG2opdfyyQ==",
+ "cpu": [
+ "riscv64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-s390x": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.1.tgz",
+ "integrity": "sha512-/lAIjX8aYFRByhh6L5rYtPEDRqa9de/4V/juOXcta5frjvzXO4/sqEtyytse0g3zZFuWu5cDN0MkLz2qRDD2Ag==",
+ "cpu": [
+ "s390x"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/linux-x64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.1.tgz",
+ "integrity": "sha512-u/anNYF2mmVOEDwLtnQ1wOr3EZ9sTNGLWrsYGYwHWzGA3Si84IOkHXlbWTD1NB+9/1lcnweYKO54uhxZydNzfA==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/netbsd-arm64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.1.tgz",
+ "integrity": "sha512-oks0DYbLwWMmaakTsCb+zL4E+aHRVLom9IJZOAthMQEPiQmydXHkziYEsGYRx0uNV/IjEKGAV941JzH02pflqw==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "netbsd"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/netbsd-x64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.1.tgz",
+ "integrity": "sha512-aeL6lAnN89Hz43Mlh1G8ARasbuoYvSITDEx0tHh5b7jJnHcssqgjy9Yx430GDpmCa6OyrKoS0aNRjKundRizGg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "netbsd"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/openbsd-arm64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.1.tgz",
+ "integrity": "sha512-MEFJe5C3R8pwXdZ5Y21oo6m7ePiS0d9pWucn99O/wvyJZChoIQKrQDxKrGeW8F5+T0okTHesAmDeiHDTIq0V/Q==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "openbsd"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/openbsd-x64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.1.tgz",
+ "integrity": "sha512-i/ZLIOafE0Z8cI/XANJAixoJL/uRAoS2xOA3rb0xN+KK0K177cMAsQYkzHtBrtMXAKuAc7HGgcWiZ/sRC1Nxgw==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "openbsd"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/openharmony-arm64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.1.tgz",
+ "integrity": "sha512-ge+Z7EXFNt2BO1oAMsVpiQ8EwndV9i1xXerAeTIK7AtPs3bKFXQM7nlRxDSIUIMeueR1CNXxqztLzdNeReKBJg==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "openharmony"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/sunos-x64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.1.tgz",
+ "integrity": "sha512-BEjgtECkL3vY+SaSQ6nzVfiALUeFxpawyp8Jmf5PtYhf1Ug40N1h/hxlhts+f1FvSvarEigdxS3BlSMI2PJLcQ==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "sunos"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/win32-arm64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.1.tgz",
+ "integrity": "sha512-lCv9eK/H6ZJWbE7bh2nw54CZ9M2nupBxJcTsdk/QQnWkdSjKGuxmmH8/GWrlT1eMmZfn4dGcCjRte397WqfQXA==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/win32-ia32": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.1.tgz",
+ "integrity": "sha512-zvb/mB2bSCoJOpoCBgYKKpX6YM6mJBlBUVUtVj41DlZJVEB6/0CKlRYxP5wWl1C1ILiCoAU5wZZ4q1P3qeS6Eg==",
+ "cpu": [
+ "ia32"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@esbuild/win32-x64": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.1.tgz",
+ "integrity": "sha512-bm4Mowrv+GXMlpWX++EcXw/iLyd1o3+bJkC2DkWXYVvgZCqD/bSj9ctZeAMC3cIxgjRVR2Dufaiu4YPxr5gW1A==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@img/colour": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.1.0.tgz",
+ "integrity": "sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ }
+ },
+ "node_modules/@img/sharp-darwin-arm64": {
+ "version": "0.35.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.35.4.tgz",
+ "integrity": "sha512-Uhfl4V4lhP2nbUVF9+hyH1+luj86f1gUFeo8ALYxFoULoU+G87D43BfeMP8XHsk9boxAnCY/bf2EHwhA7MuGsA==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": ">=20.9.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-darwin-arm64": "1.3.3"
+ }
+ },
+ "node_modules/@img/sharp-darwin-x64": {
+ "version": "0.35.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.35.4.tgz",
+ "integrity": "sha512-hWniXY3bG5qKpkKrAwPe4y+VTPmf086YQAnkxWh7uA1YrlRouWGa0M0Mxj3ZjnXFkv7/TD1bTy9lGUK26vRvWw==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": ">=20.9.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-darwin-x64": "1.3.3"
+ }
+ },
+ "node_modules/@img/sharp-freebsd-wasm32": {
+ "version": "0.35.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-freebsd-wasm32/-/sharp-freebsd-wasm32-0.35.4.tgz",
+ "integrity": "sha512-lIsKw/BU+kjB4eZjxrYrZmwOJYi3Ajrv66iAlBmUPyKc3HpnloevB1g3wxGD9P/5BbQ1brBGl65VRRrCvQDEqA==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "freebsd"
+ ],
+ "dependencies": {
+ "@img/sharp-wasm32": "0.35.4"
+ },
+ "engines": {
+ "node": ">=20.9.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-darwin-arm64": {
+ "version": "1.3.3",
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.3.3.tgz",
+ "integrity": "sha512-suTBPTDGrI9WodccaDdwZItTSaBYASlBk1NSfElSHrUfzu3szG6lvIF58+WiFvnfzuK8ZBFS5zE00PxqxnRiPg==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-darwin-x64": {
+ "version": "1.3.3",
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.3.3.tgz",
+ "integrity": "sha512-FVJZ5mITMobmXIz/hPDTw0EintTW5H3WfrxwLqEqjiIihlu+hVRyGrFQ60xl0Lxn7Bt3zdpevPaQi0HEzqz9fw==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-linux-arm": {
+ "version": "1.3.3",
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.3.3.tgz",
+ "integrity": "sha512-3rbU4vqXXc3hY/OiXdl52xZvT0F1yEngWfvqudtPJg/KkyiaQw2DRsFrNzpmLvfavbwOq3qXn36GP8obHRULQA==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-linux-arm64": {
+ "version": "1.3.3",
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.3.3.tgz",
+ "integrity": "sha512-0DaL0A6Xu6sQSQFwe4iVCrKWU2cCTItnRsYsCdxAMm9NF6twAA9BKnoqy4hqz4+azQ0JHuA26qiUKsf1XJ/v5A==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-linux-ppc64": {
+ "version": "1.3.3",
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.3.3.tgz",
+ "integrity": "sha512-cdn1OvUBwsXhbC0zSzJnNzf5MZ/mTrobawDvNXBTxe8VtqKAm0sRuEY2Evzovb/w9JMk4TvRxqt1mekSuJz64w==",
+ "cpu": [
+ "ppc64"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-linux-riscv64": {
+ "version": "1.3.3",
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.3.3.tgz",
+ "integrity": "sha512-HjPVx7yKz+0lqdhDlTw1tt90wamBoxhiXpvl1XZpJLiHH4RCJ5yDTqH+VlYPv2fwFs89JFw4c1IexYOcQUi4IQ==",
+ "cpu": [
+ "riscv64"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-linux-s390x": {
+ "version": "1.3.3",
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.3.3.tgz",
+ "integrity": "sha512-neWLh+3yCNThxnfy3c4BbVBeGgt9aftno+XbT56iK28RgeDs3UOFWviLWlUu0bArYVYJaFDK+RRohbicUNCm8Q==",
+ "cpu": [
+ "s390x"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-linux-x64": {
+ "version": "1.3.3",
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.3.3.tgz",
+ "integrity": "sha512-4vKmvAst9nrowcqquKFAyZJUDolUaIp8uRiN0mWFguJ1IplC9/pitXtlnnlU4aa/eJw3J7i67V+pwUL+wZGdsA==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-linuxmusl-arm64": {
+ "version": "1.3.3",
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.3.3.tgz",
+ "integrity": "sha512-Y9kQaLMuNoB0bPYOOdcZMaseNrFpPodIWWMrx+CZyydf2xn68j9WYc6sWWRrDwNkzCQjKYfc68L7jKjGlHMibw==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "libc": [
+ "musl"
+ ],
+ "license": "LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-linuxmusl-x64": {
+ "version": "1.3.3",
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.3.3.tgz",
+ "integrity": "sha512-fj8Mv0HHfD1Rr+4I68+3agJynxDWtBFgicTbSOb9Bke6pIwzGcJ+RX/yHjmiEGFMCavY/dxvem7MyNaJF+wDiw==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "libc": [
+ "musl"
+ ],
+ "license": "LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-linux-arm": {
+ "version": "0.35.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.35.4.tgz",
+ "integrity": "sha512-7OAS8gI0EReKGVN2HssHlM6umJgxF5VI3xN0p9FA91p/YO+ou5hiNghLdZ5BEHztwaaK5+bLKRf8x/o2L2nk9A==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=20.9.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-linux-arm": "1.3.3"
+ }
+ },
+ "node_modules/@img/sharp-linux-arm64": {
+ "version": "0.35.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.35.4.tgz",
+ "integrity": "sha512-De4jpEnAU8Hd5oT0j1G3uL4ZvTuipVMn7YC6vPaJhy6/7EwEae0SVAoBrUMYQbkLGDm85taVWwuPc1a44LTzCQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=20.9.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-linux-arm64": "1.3.3"
+ }
+ },
+ "node_modules/@img/sharp-linux-ppc64": {
+ "version": "0.35.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.35.4.tgz",
+ "integrity": "sha512-2oYZJeIl4kCcMGk4ouZVjnkCtFrpQFlNEtJ6GbxzhHQchwH0NH/qEb9ykmOl29dqwMq+JhFdZn+1ak2FKhI9fQ==",
+ "cpu": [
+ "ppc64"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=20.9.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-linux-ppc64": "1.3.3"
+ }
+ },
+ "node_modules/@img/sharp-linux-riscv64": {
+ "version": "0.35.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.35.4.tgz",
+ "integrity": "sha512-cPbNChoRURAWdebDIHSenxRpgEdy7JkPydSnUxRm9VvKD7m0/xVaR/8Fzlu81pk5nHEvHH87UZUA7cTtwnbJSA==",
+ "cpu": [
+ "riscv64"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=20.9.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-linux-riscv64": "1.3.3"
+ }
+ },
+ "node_modules/@img/sharp-linux-s390x": {
+ "version": "0.35.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.35.4.tgz",
+ "integrity": "sha512-RY0JFY8Fd6RonCBtHz+DvadaPkXDSI1AUn6yWL9TipqkZ1vY8w8evqdgyDFnkm4/K1ve1TvZiaePP5oSd4+WVQ==",
+ "cpu": [
+ "s390x"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=20.9.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-linux-s390x": "1.3.3"
+ }
+ },
+ "node_modules/@img/sharp-linux-x64": {
+ "version": "0.35.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.35.4.tgz",
+ "integrity": "sha512-9qvvEAuk8k89TfWUoX2htWjbAMX8p+NxCppjpcg5k6xMsjhBQPTsoIh36h9Qde4WRuGpJeYnOjdosDn/cnv+OA==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "libc": [
+ "glibc"
+ ],
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=20.9.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-linux-x64": "1.3.3"
+ }
+ },
+ "node_modules/@img/sharp-linuxmusl-arm64": {
+ "version": "0.35.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.35.4.tgz",
+ "integrity": "sha512-KB5jxpfWQTr0nc3xdHtWChdbifHrBGsd2SM62Eyxrl8afikm+f5qGBU75SJIZBT/S1MC8XyacdlXBMSWq6OURA==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "libc": [
+ "musl"
+ ],
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=20.9.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-linuxmusl-arm64": "1.3.3"
+ }
+ },
+ "node_modules/@img/sharp-linuxmusl-x64": {
+ "version": "0.35.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.35.4.tgz",
+ "integrity": "sha512-f+eZJZIQNEEd26RPSW+76chwOf1XtA2Y/O+5ocVyLliHkeih3e+jhLVBdNTd2rS3IbNXK8+ug93Vf5ZXtF5Lxg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "libc": [
+ "musl"
+ ],
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=20.9.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-linuxmusl-x64": "1.3.3"
+ }
+ },
+ "node_modules/@img/sharp-wasm32": {
+ "version": "0.35.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.35.4.tgz",
+ "integrity": "sha512-zQnl4Kwp7Q6NHsENtU2T/00Zi+w3AQNwz3+UaTyVBy2FpXrzXzGjndpK61onhZjRtRpQXxCTeqw19bVyXOh7jA==",
+ "dev": true,
+ "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT",
+ "optional": true,
+ "dependencies": {
+ "@emnapi/runtime": "^1.11.3"
+ },
+ "engines": {
+ "node": ">=20.9.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-webcontainers-wasm32": {
+ "version": "0.35.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-webcontainers-wasm32/-/sharp-webcontainers-wasm32-0.35.4.tgz",
+ "integrity": "sha512-ESfNkywmCfPNyaZjxooddJQiQ+l/nTpGEOGthxiLnIHXC/CmcBixnfwUleX9mCz9ovrUUvKMap/pm8RYbzfwaA==",
+ "cpu": [
+ "wasm32"
+ ],
+ "dev": true,
+ "license": "Apache-2.0",
+ "optional": true,
+ "dependencies": {
+ "@img/sharp-wasm32": "0.35.4"
+ },
+ "engines": {
+ "node": ">=20.9.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-win32-arm64": {
+ "version": "0.35.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.35.4.tgz",
+ "integrity": "sha512-iNdlBX9gLVvqe2I3uIJSIKTq6wckP/DYxZtcqxm09x5Gi24DnFBmPAWZmr60ZyYMG0xlzo6goG3670ar+RXvRw==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "Apache-2.0 AND LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">=20.9.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-win32-ia32": {
+ "version": "0.35.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.35.4.tgz",
+ "integrity": "sha512-kqRsbaa5CS6KHlpxnN7WhE6vAAugXyZButpRdvDWetlv6Qv4N9WTcrWzF7tXfB9T7MsoadqdI8hmwLq6UlLvtw==",
+ "cpu": [
+ "ia32"
+ ],
+ "dev": true,
+ "license": "Apache-2.0 AND LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": "^20.9.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-win32-x64": {
+ "version": "0.35.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.35.4.tgz",
+ "integrity": "sha512-XtmnYhBcrORsJ4XJngyzr/EWP0hRZLAZRFaApdKuviyqF78+ylxh2y06ZmtULAMOnObJ3ucpN0AcwSWnMowTRg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "Apache-2.0 AND LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">=20.9.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@jridgewell/resolve-uri": {
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
+ "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=6.0.0"
+ }
+ },
+ "node_modules/@jridgewell/sourcemap-codec": {
+ "version": "1.6.0",
+ "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz",
+ "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/@jridgewell/trace-mapping": {
+ "version": "0.3.9",
+ "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz",
+ "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@jridgewell/resolve-uri": "^3.0.3",
+ "@jridgewell/sourcemap-codec": "^1.4.10"
+ }
+ },
+ "node_modules/@poppinss/colors": {
+ "version": "4.1.6",
+ "resolved": "https://registry.npmjs.org/@poppinss/colors/-/colors-4.1.6.tgz",
+ "integrity": "sha512-H9xkIdFswbS8n1d6vmRd8+c10t2Qe+rZITbbDHHkQixH5+2x1FDGmi/0K+WgWiqQFKPSlIYB7jlH6Kpfn6Fleg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "kleur": "^4.1.5"
+ }
+ },
+ "node_modules/@poppinss/dumper": {
+ "version": "0.6.5",
+ "resolved": "https://registry.npmjs.org/@poppinss/dumper/-/dumper-0.6.5.tgz",
+ "integrity": "sha512-NBdYIb90J7LfOI32dOewKI1r7wnkiH6m920puQ3qHUeZkxNkQiFnXVWoE6YtFSv6QOiPPf7ys6i+HWWecDz7sw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@poppinss/colors": "^4.1.5",
+ "@sindresorhus/is": "^7.0.2",
+ "supports-color": "^10.0.0"
+ }
+ },
+ "node_modules/@poppinss/exception": {
+ "version": "1.2.3",
+ "resolved": "https://registry.npmjs.org/@poppinss/exception/-/exception-1.2.3.tgz",
+ "integrity": "sha512-dCED+QRChTVatE9ibtoaxc+WkdzOSjYTKi/+uacHWIsfodVfpsueo3+DKpgU5Px8qXjgmXkSvhXvSCz3fnP9lw==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/@sindresorhus/is": {
+ "version": "7.2.0",
+ "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-7.2.0.tgz",
+ "integrity": "sha512-P1Cz1dWaFfR4IR+U13mqqiGsLFf1KbayybWwdd2vfctdV6hDpUkgCY0nKOLLTMSoRd/jJNjtbqzf13K8DCCXQw==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sindresorhus/is?sponsor=1"
+ }
+ },
+ "node_modules/@speed-highlight/core": {
+ "version": "1.2.24",
+ "resolved": "https://registry.npmjs.org/@speed-highlight/core/-/core-1.2.24.tgz",
+ "integrity": "sha512-qeW2e1l78afw8VhRPfPQ1Gjj+KU5XFQ/OFV5ti6eTa9bruO7mJyZtA4vw0ofqmA3tKCkROE9xLk3VZoeRc98nw==",
+ "dev": true,
+ "license": "CC0-1.0"
+ },
+ "node_modules/blake3-wasm": {
+ "version": "2.1.5",
+ "resolved": "https://registry.npmjs.org/blake3-wasm/-/blake3-wasm-2.1.5.tgz",
+ "integrity": "sha512-F1+K8EbfOZE49dtoPtmxUQrpXaBIl3ICvasLh+nJta0xkz+9kF/7uet9fLnwKqhDrmj6g+6K3Tw9yQPUg2ka5g==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/cookie": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/cookie/-/cookie-1.1.1.tgz",
+ "integrity": "sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/express"
+ }
+ },
+ "node_modules/detect-libc": {
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",
+ "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/error-stack-parser-es": {
+ "version": "1.0.5",
+ "resolved": "https://registry.npmjs.org/error-stack-parser-es/-/error-stack-parser-es-1.0.5.tgz",
+ "integrity": "sha512-5qucVt2XcuGMcEGgWI7i+yZpmpByQ8J1lHhcL7PwqCwu9FPP3VUXzT4ltHe5i2z9dePwEHcDVOAfSnHsOlCXRA==",
+ "dev": true,
+ "license": "MIT",
+ "funding": {
+ "url": "https://github.com/sponsors/antfu"
+ }
+ },
+ "node_modules/esbuild": {
+ "version": "0.28.1",
+ "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.1.tgz",
+ "integrity": "sha512-HrJrvZv5ayxBzPfwphOoNzkzOIIlifzk0KJrGK2c8R4+LKpMtpYLQeUdjnwjWv/LZlkH2laZk+4w78pi99D4Vw==",
+ "dev": true,
+ "hasInstallScript": true,
+ "license": "MIT",
+ "bin": {
+ "esbuild": "bin/esbuild"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "optionalDependencies": {
+ "@esbuild/aix-ppc64": "0.28.1",
+ "@esbuild/android-arm": "0.28.1",
+ "@esbuild/android-arm64": "0.28.1",
+ "@esbuild/android-x64": "0.28.1",
+ "@esbuild/darwin-arm64": "0.28.1",
+ "@esbuild/darwin-x64": "0.28.1",
+ "@esbuild/freebsd-arm64": "0.28.1",
+ "@esbuild/freebsd-x64": "0.28.1",
+ "@esbuild/linux-arm": "0.28.1",
+ "@esbuild/linux-arm64": "0.28.1",
+ "@esbuild/linux-ia32": "0.28.1",
+ "@esbuild/linux-loong64": "0.28.1",
+ "@esbuild/linux-mips64el": "0.28.1",
+ "@esbuild/linux-ppc64": "0.28.1",
+ "@esbuild/linux-riscv64": "0.28.1",
+ "@esbuild/linux-s390x": "0.28.1",
+ "@esbuild/linux-x64": "0.28.1",
+ "@esbuild/netbsd-arm64": "0.28.1",
+ "@esbuild/netbsd-x64": "0.28.1",
+ "@esbuild/openbsd-arm64": "0.28.1",
+ "@esbuild/openbsd-x64": "0.28.1",
+ "@esbuild/openharmony-arm64": "0.28.1",
+ "@esbuild/sunos-x64": "0.28.1",
+ "@esbuild/win32-arm64": "0.28.1",
+ "@esbuild/win32-ia32": "0.28.1",
+ "@esbuild/win32-x64": "0.28.1"
+ }
+ },
+ "node_modules/fsevents": {
+ "version": "2.3.3",
+ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
+ "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
+ "dev": true,
+ "hasInstallScript": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
+ }
+ },
+ "node_modules/kleur": {
+ "version": "4.1.5",
+ "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz",
+ "integrity": "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=6"
+ }
+ },
+ "node_modules/miniflare": {
+ "version": "5.20260918.0-alpha",
+ "resolved": "https://registry.npmjs.org/miniflare/-/miniflare-5.20260918.0-alpha.tgz",
+ "integrity": "sha512-vyIes7yW/OTzHtz4GhcBCTohZfqk2eQNiIkngZ07VRA5Qu24aNgW/TrFwlPkMLMjWDQ8R4JJBBHR/KX+liSDtg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@cspotcode/source-map-support": "0.8.1",
+ "sharp": "0.35.4",
+ "undici": "7.29.0",
+ "workerd": "1.20260918.1",
+ "ws": "8.21.0",
+ "youch": "4.1.0-beta.10"
+ },
+ "engines": {
+ "node": ">=22.0.0"
+ }
+ },
+ "node_modules/path-to-regexp": {
+ "version": "6.3.0",
+ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.3.0.tgz",
+ "integrity": "sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/pathe": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz",
+ "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/semver": {
+ "version": "7.8.5",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",
+ "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",
+ "dev": true,
+ "license": "ISC",
+ "bin": {
+ "semver": "bin/semver.js"
+ },
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/sharp": {
+ "version": "0.35.4",
+ "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.35.4.tgz",
+ "integrity": "sha512-n++8XWcj+jCOr2IOl7h8LbKnGBDY4aPbmprMONBNFdn0ImXqpGVv5zliDs0V9HbmbCQLpbuo2ej9rAoOQTvMDA==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@img/colour": "^1.1.0",
+ "detect-libc": "^2.1.2",
+ "semver": "^7.8.5"
+ },
+ "engines": {
+ "node": ">=20.9.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-darwin-arm64": "0.35.4",
+ "@img/sharp-darwin-x64": "0.35.4",
+ "@img/sharp-freebsd-wasm32": "0.35.4",
+ "@img/sharp-libvips-darwin-arm64": "1.3.3",
+ "@img/sharp-libvips-darwin-x64": "1.3.3",
+ "@img/sharp-libvips-linux-arm": "1.3.3",
+ "@img/sharp-libvips-linux-arm64": "1.3.3",
+ "@img/sharp-libvips-linux-ppc64": "1.3.3",
+ "@img/sharp-libvips-linux-riscv64": "1.3.3",
+ "@img/sharp-libvips-linux-s390x": "1.3.3",
+ "@img/sharp-libvips-linux-x64": "1.3.3",
+ "@img/sharp-libvips-linuxmusl-arm64": "1.3.3",
+ "@img/sharp-libvips-linuxmusl-x64": "1.3.3",
+ "@img/sharp-linux-arm": "0.35.4",
+ "@img/sharp-linux-arm64": "0.35.4",
+ "@img/sharp-linux-ppc64": "0.35.4",
+ "@img/sharp-linux-riscv64": "0.35.4",
+ "@img/sharp-linux-s390x": "0.35.4",
+ "@img/sharp-linux-x64": "0.35.4",
+ "@img/sharp-linuxmusl-arm64": "0.35.4",
+ "@img/sharp-linuxmusl-x64": "0.35.4",
+ "@img/sharp-webcontainers-wasm32": "0.35.4",
+ "@img/sharp-win32-arm64": "0.35.4",
+ "@img/sharp-win32-ia32": "0.35.4",
+ "@img/sharp-win32-x64": "0.35.4"
+ },
+ "peerDependenciesMeta": {
+ "@types/node": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/supports-color": {
+ "version": "10.2.2",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-10.2.2.tgz",
+ "integrity": "sha512-SS+jx45GF1QjgEXQx4NJZV9ImqmO2NPz5FNsIHrsDjh2YsHnawpan7SNQ1o8NuhrbHZy9AZhIoCUiCeaW/C80g==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/chalk/supports-color?sponsor=1"
+ }
+ },
+ "node_modules/tslib": {
+ "version": "2.8.1",
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
+ "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
+ "dev": true,
+ "license": "0BSD",
+ "optional": true
+ },
+ "node_modules/typescript": {
+ "version": "6.0.3",
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz",
+ "integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "bin": {
+ "tsc": "bin/tsc",
+ "tsserver": "bin/tsserver"
+ },
+ "engines": {
+ "node": ">=14.17"
+ }
+ },
+ "node_modules/undici": {
+ "version": "7.29.0",
+ "resolved": "https://registry.npmjs.org/undici/-/undici-7.29.0.tgz",
+ "integrity": "sha512-IDxfleLmmbSskfWSUATiN1nfn2rDuvnMOqb5CWR92iIfojA0Ud+ulOAAEQ57LPr9rWmsreUyf5lwyao+7GNNVw==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=20.18.1"
+ }
+ },
+ "node_modules/unenv": {
+ "version": "2.0.0-rc.24",
+ "resolved": "https://registry.npmjs.org/unenv/-/unenv-2.0.0-rc.24.tgz",
+ "integrity": "sha512-i7qRCmY42zmCwnYlh9H2SvLEypEFGye5iRmEMKjcGi7zk9UquigRjFtTLz0TYqr0ZGLZhaMHl/foy1bZR+Cwlw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "pathe": "^2.0.3"
+ }
+ },
+ "node_modules/workerd": {
+ "version": "1.20260918.1",
+ "resolved": "https://registry.npmjs.org/workerd/-/workerd-1.20260918.1.tgz",
+ "integrity": "sha512-NsjfQlBNQ0iEniv/STOy4zbp8s5k60PzL1Ter02Eg44arbDhHtf6UOs03E31XDRmmBFxSIkAZuCyld3RKH1wqA==",
+ "dev": true,
+ "hasInstallScript": true,
+ "license": "Apache-2.0",
+ "bin": {
+ "workerd": "bin/workerd"
+ },
+ "engines": {
+ "node": ">=16"
+ },
+ "optionalDependencies": {
+ "@cloudflare/workerd-darwin-64": "1.20260918.1",
+ "@cloudflare/workerd-darwin-arm64": "1.20260918.1",
+ "@cloudflare/workerd-linux-64": "1.20260918.1",
+ "@cloudflare/workerd-linux-arm64": "1.20260918.1",
+ "@cloudflare/workerd-windows-64": "1.20260918.1"
+ }
+ },
+ "node_modules/wrangler": {
+ "version": "4.135.0",
+ "resolved": "https://registry.npmjs.org/wrangler/-/wrangler-4.135.0.tgz",
+ "integrity": "sha512-WrNBQSfIG6YcILJcodYr5ty8vgkzGsV8YX+kfd+uZ5/Bd8cUW0GnUIRKAVfn5kYKqh1m/BPcji9h1d7mE8euFw==",
+ "dev": true,
+ "license": "MIT OR Apache-2.0",
+ "dependencies": {
+ "@cloudflare/kv-asset-handler": "0.5.0",
+ "@cloudflare/unenv-preset": "2.16.1",
+ "blake3-wasm": "2.1.5",
+ "esbuild": "0.28.1",
+ "miniflare": "5.20260918.0-alpha",
+ "path-to-regexp": "6.3.0",
+ "unenv": "2.0.0-rc.24",
+ "workerd": "1.20260918.1"
+ },
+ "bin": {
+ "cf-wrangler": "bin/cf-wrangler.js",
+ "wrangler": "bin/wrangler.js",
+ "wrangler2": "bin/wrangler.js"
+ },
+ "engines": {
+ "node": ">=22.0.0"
+ },
+ "optionalDependencies": {
+ "fsevents": "2.3.3"
+ },
+ "peerDependencies": {
+ "@cloudflare/workers-types": "^5.20260918.1"
+ },
+ "peerDependenciesMeta": {
+ "@cloudflare/workers-types": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/ws": {
+ "version": "8.21.0",
+ "resolved": "https://registry.npmjs.org/ws/-/ws-8.21.0.tgz",
+ "integrity": "sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=10.0.0"
+ },
+ "peerDependencies": {
+ "bufferutil": "^4.0.1",
+ "utf-8-validate": ">=5.0.2"
+ },
+ "peerDependenciesMeta": {
+ "bufferutil": {
+ "optional": true
+ },
+ "utf-8-validate": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/youch": {
+ "version": "4.1.0-beta.10",
+ "resolved": "https://registry.npmjs.org/youch/-/youch-4.1.0-beta.10.tgz",
+ "integrity": "sha512-rLfVLB4FgQneDr0dv1oddCVZmKjcJ6yX6mS4pU82Mq/Dt9a3cLZQ62pDBL4AUO+uVrCvtWz3ZFUL2HFAFJ/BXQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@poppinss/colors": "^4.1.5",
+ "@poppinss/dumper": "^0.6.4",
+ "@speed-highlight/core": "^1.2.7",
+ "cookie": "^1.0.2",
+ "youch-core": "^0.3.3"
+ }
+ },
+ "node_modules/youch-core": {
+ "version": "0.3.3",
+ "resolved": "https://registry.npmjs.org/youch-core/-/youch-core-0.3.3.tgz",
+ "integrity": "sha512-ho7XuGjLaJ2hWHoK8yFnsUGy2Y5uDpqSTq1FkHLK4/oqKtyUU1AFbOOxY4IpC9f0fTLjwYbslUz0Po5BpD1wrA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@poppinss/exception": "^1.2.2",
+ "error-stack-parser-es": "^1.0.5"
+ }
+ }
+ }
+}
diff --git a/telemetry-hub/package.json b/telemetry-hub/package.json
new file mode 100644
index 0000000..20dedde
--- /dev/null
+++ b/telemetry-hub/package.json
@@ -0,0 +1,20 @@
+{
+ "name": "bettershift-telemetry-hub",
+ "private": true,
+ "type": "module",
+ "scripts": {
+ "dev": "wrangler dev",
+ "deploy": "wrangler deploy",
+ "dashboard": "node scripts/create-posthog-dashboard.mjs",
+ "typecheck": "tsc --noEmit"
+ },
+ "devDependencies": {
+ "@cloudflare/workers-types": "^5.20260919.1",
+ "typescript": "^6.0.3",
+ "wrangler": "^4.135.0"
+ },
+ "allowScripts": {
+ "esbuild": true,
+ "workerd": true
+ }
+}
diff --git a/telemetry-hub/scripts/create-posthog-dashboard.mjs b/telemetry-hub/scripts/create-posthog-dashboard.mjs
new file mode 100644
index 0000000..c0c91b7
--- /dev/null
+++ b/telemetry-hub/scripts/create-posthog-dashboard.mjs
@@ -0,0 +1,456 @@
+#!/usr/bin/env node
+// Creates the "BetterShift Instanzen" dashboards in PostHog from the instance_ping events.
+//
+// npm run dashboard [-- --dry-run]
+//
+// Settings come from telemetry-hub/.env (copy .env.example) or the environment; the environment wins.
+// Only POSTHOG_PERSONAL_API_KEY is required, everything else has a default:
+// POSTHOG_PERSONAL_API_KEY personal key (phx_..., not the phc_ project key) with the
+// dashboard:write and insight:write scopes, plus project:read for
+// finding the project id
+// POSTHOG_PROJECT_ID only needed if the key can see more than one project
+// POSTHOG_HOST app host, default https://eu.posthog.com (not the eu.i. ingest host)
+// DASHBOARD_NAME default "BetterShift Instanzen"
+// DASHBOARD_VARIANTS all,no-dev,dev-only,no-ids (default: all four)
+// EXCLUDE_INSTANCE_IDS id1,id2 for the no-ids dashboard
+//
+// One run builds up to four dashboards with the same insights and a different filter each:
+// all "<name>" no filter
+// no-dev "<name> · ohne Dev-Builds" instances running a dev build left out
+// dev-only "<name> · nur Dev-Builds" only instances running a dev build
+// no-ids "<name> · ohne Test-Instanzen" EXCLUDE_INSTANCE_IDS left out
+// A dashboard that already exists (matched by name) is updated in place, insight by insight,
+// so new instance ids can be added later by running the script again.
+
+import { existsSync } from "node:fs";
+import { fileURLToPath } from "node:url";
+
+// loadEnvFile never overrides variables that are already set.
+const envFile = fileURLToPath(new URL("../.env", import.meta.url));
+if (existsSync(envFile)) process.loadEnvFile(envFile);
+
+const args = new Set(process.argv.slice(2));
+const dryRun = args.has("--dry-run");
+
+const HOST = (process.env.POSTHOG_HOST || "https://eu.posthog.com").replace(/\/$/, "");
+const KEY = process.env.POSTHOG_PERSONAL_API_KEY;
+let PROJECT = process.env.POSTHOG_PROJECT_ID;
+const DASHBOARD_NAME = process.env.DASHBOARD_NAME || "BetterShift Instanzen";
+const EVENT = "instance_ping";
+const TAG = "bettershift-telemetry";
+
+function fail(message) {
+ console.error(`Fehler: ${message}`);
+ process.exit(1);
+}
+
+const excluded = (process.env.EXCLUDE_INSTANCE_IDS || "")
+ .split(",")
+ .map((id) => id.trim())
+ .filter(Boolean);
+// The ids end up inside SQL, so only the characters of a UUID are accepted.
+for (const id of excluded) {
+ if (!/^[A-Za-z0-9-]+$/.test(id)) fail(`Ungültige Instanz-ID in EXCLUDE_INSTANCE_IDS: ${id}`);
+}
+
+// Dev builds send like any other; app_is_dev only exists to tell them apart here.
+const IS_DEV = `toString(coalesce(properties.app_is_dev, 'false')) IN ('true', '1')`;
+const VARIANTS = {
+ all: { suffix: "", condition: "" },
+ "no-dev": { suffix: " · ohne Dev-Builds", condition: `NOT (${IS_DEV})` },
+ "dev-only": { suffix: " · nur Dev-Builds", condition: IS_DEV },
+ "no-ids": {
+ suffix: " · ohne Test-Instanzen",
+ condition: excluded.length ? `distinct_id NOT IN (${excluded.map((id) => `'${id}'`).join(", ")})` : "",
+ },
+};
+
+const requested = (process.env.DASHBOARD_VARIANTS || "").split(",").map((v) => v.trim()).filter(Boolean);
+for (const key of requested) {
+ if (!VARIANTS[key]) fail(`Unbekannte Variante in DASHBOARD_VARIANTS: ${key} (erlaubt: ${Object.keys(VARIANTS).join(", ")})`);
+}
+if (requested.includes("no-ids") && !excluded.length) fail("Variante no-ids braucht EXCLUDE_INSTANCE_IDS.");
+const variantKeys = (requested.length ? requested : Object.keys(VARIANTS)).filter(
+ (key) => key !== "no-ids" || excluded.length
+);
+if (!requested.length && !excluded.length) console.log("Ohne EXCLUDE_INSTANCE_IDS entfällt das Dashboard \"ohne Test-Instanzen\".");
+
+
+/** All insights of one dashboard; `condition` is the HogQL filter of its variant (may be empty). */
+function buildInsights(condition) {
+ const andNotExcluded = condition ? ` AND ${condition}` : "";
+ const trendProperties = condition ? [{ type: "hogql", key: condition }] : [];
+
+ // ---------------------------------------------------------------------------
+ // Query builders
+ // ---------------------------------------------------------------------------
+
+ /** Trends over unique instances (distinct_id), never over raw pings. */
+ function trends({ display, interval = "week", from = "-30d", math = "dau", mathProperty, breakdown }) {
+ return {
+ kind: "InsightVizNode",
+ source: {
+ kind: "TrendsQuery",
+ series: [
+ {
+ kind: "EventsNode",
+ event: EVENT,
+ name: EVENT,
+ math,
+ ...(mathProperty && { math_property: mathProperty, math_property_type: "event_properties" }),
+ },
+ ],
+ interval,
+ dateRange: { date_from: from },
+ properties: trendProperties,
+ filterTestAccounts: false,
+ ...(breakdown && { breakdownFilter: { breakdowns: [{ property: breakdown, type: "event" }] } }),
+ trendsFilter: { display },
+ version: 2,
+ },
+ };
+ }
+
+ function sql(query) {
+ return { kind: "DataVisualizationNode", source: { kind: "HogQLQuery", query: query.trim() } };
+ }
+
+ /** Latest ping per instance in the last 30 days, so every instance counts once. */
+ function latestPerInstance(columns) {
+ return `
+ SELECT distinct_id, ${columns}
+ FROM events
+ WHERE event = '${EVENT}' AND timestamp > now() - INTERVAL 30 DAY${andNotExcluded}
+ GROUP BY distinct_id`;
+ }
+
+ const bars = (name, description, breakdown) => ({
+ name,
+ description,
+ query: trends({ display: "ActionsBarValue", breakdown }),
+ });
+ const pie = (name, description, breakdown) => ({
+ name,
+ description,
+ query: trends({ display: "ActionsPie", breakdown }),
+ });
+
+ // A boolean breakdown would only show a bare instance count, so yes/no flags get an explicit table.
+ const yesNo = (name, property) => ({
+ name,
+ description: "Jede Instanz zählt einmal, mit dem Wert ihres letzten Pings (letzte 30 Tage).",
+ query: sql(`
+ SELECT multiIf(flag IN ('true', '1'), 'Ja', flag IN ('false', '0'), 'Nein', 'Unbekannt') AS Wert, count() AS Instanzen
+ FROM (${latestPerInstance(`toString(argMax(properties.${property}, timestamp)) AS flag`)})
+ GROUP BY Wert
+ ORDER BY Instanzen DESC`),
+ });
+
+ const BY_INSTANCE = "Aktive Instanzen der letzten 30 Tage, aufgeteilt nach dem gemeldeten Wert.";
+
+ // ---------------------------------------------------------------------------
+ // Insights, in dashboard order
+ // ---------------------------------------------------------------------------
+
+ const insights = [
+ // Growth
+ {
+ name: "Wachstum · Aktive Instanzen (7 Tage)",
+ description: "Instanzen, die in den letzten 7 Tagen mindestens einmal gemeldet haben.",
+ query: trends({ display: "BoldNumber", from: "-7d", interval: "day" }),
+ },
+ {
+ name: "Wachstum · Bekannte Instanzen (gesamt)",
+ description: "Alle Instanzen, die je einen Ping gesendet haben.",
+ query: sql(`
+ SELECT count(DISTINCT distinct_id) AS instances
+ FROM events
+ WHERE event = '${EVENT}'${andNotExcluded}`),
+ },
+ {
+ name: "Wachstum · Neue Instanzen (30 Tage)",
+ description: "Instanzen, deren erster Ping in den letzten 30 Tagen liegt.",
+ query: sql(`
+ SELECT count() AS new_instances
+ FROM (
+ SELECT distinct_id, min(timestamp) AS first_seen
+ FROM events
+ WHERE event = '${EVENT}'${andNotExcluded}
+ GROUP BY distinct_id
+ HAVING first_seen > now() - INTERVAL 30 DAY
+ )`),
+ },
+ {
+ name: "Wachstum · Aktive Instanzen pro Woche",
+ description: "Eindeutige Instanzen je Woche, unabhängig von der Zahl der Pings.",
+ query: trends({ display: "ActionsLineGraph", from: "-180d" }),
+ },
+ {
+ name: "Wachstum · Neu, wiederkehrend, inaktiv",
+ description: "Lebenszyklus der Instanzen je Woche.",
+ query: {
+ kind: "InsightVizNode",
+ source: {
+ kind: "LifecycleQuery",
+ series: [{ kind: "EventsNode", event: EVENT, name: EVENT, math: "total" }],
+ interval: "week",
+ dateRange: { date_from: "-90d" },
+ properties: trendProperties,
+ filterTestAccounts: false,
+ lifecycleFilter: { showLegend: true },
+ },
+ },
+ },
+ {
+ name: "Wachstum · Verbleib (Retention)",
+ description: "Wie viele Instanzen nach ihrem ersten Ping in den Folgewochen weiter melden.",
+ query: {
+ kind: "InsightVizNode",
+ source: {
+ kind: "RetentionQuery",
+ dateRange: { date_from: "-12w" },
+ properties: trendProperties,
+ filterTestAccounts: false,
+ retentionFilter: {
+ period: "Week",
+ totalIntervals: 12,
+ retentionType: "retention_first_time",
+ targetEntity: { id: EVENT, name: EVENT, type: "events" },
+ returningEntity: { id: EVENT, name: EVENT, type: "events" },
+ },
+ },
+ },
+ },
+
+ // Versions
+ bars("Version · Aktive Instanzen je Version", BY_INSTANCE, "app_version"),
+ {
+ name: "Version · Aktuelle Version je Instanz",
+ description: "Jede Instanz zählt einmal, mit ihrer zuletzt gemeldeten Version.",
+ query: sql(`
+ SELECT version, count() AS instances
+ FROM (${latestPerInstance("argMax(properties.app_version, timestamp) AS version")})
+ GROUP BY version
+ ORDER BY instances DESC`),
+ },
+ yesNo("Version · Dev-Builds", "app_is_dev"),
+ bars("Version · Datenbank-Migrationen", `${BY_INSTANCE} Zeigt, wie aktuell das Schema ist.`, "app_migrations"),
+
+ // Environment
+ bars("Umgebung · Node.js", BY_INSTANCE, "runtime_node"),
+ pie("Umgebung · Plattform", BY_INSTANCE, "runtime_platform"),
+ pie("Umgebung · Architektur", BY_INSTANCE, "runtime_arch"),
+ bars("Umgebung · SQLite", BY_INSTANCE, "runtime_sqlite"),
+ bars("Umgebung · Zeitzone", BY_INSTANCE, "runtime_timezone"),
+ pie("Umgebung · Standardsprache", BY_INSTANCE, "config_default_locale"),
+
+ // Scale (buckets)
+ bars("Größe · Nutzer", `${BY_INSTANCE} Größenklassen, keine genauen Zahlen.`, "scale_users"),
+ bars("Größe · Kalender", `${BY_INSTANCE} Größenklassen, keine genauen Zahlen.`, "scale_calendars"),
+ bars("Größe · Schichten", `${BY_INSTANCE} Größenklassen, keine genauen Zahlen.`, "scale_shifts"),
+ bars("Größe · Schichtvorlagen", `${BY_INSTANCE} Größenklassen, keine genauen Zahlen.`, "scale_presets"),
+ bars("Größe · Notizen", `${BY_INSTANCE} Größenklassen, keine genauen Zahlen.`, "scale_notes"),
+ bars("Größe · Berechtigungs-Bundles", `${BY_INSTANCE} Größenklassen, keine genauen Zahlen.`, "scale_bundles"),
+ bars("Größe · Freigaben", `${BY_INSTANCE} Größenklassen, keine genauen Zahlen.`, "scale_shares"),
+ bars("Größe · Freigabe-Links", `${BY_INSTANCE} Größenklassen, keine genauen Zahlen.`, "scale_access_tokens"),
+ bars("Größe · Schicht-Anmeldungen", `${BY_INSTANCE} Größenklassen, keine genauen Zahlen.`, "scale_signups"),
+
+ // Configuration
+ yesNo("Konfiguration · Authentifizierung aktiv", "config_auth_enabled"),
+ yesNo("Konfiguration · Gastzugang erlaubt", "config_guest_access"),
+ yesNo("Konfiguration · Registrierung offen", "config_registration_open"),
+ yesNo("Konfiguration · Update-Prüfung aktiv", "config_update_check_enabled"),
+ bars("Konfiguration · Rate-Limit-Überschreibungen", `${BY_INSTANCE} Anzahl gesetzter RATE_LIMIT_*-Variablen.`, "config_rate_limit_overrides"),
+
+ // Features
+ bars("Funktionen · Externe Synchronisierungen", `${BY_INSTANCE} Größenklassen.`, "features_external_syncs"),
+ bars("Funktionen · Kalender mit eigener Ansicht", `${BY_INSTANCE} Größenklassen.`, "features_calendar_view_overrides"),
+ bars("Funktionen · Eigene Felder (Anzahl)", `${BY_INSTANCE} Größenklassen.`, "features_custom_fields_count"),
+ {
+ name: "Funktionen · Typen eigener Felder",
+ description: "Wie viele Instanzen welchen Feldtyp nutzen (letzte 30 Tage).",
+ query: sql(`
+ SELECT field_type, count(DISTINCT distinct_id) AS instances
+ FROM (
+ SELECT
+ distinct_id,
+ arrayJoin(JSONExtractArrayRaw(coalesce(properties.features_custom_field_types, '[]'))) AS raw_type,
+ trim(BOTH '"' FROM raw_type) AS field_type
+ FROM events
+ WHERE event = '${EVENT}' AND timestamp > now() - INTERVAL 30 DAY${andNotExcluded}
+ )
+ GROUP BY field_type
+ ORDER BY instances DESC`),
+ },
+ yesNo("Funktionen · Archivierte Vorlagen", "features_archived_presets"),
+ yesNo("Funktionen · Geteilte Schichten", "features_split_shifts"),
+
+ // Operations
+ {
+ name: "Betrieb · Ø Laufzeit (Stunden)",
+ description: "Durchschnittliche Zeit seit dem letzten Neustart, je Woche.",
+ query: trends({ display: "ActionsLineGraph", math: "avg", mathProperty: "health_uptime_hours", from: "-90d" }),
+ },
+ {
+ name: "Betrieb · Ø Sync-Läufe je Instanz (24 h)",
+ description: "Durchschnitt der gemeldeten Sync-Läufe der letzten 24 Stunden, je Woche.",
+ query: trends({ display: "ActionsLineGraph", math: "avg", mathProperty: "health_sync_runs_24h", from: "-90d" }),
+ },
+ {
+ name: "Betrieb · Ø Sync-Fehler je Instanz (24 h)",
+ description: "Durchschnitt der gemeldeten Sync-Fehler der letzten 24 Stunden, je Woche.",
+ query: trends({ display: "ActionsLineGraph", math: "avg", mathProperty: "health_sync_failures_24h", from: "-90d" }),
+ },
+ {
+ name: "Betrieb · Instanzen mit Sync-Fehlern",
+ description: "Instanzen, deren letzter Ping Sync-Fehler in den letzten 24 Stunden meldet.",
+ query: sql(`
+ SELECT distinct_id, version, sync_runs, sync_failures, last_seen
+ FROM (${latestPerInstance(`
+ argMax(properties.app_version, timestamp) AS version,
+ argMax(properties.health_sync_runs_24h, timestamp) AS sync_runs,
+ argMax(properties.health_sync_failures_24h, timestamp) AS sync_failures,
+ max(timestamp) AS last_seen`)})
+ WHERE sync_failures > 0
+ ORDER BY sync_failures DESC`),
+ },
+
+ // Overview table
+ {
+ name: "Instanzen · Letzter Stand je Instanz",
+ description: "Eine Zeile je Instanz mit den Werten ihres letzten Pings.",
+ query: sql(`
+ SELECT
+ distinct_id,
+ max(timestamp) AS last_seen,
+ argMax(properties.app_version, timestamp) AS version,
+ argMax(properties.runtime_platform, timestamp) AS platform,
+ argMax(properties.runtime_arch, timestamp) AS arch,
+ argMax(properties.runtime_node, timestamp) AS node,
+ argMax(properties.scale_users, timestamp) AS users,
+ argMax(properties.scale_calendars, timestamp) AS calendars,
+ argMax(properties.scale_shifts, timestamp) AS shifts,
+ argMax(properties.health_uptime_hours, timestamp) AS uptime_hours
+ FROM events
+ WHERE event = '${EVENT}' AND timestamp > now() - INTERVAL 30 DAY${andNotExcluded}
+ GROUP BY distinct_id
+ ORDER BY last_seen DESC`),
+ },
+ ];
+
+ return insights;
+}
+
+// ---------------------------------------------------------------------------
+// API
+// ---------------------------------------------------------------------------
+
+async function api(method, path, body) {
+ return request(method, `/api/projects/${PROJECT}${path}`, body);
+}
+
+async function request(method, path, body) {
+ const response = await fetch(`${HOST}${path}`, {
+ method,
+ headers: { Authorization: `Bearer ${KEY}`, "Content-Type": "application/json" },
+ body: body ? JSON.stringify(body) : undefined,
+ });
+ const text = await response.text();
+ if (!response.ok) throw new Error(`${method} ${path} -> ${response.status} ${text.slice(0, 300)}`);
+ return text ? JSON.parse(text) : {};
+}
+
+/** Uses the only project the key can see; with several (or no project:read scope) the id must be set. */
+async function findProject() {
+ let projects;
+ try {
+ projects = (await request("GET", "/api/projects/")).results ?? [];
+ } catch (error) {
+ fail(`POSTHOG_PROJECT_ID fehlt und die Projektliste ließ sich nicht laden (${error.message}).`);
+ }
+ if (projects.length !== 1) {
+ const list = projects.map((p) => ` ${p.id} ${p.name}`).join("\n");
+ fail(`POSTHOG_PROJECT_ID fehlt und der Key sieht ${projects.length} Projekte:\n${list}`);
+ }
+ console.log(`Projekt "${projects[0].name}" (ID ${projects[0].id}) automatisch gewählt.`);
+ return projects[0].id;
+}
+
+/** Creates or updates the insights of one dashboard; returns the names that failed. */
+async function syncInsights(dashboardId, existingTiles, insights) {
+ const byName = new Map(existingTiles.filter((t) => t.insight).map((t) => [t.insight.name, t.insight.id]));
+ const failures = [];
+ for (const insight of insights) {
+ const id = byName.get(insight.name);
+ try {
+ if (id) {
+ await api("PATCH", `/insights/${id}/`, { description: insight.description, query: insight.query });
+ } else {
+ await api("POST", "/insights/", {
+ name: insight.name,
+ description: insight.description,
+ query: insight.query,
+ dashboards: [dashboardId],
+ tags: [TAG],
+ });
+ }
+ console.log(` ${id ? "aktual." : "neu "} ${insight.name}`);
+ } catch (error) {
+ failures.push(insight.name);
+ console.error(` FEHLER ${insight.name}\n ${error.message}`);
+ }
+ }
+ return failures;
+}
+
+async function main() {
+ const plan = variantKeys.map((key) => ({
+ key,
+ name: DASHBOARD_NAME + VARIANTS[key].suffix,
+ insights: buildInsights(VARIANTS[key].condition),
+ }));
+
+ if (dryRun) {
+ for (const { key, name, insights } of plan) {
+ console.log(`Trockenlauf: ${insights.length} Insights für "${name}" (${key})`);
+ }
+ for (const insight of plan[0].insights) console.log(` - ${insight.name}`);
+ if (excluded.length) console.log(`Ausgeschlossene Instanzen: ${excluded.length}`);
+ return;
+ }
+
+ if (!KEY) {
+ fail("POSTHOG_PERSONAL_API_KEY fehlt. In telemetry-hub/.env eintragen (Vorlage: .env.example) oder als Variable setzen.");
+ }
+ if (!PROJECT) PROJECT = await findProject();
+
+ const existing = (await api("GET", "/dashboards/?limit=200")).results ?? [];
+ let failed = 0;
+
+ for (const { name, insights } of plan) {
+ const found = existing.find((d) => d.name === name && !d.deleted);
+ let dashboard = found;
+ let tiles = [];
+ if (found) {
+ // The list endpoint carries no tiles, so fetch the dashboard itself.
+ tiles = (await api("GET", `/dashboards/${found.id}/`)).tiles ?? [];
+ console.log(`\nDashboard "${name}" existiert (ID ${found.id}), wird aktualisiert.`);
+ } else {
+ dashboard = await api("POST", "/dashboards/", {
+ name,
+ description: "Anonyme Instanz-Pings von BetterShift. Gezählt werden eindeutige Instanzen, nicht Pings.",
+ tags: [TAG],
+ });
+ console.log(`\nDashboard "${name}" angelegt (ID ${dashboard.id}).`);
+ }
+
+ const failures = await syncInsights(dashboard.id, tiles, insights);
+ failed += failures.length;
+ console.log(`${insights.length - failures.length} von ${insights.length} Insights synchronisiert.`);
+ console.log(`${HOST}/project/${PROJECT}/dashboard/${dashboard.id}`);
+ }
+
+ if (failed) process.exit(1);
+}
+
+main().catch((error) => fail(error.message));
diff --git a/telemetry-hub/src/index.ts b/telemetry-hub/src/index.ts
new file mode 100644
index 0000000..09302bb
--- /dev/null
+++ b/telemetry-hub/src/index.ts
@@ -0,0 +1,48 @@
+import { parseV1 } from "./schemas/v1";
+import { sendToPostHog } from "./targets/posthog";
+
+interface Env {
+ POSTHOG_API_KEY: string;
+ // Optional ingest host, e.g. https://us.i.posthog.com; defaults to EU.
+ POSTHOG_HOST?: string;
+}
+
+const MAX_BODY_BYTES = 16 * 1024;
+
+export default {
+ async fetch(request: Request, env: Env): Promise<Response> {
+ if (request.method !== "POST") {
+ return new Response(null, { status: 405 });
+ }
+
+ // Content-Length only: a chunked body skips this check, which is acceptable
+ // because Workers cap the request size first and parseV1 gates every field.
+ const length = Number(request.headers.get("content-length") ?? "0");
+ if (length > MAX_BODY_BYTES) {
+ return new Response(null, { status: 413 });
+ }
+
+ let input: unknown;
+ try {
+ input = await request.json();
+ } catch {
+ return new Response(null, { status: 400 });
+ }
+
+ const payload = parseV1(input);
+ // Unknown or retired schema versions are accepted and discarded: the
+ // sender is fire-and-forget and must never learn anything but "received".
+ if (!payload) {
+ return new Response(null, { status: 200 });
+ }
+
+ try {
+ await sendToPostHog(payload, env.POSTHOG_API_KEY, env.POSTHOG_HOST || undefined);
+ } catch (error) {
+ // The sender still gets a 200. Only the message is logged (a status, never the payload).
+ console.error(error instanceof Error ? error.message : "PostHog forward failed");
+ }
+
+ return new Response(null, { status: 200 });
+ },
+};
diff --git a/telemetry-hub/src/schemas/v1.ts b/telemetry-hub/src/schemas/v1.ts
new file mode 100644
index 0000000..1ae278f
--- /dev/null
+++ b/telemetry-hub/src/schemas/v1.ts
@@ -0,0 +1,121 @@
+// Mirrors lib/telemetry/schema.ts's TelemetryPayload (schemaVersion 1) by value.
+// This project must not import from the main app — see telemetry-hub's isolation note.
+export interface PayloadV1 {
+ schemaVersion: 1;
+ instanceId: string | null;
+ sentAt: string;
+ app: { version: string; isDev: boolean; migrations: number };
+ runtime: { node: string; arch: string; platform: string; sqlite: string; timezone: string };
+ config: {
+ authEnabled: boolean;
+ guestAccess: boolean;
+ registrationOpen: boolean;
+ defaultLocale: string;
+ updateCheckEnabled: boolean;
+ rateLimitOverrides: number;
+ };
+ scale: {
+ users: string;
+ calendars: string;
+ shifts: string;
+ presets: string;
+ notes: string;
+ bundles: string;
+ shares: string;
+ accessTokens: string;
+ signups: string;
+ };
+ features: {
+ externalSyncs: string;
+ calendarViewOverrides: string;
+ customFields: { count: string; types: string[] };
+ archivedPresets: boolean;
+ splitShifts: boolean;
+ };
+ health: { uptimeHours: number; syncRuns24h: number; syncFailures24h: number };
+}
+
+const BUCKETS = new Set(["0", "1-5", "6-20", "21-100", "101-500", "500+"]);
+const SCALE_KEYS = [
+ "users",
+ "calendars",
+ "shifts",
+ "presets",
+ "notes",
+ "bundles",
+ "shares",
+ "accessTokens",
+ "signups",
+] as const;
+
+/** Returns null for anything that is not a well-formed v1 payload. */
+export function parseV1(input: unknown): PayloadV1 | null {
+ if (typeof input !== "object" || input === null) return null;
+ const p = input as Record<string, unknown>;
+ if (p.schemaVersion !== 1) return null;
+ if (typeof p.sentAt !== "string") return null;
+ if (p.instanceId !== null && typeof p.instanceId !== "string") return null;
+
+ const scale = p.scale;
+ if (typeof scale !== "object" || scale === null) return null;
+ const scaleRecord = scale as Record<string, unknown>;
+ for (const key of SCALE_KEYS) {
+ const value = scaleRecord[key];
+ if (typeof value !== "string" || !BUCKETS.has(value)) return null;
+ }
+
+ const app = p.app;
+ if (typeof app !== "object" || app === null) return null;
+ const appRecord = app as Record<string, unknown>;
+ if (typeof appRecord.version !== "string") return null;
+ if (typeof appRecord.isDev !== "boolean") return null;
+ if (typeof appRecord.migrations !== "number") return null;
+
+ const runtime = p.runtime;
+ if (typeof runtime !== "object" || runtime === null) return null;
+ const runtimeRecord = runtime as Record<string, unknown>;
+ for (const key of ["node", "arch", "platform", "sqlite", "timezone"]) {
+ if (typeof runtimeRecord[key] !== "string") return null;
+ }
+
+ const config = p.config;
+ if (typeof config !== "object" || config === null) return null;
+ const configRecord = config as Record<string, unknown>;
+ for (const key of ["authEnabled", "guestAccess", "registrationOpen", "updateCheckEnabled"]) {
+ if (typeof configRecord[key] !== "boolean") return null;
+ }
+ if (typeof configRecord.defaultLocale !== "string") return null;
+ if (typeof configRecord.rateLimitOverrides !== "number") return null;
+
+ const features = p.features;
+ if (typeof features !== "object" || features === null) return null;
+ const featuresRecord = features as Record<string, unknown>;
+ if (typeof featuresRecord.externalSyncs !== "string" || !BUCKETS.has(featuresRecord.externalSyncs))
+ return null;
+ if (
+ typeof featuresRecord.calendarViewOverrides !== "string" ||
+ !BUCKETS.has(featuresRecord.calendarViewOverrides)
+ )
+ return null;
+ const customFields = featuresRecord.customFields;
+ if (typeof customFields !== "object" || customFields === null) return null;
+ const customFieldsRecord = customFields as Record<string, unknown>;
+ if (typeof customFieldsRecord.count !== "string" || !BUCKETS.has(customFieldsRecord.count))
+ return null;
+ if (
+ !Array.isArray(customFieldsRecord.types) ||
+ !customFieldsRecord.types.every((t) => typeof t === "string")
+ )
+ return null;
+ if (typeof featuresRecord.archivedPresets !== "boolean") return null;
+ if (typeof featuresRecord.splitShifts !== "boolean") return null;
+
+ const health = p.health;
+ if (typeof health !== "object" || health === null) return null;
+ const healthRecord = health as Record<string, unknown>;
+ for (const key of ["uptimeHours", "syncRuns24h", "syncFailures24h"]) {
+ if (typeof healthRecord[key] !== "number") return null;
+ }
+
+ return p as unknown as PayloadV1;
+}
diff --git a/telemetry-hub/src/targets/posthog.ts b/telemetry-hub/src/targets/posthog.ts
new file mode 100644
index 0000000..52f6ea4
--- /dev/null
+++ b/telemetry-hub/src/targets/posthog.ts
@@ -0,0 +1,67 @@
+import type { PayloadV1 } from "../schemas/v1";
+
+// The ingest host is region-specific, and so is the project API key (US: https://us.i.posthog.com).
+const DEFAULT_POSTHOG_HOST = "https://eu.i.posthog.com";
+
+// Enumerates target fields rather than spreading, so an unknown input field cannot pass through.
+export async function sendToPostHog(
+ payload: PayloadV1,
+ apiKey: string,
+ host: string = DEFAULT_POSTHOG_HOST,
+): Promise<void> {
+ const body = {
+ api_key: apiKey,
+ event: "instance_ping",
+ distinct_id: payload.instanceId ?? "anonymous",
+ timestamp: payload.sentAt,
+ properties: {
+ // The Worker runs in the PoP nearest the sending instance, so PostHog would
+ // geolocate that IP and approximate every instance's location.
+ $ip: null,
+ $geoip_disable: true,
+ // Keeps PostHog from creating a person profile per instance -- there is no person here.
+ $process_person_profile: false,
+ schema_version: payload.schemaVersion,
+ app_version: payload.app.version,
+ app_is_dev: payload.app.isDev,
+ app_migrations: payload.app.migrations,
+ runtime_node: payload.runtime.node,
+ runtime_arch: payload.runtime.arch,
+ runtime_platform: payload.runtime.platform,
+ runtime_sqlite: payload.runtime.sqlite,
+ runtime_timezone: payload.runtime.timezone,
+ config_auth_enabled: payload.config.authEnabled,
+ config_guest_access: payload.config.guestAccess,
+ config_registration_open: payload.config.registrationOpen,
+ config_default_locale: payload.config.defaultLocale,
+ config_update_check_enabled: payload.config.updateCheckEnabled,
+ config_rate_limit_overrides: payload.config.rateLimitOverrides,
+ scale_users: payload.scale.users,
+ scale_calendars: payload.scale.calendars,
+ scale_shifts: payload.scale.shifts,
+ scale_presets: payload.scale.presets,
+ scale_notes: payload.scale.notes,
+ scale_bundles: payload.scale.bundles,
+ scale_shares: payload.scale.shares,
+ scale_access_tokens: payload.scale.accessTokens,
+ scale_signups: payload.scale.signups,
+ features_external_syncs: payload.features.externalSyncs,
+ features_calendar_view_overrides: payload.features.calendarViewOverrides,
+ features_custom_fields_count: payload.features.customFields.count,
+ features_custom_field_types: payload.features.customFields.types,
+ features_archived_presets: payload.features.archivedPresets,
+ features_split_shifts: payload.features.splitShifts,
+ health_uptime_hours: payload.health.uptimeHours,
+ health_sync_runs_24h: payload.health.syncRuns24h,
+ health_sync_failures_24h: payload.health.syncFailures24h,
+ },
+ };
+
+ const response = await fetch(`${host.replace(/\/$/, "")}/i/v0/e/`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify(body),
+ });
+ // fetch resolves on 4xx/5xx, so a rejected key or wrong region would otherwise vanish.
+ if (!response.ok) throw new Error(`PostHog responded with ${response.status}`);
+}
diff --git a/telemetry-hub/tsconfig.json b/telemetry-hub/tsconfig.json
new file mode 100644
index 0000000..02322e9
--- /dev/null
+++ b/telemetry-hub/tsconfig.json
@@ -0,0 +1,12 @@
+{
+ "compilerOptions": {
+ "target": "ES2022",
+ "module": "ES2022",
+ "moduleResolution": "bundler",
+ "types": ["@cloudflare/workers-types"],
+ "strict": true,
+ "noEmit": true,
+ "skipLibCheck": true
+ },
+ "include": ["src/**/*.ts"]
+}
diff --git a/telemetry-hub/wrangler.toml b/telemetry-hub/wrangler.toml
new file mode 100644
index 0000000..c68336c
--- /dev/null
+++ b/telemetry-hub/wrangler.toml
@@ -0,0 +1,13 @@
+name = "bettershift-telemetry-hub"
+main = "src/index.ts"
+compatibility_date = "2026-09-18"
+
+routes = [
+ { pattern = "telemetry-bettershift.pantelx.com", custom_domain = true, zone_name = "pantelx.com", enabled = true, previews_enabled = false }
+]
+
+[dev]
+ip = "0.0.0.0"
+
+[vars]
+POSTHOG_HOST = "https://eu.i.posthog.com"
\ No newline at end of file
diff --git a/tsconfig.json b/tsconfig.json
index db83c1d..3818482 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -31,5 +31,5 @@
".next/dev/types/**/*.ts",
"**/*.mts"
],
- "exclude": ["node_modules"]
+ "exclude": ["node_modules", "telemetry-hub"]
}