Skip to content

Commit

Permalink
Version 0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
nonrational committed Oct 25, 2024
1 parent 09bb557 commit cc4f9de
Show file tree
Hide file tree
Showing 36 changed files with 1,339 additions and 926 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: CI

on: push

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Clone repository
uses: actions/checkout@v4

- name: Install Deno
uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- run: deno test --allow-env
- run: deno fmt --check
- run: deno lint

deploy:
runs-on: ubuntu-latest
needs: test

steps:
- name: Clone repository
uses: actions/checkout@v4

- name: Install Deno
uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- name: Install deployctl
run: deno install -gArf jsr:@deno/deployctl

- name: Add CANIUSE_AS_OF_EPOCH to .env
run: deno scripts/print-as-of-env.ts | tee -a .env

- name: Build
run: deno task build

- name: Deploy to Preview
run: deployctl deploy --token=${{ secrets.DENO_DEPLOY_TOKEN }}
if: github.ref != 'refs/tags/prod'

# If we're building a thing that's called prod
- name: Deploy to Production
run: deployctl deploy --prod --token=${{ secrets.DENO_DEPLOY_TOKEN }}
if: github.ref == 'refs/tags/prod'
21 changes: 12 additions & 9 deletions .github/workflows/deploy.yml → .github/workflows/dmz-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: Deploy
name: run-dmz

on:
push:
branches: main
pull_request:
branches: main

jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
if: github.repository_owner == 'run-dmz'

permissions:
id-token: write # Needed for auth with Deno Deploy
Expand All @@ -19,16 +19,19 @@ jobs:
uses: actions/checkout@v4

- name: Install Deno
uses: denoland/setup-deno@v1
uses: denoland/setup-deno@v2
with:
deno-version: v1.x
deno-version: v2.x

- name: Add CANIUSE_AS_OF_EPOCH to .env
run: deno scripts/print-as-of-env.ts | tee -a .env

- name: Build step
run: "deno task build"
run: 'deno task build'

- name: Upload to Deno Deploy
uses: denoland/deployctl@v1
with:
project: "user-agent-info"
entrypoint: "main.ts"
root: "."
project: 'user-agent-info'
entrypoint: 'main.ts'
root: '.'
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
deno 2.0.1
deno 2.0.3
39 changes: 32 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,41 @@
# Fresh project
<h2><img src='/static/[email protected]' height='30' alt='User-Agent.Info Logo' /> User Agent Info</h2>

Your new Fresh project is ready to go. You can follow the Fresh "Getting
Started" guide here: https://fresh.deno.dev/docs/getting-started
### Features

### Usage
- User-Agent lookup via Web UI and API
- Release date and version-specific usage stats from `caniuse-lite`
- Usage / popularity stats for browsers from `statscounter`

Make sure to install Deno: https://deno.land/manual/getting_started/installation
### Future Ideas

Then start the project:
- List N most recently queried User-Agents
- Specify your browserslist string to check whether a given User-Agent is covered
- Include additional datasets for usage and popularity (e.g., `useragents.me`)

### API Usage

Specify a `User-Agent` header or `?ua` query parameter to fetch agent details via JSON. See the [Agent](./lib/agent.ts) type for schema
details.

```sh
# `User-Agent` header
curl -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.3' https://user-agent.info/api/v1/agents

# `ua` query parameter
curl 'https://user-agent.info/api/v1/agents?ua=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.3'
```

## Local Development

```sh
git clone https://github.com/nonrational/user-agent.info
cd user-agent.info/
asdf install
deno task start
```

This will watch the project directory and restart as necessary.
Common tasks are also available via `just`. See `just --list` if you have `just` installed.

## Deployment

See https://deno.com/deploy and [dmz-deploy.yml](./.github/workflows/dmz-deploy.yml).
8 changes: 4 additions & 4 deletions components/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { JSX } from "preact";
import { IS_BROWSER } from "$fresh/runtime.ts";
import { JSX } from 'preact'
import { IS_BROWSER } from '$fresh/runtime.ts'

