Package Exports
- @logtail/browser
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@logtail/browser) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
🪵 Logtail - Browser logging
New to Logtail? Here's a low-down on logging in JavaScript.
@logtail/browser
This NPM library is for logging in the browser.
Here's how to get started:
Installation
Using Webpack / Rollup
If you're using a module bundler like Webpack or Rollup, you can install the package directly from NPM:
npm i @logtail/browserIn ES6/Typescript, import the Logtail class:
import { Logtail } from "@logtail/browser";For CommonJS, require the package:
const { Logtail } = require("@logtail/browser");Via a <script> tag
If you're not using a Node.js module bundler, you can log in any client-side app by dropping in a <script> tag:
<script src="https://unpkg.com/@logtail/browser@0.31.0/dist/umd/logtail.js"></script>This will place the Logtail class on window.Logtail.
Creating a client
You can instantiate the client in the same way, whether you use a module bundler or the <script> tag method.
Simply pass your Logtail.com organization API + source keys as parameters to a new Logtail instance (you can grab both from the Logtail.com console):
const logtail = new Logtail("logtail-access-token");Documentation
This browser library extends @logtail/core, which provides a simple API for logging, adding middleware and more.
Visit the relevant readme section for more info/how-to: