Error reporting for web apps
Before you begin, make sure that Apptics is integrated into your project by following the Integration Guide.
Global error tracking
To enable global error tracking in your web application, you can use the global error handler. This allows Apptics to automatically capture all unhandled errors that occur on your website.
CopiedApptics.enableGlobalErrorHandler(true/false);
Selective error tracking
If you prefer to track only specific errors, you can manually use the Apptics.trackError method to log those errors. This method provides flexibility to include additional data or context about the error.
CopiedApptics.trackError(error, jsonObject);
- error: The error object or message that you want to track.
- jsonObject: An optional object containing additional properties related to the error, such as user details, environment, or custom attributes.
Example
Copiedtry {
// Your code here
} catch (error) {
// Track the error using Apptics
Apptics.trackError(error, {
module: 'User Authentication',
severity: 'critical',
submoduleid: '12345'
});
}
Cross-origin Resource Sharing (CORS) policies for script resources:
- If you are loading the scripts or resources from other domains, ensure that those resources support the crossorigin attribute. This attribute helps with controlling how cross-origin requests are handled.
Copied<script src="https://example.com/script.js" crossorigin="anonymous"></script>