feat(telemetry): opt-in admin alert pushes

- telemetryAlerts metadata flag, admin-gated server fn
- alerts sent only to admins with the flag enabled
- settings toggle visible to admins only, under device notifications
This commit is contained in:
2026-08-25 23:33:01 -07:00
parent 1ddcffc511
commit 3d8ee52a15
8 changed files with 200 additions and 85 deletions
+27 -1
View File
@@ -1,5 +1,8 @@
import { createServerFn } from "@tanstack/react-start";
import { superTokensFunctionMiddleware } from "@/utils/supertokens";
import {
superTokensAdminFunctionMiddleware,
superTokensFunctionMiddleware,
} from "@/utils/supertokens";
// Whitelists: these values flow into Mantine's primaryColor / the
// data-mantine-color-scheme attribute — an unknown value crash-loops or
@@ -139,3 +142,26 @@ export const updateUserAccentColor = createServerFn({ method: "POST" })
},
};
});
export const updateUserTelemetryAlerts = createServerFn({ method: "POST" })
.validator((data: boolean) => data === true)
.middleware([superTokensAdminFunctionMiddleware])
.handler(async ({ context, data }) => {
const { userAuthId, metadata } = context;
if (!userAuthId) return;
const { updateUserMetadataFields } = await import(
"@/utils/supertokens-core.server"
);
await updateUserMetadataFields(userAuthId, {
telemetryAlerts: data,
});
return {
metadata: {
...metadata,
telemetryAlerts: data,
},
};
});