npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

nuxt-ki-bot-tracker

v1.0.6

Published

AI Bot tracking for Nuxt 3 applications with server-side detection

Readme

KI Bot Tracker for Nuxt 3

A powerful Nuxt 3 module for server-side AI bot detection and tracking. This module integrates with the KI Score platform to provide accurate bot analytics for your Nuxt applications.

Features

  • 🤖 Server-side bot detection - 100% accurate tracking
  • 🚀 Zero client-side impact - Non-blocking async tracking
  • 🔧 Easy integration - Single module installation
  • 📊 Real-time analytics - Connects to KI Score dashboard
  • 🎯 Nuxt 3/4 compatible - Built for modern Nuxt applications
  • 🛡️ Privacy focused - No cookies or client-side tracking
  • Edge compatible - Works on Vercel, Netlify, Cloudflare

Installation

For local testing, build and install the module:

# Build the module
npm run build

# Install in your Nuxt project
npm install /path/to/nuxt-ki-bot-tracker

Quick Setup

  1. Add the module to your nuxt.config.ts:
export default defineNuxtConfig({
  modules: [
    'nuxt-ki-bot-tracker'
  ],
  
  kiBotTracker: {
    siteId: 'your-site-id', // Required: Get this from KI Score dashboard
    apiEndpoint: 'https://api.ki-score.com/track', // Optional
    enabled: true, // Optional, default: true
    debug: false // Optional, default: false
  }
})
  1. Get your Site ID from your KI Score dashboard

  2. That's it! 🎉 Bot tracking is now active on your site.

Configuration

Basic Configuration

export default defineNuxtConfig({
  kiBotTracker: {
    siteId: 'your-site-id',        // Required: Your KI Score site ID
    enabled: true,                  // Optional: Enable/disable tracking
    debug: false                    // Optional: Enable debug logging
  }
})

Advanced Configuration

export default defineNuxtConfig({
  kiBotTracker: {
    siteId: 'your-site-id',
    apiEndpoint: 'https://api.ki-score.com/track',
    enabled: true,
    debug: false,
    timeout: 2000,                  // Request timeout in milliseconds
    excludePaths: [                 // Paths to exclude from tracking
      '/api/',
      '/_nuxt/',
      '/favicon.ico',
      '/robots.txt'
    ]
  }
})

Environment Variables

You can also use environment variables:

# .env
NUXT_KI_BOT_TRACKER_SITE_ID=your-site-id
NUXT_KI_BOT_TRACKER_ENABLED=true
NUXT_KI_BOT_TRACKER_DEBUG=false

Usage

Automatic Tracking

Once installed, the module automatically tracks all page requests server-side. No additional code required!

Client-side Composable (Optional)

For advanced use cases, you can use the provided composable:

<template>
  <div>
    <button @click="trackCustomEvent">Track Custom Event</button>
    <p>Tracking enabled: {{ isEnabled }}</p>
    <p>Site ID: {{ siteId }}</p>
  </div>
</template>

<script setup>
const { 
  isEnabled, 
  siteId, 
  trackCustomEvent, 
  trackPageView 
} = useKiBotTracker()

const trackCustomEvent = () => {
  trackCustomEvent('button_click', {
    button_name: 'custom_button',
    page: 'home'
  })
}
</script>

Available Composable Methods

const {
  // State
  isEnabled,          // Computed<boolean> - Is tracking enabled
  siteId,            // Computed<string> - Your site ID
  isDebug,           // Computed<boolean> - Is debug mode on
  
  // Methods
  trackPageView,     // () => void - Manual page view tracking
  trackCustomEvent,  // (name: string, props?: object) => void
  trackEvent        // (data?: object) => void - Generic event tracking
} = useKiBotTracker()

How It Works

  1. Server Middleware: Intercepts all requests at the Nitro server level
  2. Bot Detection: Analyzes user agents, IPs, and request patterns
  3. Async Tracking: Sends data to KI Score API without blocking responses
  4. Real-time Analytics: View bot activity in your KI Score dashboard

Platform Compatibility

This module works on all Nuxt 3 hosting platforms:

  • Vercel (Edge Runtime)
  • Netlify (Netlify Functions)
  • Cloudflare Workers
  • Node.js servers
  • Static hosting (with API routes)

Development

Building the Module

# Install dependencies
yarn install

# Build for production
yarn build

# Build stub for development
yarn stub

Local Development

To build the module for local testing:

# Build the module
npm run build

# Or create a stub for development
npm run stub

Configuration Reference

| Option | Type | Default | Description | |--------|------|---------|-------------| | siteId | string | Required | Your KI Score site ID | | apiEndpoint | string | https://api.ki-score.com/track | API endpoint for tracking | | enabled | boolean | true | Enable/disable tracking | | debug | boolean | false | Enable debug logging | | timeout | number | 2000 | Request timeout (ms) | | excludePaths | string[] | ['/api/', '/_nuxt/', ...] | Paths to exclude |

Troubleshooting

Common Issues

Module not tracking:

  • Verify your siteId is correct
  • Check that enabled: true in config
  • Enable debug: true to see console logs

Build errors:

  • Ensure you're using Nuxt 3.0+
  • Check TypeScript configuration

Network requests failing:

  • Verify API endpoint is accessible
  • Check firewall/proxy settings

Debug Mode

Enable debug mode to see detailed logging:

kiBotTracker: {
  debug: true
}

This will log all tracking attempts to the console.

Support

License

MIT License - see LICENSE file for details.


Built with ❤️ for the Nuxt community by KI Score