export function Button(props: JSX.HTMLAttributes<HTMLButtonElement>) {
return (
<button
{...props}
disabled={!IS_BROWSER || props.disabled}
class="px-2 py-1 border-gray-500 border-2 rounded bg-white hover:bg-gray-200 transition-colors"
class='px-2 py-1 border-gray-500 border-2 rounded bg-white hover:bg-gray-200 transition-colors'
/>
);
)
}
85 changes: 85 additions & 0 deletions data/statscounter.ts
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-21T20:52:12.199Z',
ww: {
desktop: {
'Chrome': 64.93,
'Edge': 13.72,
'Safari': 9.15,
'Firefox': 6.5,
'Opera': 3.09,
'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.2,
'Safari': 22.99,
'Samsung Internet': 3.79,
'Opera': 1.83,
'UC Browser': 1.74,
'Firefox': 0.53,
'Edge': 0.44,
'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.67,
'Safari': 15.55,
'Edge': 15.22,
'Firefox': 7.2,
'Opera': 1.65,
'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': 49.23,
'Safari': 45.39,
'Samsung Internet': 3,
'Firefox': 0.98,
'Opera': 0.5,
'Edge': 0.42,
'UC Browser': 0.13,
'Android': 0.12,
'Yandex Browser': 0.07,
'Unknown': 0.04,
'QQ Browser': 0.04,
'Ecosia': 0.02,
'Other': 0.05,
},
},
}
export default UsageStats
50 changes: 50 additions & 0 deletions data/useragents-me_desktop.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[
{ "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.3", "pct": 32.43 },
{
"ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.3",
"pct": 12.23
},
{
"ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.6 Safari/605.1.1",
"pct": 11.07
},
{
"ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.1 Safari/605.1.1",
"pct": 10.3
},
{
"ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36 Edg/129.0.0.",
"pct": 7.72
},
{ "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:130.0) Gecko/20100101 Firefox/130.", "pct": 6.69 },
{
"ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.",
"pct": 5.15
},
{
"ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.",
"pct": 3.6
},
{ "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/117.", "pct": 2.06 },
{ "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.3", "pct": 1.54 },
{ "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.3", "pct": 1.54 },
{
"ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 OPR/113.0.0.",
"pct": 1.03
},
{ "ua": "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Geck", "pct": 1.03 },
{
"ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.0.",
"pct": 1.03
},
{ "ua": "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.", "pct": 1.03 },
{
"ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36 OpenWave/93.4.3888.3",
"pct": 0.51
},
{
"ua": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/26.0 Chrome/122.0.0.0 Safari/537.3",
"pct": 0.51
},
{ "ua": "Mozilla/5.0 (Windows NT 6.1; rv:109.0) Gecko/20100101 Firefox/115.", "pct": 0.51 }
]
66 changes: 66 additions & 0 deletions data/useragents-me_mobile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[
{ "ua": "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Mobile Safari/537.3", "pct": 51.75 },
{
"ua": "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/26.0 Chrome/122.0.0.0 Mobile Safari/537.3",
"pct": 8.77
},
{ "ua": "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Mobile Safari/537.3", "pct": 7.89 },
{
"ua": "Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Mobile/15E148 Safari/604.",
"pct": 7.02
},
{
"ua": "Mozilla/5.0 (iPhone; CPU iPhone OS 17_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.6 Mobile/15E148 Safari/604.",
"pct": 3.51
},
{ "ua": "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Mobile Safari/537.3", "pct": 2.63 },
{ "ua": "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Mobile Safari/537.3", "pct": 2.63 },
{
"ua": "Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/129.0.6668.69 Mobile/15E148 Safari/604.",
"pct": 1.75
},
{
"ua": "Mozilla/5.0 (iPhone; CPU iPhone OS 15_8 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) GSA/329.0.660098639 Mobile/15E148 Safari/604.",
"pct": 1.75
},
{
"ua": "Mozilla/5.0 (Linux; Android 11; moto e20 Build/RONS31.267-94-14) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.6668.70 Mobile Safari/537.3",
"pct": 1.75
},
{
"ua": "Mozilla/5.0 (iPhone; CPU iPhone OS 16_7_10 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.7 Mobile/15E148 Safari/604.1 Ddg/16.",
"pct": 0.88
},
{
"ua": "Mozilla/5.0 (Linux; Android 10; SAMSUNG SM-G980F) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/22.0 Chrome/111.0.5563.116 Mobile Safari/537.3",
"pct": 0.88
},
{
"ua": "Mozilla/5.0 (iPhone; CPU iPhone OS 17_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/129.0.6668.69 Mobile/15E148 Safari/604.",
"pct": 0.88
},
{
"ua": "Mozilla/5.0 (iPhone; CPU iPhone OS 17_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.6 Mobile/15E148 Safari/604.1 Ddg/17.",
"pct": 0.88
},
{
"ua": "Mozilla/5.0 (iPhone; CPU iPhone OS 17_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/129.0.6668.69 Mobile/15E148 Safari/604.",
"pct": 0.88
},
{
"ua": "Mozilla/5.0 (iPhone; CPU iPhone OS 15_8_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6.6 Mobile/15E148 Safari/604.",
"pct": 0.88
},
{ "ua": "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Mobile Safari/537.3", "pct": 0.88 },
{ "ua": "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Mobile Safari/537.3", "pct": 0.88 },
{ "ua": "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Mobile Safari/537.3", "pct": 0.88 },
{
"ua": "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/24.0 Chrome/117.0.0.0 Mobile Safari/537.3",
"pct": 0.88
},
{
"ua": "Mozilla/5.0 (Linux; Android 7.0; SM-G930V Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.125 Mobile Safari/537.36 (compatible; Google-Read-Aloud; +https://support.google.com/webmasters/answer/1061943",
"pct": 0.88
},
{ "ua": "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Mobile Safari/537.3", "pct": 0.88 }
]
Loading

0 comments on commit cc4f9de

Please sign in to comment.