Documentation
Nuxt
Nuxt is Vue-based, so use @telemetry-tracker/core directly (there is no telemetry-nuxt package). Add a client plugin to init and a global middleware to track page views. After init(), uncaught errors and unhandled promise rejections in the browser are reported automatically, and installVueErrorHandler() reports errors thrown inside components.
Install
pnpm add @telemetry-tracker/core
# or
npm install @telemetry-tracker/coreRuntime config
In nuxt.config.ts expose the ingest URL, app name, and API key:
export default defineNuxtConfig({
runtimeConfig: {
public: {
telemetryIngestUrl: process.env.NUXT_PUBLIC_TELEMETRY_INGEST_URL || "https://your-api.example.com",
telemetryApp: process.env.NUXT_PUBLIC_TELEMETRY_APP || "my-nuxt-app",
telemetryApiKey: process.env.NUXT_PUBLIC_TELEMETRY_API_KEY || "",
},
},
});Where the files go
Nuxt 4 reads plugins and route middleware from the app/ source directory: app/plugins/ and app/middleware/. Files in a root plugins/ or middleware/ folder are ignored, so nothing is sent. On Nuxt 3 (or Nuxt 4 with srcDir: "."), use plugins/ and middleware/ at the project root instead. The file contents are the same.
Plugin (client-only)
Create app/plugins/telemetry.client.ts (Nuxt 3: plugins/telemetry.client.ts):
import { init, installVueErrorHandler } from "@telemetry-tracker/core";
export default defineNuxtPlugin((nuxtApp) => {
const config = useRuntimeConfig();
init({
ingestUrl: config.public.telemetryIngestUrl as string,
app: config.public.telemetryApp as string,
apiKey: config.public.telemetryApiKey as string,
platform: "web",
environment: import.meta.dev ? "development" : "production",
});
// Report errors thrown inside components (Vue catches them before window.onerror).
installVueErrorHandler(nuxtApp.vueApp);
});Page tracking
Create app/middleware/telemetry.global.ts (Nuxt 3: middleware/telemetry.global.ts) to send a screen event on each route:
import { screen } from "@telemetry-tracker/core";
export default defineNuxtRouteMiddleware((to) => {
if (import.meta.client) {
screen(to.path || "/");
}
});Custom events and errors
import { trackEvent, trackError } from "@telemetry-tracker/core";
trackEvent("button_click", { id: "submit" });
trackError(new Error("Something broke"), { page: "/checkout" });Core registers window.onerror and unhandledrejection after init(), so uncaught errors and promise rejections are reported automatically; component errors are reported by installVueErrorHandler() (core 1.6.0+). Use trackError() in try/catch for extra context.
Optional: identify user
import { identify } from "@telemetry-tracker/core";
identify(user.id); // after login
identify(null); // on logout