[v10.2.x] Auth: Fix anonymous user table useragent not parsable (#79319)
Auth: Fix anonymous user table useragent not parsable (#79307) fix for useragent not parsable (cherry picked from commit2447e90be9) Co-authored-by: Eric Leijonmarck <eric.leijonmarck@gmail.com> (cherry picked from commit943d5eadd7)
This commit is contained in:
@@ -10,9 +10,18 @@ type Cell<T extends keyof UserAnonymousDeviceDTO = keyof UserAnonymousDeviceDTO>
|
||||
|
||||
// A helper function to parse the user agent string and extract parts
|
||||
const parseUserAgent = (userAgent: string) => {
|
||||
// If the user agent string doesn't contain a space, it's probably just the browser name
|
||||
// or some other entity that are accessing grafana
|
||||
if (!userAgent.includes(' ')) {
|
||||
return {
|
||||
browser: userAgent,
|
||||
computer: '',
|
||||
};
|
||||
}
|
||||
const parts = userAgent.split(' ');
|
||||
return {
|
||||
browser: userAgent.split(' ')[0],
|
||||
computer: userAgent.split(' ')[1],
|
||||
browser: parts[0],
|
||||
computer: parts[1],
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user