mirror of
https://gh-proxy.org/https://github.com/klinsmaya/multica.git
synced 2026-11-10 10:26:46 +08:00
* feat(analytics): add daily client usage reporting (MUL-5125) Co-authored-by: multica-agent <[email protected]> * fix(analytics): clarify daily usage semantics (MUL-5125) Co-authored-by: multica-agent <[email protected]> * fix(analytics): resolve usage review blockers (MUL-5125) Co-authored-by: multica-agent <[email protected]> --------- Co-authored-by: Eve <[email protected]> Co-authored-by: multica-agent <[email protected]>
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";
|
|
}
|