Added browser / os / device override in payload
This commit is contained in:
@@ -41,6 +41,9 @@ const schema = z.object({
|
|||||||
userAgent: z.string().optional(),
|
userAgent: z.string().optional(),
|
||||||
timestamp: z.coerce.number().int().optional(),
|
timestamp: z.coerce.number().int().optional(),
|
||||||
id: z.string().optional(),
|
id: z.string().optional(),
|
||||||
|
browser: z.string().optional(),
|
||||||
|
os: z.string().optional(),
|
||||||
|
device: z.string().optional(),
|
||||||
})
|
})
|
||||||
.refine(
|
.refine(
|
||||||
data => {
|
data => {
|
||||||
|
|||||||
@@ -114,9 +114,9 @@ export async function getClientInfo(request: Request, payload: Record<string, an
|
|||||||
const country = safeDecodeURIComponent(location?.country);
|
const country = safeDecodeURIComponent(location?.country);
|
||||||
const region = safeDecodeURIComponent(location?.region);
|
const region = safeDecodeURIComponent(location?.region);
|
||||||
const city = safeDecodeURIComponent(location?.city);
|
const city = safeDecodeURIComponent(location?.city);
|
||||||
const browser = browserName(userAgent);
|
const browser = payload?.browser ?? browserName(userAgent);
|
||||||
const os = detectOS(userAgent) as string;
|
const os = payload?.os ?? (detectOS(userAgent) as string);
|
||||||
const device = getDevice(userAgent, payload?.screen);
|
const device = payload?.device ?? getDevice(userAgent, payload?.screen);
|
||||||
|
|
||||||
return { userAgent, browser, os, ip, country, region, city, device };
|
return { userAgent, browser, os, ip, country, region, city, device };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user