Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

LaraBug

LaraBug JavaScript SDK

Official JavaScript SDK for larabug.com. Ships frontend error tracking for vanilla JavaScript, TypeScript, React, Vue 3, and Inertia.js.

License @larabug/core @larabug/browser @larabug/react @larabug/vue @larabug/inertia @larabug/vite @larabug/sourcemaps

Installation

Install the package that matches your stack.

# Vanilla JavaScript / TypeScript
npm install @larabug/browser

# React
npm install @larabug/react

# Vue 3
npm install @larabug/vue

# Inertia.js (use alongside @larabug/vue or @larabug/react)
npm install @larabug/inertia

# Source maps, for Vite builds
npm install --save-dev @larabug/vite

# Source maps, for any other bundler
npm install --save-dev @larabug/sourcemaps

Getting started

import * as LaraBug from '@larabug/browser';

LaraBug.init({
  ingest_key: 'lbi_...', // from your project settings at larabug.com
  environment: 'production',
});

The ingest key is write only and scoped to a single project, which makes it the only credential that is safe to put in a page your visitors can read. The dsn in your project settings carries the same key, so you can pass that instead. The older account login_key together with project_key keeps working for existing installs, but it is account wide and does not belong in browser JavaScript.

Initialising never throws. A client without usable credentials warns once, stays inert and leaves the rest of the page running, which matters because the SDK loads before the code it watches. Ask the client when you need to know:

const client = LaraBug.init({ ingest_key: window.LB_INGEST_KEY });

client.isActive();  // false when nothing will be reported
client.getStatus(); // { active: false, reason: 'no usable credentials. ...' }

Source maps

Production bundles are minified, so a raw stack trace points at line 1, column 48213 of app-D4wpJuT4.js. Upload your source maps and LaraBug shows the original file, line and function instead.

With Vite, add @larabug/vite to your config and set LARABUG_KEY in .env.

// vite.config.js
import laravel from 'laravel-vite-plugin';
import larabug from '@larabug/vite';

export default {
  plugins: [laravel({ input: ['resources/js/app.js'] }), larabug()],
};

Every vite build then uploads its maps under the current git commit, removes them from public/build, and puts the commit in your bundle. The SDK sends it as the release of every error, so LaraBug knows which maps belong to which error.

For webpack, Laravel Mix or any other bundler, run the uploader from @larabug/sourcemaps after the build.

npx @larabug/sourcemaps upload --release "$(git rev-parse HEAD)" --dir public/js --url-prefix "~/js"

That README shows how to inject the release with webpack's DefinePlugin.

Documentation

Full documentation (configuration, framework integrations, data filtering, source maps) lives at larabug.com/docs.

Related

License

The LaraBug JavaScript SDK is open source software licensed under the MIT license.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages