LogRocket React Native Module
Getting started
$ npm install @logrocket/react-native --save
If you are using React Native < 0.60, link the package using react-native:
npx react-native link @logrocket/react-native
Add the maven repository to the repositories
block of build.gradle
:
maven { url "https://storage.googleapis.com/logrocket-maven/" }
Supported Features
- Identify and add traits for users
- Capture network requests/responses
- Capture messages logged to the console
- Redact views
LogRocket instruments the XmlHttpRequest and fetch APIs to capture network requests and responses.
For network sanitization, visit our docs: https://docs.logrocket.com/reference#network
LogRocket also automatically captures all messages logged to the console. For configuration options see
our docs: https://docs.logrocket.com/reference#console. Note that the shouldAggregateConsoleErrors
option is not currently supported and will be forced to false
.
To use the redaction feature, first set the testID
prop on any element you want redacted, e.g., <Foo testID='RedactionString' />
Then, when you call init
, send the testID
value as part of the redactionTags
configuration option.
Notes
- We currently only support React Native on Android
identify()
currently does not support only passing in user data and must be provided at least a uid
Usage
import LogRocket from '@logrocket/react-native';
LogRocket.init('YOUR_APP_ID', {
network: {
requestSanitizer: request => {
if (request.headers['x-auth-token']) {
request.headers['x-auth-token'] = '';
}
return request;
},
},
console: {
isEnabled: {
info: false,
},
},
redactionTags: ['RedactionString'],
});
LogRocket.getSessionURL((url) => {
console.log("LogRocket session URL: " + url);
})
LogRocket.identify('12345', {
name: 'Rog Locket',
email: 'roglocket@logrocket.com',
});