Reputation: 7909
I have a client-side JavaScript application and I would like to report errors and exceptions to Stackdriver Error Reporting.
Upvotes: 8
Views: 3708
Reputation: 7909
Stackdriver Error Reporting can process errors coming from client-side JavaScript.
You need a Google Cloud Console project. Then enable the Stackdriver Error Reporting API and get an API key.
Reporting client-side error is done by calling the report API endpoint with an API key.
You can use this JavaScript module to normalize the exception stack traces, and send them to Stackdriver in the expected format: https://github.com/GoogleCloudPlatform/stackdriver-errors-js
Example:
<!-- Warning: This is an experimental library, do not use it on production environments -->
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/stackdriver-errors-concat.min.js"></script>
<script type="text/javascript">
window.addEventListener('DOMContentLoaded', function() {
var errorHandler = new StackdriverErrorReporter();
errorHandler.start({
key: '<my-api-key>',
projectId: '<my-project-id>'
});
});
</script>
Upvotes: 9