JavaScript error tracking and monitoring library for Node.js and browser environments with telemetry, automatic error grouping, and real-time notifications
—
React Native specific functionality for person management and error tracking in React Native applications.
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'
});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');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 };setPerson() as soon as user authentication is availableclearPerson() when users log outsetPerson() again if person information changesThe person information is sent with error reports to help with debugging and user impact assessment. Be mindful of:
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');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 contextPerson 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