~ knotless Search/
↑↓ move↵ open⇧↵ all results

chadtmiller.com/knotless

git that lives in your Atmosphere account

knotless.dev
1 collaborator

knotless 0.13.0 Latest 2 packages, 1 image

1
10

The pages' own queries are counted as pages, not as a bot

Merged chadtmiller.com asked to merge into main from chadtmiller.com/knotless:serve/pages-client
crates/knotless-serve/src/usage.rs+6−1
@@ -736,13 +736,16 @@ fn surface(route: Option<&str>, path: &str) -> Option<(&'static str, String)> {
Some((surface, route.to_string()))
}
/// The kind of client `agent` names.
/// The kind of client `agent` names. The pages' own queries, as they draw
/// a page someone asked for, are `pages`, counted apart from every client.
fn client(agent: &str) -> &'static str {
let lower = agent.to_ascii_lowercase();
if lower.starts_with("git/") {
"git"
} else if lower.starts_with("knotless/") {
"cli"
} else if lower == "knotless-pages" {
"pages"
} else if bot(&lower) {
"bot"
} else if lower.starts_with("mozilla/") {
@@ -1058,6 +1061,8 @@ mod tests {
for (agent, kind) in [
("git/2.47.0", "git"),
("knotless/0.1.0", "cli"),
("knotless-pages", "pages"),
("node", "bot"),
("Mozilla/5.0 (compatible; Googlebot/2.1)", "bot"),
("Mozilla/5.0 (compatible; GoogleOther)", "bot"),
("Mozilla/5.0 (X11; Linux x86_64) HeadlessChrome/120", "bot"),
deploy/README.md+3−1
@@ -247,7 +247,9 @@ KNOTLESS_APPVIEW=https://knotless.dev knotless admin stats
answer's head, so a long clone counts its start.
- **Pages, referrers and clients**: the routes people looked at, the
sites that sent them, and requests by kind of client (`browser`, `git`,
the `cli`, `bot`, `other`, from the `User-Agent`).
the `cli`, `bot`, `other`, from the `User-Agent`), and `pages`, the
queries the pages ask as they draw a page (`knotless-pages`), which are
not a client of their own.
- **Events**, what the handlers saw, with how often each failed, its mean
time and the accounts that did it, in the days asked but at most the
last 30: `mcp.tool` by tool, `mcp.resource` by the tool that answers
web/src/hooks.server.ts+3−0
@@ -79,6 +79,9 @@ export const handleFetch: HandleFetch = ({ event, request, fetch }) => {
// to be logged under the same one.
const trace = event.request.headers.get('traceparent');
if (trace) asked.headers.set('traceparent', trace);
// Named as the pages, which knotless-serve counts apart from the
// clients that ask it: node would call itself `node`, as scripts do.
asked.headers.set('user-agent', 'knotless-pages');
return globalThis.fetch(asked);
}
return fetch(request);