report(e, callback), where callback happens on both success or failure (passed XHR error on transaction failure).
In the event that the Stackdriver XHR succeeds with a non-200, e.g. 403 due to API key origin restriction, callback is invoked without parameters, so it looks like a success to the client. This is because XMLHttpRequest.onerror is not dependent on the HTTP status code: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequestEventTarget/onerror
Possibly this method could be changed to accept two callbacks, or else use a Promise. The error path should trigger if the HTTP response status is not a 200.
Current API signature:
report(e, callback)
, where callback happens on both success or failure (passed XHR error on transaction failure).In the event that the Stackdriver XHR succeeds with a non-200, e.g. 403 due to API key origin restriction, callback is invoked without parameters, so it looks like a success to the client. This is because
XMLHttpRequest.onerror
is not dependent on the HTTP status code: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequestEventTarget/onerrorRelevant code: https://github.com/GoogleCloudPlatform/stackdriver-errors-js/blob/f549a50048f424768d819eb36784817e86c13a2a/stackdriver-errors.js#L146
Possibly this method could be changed to accept two callbacks, or else use a Promise. The error path should trigger if the HTTP response status is not a 200.