2027-track 0.1.2 → 0.1.3

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 +37 -52
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,14 +1,16 @@
1
1
  # 2027-track
2
2
 
3
- Track AI coding agents (Claude Code, Codex, OpenCode) visiting your documentation.
3
+ **Know who's using your product: humans or agents**
4
4
 
5
- ## Installation
5
+ Lightweight middleware to detect and track AI coding agents visiting your docs.
6
+
7
+ ## Install
6
8
 
7
9
  ```bash
8
10
  npm install 2027-track
9
11
  ```
10
12
 
11
- ## Usage with Next.js
13
+ ## Next.js
12
14
 
13
15
  ```ts
14
16
  // middleware.ts
@@ -16,76 +18,59 @@ import { withAIAnalytics } from "2027-track/next";
16
18
 
17
19
  export default withAIAnalytics();
18
20
 
19
- // Or wrap your existing middleware:
20
- export default withAIAnalytics(yourExistingMiddleware);
21
+ export const config = {
22
+ matcher: ["/((?!api|_next|admin|auth).*)",],
23
+ };
24
+ ```
25
+
26
+ Or wrap existing middleware:
27
+
28
+ ```ts
29
+ export default withAIAnalytics(yourMiddleware);
21
30
  ```
22
31
 
23
- ## Usage (generic)
32
+ ## Generic Usage
24
33
 
25
34
  ```ts
26
35
  import { trackVisit } from "2027-track";
27
36
 
28
37
  await trackVisit({
29
38
  host: "docs.example.com",
30
- path: "/api/getting-started",
39
+ path: "/getting-started",
31
40
  userAgent: request.headers.get("user-agent"),
32
41
  accept: request.headers.get("accept"),
33
- country: "US", // optional
34
42
  });
35
43
  ```
36
44
 
37
- ## Route Filtering
38
-
39
- **Important:** Only track public documentation routes. Exclude private endpoints to avoid leaking sensitive paths.
40
-
41
- ### Next.js matcher (recommended)
42
-
43
- ```ts
44
- // middleware.ts
45
- import { withAIAnalytics } from "2027-track/next";
46
-
47
- export default withAIAnalytics();
48
-
49
- export const config = {
50
- matcher: [
51
- // Exclude private routes, track everything else
52
- "/((?!api|_next|app|admin|dashboard|auth|login|signup).*)",
53
- ],
54
- };
55
- ```
56
-
57
- ### Manual filtering
58
-
59
- ```ts
60
- import { trackVisit } from "2027-track";
61
-
62
- // Only track if path starts with /docs
63
- if (path.startsWith("/docs")) {
64
- await trackVisit({ host, path, userAgent, accept });
65
- }
66
- ```
67
-
68
45
  ## Configuration
69
46
 
70
- ### Kill switch
47
+ ```bash
48
+ # Disable tracking
49
+ AI_ANALYTICS_ENDPOINT=""
71
50
 
72
- Set `AI_ANALYTICS_ENDPOINT=""` to disable tracking entirely.
51
+ # Self-host (optional)
52
+ AI_ANALYTICS_ENDPOINT="https://your-api.workers.dev/track"
53
+ ```
73
54
 
74
- ### Custom endpoint
55
+ ## Privacy
75
56
 
76
- Set `AI_ANALYTICS_ENDPOINT` to your own endpoint URL.
57
+ - Events sent **server-side** visitor IPs never reach the analytics endpoint
58
+ - No cookies, no fingerprinting, no PII
59
+ - Fully open source — [audit the code](https://github.com/team2027/track)
77
60
 
78
- ## Privacy
61
+ ## Detection
79
62
 
80
- - Events are sent **server-side** from Vercel Edge (or your server)
81
- - Visitor IP addresses **never reach** the analytics endpoint
82
- - Only headers (user-agent, accept) and page info (host, path) are sent
83
- - **No cookies, no fingerprinting, no personal identifiers**
63
+ | Agent | Signal |
64
+ |-------|--------|
65
+ | Claude Code | `axios` + `text/markdown` |
66
+ | OpenCode | `text/markdown` with `q=` weights |
67
+ | Codex | `ChatGPT-User` user-agent |
84
68
 
85
- This middleware collects no personally identifiable information (PII). Because there are no cookies, no IP forwarding, and no user identifiers, it generally does not trigger privacy policy or cookie-consent requirements under GDPR, CCPA, or similar regulations. That said, you should verify with your own legal counsel, especially under strict EU interpretations.
69
+ ## Links
86
70
 
87
- ## Detection
71
+ - [GitHub](https://github.com/team2027/track)
72
+ - [Test your agent](https://ai-docs-analytics-api.theisease.workers.dev/detect)
88
73
 
89
- Agent classification (user-agent and accept header matching) happens server-side at the analytics endpoint — the middleware only forwards raw headers.
74
+ ## License
90
75
 
91
- Dashboard: https://ai-docs-analytics.vercel.app
76
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "2027-track",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Track AI coding agents visiting your documentation",
5
5
  "repository": {
6
6
  "type": "git",