@neomanex/analytics-nuxt
@neomanex/analytics
Nuxt module for analytics tracking with SSR middleware, browser plugin, and server proxy.
Quick Start
pnpm add @neomanex/analytics
// nuxt.config.ts
export default defineNuxtConfig({
modules: ['@neomanex/analytics'],
analytics: {
apiUrl: 'https://analytics-api.neomanex.com',
source: 'my-app', // private, server-only; override with NUXT_ANALYTICS_SOURCE
},
})
source is required in every deployed environment. The /api/_analytics relay stamps it on every browser event; an empty source makes the relay answer 500.
Migrating from 1.x
2.0.0 moves event attribution fully server-side:
| Change | What to do |
|---|---|
source is no longer in the public runtimeConfig (runtimeConfig.public.analytics.source removed) |
Stop setting NUXT_PUBLIC_ANALYTICS_SOURCE; it is no longer read |
The relay ignores any source in the request body and stamps the private runtimeConfig.analytics.source |
Nothing; browser events no longer carry source |
| An empty private source makes the relay answer 500 and forward nothing | Set NUXT_ANALYTICS_SOURCE (or analytics.source in nuxt.config.ts) in every environment BEFORE bumping to 2.x |
Features
- Server-side tracking - Accurate analytics even with ad blockers
- Automatic events -
page.visit,page.view,session.start,page.leave - Manual tracking -
useAnalytics()composable for custom events - Correlation IDs - Links SSR and browser events across the session
- External referrer capture - Reads
document.referreronce at session landing and attaches it to every event asmetadata.external_referrer(avoids same-origin self-referrals from the analytics proxy) - Secure proxy - API URL never exposed to browser
Full Documentation
For complete documentation including installation, configuration, API reference, and guides:
Key sections:
- Introduction - What, why, and architecture
- Installation - Setup and configuration
- API Reference - Coming soon
- Guides - Coming soon
Development
npm install # Install dependencies
npm test # Run tests
npm run dev # Dev playground
npm run build # Build module
License
UNLICENSED
Related Packages
@neomanex/vitepress-docs-lint
Lint VitePress markdown for frontmatter YAML errors and unclosed elements, repor...
0
0
Version History
| Version | Released | License |
|---|---|---|
| 2.0.0 | Proprietary | |
| 1.4.5 | Proprietary | |
| 1.4.4 | Proprietary | |
| 1.3.2 | Proprietary | |
| 1.3.1 | Proprietary | |
| 1.3.0 | Proprietary | |
| 1.2.0 | Proprietary | |
| 1.1.0 | Proprietary | |
| 1.0.4 | Proprietary | |
| 1.0.3 | Proprietary | |
| 1.0.2 | Proprietary |