mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-27 21:33:41 +02:00
* feat(analytics): add daily client usage reporting (MUL-5125) Co-authored-by: multica-agent <github@multica.ai> * fix(analytics): clarify daily usage semantics (MUL-5125) Co-authored-by: multica-agent <github@multica.ai> * fix(analytics): resolve usage review blockers (MUL-5125) Co-authored-by: multica-agent <github@multica.ai> --------- Co-authored-by: Eve <eve@multica-ai.local> Co-authored-by: multica-agent <github@multica.ai>
25 lines
783 B
TypeScript
25 lines
783 B
TypeScript
export type CoarseClientOS =
|
|
| "macos"
|
|
| "windows"
|
|
| "linux"
|
|
| "ios"
|
|
| "android"
|
|
| "chromeos"
|
|
| "unknown";
|
|
|
|
/** Maps browser hints to a coarse OS bucket without retaining the raw user agent. */
|
|
export function detectWebOS(
|
|
nav: Pick<Navigator, "platform" | "userAgent"> | undefined =
|
|
typeof navigator === "undefined" ? undefined : navigator,
|
|
): CoarseClientOS {
|
|
if (!nav) return "unknown";
|
|
const hint = `${nav.platform} ${nav.userAgent}`.toLowerCase();
|
|
if (/iphone|ipad|ipod/.test(hint)) return "ios";
|
|
if (hint.includes("android")) return "android";
|
|
if (hint.includes("cros")) return "chromeos";
|
|
if (/mac|darwin/.test(hint)) return "macos";
|
|
if (/win/.test(hint)) return "windows";
|
|
if (/linux|x11/.test(hint)) return "linux";
|
|
return "unknown";
|
|
}
|