Error Tracking Setup

Capture JavaScript errors, unhandled promise rejections, and network failures.

Client-Side Error Tracking#

Add the monitoring script to capture browser errors, Web Vitals, and enable session replay:

<script
  defer
  src="https://justanalytics.app/monitor.js"
  data-site-id="YOUR_SITE_ID"
  data-capture-console="true"
  data-capture-network="true"
  data-capture-clicks="true"
  data-live-stream="true"
  data-environment="production"
  data-release="1.0.0"
></script>

Configuration Options#

| Attribute | Type | Default | Description | |-----------|------|---------|-------------| | data-site-id | string | Required | Your site identifier | | data-capture-console | boolean | false | Capture console.error/warn calls | | data-capture-network | boolean | false | Capture failed network requests | | data-capture-clicks | boolean | false | Record click events for replay | | data-capture-dom | boolean | false | Record DOM mutations for replay | | data-capture-events | boolean | false | Record custom events for replay | | data-capture-storage | boolean | false | Record storage changes | | data-live-stream | boolean | false | Enable real-time event streaming | | data-environment | string | production | Environment tag | | data-release | string | - | Release/version identifier |

What Gets Captured#

Uncaught Errors#

All uncaught JavaScript errors are automatically captured with full stack traces:

// This error is automatically captured
function processData(data) {
  return data.items.map(item => item.name); // TypeError if data is null
}

Unhandled Promise Rejections#

// Automatically captured
fetch('/api/data').then(res => res.json());
// If the fetch fails, the rejection is captured

Console Errors#

When data-capture-console="true", calls to console.error() and console.warn() are captured:

console.error('Payment processing failed', { orderId: '123' });
// Captured as an error event

Web Vitals#

The monitor script automatically tracks Core Web Vitals:

  • LCP (Largest Contentful Paint) -- loading performance
  • FID (First Input Delay) -- interactivity
  • CLS (Cumulative Layout Shift) -- visual stability
  • FCP (First Contentful Paint) -- perceived load speed
  • TTFB (Time to First Byte) -- server response time

Server-Side Error Tracking#

Use the Node.js SDK to capture server-side errors:

import JA from '@justanalyticsapp/node';

// Automatic: unhandled exceptions are captured
// Manual capture:
try {
  await riskyOperation();
} catch (error) {
  JA.captureException(error, {
    tags: { module: 'payments', severity: 'critical' },
    extra: { orderId: '123', userId: 'user_456' },
  });
}

// Capture a message
JA.captureMessage('Rate limit exceeded', 'warning', {
  tags: { endpoint: '/api/checkout' },
});

Session Replay#

When DOM capture is enabled, JustAnalytics records user interactions so you can replay exactly what happened before an error occurred. Session replay includes:

  • Mouse movements and clicks
  • Scroll position changes
  • Form interactions (inputs are masked for privacy)
  • DOM changes
  • Network requests
  • Console output

Replay recordings are available in the Error detail view.