Vanilla JavaScript setup
Use the Opslane SDK in any browser app — no framework required.
Install
Section titled “Install”npm install @opslane/sdkInitialize
Section titled “Initialize”As early as possible in your entry module:
import { init } from '@opslane/sdk';
init({ apiKey: 'your-opslane-ingest-key', endpoint: 'https://your-opslane-instance.example.com', // omit for hosted Opslane release: 'your-git-sha',});A namespace form is also exported if you prefer a single global-style object:
import { Opslane } from '@opslane/sdk';Opslane.init({ apiKey: '...' });init installs handlers for uncaught errors and unhandled promise rejections, and instruments console, fetch, and XMLHttpRequest as breadcrumb sources. It is idempotent — a second call is a no-op — and the SDK never throws into your code.
Privacy: Session recording is on by default since SDK 1.0.0; review replay privacy and masking before deploying.
Manual capture and user context
Section titled “Manual capture and user context”import { captureException, setUser, clearUser } from '@opslane/sdk';
try { riskyThing();} catch (err) { captureException(err instanceof Error ? err : new Error(String(err))); showFallbackUI();}
setUser({ id: 'user-123' }); // attach an identity to subsequent eventsclearUser(); // e.g. on logoutThrow real Error objects, not strings — string throws arrive without stack frames and are triaged as unfixable_no_app_frames (reason codes).
Cross-origin scripts
Section titled “Cross-origin scripts”If your bundle is served from a CDN on another origin, add crossorigin to the script tag (and CORS headers on the CDN) — otherwise the browser gives error handlers only "Script error." with no frames, and there is nothing to investigate.
<script src="https://cdn.example.com/app.js" crossorigin="anonymous"></script>Verify it works
Section titled “Verify it works”Run throw new Error('opslane vanilla smoke test') from your app (not the devtools console — extensions and console context can muddy origins). The event should appear in your dashboard within seconds.
- Upload source maps so minified stacks resolve
- All init options: SDK options reference