Nuxt.js Integration
Spyglasses integrates seamlessly with Nuxt.js applications through our official module. Follow these steps to set up Spyglasses in your Nuxt project.
Installation
-
Install the package:
with yarn:
with pnpm:
-
Add your API key: Create or update your
.env
file with your Spyglasses API key:
Configuration
Add the Spyglasses module to your Nuxt configuration:
Basic Configuration
The minimal configuration requires only your API key:
Advanced Configuration
For more control, you can configure additional options:
Configuration Options
The module accepts these configuration options:
Option | Type | Required | Description | Default |
---|---|---|---|---|
apiKey | string | Yes | Your Spyglasses API key | - |
debug | boolean | No | Enable debug logging | false |
collectorEndpoint | string | No | Custom collector endpoint | Spyglasses default |
excludePaths | string[] | No | Paths to exclude from monitoring | [] |
Docker
If you deploy with Docker, set your API key in your Dockerfile or docker-compose:
Dockerfile:
docker-compose:
Server Middleware
The Spyglasses module automatically registers server middleware to monitor all incoming requests. This middleware:
- Detects AI and bot traffic using user agents
- Identifies AI referrers from platforms like ChatGPT
- Logs analytics data to your Spyglasses dashboard
- Works automatically with Nuxt's server routes and API endpoints
Deployment
When deploying your Nuxt.js application, make sure to add your Spyglasses API key to your environment variables:
Vercel
- Go to Project Settings > Environment Variables
- Add
SPYGLASSES_API_KEY
- Deploy to apply changes
Netlify
- Go to Site Settings > Build & Deploy > Environment
- Add
SPYGLASSES_API_KEY
- Trigger a new deploy
Cloudflare Pages
- Go to Workers & Pages > Your Project > Settings > Environment Variables
- Add
SPYGLASSES_API_KEY
- Redeploy your application
AWS Amplify
- Go to App Settings > Environment Variables
- Add
SPYGLASSES_API_KEY
- Redeploy your application
DigitalOcean
- Go to App Settings > Environment Variables
- Add
SPYGLASSES_API_KEY
- Trigger a new deployment
Verifying Installation
After deploying your application with Spyglasses, you can verify the installation by checking your Spyglasses dashboard. If everything is set up correctly, you should start seeing data from your Nuxt.js application.
Troubleshooting
API Key Not Found
- Verify environment variable is set
- Check for typos in variable name
- Ensure deployment includes environment variables
Module Not Loading
- Confirm
@spyglasses/nuxt
is in your modules array - Verify Nuxt version (3.0.0 or higher required)
- Check for module registration errors in console
No Data in Dashboard
- Verify your API key is correct
- Check that the module is properly configured
- Ensure your deployment includes the environment variables
- Check server logs for any errors
Performance Issues
- Enable debug mode to check for errors
- Verify excludePaths configuration
- Check network latency to collector endpoint
If you're not seeing data in your Spyglasses dashboard:
- Verify your API key is correct
- Check that the module is properly configured
- Ensure your deployment includes the environment variables
- Check your server console for any errors
Need help? Contact support@spyglasses.io