Skip to content

AI-native design editor. Open-source Figma alternative.

feat: count daily pings by the network they come from (#1614)

Danila Poyarkova96e81cd3d9b
diff --git a/packages/docs/overview/privacy.md b/packages/docs/overview/privacy.md
index b8a755372..375326d11 100644
--- a/packages/docs/overview/privacy.md
+++ b/packages/docs/overview/privacy.md
@@ -48,7 +48,7 @@ POST https://feedback.openpencil.dev/ping
<SdkDataTable :columns="columns" :rows="pingRows" />
-It carries no ID, so pings from the same install cannot be linked. The answer to the usage stats question is the only way we learn how many people decline, since declining means nothing else is ever sent. The app stores only the date of its last ping, so it pings once a day. The server adds one to a counter for that day and build, and keeps nothing else. It does not log addresses, and it rejects a ping that carries any other field.
+It carries no ID, so pings from the same install cannot be linked. The answer to the usage stats question is the only way we learn how many people decline, since declining means nothing else is ever sent. The app stores only the date of its last ping, so it pings once a day. The server adds one to a counter for that day and build. It also adds one to a counter for that day, the app and platform, and the network the ping came from: the network's number and operator name as Cloudflare reports them, such as a home internet provider, a university, or a cloud host. That tells real people apart from automated installs running in data centers, without anything that identifies a device. The server keeps nothing else. It does not log addresses, and it rejects a ping that carries any other field.
The ping is on by default. Turn it off in **Settings → Privacy**.
diff --git a/packages/feedback/AGENTS.md b/packages/feedback/AGENTS.md
index 9c3ce2c56..aa682919a 100644
--- a/packages/feedback/AGENTS.md
+++ b/packages/feedback/AGENTS.md
@@ -3,7 +3,7 @@
Cloudflare Worker for pings, opt-in usage stats, and the Cloud waitlist; overview and setup in `README.md`.
- Every field the app may send is a closed Valibot list in `src/contract/schema.ts`, with its plain-language meaning in `src/contract/describe.ts`; the privacy page renders both. Add an event or property in both files and update `packages/docs/overview/privacy.md` prose if what is collected changes (`tests/contract.test.ts`).
-- The Worker never stores or forwards a client address: rate limits key on it in memory, PostHog requests are new requests from the Worker, and Turnstile is verified without `remoteip` (`tests/ingest.test.ts`).
+- The Worker never stores or forwards a client address: rate limits key on it in memory, PostHog requests are new requests from the Worker, and Turnstile is verified without `remoteip` (`tests/ingest.test.ts`). Pings count the sender's network only as Cloudflare's AS number and operator name (`tests/ping.test.ts`).
- Schema changes are new files in `migrations/`, applied by `wrangler d1 migrations`; keep `src/db/tables.ts` in step (`tests/harness.ts` applies them). Everything else, tests included, queries D1 through the typed Kysely database; raw `sql` templates are rejected (`open-pencil/no-raw-sql`).
- Calendar days are `CalendarDate`s from `@internationalized/date` (`src/days.ts`), turned into ISO dates only where they are stored or sent; `Date` is for moments such as the clock and sign-up times (`tests/snapshot.test.ts`).
- Routes are chained Hono routers that validate bodies with `validatedJSON(schema)` and export `FeedbackAPI`; clients use `createFeedbackClient` (`hc<FeedbackAPI>`), as Cloud's do, never hand-written paths (`tests/harness.ts` uses `testClient`).
diff --git a/packages/feedback/README.md b/packages/feedback/README.md
index 412435529..3cc1fad42 100644
--- a/packages/feedback/README.md
+++ b/packages/feedback/README.md
@@ -4,7 +4,7 @@ The Cloudflare Worker behind `feedback.openpencil.dev`. It is operated by the Op
| Route | What it does | What it keeps |
| --- | --- | --- |
-| `POST /ping` | The daily anonymous ping. | One counter per day and build (version, OS, architecture, desktop or web, browser family). Nothing per install, no addresses. |
+| `POST /ping` | The daily anonymous ping. | One counter per day and build (version, OS, architecture, desktop or web, browser family), and one per day, app, platform, and network (Cloudflare's AS number and operator name). Nothing per install, no addresses. |
| `POST /ingest` | Opt-in usage stats, forwarded to PostHog EU. Refuses any event or property not in `src/contract`. | Nothing. PostHog gets no client address, person profile, or GeoIP. |
| `GET /admin/` | The team's metrics dashboard, built from the app's `metrics.html` (`bun run build:metrics` writes `dist-metrics/`, which Wrangler uploads as the Worker's assets), behind Cloudflare Access. | Nothing. |
| `GET /admin/api/snapshot?start&end` | The metrics dashboard's data for a range of UTC days, behind Cloudflare Access. | Nothing; it reads pings, snapshots, and the waitlist from D1 (email domains only) and asks PostHog for usage. |
diff --git a/packages/feedback/migrations/0005_ping_networks.sql b/packages/feedback/migrations/0005_ping_networks.sql
new file mode 100644
index 000000000..6a1c25748
--- /dev/null
+++ b/packages/feedback/migrations/0005_ping_networks.sql
@@ -0,0 +1,14 @@
+-- Daily pings by the network they came from: the autonomous system Cloudflare reports for the
+-- request, never the address. Kept apart from usage_pings so the build counters stay as they are.
+CREATE TABLE ping_networks (
+ day TEXT NOT NULL,
+ -- The AS number, or 0 when Cloudflare reported none.
+ asn INTEGER NOT NULL,
+ app TEXT NOT NULL,
+ platform TEXT NOT NULL,
+ -- The operator's name as reported; Cloudflare words it differently between requests, so each
+ -- wording keeps its own count and the dashboard names the network by the commonest.
+ name TEXT NOT NULL,
+ count INTEGER NOT NULL DEFAULT 0,
+ PRIMARY KEY (day, asn, app, platform, name)
+) WITHOUT ROWID;
diff --git a/packages/feedback/src/admin/snapshot.ts b/packages/feedback/src/admin/snapshot.ts
index 04b3ac6cc..d5c119bda 100644
--- a/packages/feedback/src/admin/snapshot.ts
+++ b/packages/feedback/src/admin/snapshot.ts
@@ -108,6 +108,36 @@ async function pings(db: Kysely<FeedbackDatabase>, range: MetricsQuery, days: st
}
}
+async function networks(db: Kysely<FeedbackDatabase>, range: MetricsQuery) {
+ const rows = await db
+ .selectFrom('pingNetworks')
+ .select(['asn', 'app', 'name', (eb) => eb.fn.sum<number>('count').as('pings')])
+ .where('day', '>=', range.start)
+ .where('day', '<=', range.end)
+ .groupBy(['asn', 'app', 'name'])
+ .execute()
+ const ranked = Object.values(groupBy(rows, (row) => String(row.asn)))
+ .map((network) => ({
+ asn: network[0]?.asn ?? 0,
+ // Cloudflare words an operator's name differently between requests, and sometimes leaves it
+ // out; the commonest reported one names it.
+ name:
+ maxBy(
+ Object.values(
+ groupBy(
+ network.filter((row) => row.name !== ''),
+ (row) => row.name
+ )
+ ),
+ (wording) => sumBy(wording, (row) => Number(row.pings))
+ )?.[0]?.name ?? '',
+ desktop: sumBy(network, (row) => (row.app === 'desktop' ? Number(row.pings) : 0)),
+ web: sumBy(network, (row) => (row.app === 'web' ? Number(row.pings) : 0))
+ }))
+ .toSorted((a, b) => b.desktop + b.web - (a.desktop + a.web))
+ return { total: sumBy(rows, (row) => Number(row.pings)), top: ranked.slice(0, TOP) }
+}
+
async function site(
db: Kysely<FeedbackDatabase>,
env: FeedbackBindings,
@@ -390,9 +420,10 @@ export async function buildSnapshot(
// Visits and the issue mirror are recorded once a day has ended, so today never has any.
const finished = days.filter((day) => parseDate(day).compare(today) < 0)
const db = createFeedbackDatabase(env.DB)
- const [earliest, pinged, visited, repository, signups, usage] = await Promise.all([
+ const [earliest, pinged, byNetwork, visited, repository, signups, usage] = await Promise.all([
firstDay(db),
pings(db, range, days),
+ networks(db, range),
site(db, env, range, finished),
github(db, range, days, finished),
waitlist(db, range),
@@ -407,6 +438,7 @@ export async function buildSnapshot(
earliest,
...range,
...pinged,
+ networks: byNetwork,
...visited,
github: repository,
waitlist: signups,
diff --git a/packages/feedback/src/contract/schema.ts b/packages/feedback/src/contract/schema.ts
index 5b7c99c62..9c14e548b 100644
--- a/packages/feedback/src/contract/schema.ts
+++ b/packages/feedback/src/contract/schema.ts
@@ -239,6 +239,16 @@ export const metricsSnapshotSchema = v.object({
dailyActive: v.array(v.object({ day: isoDaySchema, desktop: countSchema, web: countSchema })),
/** Pings in the range by OS, desktop and web. */
platforms: v.array(v.object({ os: v.string(), desktop: countSchema, web: countSchema })),
+ /**
+ * Pings by network since network counting began: every network's pings in the range, and the
+ * networks with the most; AS 0 holds pings with none reported.
+ */
+ networks: v.object({
+ total: countSchema,
+ top: v.array(
+ v.object({ asn: countSchema, name: v.string(), desktop: countSchema, web: countSchema })
+ )
+ }),
/** Pings each day on the newest stable version and on everything else. */
versions: v.object({
latest: v.nullable(v.string()),
diff --git a/packages/feedback/src/db/index.ts b/packages/feedback/src/db/index.ts
index 9da718335..c080f2262 100644
--- a/packages/feedback/src/db/index.ts
+++ b/packages/feedback/src/db/index.ts
@@ -1,5 +1,5 @@
import type { D1Database } from '@cloudflare/workers-types/index'
-import { CamelCasePlugin, Kysely } from 'kysely'
+import { CamelCasePlugin, Kysely, type CompiledQuery } from 'kysely'
import { D1Dialect } from 'kysely-d1'
import type { FeedbackDatabase } from './tables'
@@ -12,3 +12,9 @@ export function createFeedbackDatabase(database: D1Database): Kysely<FeedbackDat
plugins: [new CamelCasePlugin()]
})
}
+
+/** Runs Kysely-built statements as one D1 batch, which is atomic. */
+export async function runBatch(d1: D1Database, statements: CompiledQuery[]): Promise<void> {
+ if (!statements.length) return
+ await d1.batch(statements.map((query) => d1.prepare(query.sql).bind(...query.parameters)))
+}
diff --git a/packages/feedback/src/db/tables.ts b/packages/feedback/src/db/tables.ts
index 64fb97556..6afe91e3d 100644
--- a/packages/feedback/src/db/tables.ts
+++ b/packages/feedback/src/db/tables.ts
@@ -11,6 +11,15 @@ export interface UsagePingTable {
count: number
}
+export interface PingNetworkTable {
+ day: string
+ asn: number
+ app: string
+ platform: string
+ name: string
+ count: number
+}
+
export interface WaitlistTable {
id: Generated<number>
email: string
@@ -81,6 +90,7 @@ export interface RepoItemTable {
/** The D1 tables `migrations/` creates, in Kysely's camelCase. */
export interface FeedbackDatabase {
usagePings: UsagePingTable
+ pingNetworks: PingNetworkTable
waitlist: WaitlistTable
githubStars: GithubStarsTable
releaseDownloads: ReleaseDownloadsTable
diff --git a/packages/feedback/src/ping/record.ts b/packages/feedback/src/ping/record.ts
index 02b05cdbf..091e5d2cb 100644
--- a/packages/feedback/src/ping/record.ts
+++ b/packages/feedback/src/ping/record.ts
@@ -1,21 +1,64 @@
import type { Ping } from '#feedback/contract'
import { utcDayOf } from '#feedback/days'
-import type { FeedbackDatabase } from '#feedback/db'
-import type { Kysely } from 'kysely'
+import { createFeedbackDatabase, runBatch } from '#feedback/db'
+import type { D1Database } from '@cloudflare/workers-types/index'
+import * as v from 'valibot'
-/** Adds one to today's count for the ping's build and answer; no row ever describes a single install. */
+/** The network a request came from, as Cloudflare reports it: the autonomous system, never the address. */
+export interface PingNetwork {
+ asn: number
+ name: string
+}
+
+const UNKNOWN_NETWORK: PingNetwork = { asn: 0, name: '' }
+
+// Cloudflare attaches `cf` to every request it forwards to a Worker; requests from elsewhere,
+// such as tests, may carry none.
+const requestNetworkSchema = v.object({
+ cf: v.object({
+ asn: v.pipe(v.number(), v.integer(), v.minValue(0)),
+ asOrganization: v.optional(v.string(), '')
+ })
+})
+
+/** The network Cloudflare reports for `request`, or AS 0 with no name when it reports none. */
+export function requestNetwork(request: Request): PingNetwork {
+ const parsed = v.safeParse(requestNetworkSchema, request)
+ return parsed.success
+ ? { asn: parsed.output.cf.asn, name: parsed.output.cf.asOrganization }
+ : UNKNOWN_NETWORK
+}
+
+/**
+ * Adds one to today's count for the ping's build and answer, and to today's count for its
+ * network, in one batch; no row ever describes a single install.
+ */
export async function recordPing(
- db: Kysely<FeedbackDatabase>,
+ d1: D1Database,
ping: Ping,
+ network: PingNetwork,
now: Date
): Promise<void> {
- await db
- .insertInto('usagePings')
- .values({ ...ping, day: utcDayOf(now).toString(), count: 1 })
- .onConflict((conflict) =>
- conflict
- .columns(['day', 'version', 'platform', 'arch', 'app', 'browser', 'usageStats'])
- .doUpdateSet((eb) => ({ count: eb('usagePings.count', '+', 1) }))
- )
- .execute()
+ const db = createFeedbackDatabase(d1)
+ const day = utcDayOf(now).toString()
+ await runBatch(d1, [
+ db
+ .insertInto('usagePings')
+ .values({ ...ping, day, count: 1 })
+ .onConflict((conflict) =>
+ conflict
+ .columns(['day', 'version', 'platform', 'arch', 'app', 'browser', 'usageStats'])
+ .doUpdateSet((eb) => ({ count: eb('usagePings.count', '+', 1) }))
+ )
+ .compile(),
+ db
+ .insertInto('pingNetworks')
+ .values({ day, ...network, app: ping.app, platform: ping.platform, count: 1 })
+ .onConflict((conflict) =>
+ conflict
+ .columns(['day', 'asn', 'app', 'platform', 'name'])
+ .doUpdateSet((eb) => ({ count: eb('pingNetworks.count', '+', 1) }))
+ )
+ .compile()
+ ])
}
diff --git a/packages/feedback/src/ping/route.ts b/packages/feedback/src/ping/route.ts
index 397b8b3d5..2d8aa2ce6 100644
--- a/packages/feedback/src/ping/route.ts
+++ b/packages/feedback/src/ping/route.ts
@@ -1,10 +1,9 @@
import { pingSchema } from '#feedback/contract'
-import { createFeedbackDatabase } from '#feedback/db'
import type { FeedbackEnv, FeedbackServices } from '#feedback/env'
import { rateLimited, validatedJSON } from '#feedback/http/request'
import { Hono } from 'hono'
-import { recordPing } from './record'
+import { recordPing, requestNetwork } from './record'
export function pingRoutes(services: FeedbackServices) {
return new Hono<FeedbackEnv>().post(
@@ -12,7 +11,7 @@ export function pingRoutes(services: FeedbackServices) {
rateLimited((env) => env.PING_LIMITER),
validatedJSON(pingSchema),
async (c) => {
- await recordPing(createFeedbackDatabase(c.env.DB), c.req.valid('json'), services.now())
+ await recordPing(c.env.DB, c.req.valid('json'), requestNetwork(c.req.raw), services.now())
return c.body(null, 204)
}
)
diff --git a/packages/feedback/src/snapshot/store.ts b/packages/feedback/src/snapshot/store.ts
index 95de62cb5..e8f471c33 100644
--- a/packages/feedback/src/snapshot/store.ts
+++ b/packages/feedback/src/snapshot/store.ts
@@ -1,4 +1,4 @@
-import type { FeedbackDatabase } from '#feedback/db'
+import { runBatch, type FeedbackDatabase } from '#feedback/db'
import type { D1Database } from '@cloudflare/workers-types/index'
import type { CalendarDate } from '@internationalized/date'
import { chunk } from 'es-toolkit'
@@ -61,11 +61,6 @@ export async function replaceDays<T extends SnapshotTable>(
await runBatch(d1, statements)
}
-async function runBatch(d1: D1Database, statements: CompiledQuery[]): Promise<void> {
- if (!statements.length) return
- await d1.batch(statements.map((query) => d1.prepare(query.sql).bind(...query.parameters)))
-}
-
/** Adds issues and pull requests, or updates the ones already mirrored, in one batch. */
export async function saveRepoItems(
{ db, d1 }: SnapshotStore,
diff --git a/packages/feedback/tests/admin.test.ts b/packages/feedback/tests/admin.test.ts
index 4896d8afb..99ee63b61 100644
--- a/packages/feedback/tests/admin.test.ts
+++ b/packages/feedback/tests/admin.test.ts
@@ -16,6 +16,7 @@ const POSTHOG_QUERY = 'https://eu.posthog.com/api/projects/267806/query/'
const NOW = new Date('2026-10-20T12:00:00.000Z')
const TABLES = [
'usagePings',
+ 'pingNetworks',
'waitlist',
'githubStars',
'releaseDownloads',
@@ -217,6 +218,66 @@ describe('metrics snapshot API', () => {
])
})
+ test('networks rank the range by pings under their commonest name', async () => {
+ const counts = [
+ ['2026-10-18', 9299, 'PLDT', 'desktop', 30],
+ // The commonest wording is split between apps and comes first, so neither the biggest row
+ // nor the latest day would pick it.
+ ['2026-10-18', 136907, 'Huawei Cloud Singapore Region', 'desktop', 200],
+ ['2026-10-18', 136907, 'Huawei Cloud Singapore Region', 'web', 150],
+ ['2026-10-19', 136907, 'Huawei-Cloud-SG', 'desktop', 300],
+ ['2026-10-19', 9299, 'PLDT', 'web', 20],
+ // Pings without an operator name outnumber the named ones but never name the network.
+ ['2026-10-19', 9299, '', 'desktop', 60],
+ ['2026-10-19', 0, '', 'desktop', 5]
+ ] as const
+ await database()
+ .insertInto('pingNetworks')
+ .values(
+ counts.map(([day, asn, name, app, count]) => ({
+ day,
+ asn,
+ name,
+ app,
+ platform: 'macos',
+ count
+ }))
+ )
+ .execute()
+
+ const { networks } = await snapshot()
+ expect(networks).toEqual({
+ total: 765,
+ top: [
+ { asn: 136907, name: 'Huawei Cloud Singapore Region', desktop: 500, web: 150 },
+ { asn: 9299, name: 'PLDT', desktop: 90, web: 20 },
+ { asn: 0, name: '', desktop: 5, web: 0 }
+ ]
+ })
+ })
+
+ test('the network total counts the networks the ranking leaves out', async () => {
+ await database()
+ .insertInto('pingNetworks')
+ .values(
+ Array.from({ length: 12 }, (_, index) => ({
+ day: '2026-10-19',
+ asn: 64500 + index,
+ name: `Network ${index}`,
+ app: 'desktop',
+ platform: 'linux',
+ count: 12 - index
+ }))
+ )
+ .execute()
+
+ const { networks } = await snapshot()
+ expect(networks.top.map((network) => network.asn)).toEqual(
+ Array.from({ length: 10 }, (_, index) => 64500 + index)
+ )
+ expect(networks.total).toBe(78)
+ })
+
test('earliest is the first day with pings or backfilled visits', async () => {
expect((await snapshot()).earliest).toBeNull()
await ping('2026-10-12', { version: '0.16.0-beta.2', platform: 'macos', app: 'desktop' }, 6)
diff --git a/packages/feedback/tests/harness.ts b/packages/feedback/tests/harness.ts
index d0af54f54..3e15a07d6 100644
--- a/packages/feedback/tests/harness.ts
+++ b/packages/feedback/tests/harness.ts
@@ -109,8 +109,18 @@ export async function createTestService() {
}
const app = createFeedbackApp(services)
- const request = (path: string, init?: RequestInit) =>
- app.request(`https://feedback.openpencil.dev${path}`, init, env)
+ /**
+ * Sends a request into the app, carrying `cf` as Cloudflare attaches it when given. A text body
+ * gets its Content-Length, as browsers send it; without one, the body limit rebuilds the request.
+ */
+ const request = (path: string, init?: RequestInit, cf?: Record<string, unknown>) => {
+ const headers = new Headers(init?.headers)
+ if (typeof init?.body === 'string')
+ headers.set('Content-Length', String(new TextEncoder().encode(init.body).length))
+ const sent = new Request(`https://feedback.openpencil.dev${path}`, { ...init, headers })
+ if (cf) Object.defineProperty(sent, 'cf', { value: cf })
+ return app.request(sent, undefined, env)
+ }
return {
/** A client typed by the service's routes, as the app's is, sending into the app under test. */
@@ -135,12 +145,21 @@ export async function createTestService() {
},
request,
/** Posts any body, including ones the typed client would not let through. */
- postJSON(path: string, body: unknown, headers: Record<string, string> = {}) {
- return request(path, {
- method: 'POST',
- headers: { 'Content-Type': 'application/json', ...headers },
- body: JSON.stringify(body)
- })
+ postJSON(
+ path: string,
+ body: unknown,
+ headers: Record<string, string> = {},
+ cf?: Record<string, unknown>
+ ) {
+ return request(
+ path,
+ {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json', ...headers },
+ body: JSON.stringify(body)
+ },
+ cf
+ )
},
dispose: () => proxy.dispose()
}
diff --git a/packages/feedback/tests/ping.test.ts b/packages/feedback/tests/ping.test.ts
index 3a3df22ef..916724f4c 100644
--- a/packages/feedback/tests/ping.test.ts
+++ b/packages/feedback/tests/ping.test.ts
@@ -72,6 +72,52 @@ describe('ping', () => {
])
})
+ test('counts pings per day by the network and wording Cloudflare reports, never the address', async () => {
+ const huawei = { asn: 136907, asOrganization: 'Huawei Cloud Singapore Region' }
+ await service.postJSON('/ping', BUILD, { 'CF-Connecting-IP': '203.0.113.7' }, huawei)
+ await service.postJSON('/ping', BUILD, {}, huawei)
+ await service.postJSON('/ping', BUILD, {}, { ...huawei, asOrganization: 'Huawei-Cloud-SG' })
+ await service.postJSON('/ping', { ...BUILD, app: 'web' }, {}, { asn: 9299 })
+
+ const networks = await createFeedbackDatabase(service.db)
+ .selectFrom('pingNetworks')
+ .selectAll()
+ .where('asn', '!=', 0)
+ .orderBy(['asn', 'app', 'name'])
+ .execute()
+ expect(networks).toEqual([
+ { day: '2026-10-12', asn: 9299, app: 'web', platform: 'macos', name: '', count: 1 },
+ {
+ day: '2026-10-12',
+ asn: 136907,
+ app: 'desktop',
+ platform: 'macos',
+ name: 'Huawei Cloud Singapore Region',
+ count: 2
+ },
+ {
+ day: '2026-10-12',
+ asn: 136907,
+ app: 'desktop',
+ platform: 'macos',
+ name: 'Huawei-Cloud-SG',
+ count: 1
+ }
+ ])
+ expect(JSON.stringify(networks)).not.toContain('203.0.113.7')
+ })
+
+ test('counts a ping without network details under AS 0', async () => {
+ await service.postJSON('/ping', { ...BUILD, platform: 'linux' })
+
+ const unknown = await createFeedbackDatabase(service.db)
+ .selectFrom('pingNetworks')
+ .select(['asn', 'name', 'count'])
+ .where('platform', '=', 'linux')
+ .execute()
+ expect(unknown).toEqual([{ asn: 0, name: '', count: 1 }])
+ })
+
test('refuses a ping without the usage stats answer', async () => {
expect((await service.postJSON('/ping', omit(BUILD, ['usageStats']))).status).toBe(400)
})
diff --git a/src/components/metrics/MetricsDashboard.stories.ts b/src/components/metrics/MetricsDashboard.stories.ts
index 6880d7196..bc9bd8aac 100644
--- a/src/components/metrics/MetricsDashboard.stories.ts
+++ b/src/components/metrics/MetricsDashboard.stories.ts
@@ -239,6 +239,18 @@ function scope(range: MetricsRange, withUsage: boolean, withActivity: boolean):
{ os: 'android', desktop: 0, web: 43 },
{ os: 'ios', desktop: 0, web: 28 }
],
+ // Networks are illustrative, shaped like a cloud network's automated installs.
+ networks: {
+ total: 2512,
+ top: [
+ { asn: 136907, name: 'Huawei Cloud Singapore Region', desktop: 2089, web: 0 },
+ { asn: 7922, name: 'Comcast Cable Communications, LLC', desktop: 101, web: 88 },
+ { asn: 4134, name: 'Chinanet', desktop: 54, web: 61 },
+ { asn: 3320, name: 'Deutsche Telekom AG', desktop: 40, web: 33 },
+ { asn: 9299, name: 'Philippine Long Distance Telephone Company', desktop: 12, web: 9 },
+ { asn: 0, name: '', desktop: 3, web: 1 }
+ ]
+ },
versions: { latest: '0.16.0', daily: inRange(versions) },
releases: inRange([{ day: '2026-10-14', version: '0.16.0' }]),
visits: inRange(visits),
@@ -336,7 +348,7 @@ export const Overview = story('h-[3950px]')
export const WithoutUsage = story('h-[3550px]', false)
/** Before the first nightly sync, issues and pull requests give way to a notice. */
-export const BeforeIssueSync = story('h-[3000px]', true, false)
+export const BeforeIssueSync = story('h-[3400px]', true, false)
/** The dashboard in a phone-width window. */
-export const Narrow = story('h-[6100px] w-[390px]')
+export const Narrow = story('h-[6450px] w-[390px]')
diff --git a/src/components/metrics/MetricsDashboard.vue b/src/components/metrics/MetricsDashboard.vue
index dc822d6d2..4d369d025 100644
--- a/src/components/metrics/MetricsDashboard.vue
+++ b/src/components/metrics/MetricsDashboard.vue
@@ -28,6 +28,7 @@ import DailyLevelChart from './DailyLevelChart.vue'
import MetricsCard from './MetricsCard.vue'
import MetricsRangePicker from './MetricsRangePicker.vue'
import MetricsTile from './MetricsTile.vue'
+import NetworksTable from './NetworksTable.vue'
import PlatformsChart from './PlatformsChart.vue'
import RetentionChart from './RetentionChart.vue'
import type { DailyActiveDay, DailyPulls, DailyTraffic, DailyVersions, DailyVisits } from './types'
@@ -258,22 +259,33 @@ const sharingNote = computed(() => {
<PlatformsChart :platforms="snapshot.platforms" />
</MetricsCard>
<MetricsCard
- heading="Versions"
- note="Daily pings by version. Versions before 0.16.0 send no pings, so older installs show up from the next release on."
+ heading="Networks"
+ note="Daily pings added up by the network Cloudflare reports"
>
- <template v-if="latestShare !== undefined && snapshot.versions.latest" #aside>
- {{ formatShare(latestShare) }} on {{ snapshot.versions.latest }}
- </template>
- <DailyChart
- label="Daily pings on the latest version and on others"
- :days="snapshot.versions.daily"
- :series="versionSeries"
- :today="snapshot.today"
- :height="200"
- stacked
+ <NetworksTable
+ v-if="snapshot.networks.top.length"
+ :networks="snapshot.networks.top"
+ :total="snapshot.networks.total"
/>
+ <p v-else :class="ui.sectionLabel()">No networks recorded in this range yet</p>
</MetricsCard>
</div>
+ <MetricsCard
+ heading="Versions"
+ note="Daily pings by version. Versions before 0.16.0 send no pings, so older installs show up from the next release on."
+ >
+ <template v-if="latestShare !== undefined && snapshot.versions.latest" #aside>
+ {{ formatShare(latestShare) }} on {{ snapshot.versions.latest }}
+ </template>
+ <DailyChart
+ label="Daily pings on the latest version and on others"
+ :days="snapshot.versions.daily"
+ :series="versionSeries"
+ :today="snapshot.today"
+ :height="200"
+ stacked
+ />
+ </MetricsCard>
<MetricsCard heading="Website" note="Visits to openpencil.dev by page and country">
<div :class="ui.breakdown()">
<div>
diff --git a/src/components/metrics/NetworksTable.vue b/src/components/metrics/NetworksTable.vue
new file mode 100644
index 000000000..2440c240f
--- /dev/null
+++ b/src/components/metrics/NetworksTable.vue
@@ -0,0 +1,60 @@
+<script setup lang="ts">
+import { tv } from 'tailwind-variants'
+import { computed } from 'vue'
+
+import { formatCount, formatShare } from '@/app/metrics/format'
+import { metricsNetworksTheme } from '@/theme/metrics/dashboard'
+
+import type { PingNetwork } from './types'
+
+const metricsNetworks = tv(metricsNetworksTheme)
+
+/**
+ * The busiest networks by pings, with each one's share of every network's pings; one cloud
+ * network far ahead of the rest usually means automated installs rather than people.
+ */
+const {
+ networks,
+ total,
+ limit = 5
+} = defineProps<{
+ networks: PingNetwork[]
+ /** Every network's pings, so a share counts the ones the table leaves out. */
+ total: number
+ limit?: number
+}>()
+const ui = metricsNetworks()
+
+const rows = computed(() =>
+ networks.slice(0, limit).map((network) => {
+ const pings = network.desktop + network.web
+ return {
+ asn: network.asn,
+ name: network.asn && network.name ? network.name : 'Not reported',
+ pings,
+ share: total ? pings / total : 0
+ }
+ })
+)
+</script>
+
+<template>
+ <table :class="ui.table()">
+ <thead>
+ <tr :class="ui.row()">
+ <th :class="ui.asn()" scope="col">AS</th>
+ <th :class="ui.name()" scope="col">Network</th>
+ <th :class="ui.number()" scope="col">Share</th>
+ <th :class="ui.number()" scope="col">Pings</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr v-for="row in rows" :key="row.asn" :class="ui.row()">
+ <td :class="ui.asn()">{{ row.asn || '—' }}</td>
+ <td :class="ui.name()">{{ row.name }}</td>
+ <td :class="ui.number()">{{ formatShare(row.share) }}</td>
+ <td :class="ui.number()">{{ formatCount(row.pings) }}</td>
+ </tr>
+ </tbody>
+ </table>
+</template>
diff --git a/src/components/metrics/types.ts b/src/components/metrics/types.ts
index 7e4a8a8b2..0e7c465a7 100644
--- a/src/components/metrics/types.ts
+++ b/src/components/metrics/types.ts
@@ -7,6 +7,7 @@ export type DailyVersions = MetricsSnapshot['versions']['daily'][number]
export type DailyTraffic = MetricsSnapshot['github']['traffic'][number]
export type DailyIssues = MetricsSnapshot['github']['activity']['issues'][number]
export type DailyPulls = MetricsSnapshot['github']['activity']['pulls'][number]
+export type PingNetwork = MetricsSnapshot['networks']['top'][number]
export type PlatformCount = MetricsSnapshot['platforms'][number]
export type Release = MetricsSnapshot['releases'][number]
export type WaitlistSignup = MetricsSnapshot['waitlist']['recent'][number]
diff --git a/src/theme/metrics/dashboard.ts b/src/theme/metrics/dashboard.ts
index 860d42cb1..476c736f8 100644
--- a/src/theme/metrics/dashboard.ts
+++ b/src/theme/metrics/dashboard.ts
@@ -57,6 +57,17 @@ export const metricsWaitlistTheme = {
}
} as const
+/** The busiest networks as a compact table: AS number, operator, share, and pings. */
+export const metricsNetworksTheme = {
+ slots: {
+ table: 'w-full table-fixed text-xs',
+ row: 'h-9 border-b border-border last:border-b-0 [&>th]:h-7 [&>th]:text-[11px] [&>th]:font-normal [&>th]:text-muted',
+ asn: 'w-16 text-left text-muted tabular-nums',
+ name: 'truncate pr-3 text-left font-medium',
+ number: 'w-16 text-right tabular-nums'
+ }
+} as const
+
/** Presets as rows beside a month calendar; the trigger shows the preset and its days. */
export const metricsRangePickerTheme = {
slots: {