openvibers/openvibe.report Commits

Traffic: sign-in plumbing and avatars are not pages

OP OpenVibers committed 5 h ago · 987d87f6d9 · 2 files, +14 −2

Found with #327's pages-beside-pages: openvibe.network logged 34,672 "pages opened by people" in a week beside 109 a
browser ran. The top "pages" were sign-in plumbing every site calls (/sso/check 1,535, /fedcm/accounts 1,045 in the
last 300k requests) and avatar pictures at extensionless addresses (/avatar/<name>). /sso, /fedcm, /beacon, /rum,
/health(z), /ready and /metrics count as API; /avatar(s) as pictures. Counts already stored keep their old kind; new
ones are right. Test: traffic-kinds; traffic unchanged.

Changes

ddiff --git a/server/traffic/paths.js b/server/traffic/paths.js
iindex dab49e2..89510d0 100644
---- a/server/traffic/paths.js
++++ b/server/traffic/paths.js
@@@ -20,10 +20,10 @@ const FILES = new Set([
]);
const FEED = /^\/(?:feed|rss|atom)(?:\.xml|\.json)?$|\/(?:feed|rss|atom)\.(?:xml|json)$|^\/feeds?\//;
const SITEMAP = /^\/sitemap[\w-]*\.xml$|^\/sitemaps?\/[\w.-]+\.xml$/;
--const ASSET_DIR = /^\/(?:css|js|shared|assets|static|fonts|img|images|icons|vendor|dist|build|_next|public|favicon[\w.-]*|apple-touch-icon[\w.-]*)(?:\/|$)/;
++const ASSET_DIR = /^\/(?:css|js|shared|assets|static|fonts|img|images|icons|avatars?|vendor|dist|build|_next|public|favicon[\w.-]*|apple-touch-icon[\w.-]*)(?:\/|$)/;
const ASSET_EXT = /\.(?:css|js|mjs|map|woff2?|ttf|otf|eot|png|jpe?g|gif|webp|avif|svg|ico|bmp|wasm)$/i;
const MEDIA = /^\/(?:hls|media|vod|vods|clips|thumbnails|thumbs|recordings|live|o|uploads|files)\/|\.(?:m3u8|ts|m4s|mp4|webm|mp3|m4a|ogg|wav|flac|mov|mkv|vtt|srt)$/i;
--const API = /^\/(?:api|auth|internal|mcp|ws|graphql|oauth|oidc|webhooks?|v1|v2|rpc|socket\.io|events|cdn-cgi)(?:\/|$)/i;
++const API = /^\/(?:api|auth|internal|mcp|ws|graphql|oauth|oidc|sso|fedcm|beacon|rum|healthz?|ready|metrics|webhooks?|v1|v2|rpc|socket\.io|events|cdn-cgi)(?:\/|$)/i;
const WORD = /^[a-z][a-z0-9._~-]{0,39}$/i;
/** A section as kept: "/section" or "/section/*"; anything that looks like an id or a token is "/*". */
ddiff --git a/test/traffic-kinds.test.js b/test/traffic-kinds.test.js
nnew file mode 100644
iindex 0000000..3331f90
---- /dev/null
++++ b/test/traffic-kinds.test.js
@@@ -0,0 +1,12 @@
++'use strict';
++// What counts as a page (12-01): openvibe.network logged 34,672 "pages opened by people" in a week beside 109 a browser
++// ran, because sign-in plumbing every site calls (/sso/check, /fedcm/accounts) and avatar pictures at addresses with no
++// extension (/avatar/<name>) were counted as pages. They are API calls and pictures; real pages stay pages.
++const assert = require('assert');
++const { kindOf } = require('../server/traffic/paths');
++
++const kind = (u, m = 'GET') => kindOf(m, u).kind;
++for (const u of ['/sso/check', '/sso/check?next=x', '/fedcm/accounts', '/fedcm/token', '/oauth/authorize', '/beacon', '/healthz', '/ready']) assert.strictEqual(kind(u), 'api', u);
++for (const u of ['/avatar/alex', '/avatar/Maticus', '/avatars/usr_1.webp']) assert.strictEqual(kind(u), 'asset', u);
++for (const u of ['/', '/@alex', '/c/abc', '/my', '/docs/whip', '/traffic']) assert.strictEqual(kind(u), 'page', u);
++console.log('traffic-kinds: sign-in plumbing is API, avatars are pictures, pages are pages');