Raygun Error Tracking and Real User Monitoring: A Complete Testing Guide

Raygun Error Tracking and Real User Monitoring: A Complete Testing Guide

Raygun occupies a specific niche in the error monitoring market: a platform that combines crash reporting, error tracking, and real user monitoring (RUM) in a single product, with a focus on application performance alongside error detection. Where most error tracking tools ask "what broke?", Raygun also asks "how slow is it, and for whom?"

This guide covers Raygun's capabilities, its real user monitoring features, and how to use both together for production quality validation.

Raygun's Three Core Products

Raygun bundles three capabilities that are often purchased separately:

Crash Reporting: Error and exception tracking for web and mobile applications. Captures stack traces, breadcrumbs, user context, and groups errors by root cause.

Real User Monitoring (RUM): Performance monitoring from actual user sessions — page load times, Core Web Vitals, API response times, and performance by geography, device, and browser.

APM (Application Performance Monitoring): Server-side performance profiling, available for .NET and Java applications specifically.

The combination of crash reporting and RUM in one platform is useful: you can correlate error rates with performance degradation, understanding whether users who experience errors also experience slow load times.

Crash Reporting Setup

JavaScript:

import rg4js from 'raygun4js';

rg4js('apiKey', 'YOUR_API_KEY');
rg4js('enableCrashReporting', true);
rg4js('enablePulse', true); // Enable RUM
rg4js('setVersion', '1.4.2');

// Set user identity
rg4js('setUser', {
  identifier: 'user@example.com',
  isAnonymous: false,
  email: 'user@example.com',
  firstName: 'Jane',
  fullName: 'Jane Smith',
  uuid: 'user-123',
});

// Add custom data to all errors
rg4js('withCustomData', {
  plan: 'professional',
  account_id: '456',
});

// Manual error reporting
try {
  riskyOperation();
} catch (e) {
  rg4js('send', {
    error: e,
    customData: { context: 'checkout flow', step: 'payment' },
    tags: ['checkout', 'payment'],
  });
}

Node.js:

const raygun = require('raygun');

const raygunClient = new raygun.Client().init({
  apiKey: 'YOUR_API_KEY',
  useSSL: true,
  batch: true, // Buffer sends for performance
  batchFrequency: 5000,
});

raygunClient.setVersion('1.4.2');

// Express error handler
app.use(raygunClient.expressHandler);

// Manual send
raygunClient.send(new Error('Something went wrong'), {
  custom_data: { user_id: 'user-123' },
  tags: ['payment', 'stripe'],
});

React:

import React from 'react';
import { RaygunErrorHandler } from 'raygun4js';

// Using React Error Boundary
class ErrorBoundary extends React.Component {
  componentDidCatch(error, errorInfo) {
    rg4js('send', {
      error: error,
      customData: { component_stack: errorInfo.componentStack },
      tags: ['react', 'error-boundary'],
    });
  }
  
  render() {
    if (this.state.hasError) {
      return <ErrorFallback />;
    }
    return this.props.children;
  }
}

Real User Monitoring

Raygun's RUM product, called Pulse, captures performance data from real user sessions. When you enable Pulse alongside crash reporting, every page load and API call is measured from the user's perspective.

Pulse captures:

Page load performance: Full page load time, Time to First Byte, First Contentful Paint, Largest Contentful Paint, and other Core Web Vitals.

Ajax/Fetch tracking: Every XHR and Fetch request is tracked with URL, duration, and status code.

Session timeline: A waterfall view of all resources and API calls for a page load.

Performance segmentation: Filter performance data by country, browser, device type, and OS. Useful for identifying performance regressions that only affect specific user segments.

// Enable RUM with crash reporting
rg4js('apiKey', 'YOUR_API_KEY');
rg4js('enableCrashReporting', true);
rg4js('enablePulse', true);

// Track custom timings (for operations that matter to your application)
rg4js('trackEvent', {
  type: 'customTiming',
  name: 'checkout_complete',
  duration: checkoutDuration, // in milliseconds
});

// Track virtual page views (for SPAs)
rg4js('trackEvent', {
  type: 'pageView',
  path: window.location.pathname,
});

Correlating Errors with Performance

The dashboard that combines crash reporting and RUM data reveals patterns that neither alone would show. Common useful correlations:

Slow page loads preceding errors: If users on slow connections are more likely to encounter JavaScript errors, the underlying issue might be a race condition triggered by slow resource loading — not an application logic bug per se.

Geography-specific issues: If errors cluster in a specific region AND RUM shows high latency from that region, the errors might be API timeout-related rather than logic bugs.

Browser-specific performance: If a particular browser shows both high error rates and poor performance, you might be hitting a known browser rendering issue or a missing polyfill.

