CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-rollbar

JavaScript error tracking and monitoring library for Node.js and browser environments with telemetry, automatic error grouping, and real-time notifications

Pending
Overview
Eval results
Files

react-native-integration.mddocs/

React Native Integration

React Native specific functionality for person management and error tracking in React Native applications.

Capabilities

Set Person

Associate a person with error reports and telemetry events.

/**
 * Set the person associated with error reports
 * @param personInfo - Person information to associate with errors
 */
function setPerson(personInfo: PersonInfo): void;

interface PersonInfo {
  id: string | number | null;
  username?: string;
  email?: string;
  [property: string]: any;
}

Usage Examples:

// Set basic person information
rollbar.setPerson({
  id: '12345',
  username: 'alice',
  email: 'alice@example.com'
});

// Set person with custom fields
rollbar.setPerson({
  id: 67890,
  username: 'bob',
  email: 'bob@company.com',
  role: 'admin',
  department: 'engineering',
  custom_field: 'value'
});

// Set person with minimal info
rollbar.setPerson({
  id: 'anonymous_user_123'
});

Clear Person

Remove person association from future error reports.

/**
 * Clear the person associated with error reports
 */
function clearPerson(): void;

Usage Example:

// Clear person information (e.g., on logout)
rollbar.clearPerson();

// Subsequent errors will not be associated with any person
rollbar.error('This error has no person associated');

React Native Setup Example

import Rollbar from 'rollbar';

// Initialize Rollbar for React Native
const rollbar = new Rollbar({
  accessToken: 'YOUR_POST_CLIENT_ITEM_ACCESS_TOKEN',
  environment: 'production',
  captureUncaught: true,
  captureUnhandledRejections: true
});

// Set person information after login
function onUserLogin(user) {
  rollbar.setPerson({
    id: user.id,
    username: user.username,
    email: user.email,
    role: user.role,
    subscription_tier: user.subscriptionTier
  });
  
  rollbar.info('User logged in', { userId: user.id });
}

// Clear person information on logout
function onUserLogout() {
  rollbar.info('User logging out');
  rollbar.clearPerson();
}

// Error handling with person context
function processPayment(paymentData) {
  try {
    // Payment processing logic
    return processPaymentAPI(paymentData);
  } catch (error) {
    // Error will be associated with current person
    rollbar.error('Payment processing failed', {
      paymentAmount: paymentData.amount,
      paymentMethod: paymentData.method
    });
    throw error;
  }
}

export { rollbar, onUserLogin, onUserLogout };

Person Information Guidelines

Required Fields

  • id: Unique identifier for the person (string or number)

Optional Fields

  • username: Display name or username
  • email: Email address for notifications
  • [custom fields]: Any additional custom properties

Best Practices

  1. Set person early: Call setPerson() as soon as user authentication is available
  2. Clear on logout: Always call clearPerson() when users log out
  3. Update on changes: Call setPerson() again if person information changes
  4. Privacy considerations: Only include necessary information, avoid sensitive data
  5. Custom fields: Use custom fields for application-specific context like user roles, subscription tiers, etc.

Person Data Privacy

The person information is sent with error reports to help with debugging and user impact assessment. Be mindful of:

  • PII Data: Consider your privacy policy when including email addresses or other personally identifiable information
  • Data Retention: Person data follows Rollbar's data retention policies
  • Access Control: Ensure appropriate team access controls are in place for person data

Integration with Other Features

Error Context

When a person is set, all subsequent error reports will include the person information:

rollbar.setPerson({ id: '123', username: 'alice' });

// This error will be associated with alice
rollbar.error('Database connection failed');

Telemetry Events

Person information is also included with telemetry events:

rollbar.setPerson({ id: '123', role: 'admin' });

rollbar.captureEvent({
  type: 'user_action',
  action: 'admin_panel_access'
}, 'info');
// Event will include person context

Custom Data

Person information can be supplemented with custom data in individual error reports:

rollbar.setPerson({ id: '123', username: 'alice' });

rollbar.error('Operation failed', {
  // This additional context is added to the person info
  currentPage: '/dashboard',
  feature: 'data-export'
});

Install with Tessl CLI

npx tessl i tessl/npm-rollbar

docs

browser-integration.md

configuration.md

core-logging.md

index.md

react-native-integration.md

server-integration.md

telemetry.md

tile.json