Zero-code bot tracking for Node.js servers (Express, Fastify, NestJS, Next.js, pure Node)
npm install @jaimeflneto/bot-analyticsZero-code bot tracking for Node.js servers. Automatically detects and tracks bot traffic (Googlebot, ChatGPT, Claude, etc.) and sends events to your analytics dashboard.
``bash`
npm install @ai-growth/bot-analytics
That's it! No code changes needed.
1. Create a .env file in your project root with your API token:
`env`
AIGROWTH_API_TOKEN=your_api_token_here
AIGROWTH_ACCOUNT_ID=optional_account_id
2. The package automatically injects itself into your npm scripts (start, dev, serve, start:prod, preview).
3. Start your application normally. The package will automatically begin tracking bot traffic.
- Express.js
- Fastify
- NestJS
- Next.js
- Pure Node.js HTTP servers
The package uses Node.js's NODE_OPTIONS environment variable to pre-load a module that intercepts HTTP requests at the Node.js core level. This means:
- No code changes required in your application
- Works with any HTTP framework
- Zero runtime overhead for non-bot requests
- Automatically detects over 25+ bot types
- Search engines: Googlebot, Bingbot, DuckDuckBot, BaiduSpider, Yandexbot, Slurp
- Social media: FacebookBot, TwitterBot, LinkedInBot, PinterestBot
- AI models: GPTBot, ChatGPT-User, ClaudeBot, PerplexityBot, AnthropicAI, CCBot
- Messaging: WhatsAppBot, TelegramBot
- Others: AppleBot, SpotifyBot, MSNBot, AhrefsBot, SemrushBot, and more
For each bot request, the following is sent to analytics.aigrowthagent.co/bot-track:
`json`
{
"bot_name": "Googlebot",
"bot_category": "Search Engines",
"host": "example.com",
"ip": "203.0.113.42",
"page_url": "/robots.txt",
"account_id": "optional"
}
HTTP Headers:
- X-API-Key: {AIGROWTH_API_TOKEN}Content-Type: application/json
-
- AIGROWTH_API_TOKEN (required) - Your API token for analyticsAIGROWTH_ACCOUNT_ID
- (optional) - Your account ID for organization
- No sensitive data is collected
- Only bot requests are tracked
- The .env file is never committed (add to .gitignore)
- Network failures are handled gracefully and don't affect your app
- Requests have a 2-second timeout to prevent hanging
`bash`
npm uninstall aigrowth-bot-analytics
The package will clean up by removing itself from package.json scripts. If you need to restore the original scripts, a backup is created at package.json.aigrowth.bak`.
MIT