In Raygun's dashboard, you can filter both the crash reporting and RUM data by the same dimensions (country, browser, device), making it straightforward to test these hypotheses.

Error Grouping and Noise Reduction

Raygun groups errors using stack trace fingerprinting and provides several tools for managing error noise:

Affected user counts: Each error group shows how many unique users are affected. An error that affects 1,000 users daily is more urgent than one that affects 1 user weekly, even if the occurrence count is similar.

Custom grouping: Override Raygun's automatic grouping with custom fingerprints for errors that should be treated as one issue:

rg4js('onBeforeSend', function(payload) {
  // Group all API timeout errors together regardless of endpoint
  if (payload.Details.Error.Message.includes('Network timeout')) {
    payload.Details.GroupingKey = 'network-timeout';
  }
  return payload;
});

Filtering/ignoring: Suppress errors from bots, browser extensions, or known third-party scripts:

rg4js('onBeforeSend', function(payload) {
  const message = payload.Details.Error.Message;
  
  // Ignore known browser extension errors
  if (message.includes('ResizeObserver loop limit exceeded')) {
    return false; // Return false to discard the error
  }
  
  // Ignore script errors from third-party domains
  if (payload.Details.Error.StackTrace &&
      payload.Details.Error.StackTrace[0] &&
      payload.Details.Error.StackTrace[0].FileName &&
      payload.Details.Error.StackTrace[0].FileName.includes('third-party.com')) {
    return false;
  }
  
  return payload;
});

Breadcrumbs in Raygun provide the event trail leading to a crash:

// Log navigation events
rg4js('recordBreadcrumb', {
  message: 'Navigated to checkout',
  category: 'navigation',
  level: 'info',
  customData: { cart_items: 3 },
});

// Log API calls
rg4js('recordBreadcrumb', {
  message: 'Payment API call initiated',
  category: 'api',
  level: 'debug',
  customData: {
    endpoint: '/api/payments',
    amount: 149.99,
  },
});

// Log user actions
rg4js('recordBreadcrumb', {
  message: 'User clicked Submit Payment',
  category: 'ui',
  level: 'info',
});

Raygun automatically captures some breadcrumbs (console logs, XHR requests), but manual breadcrumbs for domain-specific events give you the context needed to understand error sequences.

Deployment Tracking

Like other error monitoring tools, Raygun supports deployment tracking to correlate error rates with releases:

# Report deployment via API
curl -X POST https://app.raygun.com/deployments?authToken=YOUR_EXTERNAL_TOKEN \
  -H "Content-Type: application/json" \
  -d '{
    "version": "1.4.2",
    "ownerName": "deploy-bot",
    "emailAddress": "deploy@yourcompany.com",
    "comment": "'"$COMMIT_MESSAGE"'",
    "scmIdentifier": "'"$GIT_SHA"'",
    "scmType": "Git"
  }'

Deployment markers appear on Raygun's timeline charts, making it visually obvious when an error rate changed in relation to a deploy.

Tags for Test Environment Separation

Using tags to separate environments and build your filtering workflow:

// Set different configurations per environment
if (process.env.NODE_ENV === 'production') {
  rg4js('apiKey', 'PRODUCTION_API_KEY');
  rg4js('enableCrashReporting', true);
} else if (process.env.NODE_ENV === 'staging') {
  rg4js('apiKey', 'STAGING_API_KEY');
  rg4js('enableCrashReporting', true);
} else {
  // Disable in development to avoid polluting dashboards
  rg4js('enableCrashReporting', false);
}

// Tag all errors with build information
rg4js('withTags', ['build-' + process.env.BUILD_NUMBER]);

Staging errors go to a separate Raygun project or are tagged separately, keeping the production dashboard clean.

QA Integration Checklist

Before deployment:

  • Verify Raygun SDK installed in all application components
  • Separate API keys for staging and production
  • Error filtering configured to suppress known non-actionable errors
  • User identity tracking enabled
  • Source maps uploaded for minified JavaScript

For each release:

  • Report deployment to Raygun before or after deploying
  • Monitor error timeline for 30 minutes post-deploy for new error groups
  • Check RUM performance comparison vs. previous version
  • Review affected user counts for any new error groups

For performance validation:

  • Set performance budget thresholds (e.g., LCP under 2.5s)
  • Configure alerts when Core Web Vitals degrade
  • Segment performance data by key user cohorts (geography, plan tier)

Raygun's combined error and performance view is particularly useful for QA teams working on performance-sensitive applications — e-commerce sites, real-time dashboards, mobile web apps — where both crashes and slowdowns directly affect user experience and conversion.

Read more

Start now free