-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
58d3d51
commit 9e40c80
Showing
10 changed files
with
289 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import type { Browser, Device } from '$std/http/user_agent.ts' | ||
import usage from './usage.ts' | ||
|
||
const BROWSER_FAMILIES: Record<string, string> = { | ||
'Chrome': 'Chrome', | ||
'Mobile Chrome': 'Chrome', | ||
'DuckDuckGo': 'Chrome', | ||
|
||
'Firefox': 'Firefox', | ||
'Mobile Firefox': 'Firefox', | ||
|
||
'Safari': 'Safari', | ||
'Mobile Safari': 'Safari', | ||
|
||
'IE': 'IE', | ||
'Edge': 'Edge', | ||
|
||
'Opera': 'Opera', | ||
'Opera Mini': 'Opera Mini', | ||
|
||
'QQ Browser': 'QQ Browser', | ||
'UC': 'UC Browser', | ||
'Samsung Internet': 'Samsung Internet', | ||
} | ||
|
||
export const getFamilyName = (name: string): string => BROWSER_FAMILIES[name] | ||
|
||
// https://github.com/denoland/std/pull/6129 | ||
type FixedDeviceType = Device['type'] | 'tablet' | 'smarttv' | ||
|
||
export const getGlobalUsageStats = (browser: Browser, device: Device): number => { | ||
if (browser?.name === undefined || browser.name === 'Unknown') return 0 | ||
|
||
const usageKey = getFamilyName(browser.name) | ||
|
||
switch (device.type as FixedDeviceType) { | ||
case undefined: | ||
return usage.ww.desktop[usageKey] ?? 0 | ||
case 'mobile': | ||
return usage.ww.mobile[usageKey] ?? 0 | ||
default: | ||
return 0 | ||
} | ||
} | ||
|
||
export const getNorthAmericaUsageStats = (browser: Browser, device: Device): number => { | ||
if (browser?.name === undefined || browser.name === 'Unknown') return 0 | ||
|
||
const usageKey = getFamilyName(browser.name) | ||
|
||
switch (device.type as FixedDeviceType) { | ||
case undefined: | ||
return usage.na.desktop[usageKey] ?? 0 | ||
case 'mobile': | ||
return usage.na.mobile[usageKey] ?? 0 | ||
default: | ||
return 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
type RegionalDeviceStatProps = { | ||
asOf: string | ||
ww: { desktop: Record<string, number>; mobile: Record<string, number> } | ||
na: { desktop: Record<string, number>; mobile: Record<string, number> } | ||
} | ||
const UsageStats: RegionalDeviceStatProps = { | ||
asOf: '2024-10-20T03:16:59.483Z', | ||
ww: { | ||
desktop: { | ||
'Chrome': 64.95, | ||
'Edge': 13.75, | ||
'Safari': 9.13, | ||
'Firefox': 6.5, | ||
'Opera': 3.07, | ||
'360 Safe Browser': 0.95, | ||
'Yandex Browser': 0.53, | ||
'IE': 0.38, | ||
'QQ Browser': 0.23, | ||
'Coc Coc': 0.12, | ||
'Sogou Explorer': 0.1, | ||
'Mozilla': 0.09, | ||
'Whale Browser': 0.08, | ||
'Edge Legacy': 0.05, | ||
'UC Browser': 0.02, | ||
'Chromium': 0.01, | ||
'Other': 0.05, | ||
}, | ||
mobile: { | ||
'Chrome': 67.1, | ||
'Safari': 23.04, | ||
'Samsung Internet': 3.8, | ||
'Opera': 1.84, | ||
'UC Browser': 1.77, | ||
'Firefox': 0.53, | ||
'Edge': 0.45, | ||
'QQ Browser': 0.42, | ||
'Android': 0.36, | ||
'Yandex Browser': 0.27, | ||
'Whale Browser': 0.14, | ||
'Coc Coc': 0.08, | ||
'Instabridge': 0.05, | ||
'KaiOS': 0.04, | ||
'Ecosia': 0.03, | ||
'Puffin': 0.03, | ||
'Unknown': 0.02, | ||
'Phoenix': 0.01, | ||
'Other': 0.02, | ||
}, | ||
}, | ||
na: { | ||
desktop: { | ||
'Chrome': 59.72, | ||
'Safari': 15.48, | ||
'Edge': 15.26, | ||
'Firefox': 7.2, | ||
'Opera': 1.64, | ||
'IE': 0.24, | ||
'Mozilla': 0.23, | ||
'Yandex Browser': 0.06, | ||
'360 Safe Browser': 0.05, | ||
'Edge Legacy': 0.04, | ||
'SeaMonkey': 0.02, | ||
'QQ Browser': 0.01, | ||
'Pale Moon': 0.01, | ||
'Chromium': 0.01, | ||
'Other': 0.04, | ||
}, | ||
mobile: { | ||
'Chrome': 48.58, | ||
'Safari': 45.96, | ||
'Samsung Internet': 3.04, | ||
'Firefox': 1, | ||
'Opera': 0.51, | ||
'Edge': 0.43, | ||
'UC Browser': 0.13, | ||
'Android': 0.13, | ||
'Yandex Browser': 0.07, | ||
'Unknown': 0.04, | ||
'QQ Browser': 0.04, | ||
'Ecosia': 0.02, | ||
'Other': 0.05, | ||
}, | ||
}, | ||
} | ||
export default UsageStats |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type { FreshContext } from '$fresh/server.ts' | ||
import { getAgentReleaseInfo } from '../../lib/agent.ts' | ||
|
||
export const handler = (req: Request, _ctx: FreshContext) => { | ||
const userAgent = req.headers.get('user-agent') || 'Unknown' | ||
|
||
const body = getAgentReleaseInfo(userAgent) | ||
|
||
return new Response(JSON.stringify(body), { | ||
headers: { 'Content-Type': 'application/json' }, | ||
}) | ||
} |
Oops, something went wrong.