Capture Error Messages

Add custom errors into the LogRocket dashboard

Manually surface error messages in LogRocket

Use captureMessage() to manually report a message. This message will be treated as an error within LogRocket.

LogRocket.captureMessage('Something is wrong!', {
  tags: {
    // additional data to be grouped as "tags"
    subscription: 'Pro',
  },
  extra: {
    // additional arbitrary data associated with the event
    pageName: 'ProfileView',
  },
});

Add tags and extra fields to send extra metadata about the message. The values contained in the tags and extra objects must be scalar values (e.g., booleans, numbers, or strings). Tags and extra data will appear within the error in the LogRocket dashboard.

Automatically aggregate console errors in LogRocket

shouldAggregateConsoleErrors - Boolean

optional (default - false)

Use this option to control whether aggregated data about messages logged with console.error() or LogRocket.error() is surfaced as an error in LogRocket.

LogRocket.init(YOUR_APP_ID, {
  console: {
    shouldAggregateConsoleErrors: true,
  },
});