JavaScript SDK

Client-side SDK for error tracking in web/browser applications.

Browser ES6+

Installation

npm install @hymns/alertiqo

Basic Setup

import Alertiqo from '@hymns/alertiqo';

const alertiqo = new Alertiqo({
  apiKey: 'your-api-key',
  endpoint: 'https://alertiqo.io',
  environment: 'production',
  release: '1.0.0',
});

alertiqo.init();

Usage

Capture Exceptions

try {
  throw new Error('Something went wrong');
} catch (error) {
  alertiqo.captureException(error);
}

Capture Messages

alertiqo.captureMessage('User completed checkout', 'info');

Add Breadcrumbs

alertiqo.addBreadcrumb({
  message: 'User clicked button',
  category: 'user-action',
  level: 'info',
  data: { buttonId: 'submit-btn' }
});

Set User Context

alertiqo.setUser({
  id: '12345',
  email: '[email protected]',
  username: 'johndoe'
});

Set Tags

alertiqo.setTag('page', 'checkout');
alertiqo.setTags({ 
  feature: 'payments',
  version: '2.1.0'
});

Configuration Options

const alertiqo = new Alertiqo({
  // Required
  apiKey: 'your-api-key',
  endpoint: 'https://alertiqo.io',
  
  // Optional
  environment: 'production',  // Default: 'production'
  release: '1.0.0',           // App version
  tags: { app: 'myapp' },     // Default tags for all errors
  
  // Filter/modify errors before sending
  beforeSend: (report) => {
    // Return null to skip sending
    // Return modified report to send
    return report;
  }
});

API Reference

Method Description
init() Initialize error handlers
captureException(error, additionalData?) Capture an exception
captureMessage(message, level?) Capture a message
addBreadcrumb(breadcrumb) Add a breadcrumb
setUser(user) Set user context
setTag(key, value) Set a single tag
setTags(tags) Set multiple tags

Automatic Context

The JavaScript SDK automatically captures:

  • Current URL
  • User Agent
  • Browser information
  • Operating system
  • Screen resolution