Skip to content

activerabbit-ai/activerabbit-javascript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

activerabbit

JavaScript/TypeScript client for ActiveRabbit.ai — application monitoring and error tracking. Framework-agnostic core SDK that works in Node.js, browsers, and any JavaScript runtime.

Features

  • Event trackingtrackEvent(name, properties, options)
  • Exception trackingtrackException(error, options) with stack traces, context, deduplication and PII scrubbing
  • Performance monitoringtrackPerformance, startTransaction / finishTransaction, measure / measureAsync
  • PII scrubbing — automatic filtering of passwords, emails, phone numbers, credit cards, etc.
  • Batching — events are collected and sent in configurable batches
  • Universal — works in Node.js, browsers, and any JS runtime with fetch support

Installation

npm install activerabbit
# or
yarn add activerabbit
pnpm add activerabbit

Quick Start

import { configure, trackEvent, trackException, captureException } from 'activerabbit';

configure({
  apiKey: process.env.ACTIVERABBIT_API_KEY,
  projectId: process.env.ACTIVERABBIT_PROJECT_ID,
  environment: 'production',
});

// Track events
trackEvent('page_view', { path: '/home' });

// Track exceptions
try {
  riskyOperation();
} catch (err) {
  captureException(err, { context: { screen: 'checkout' } });
}

Node.js

const { configure, trackEvent, trackException, flush, shutdown } = require('activerabbit');

configure({
  apiKey: process.env.ACTIVERABBIT_API_KEY,
  projectId: process.env.ACTIVERABBIT_PROJECT_ID,
  environment: 'production',
});

trackEvent('job_completed', { jobId: '123', duration_ms: 450 });

// Flush before process exit
process.on('beforeExit', async () => {
  await shutdown();
});

Browser

<script type="module">
  import { configure, trackEvent, captureException } from 'activerabbit';

  configure({
    apiKey: 'YOUR_API_KEY',
    environment: 'production',
  });

  trackEvent('page_view', { path: window.location.pathname });
</script>

Performance Monitoring

import { trackPerformance, startTransaction, finishTransaction, measure, measureAsync } from 'activerabbit';

// Direct tracking
trackPerformance('api_call', 150.5, { endpoint: '/users' });

// Transactions
const txId = startTransaction('checkout_flow');
// ... do work ...
finishTransaction(txId, { items: 3 });

// Measure sync/async functions
const result = measure('compute', {}, () => heavyComputation());
const data = await measureAsync('fetch_users', {}, () => fetch('/api/users'));

Configuration

import { configure } from 'activerabbit';

configure({
  apiKey: 'your-api-key',           // Required
  apiUrl: 'https://app.activerabbit.ai',
  projectId: 'your-project-id',
  environment: 'production',         // Default: 'development'

  // Batching
  batchSize: 100,
  flushInterval: 30,                 // seconds
  queueSize: 1000,

  // Features
  enablePerformanceMonitoring: true,
  enablePiiScrubbing: true,
  piiFields: ['password', 'email', 'ssn', 'credit_card'],
  ignoredExceptions: ['AbortError'],
  dedupeWindow: 300,                 // seconds

  // Release tracking
  release: '1.2.3',
  serverName: 'web-01',

  // Hooks
  beforeSendEvent: (event) => event,       // return null to drop
  beforeSendException: (exc) => exc,       // return null to drop
});

API Reference

Function Description
configure(config) Initialize the SDK with configuration
configured() Check if SDK is configured
getConfiguration() Get current configuration
trackEvent(name, properties?, options?) Track a custom event
trackException(error, options?) Track an exception
captureException(error, options?) Alias for trackException
trackPerformance(name, duration_ms, metadata?) Track performance metric
startTransaction(name, metadata?) Start a performance transaction
finishTransaction(id, metadata?) Finish a performance transaction
measure(name, metadata, fn) Measure sync function execution
measureAsync(name, metadata, fn) Measure async function execution
testConnection() Test connection to ActiveRabbit API
notifyRelease(params?) Notify about a new release
flush() Flush pending events
shutdown() Flush and shut down the SDK

API Endpoints

Compatible with the same endpoints as the Ruby gem (activerabbit-ai):

  • POST /api/v1/events — events
  • POST /api/v1/events/errors — exceptions
  • POST /api/v1/events/performance — performance metrics
  • POST /api/v1/events/batch — batch events
  • POST /api/v1/releases — release notifications
  • POST /api/v1/test/connection — connection test

Framework Integrations

This is the core SDK. Framework-specific packages are available separately:

Framework Package Status
React activerabbit-react Coming soon
React Native activerabbit-react-native Coming soon
Next.js activerabbit-nextjs Coming soon
Nest.js activerabbit-nestjs Coming soon
Vue activerabbit-vue Coming soon

See the examples/ directory for integration patterns.

License

MIT

About

Official Activerabbit SDKs for JavaScript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors