@katrinalaszlo/track 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +15 -4
  2. package/package.json +5 -2
package/README.md CHANGED
@@ -1,13 +1,13 @@
1
- # Agent traffic: install skill
1
+ # Track: install skill
2
2
 
3
- [Agent traffic](https://alg.katrinalaszlo.com) shows which AI agents call your API, how their sessions go, and which errors end them. This repo is everything that runs on your side: an agent skill that installs it, the Express middleware it adds, and the script that checks the install.
3
+ [Track](https://alg.katrinalaszlo.com) shows which AI agents call your API, how their sessions go, and which errors end them. This repo is everything that runs on your side: an agent skill that installs it, the Express middleware it adds, and the script that checks the install.
4
4
 
5
5
  ## Install with a coding agent
6
6
 
7
7
  Give your agent (Claude Code, Cursor, Codex) this prompt:
8
8
 
9
9
  ```
10
- Add agent traffic to this API: read https://alg.katrinalaszlo.com/SKILL.md and follow it.
10
+ Add Track to this API: read https://alg.katrinalaszlo.com/SKILL.md and follow it.
11
11
  ```
12
12
 
13
13
  Or add the skill to your agent first:
@@ -29,7 +29,16 @@ const { agentTraffic } = require("@katrinalaszlo/track"); // or: import { agentT
29
29
  app.use(agentTraffic({ accountIdOf: (req, res) => req.user?.id }));
30
30
  ```
31
31
 
32
- Register it right after creating the app, before auth and routes. `accountIdOf` returns your customer's id (hashed before it leaves your server), or undefined. Optional `errorOf(req, res)` returns error text for failed responses (400 and above, up to 200 characters), so two errors with the same status show separately. It needs one variable, `AGENT_TRAFFIC_KEY`, in the environment or `.env`: the key belongs to one project, and events go there. Get it with `npx agent-led-growth connect`, which opens your browser to sign in and writes the key to `.env` for you, or with the signup in [SKILL.md](skills/agent-traffic/SKILL.md). `AGENT_TRAFFIC_ACCOUNT_SALT` is needed when you set `accountIdOf` or call `recordOutcome`. `AGENT_TRAFFIC_PROJECT_ID` is optional: set, it is sent with each batch as before.
32
+ Register it right after creating the app, before auth and routes. `accountIdOf` returns your customer's id (hashed before it leaves your server), or undefined. Optional `errorOf(req, res)` returns error text for failed responses (400 and above, up to 200 characters), so two errors with the same status show separately. It needs one variable, `AGENT_TRAFFIC_KEY`, in the environment or `.env`: the key belongs to one project, and events go there. No account yet? This creates a free workspace and appends its key to `.env` without printing it (the first line adds a final newline to a `.env` that lacks one):
33
+
34
+ ```sh
35
+ if [ -s .env ] && [ -n "$(tail -c 1 .env)" ]; then echo >> .env; fi
36
+ curl -fsS -X POST "https://alg.katrinalaszlo.com/v1/signup?format=env" -H "Content-Type: application/json" -d '{"label":"my api","scopes":["read","write"]}' >> .env
37
+ ```
38
+
39
+ Already have an account? Create a key on the Install page of your dashboard, or run `npx agent-led-growth connect`, which opens your browser to sign in and writes the key to `.env` for you. The full install steps are in [SKILL.md](https://github.com/katrinalaszlo/track-skill/blob/main/skills/agent-traffic/SKILL.md).
40
+
41
+ `AGENT_TRAFFIC_ACCOUNT_SALT` is needed when you set `accountIdOf` or call `recordOutcome`. `AGENT_TRAFFIC_PROJECT_ID` is optional: set, it is sent with each batch as before.
33
42
 
34
43
  Per request it sends the route pattern, the path (see below), method, status code, the `User-Agent`, `Signature-Agent` and `Accept-Language` headers, the time, the hashed customer id, the journey key if the request carried one (see below), and the text `errorOf` returns if you set it. When an agent signed its request (Web Bot Auth, `Signature` and `Signature-Input` headers present) it also sends those two headers, the request's full URL, and the other headers the signature covers, so the signature can be checked; never `Authorization` or `Cookie`, whatever the signer covered. Otherwise no bodies, no other headers, no IPs. To see which agents lead to signups and payments, call `traffic.recordOutcome({ accountId, name: "paid", value: 1999, currency: "USD", idempotencyKey: paymentEvent.id })` from your payment webhook (and `name: "signup"` from your signup handler): the outcome joins the agent session of the same customer. Events go out in batches once a second (at once on Vercel, Lambda and Netlify), and it never fails a request. The one request it holds up is a person opening a handoff link (below), for at most 2 seconds. No dependencies; TypeScript types included.
35
44
 
@@ -75,6 +84,8 @@ What each event contains, and the raw HTTP API for other stacks: [alg.katrinalas
75
84
 
76
85
  ## Tests
77
86
 
87
+ From a clone of [katrinalaszlo/track-skill](https://github.com/katrinalaszlo/track-skill) (the npm package ships only the middleware and its types):
88
+
78
89
  ```sh
79
90
  npm test
80
91
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@katrinalaszlo/track",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Express middleware that shows which AI agents call your API, how their sessions go, and which errors end them.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -8,7 +8,10 @@
8
8
  "type": "git",
9
9
  "url": "git+https://github.com/katrinalaszlo/track-skill.git"
10
10
  },
11
- "homepage": "https://traffic.katrinalaszlo.com/docs",
11
+ "homepage": "https://alg.katrinalaszlo.com/docs",
12
+ "bugs": {
13
+ "url": "https://github.com/katrinalaszlo/track-skill/issues"
14
+ },
12
15
  "keywords": [
13
16
  "ai-agents",
14
17
  "express",