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.
- package/README.md +37 -52
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
# 2027-track
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Know who's using your product: humans or agents**
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
##
|
|
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
|
-
|
|
20
|
-
|
|
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
|
|
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: "/
|
|
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
|
-
|
|
47
|
+
```bash
|
|
48
|
+
# Disable tracking
|
|
49
|
+
AI_ANALYTICS_ENDPOINT=""
|
|
71
50
|
|
|
72
|
-
|
|
51
|
+
# Self-host (optional)
|
|
52
|
+
AI_ANALYTICS_ENDPOINT="https://your-api.workers.dev/track"
|
|
53
|
+
```
|
|
73
54
|
|
|
74
|
-
|
|
55
|
+
## Privacy
|
|
75
56
|
|
|
76
|
-
|
|
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
|
-
##
|
|
61
|
+
## Detection
|
|
79
62
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
69
|
+
## Links
|
|
86
70
|
|
|
87
|
-
|
|
71
|
+
- [GitHub](https://github.com/team2027/track)
|
|
72
|
+
- [Test your agent](https://ai-docs-analytics-api.theisease.workers.dev/detect)
|
|
88
73
|
|
|
89
|
-
|
|
74
|
+
## License
|
|
90
75
|
|
|
91
|
-
|
|
76
|
+
MIT
|