Error Monitoring
The React Native SDK collects JavaScript errors and uncaught Promise exceptions.
JS Errors
The SDK uses ErrorUtils.setGlobalHandler to listen for JavaScript errors. You can view error information and error stacks on the RUM Pro > Log page. Promise Exceptions
The SDK uses onUnhandled to listen for uncaught Promise exceptions. You can view the exception information and stack traces on the RUM Pro > Log page. Page view
The React Native SDK for RUM Pro implements the page visit feature based on the React Navigation and React Native Navigation libraries. You can view exception information and stack traces on the RUM Pro > Log page. React Navigation
Use containerRef.addListener("state") to listen for route changes and obtain the page name based on getCurrentRoute().name.
React Native Navigation
Use Navigation.events().registerComponentDidAppearListener to listen for route changes and obtain the page name based on componentName.
Custom Reporting
The React Native SDK provides a rich set of custom reporting APIs for users.
Custom Log Reporting
info,error
These two methods are the primary means provided by the SDK for custom log reporting. Their usage is as follows:
Aegis.info('Report a log');
Aegis.error('Report an error log');
Aegis.info({
msg: 'xxx',
[key: string]: any,
});
Aegis.error({
msg: 'Error log message',
[key: string]: any,
});
You can view exception information and exception stacks on the RUM Pro > Log page. Custom Event Reporting
reportEvent
This method can be used to report custom events. The platform automatically aggregates metrics for reported events, such as PV and platform distribution. The reportEvent method supports two types of reporting parameters:
String type.
aegis.reportEvent('XXX request successful');
Object type. Users can upload custom fields.
Aegis.reportEvent({
name: 'XXX request successful',
[key: string]: any,
})
Note:
For custom event reporting, the default log type is {level: "info", type: "custom_event"}.
Custom Speed Test Reporting
Custom speed test allows you to report arbitrary values, which are then statistically processed and calculated on the server. Since the server cannot handle dirty data, it is recommended to validate and restrict values at the reporting end to prevent dirty data from affecting the overall results.
Currently, Aegis only supports numerical values in the range 0 to 60000. If your values exceed this range, it is recommended to transform them appropriately before reporting.
For high-frequency custom speed test reporting, use reportTime whenever possible. Using time and timeEnd for reporting can lead to reported value overwriting issues. For example, if aegis.time(aaa) is called, and then aegis.time(aaa) is called again before aegis.timeEnd(aaa) is invoked, the reported time will be the timeEnd timestamp minus the timestamp of the second time call.
reportTime
This method can be used to report custom speed tests. Example:
aegis.reportTime('onload', 1000);
Alternatively, if you need to use additional parameters, you can pass custom fields:
aegis.reportTime({
name: 'onload',
duration: 1000,
[key: string]: any,
});
time,timeEnd
These methods are also used for custom speed tests, suitable for measuring and reporting the duration between two points in time. Example:
aegis.time('complexOperation');
aegis.timeEnd('complexOperation');