|
|
|
@@ -1,6 +1,16 @@ |
|
|
|
const DEVICE_ID_KEY = "fpsms_device_id"; |
|
|
|
const DISPLAY_NAME_KEY = "fpsms_device_display_name"; |
|
|
|
|
|
|
|
/** Chromium User-Agent Client Hints (not in lib.dom Navigator yet). */ |
|
|
|
interface NavigatorUAData { |
|
|
|
mobile?: boolean; |
|
|
|
platform?: string; |
|
|
|
} |
|
|
|
|
|
|
|
interface NavigatorWithUAData extends Navigator { |
|
|
|
readonly userAgentData?: NavigatorUAData; |
|
|
|
} |
|
|
|
|
|
|
|
export function getOrCreateDeviceId(): string { |
|
|
|
if (typeof window === "undefined") return ""; |
|
|
|
let id = localStorage.getItem(DEVICE_ID_KEY); |
|
|
|
@@ -68,7 +78,7 @@ export function detectClientTypeFromUa(): string { |
|
|
|
} |
|
|
|
|
|
|
|
// User-Agent Client Hints (Chromium) |
|
|
|
const uad = navigator.userAgentData; |
|
|
|
const uad = (navigator as NavigatorWithUAData).userAgentData; |
|
|
|
if (uad) { |
|
|
|
const platform = uad.platform?.toLowerCase() ?? ""; |
|
|
|
if (platform.includes("android")) { |
|
|
|
|