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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@m-tracker/vue-plugin

v0.3.0

Published

Vue 3 plugin for M-Tracker error monitoring

Readme

@m-tracker/vue-plugin

npm version license

Vue 3 plugin for automatic error tracking. Captures Vue errors, unhandled rejections, and runtime exceptions, then sends them to your M-Tracker BFF backend.

Installation

npm install @m-tracker/vue-plugin
# or
pnpm add @m-tracker/vue-plugin
# or
yarn add @m-tracker/vue-plugin

Quick Start

import { createApp } from 'vue'
import App from './App.vue'
import MTracker from '@m-tracker/vue-plugin'

const app = createApp(App)

app.use(MTracker, {
  apiKey: 'mt_a1b2c3d4e5f67890abcdef1234567890abcdef12',
  dsn: 'https://your-m-tracker-server.com/api/errors',
})

app.mount('#app')

That's it — all errors are automatically captured and sent to your backend.


Options

interface PluginOptions {
  apiKey: string
  dsn: string
  capture?: {
    unhandled?: boolean      // default: true
    vueErrors?: boolean      // default: true
    consoleErrors?: boolean  // default: false
  }
  beforeSend?: (error: ErrorPayload) => ErrorPayload | null
}

| Option | Required | Default | Description | |--------|----------|---------|-------------| | apiKey | Yes | — | Project API key from your M-Tracker backend | | dsn | Yes | — | Backend endpoint URL (e.g. https://your-server.com/api/errors) | | capture.unhandled | No | true | Capture window.onerror and unhandledrejection events | | capture.vueErrors | No | true | Capture Vue component errors via app.config.errorHandler | | capture.consoleErrors | No | false | Capture console.error calls | | beforeSend | No | — | Hook to modify or suppress an error before it is sent |


Examples

With environment variables

app.use(MTracker, {
  apiKey: import.meta.env.VITE_MT_API_KEY,
  dsn: import.meta.env.VITE_MT_DSN,
})

Enrich errors with metadata

app.use(MTracker, {
  apiKey: import.meta.env.VITE_MT_API_KEY,
  dsn: import.meta.env.VITE_MT_DSN,
  beforeSend: (error) => {
    error.metadata = {
      ...error.metadata,
      appVersion: import.meta.env.VITE_APP_VERSION,
      environment: import.meta.env.MODE,
      userId: currentUser?.id ?? 'anonymous',
    }
    return error
  },
})

Filter out noisy errors

app.use(MTracker, {
  apiKey: '...',
  dsn: '...',
  beforeSend: (error) => {
    if (error.message.includes('ResizeObserver loop')) {
      return null // suppress — not sent
    }
    return error
  },
})

Disable specific capture channels

app.use(MTracker, {
  apiKey: '...',
  dsn: '...',
  capture: {
    unhandled: true,
    vueErrors: false,    // disable Vue error handler
  },
})

How It Works

The plugin registers up to three error handlers depending on your capture config:

| Handler | Errors captured | Extra metadata | |---------|----------------|----------------| | window.addEventListener('error') | JS runtime errors | lineno, colno | | window.addEventListener('unhandledrejection') | Unhandled promise rejections | — | | app.config.errorHandler | Vue component errors | lifecycle info string |

Each error is serialized into an ErrorPayload and sent via POST to your DSN with the x-api-key header.

interface ErrorPayload {
  message: string
  stack?: string
  url?: string
  userAgent?: string
  metadata?: Record<string, unknown>
}

Getting an API Key

  1. Start your M-Tracker BFF server
  2. Create a project:
curl -X POST https://your-server.com/api/projects \
  -H "Content-Type: application/json" \
  -d '{"name": "My App", "slug": "my-app"}'
  1. Copy the apiKey from the response and use it in the plugin options.

Manual Error Capture

Use captureError to send an error manually — useful for testing your integration or capturing errors in non-Vue code (e.g. API calls, utility functions).

import MTracker, { captureError } from '@m-tracker/vue-plugin'

// Install the plugin first
app.use(MTracker, { apiKey: '...', dsn: '...' })

// Then call captureError anywhere in your app
captureError(new Error('Payment failed'))

// Or pass a string
captureError('Payment failed')

// Attach extra metadata
captureError('Payment failed', {
  orderId: '123',
  userId: currentUser.id,
})

Signature

function captureError(
  error: Error | string,
  metadata?: Record<string, unknown>
): void

Note: captureError must be called after app.use(MTrackerPlugin). Calling it before installation logs a warning and does nothing.

Testing your integration

A quick way to verify errors are reaching your backend:

// In your browser console or a test component
import { captureError } from '@m-tracker/vue-plugin'

captureError('test — integration check', { source: 'manual' })

Then check your M-Tracker dashboard to confirm the event arrived.


TypeScript

The plugin ships with full TypeScript declarations. You can import types directly:

import type { PluginOptions, ErrorPayload } from '@m-tracker/vue-plugin'

License

MIT