(win, data)
| 381 | * @return {Promise<undefined>} |
| 382 | */ |
| 383 | export function reportErrorToServerOrViewer(win, data) { |
| 384 | // Report the error to viewer if it has the capability. The data passed |
| 385 | // to the viewer is exactly the same as the data passed to the server |
| 386 | // below. |
| 387 | |
| 388 | if (data['pt'] && Math.random() < THROTTLE_STABLE_THRESHOLD) { |
| 389 | return Promise.resolve(); |
| 390 | } |
| 391 | |
| 392 | return maybeReportErrorToViewer(win, data).then((reportedErrorToViewer) => { |
| 393 | if (!reportedErrorToViewer) { |
| 394 | const xhr = new XMLHttpRequest(); |
| 395 | xhr.open('POST', chooseReportingUrl_(), true); |
| 396 | xhr.send(JSON.stringify(data)); |
| 397 | } |
| 398 | }); |
| 399 | } |
| 400 | |
| 401 | /** |
| 402 | * Passes the given error data to the viewer if the following criteria is met: |
no test coverage detected