Title: Use fetch if XMLHttpRequest not available · Issue #930 · getsentry/sentry-javascript · GitHub
Open Graph Title: Use fetch if XMLHttpRequest not available · Issue #930 · getsentry/sentry-javascript
X Title: Use fetch if XMLHttpRequest not available · Issue #930 · getsentry/sentry-javascript
Description: Do you want to request a feature or report a bug? Feature What is the current behavior? When attempting to use raven-js in a ServiceWorker, Raven._makeRequest will fail because XMLHttpRequest is not available to SW environments. What is ...
Open Graph Description: Do you want to request a feature or report a bug? Feature What is the current behavior? When attempting to use raven-js in a ServiceWorker, Raven._makeRequest will fail because XMLHttpRequest is no...
X Description: Do you want to request a feature or report a bug? Feature What is the current behavior? When attempting to use raven-js in a ServiceWorker, Raven._makeRequest will fail because XMLHttpRequest is no...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/930
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Use fetch if XMLHttpRequest not available","articleBody":"**Do you want to request a *feature* or report a *bug*?**\r\nFeature\r\n\r\n**What is the current behavior?**\r\nWhen attempting to use raven-js in a ServiceWorker, `Raven._makeRequest` will fail because `XMLHttpRequest` is not available to SW environments.\r\n\r\n**What is the expected behavior?**\r\nUse the `fetch` api when available.\r\n\r\nWhich versions of Raven.js, and which browser and OS are affected by this issue?\r\nAll\r\n\r\nDid this work in previous versions of Raven.js? \r\nNo \r\n\r\nAre you using the CDN (http://ravenjs.com)? \r\nNo \r\n\r\nAre you using [hosted Sentry](https://sentry.io) or on-premises? \r\nHosted\r\n\r\nI put in a really quick hack into our /sw.js to make it work:\r\n\r\n```js\r\nRaven._makeRequest = (opts) => {\r\n const auth = Object.keys(opts.auth).map((key) => `${key}=${opts.auth[key]}`).join('&');\r\n const headers = new Headers();\r\n headers.append('origin', self.location.origin);\r\n const req = new Request(`${opts.url}?${auth}`, {\r\n method: 'POST',\r\n body: new Blob([ JSON.stringify({ ...opts.data, ...opts.auth }, null, 2)], { type: 'application/json' }),\r\n mode: 'cors',\r\n credentials: 'omit',\r\n headers,\r\n referrer: self.location.origin\r\n });\r\n\r\n fetch(req);\r\n}\r\n```","author":{"url":"https://github.com/paularmstrong","@type":"Person","name":"paularmstrong"},"datePublished":"2017-04-12T18:38:11Z","url":"https://github.com/getsentry/sentry-javascript/issues/930"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:74cd51d8-85b3-a4b4-4288-5ca64c9cf201 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DC14:2815D1:44DD:5EA2:6B0460C5 |
| html-safe-nonce | 825fb2d2b219e9e891eb7ad02b4d12c7ca0c1e0947e9dff7c2fb5e3cead1c8b8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQzE0OjI4MTVEMTo0NEREOjVFQTI6NkIwNDYwQzUiLCJ2aXNpdG9yX2lkIjoiODcwMzE2ODU4MDQ2NjAwODI2MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 1b25332b8419c88304ee706a7a5f45dbf22b92e18ec3f8ba430372adef4d53f3 |
| hovercard-subject-tag | issue:221353066 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/930/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5155a5c5ce0de020232845eb015137c2cbb7d583952a86c1a99d0b936e7cfcc7/getsentry/sentry-javascript/issues/930 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5155a5c5ce0de020232845eb015137c2cbb7d583952a86c1a99d0b936e7cfcc7/getsentry/sentry-javascript/issues/930 |
| og:image:alt | Do you want to request a feature or report a bug? Feature What is the current behavior? When attempting to use raven-js in a ServiceWorker, Raven._makeRequest will fail because XMLHttpRequest is no... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | paularmstrong |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2d58451b4bcb73c33c67bfb6b28fb75fe6d5e279daf9b560fa4fd832f3d8c9a6 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 03e114520787ad27289207f153520ef97461127c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width