You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+17Lines changed: 17 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -158,6 +158,23 @@ errorHandler.start({
158
158
159
159
where `targetUrl` is the url you'd like to send errors to and can be relative or absolute. This endpoint will need to support the [Report API endpoint](https://cloud.google.com/error-reporting/reference/rest/v1beta1/projects.events/report).
160
160
161
+
## Custom message dispatching
162
+
163
+
If you can't use HTTP Post requests for reporting your errors, or in need for some more complicated customizations, you may provide a custom function to handle the reporting.
164
+
165
+
The function will be called with a payload argument (the same one that would have been sent on the HTTP Post request) and should return a Promise.
166
+
167
+
```javascript
168
+
consterrorHandler=newStackdriverErrorReporter();
169
+
functionmyCustomFunction(payload) {
170
+
console.log("custom reporting function called with payload:", payload);
171
+
returnPromise.resolve();
172
+
}
173
+
errorHandler.start({
174
+
customReportingFunction: myCustomFunction,
175
+
});
176
+
```
177
+
161
178
## Best Practices
162
179
163
180
### Only reporting in the production environment with Webpack
Copy file name to clipboardExpand all lines: stackdriver-errors.js
+11-4Lines changed: 11 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -33,19 +33,21 @@ var StackdriverErrorReporter = function() {};
33
33
* @param {string} [config.context.user] - the user who caused or was affected by the error.
34
34
* @param {String} config.key - the API key to use to call the API.
35
35
* @param {String} config.projectId - the Google Cloud Platform project ID to report errors to.
36
+
* @param {Function} config.customReportingFunction - Custom function to be called with the error payload for reporting, instead of HTTP request. The function should return a Promise.
36
37
* @param {String} [config.service=web] - service identifier.
37
38
* @param {String} [config.version] - version identifier.
38
39
* @param {Boolean} [config.reportUncaughtExceptions=true] - Set to false to stop reporting unhandled exceptions.
39
40
* @param {Boolean} [config.disabled=false] - Set to true to not report errors when calling report(), this can be used when developping locally.
0 commit comments