Vue.js — Lescopr SDK

Integrate the Lescopr SDK into your Vue.js application for automatic error capture and real-time monitoring, from installation to configuration.

Introduction

The Lescopr SDK integrates with Vue.js by initialising at the app entry point and hooking into Vue's global error handler.

Every uncaught component error, unhandled promise rejection and explicit log call is streamed in real-time to your Lescopr dashboard.

The package is available on npm and works with Vue 3+.

Requirements

  • Node.js >= 16.0.0
  • Vue >= 3.0
  • A valid LESCOPR_SDK_KEY and LESCOPR_API_KEY
  • Vite or any modern bundler

Installation

Install via your package manager:

Terminal
bash
npm install lescopr

Configuration

Initialise the SDK in your main.ts / main.js before mounting the app, then hook it into Vue's global error handler:

Store your keys as environment variables:

Available options:

  • sdkKey — Your Lescopr SDK key (required)
  • apiKey — Your Lescopr API key (required)
  • environment — development (default) or production
src/main.ts
typescript
import lescopr from 'lescopr';
import { createApp } from 'vue';
import App from './App.vue';

lescopr.init({
  sdkKey:      import.meta.env.VITE_LESCOPR_SDK_KEY,
  apiKey:      import.meta.env.VITE_LESCOPR_API_KEY,
  environment: import.meta.env.MODE,
});

const app = createApp(App);

app.config.errorHandler = (err, instance, info) => {
  lescopr.captureException(err as Error, { info });
};

app.mount('#app');
.env
dotenv
VITE_LESCOPR_SDK_KEY=lsk_xxxx
VITE_LESCOPR_API_KEY=lak_xxxx

Usage

Once initialised, all uncaught Vue component errors and unhandled promise rejections are captured automatically.

You can also log events and capture exceptions manually:

src/stores/cart.ts
typescript
import lescopr from 'lescopr';

async function checkout() {
  try {
    await submitOrder(cart.value);
    lescopr.log('info', 'Order placed');
  } catch (err) {
    lescopr.captureException(err as Error);
    throw err;
  }
}

Advanced

CLI initialisation

Run the CLI in the project root:

Environment variables

  • LESCOPR_SDK_KEY — SDK key
  • LESCOPR_API_KEY — API key
  • LESCOPR_ENVIRONMENT — development or production
  • LESCOPR_DEBUG=true — Verbose output to .lescopr.log
Terminal
bash
npx lescopr init --sdk-key YOUR_SDK_KEY