Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@

[![Sauce Test Status](https://saucelabs.com/browser-matrix/sentryio.svg)](https://saucelabs.com/u/sentryio)

## Reason for forking repository

* Raven JS uses XHR API's for pushing errors to sentry. Since service workers doesn't have an access to XHR APIs, therefore it cannot communicate with an outside world. We have modified makeRequest method so that we can use it with service workers.


## Requirements

The latest version of Raven.js is guaranteed to work with [hosted Sentry](https://sentry.io).
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/angular.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Raven.js 3.20.0 (e6baafa) | github.com/getsentry/raven-js */
/*! Raven.js 3.20.0 (c54bf6f) | github.com/getsentry/raven-js */

/*
* Includes TraceKit
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/angular.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugins/console.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Raven.js 3.20.0 (e6baafa) | github.com/getsentry/raven-js */
/*! Raven.js 3.20.0 (c54bf6f) | github.com/getsentry/raven-js */

/*
* Includes TraceKit
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/console.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugins/ember.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Raven.js 3.20.0 (e6baafa) | github.com/getsentry/raven-js */
/*! Raven.js 3.20.0 (c54bf6f) | github.com/getsentry/raven-js */

/*
* Includes TraceKit
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/ember.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugins/require.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Raven.js 3.20.0 (e6baafa) | github.com/getsentry/raven-js */
/*! Raven.js 3.20.0 (c54bf6f) | github.com/getsentry/raven-js */

/*
* Includes TraceKit
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/require.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugins/vue.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Raven.js 3.20.0 (e6baafa) | github.com/getsentry/raven-js */
/*! Raven.js 3.20.0 (c54bf6f) | github.com/getsentry/raven-js */

/*
* Includes TraceKit
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/vue.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 15 additions & 44 deletions dist/raven.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Raven.js 3.20.0 (e6baafa) | github.com/getsentry/raven-js */
/*! Raven.js 3.20.0 (c54bf6f) | github.com/getsentry/raven-js */

/*
* Includes TraceKit
Expand Down Expand Up @@ -1947,51 +1947,22 @@ Raven.prototype = {
},

_makeRequest: function(opts) {
var request = _window.XMLHttpRequest && new _window.XMLHttpRequest();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to check if fetch exists

if (!request) return;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if not, either return or request a polyfill


// if browser doesn't support CORS (e.g. IE7), we are out of luck
var hasCORS = 'withCredentials' in request || typeof XDomainRequest !== 'undefined';
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need to handle CORS issue


if (!hasCORS) return;

var url = opts.url;

if ('withCredentials' in request) {
request.onreadystatechange = function() {
if (request.readyState !== 4) {
return;
} else if (request.status === 200) {
opts.onSuccess && opts.onSuccess();
} else if (opts.onError) {
var err = new Error('Sentry error code: ' + request.status);
err.request = request;
opts.onError(err);
}
};
} else {
request = new XDomainRequest();
// xdomainrequest cannot go http -> https (or vice versa),
// so always use protocol relative
url = url.replace(/^https?:/, '');

// onreadystatechange not supported by XDomainRequest
if (opts.onSuccess) {
request.onload = opts.onSuccess;
}
if (opts.onError) {
request.onerror = function() {
var err = new Error('Sentry error code: XDomainRequest');
err.request = request;
opts.onError(err);
};
}
}

// NOTE: auth is intentionally sent as part of query string (NOT as custom
// HTTP header) so as to avoid preflight CORS requests
request.open('POST', url + '?' + urlencode(opts.auth));
request.send(stringify(opts.data));
/* eslint-disable dot-notation */
fetch(url + '?' + urlencode(opts.auth), {
method: 'POST',
body: stringify(opts.data)
})
.then(function(response) {
opts.onSuccess && opts.onSuccess();
})
.catch(function(response) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fetch only rejects in case of network error, scenarios like 404 or else would not trigger this

var err = new Error('Sentry error code: ' + response.status);
err.response = response;
opts.onError(err);
});
/* eslint-enable dot-notation */
},

_logDebug: function(level) {
Expand Down
4 changes: 2 additions & 2 deletions dist/raven.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/raven.min.js.map

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions dist/sri.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"@dist/raven.js": {
"hashes": {
"sha256": "jYF4nOaEwqkTJLU1wOR0i8npVgKRwlqzOTb6l64UnnQ=",
"sha512": "Ub9vUbOIAuiyF0yE7dQZTldjWEMiwU3LuATVQZEo8B8gbwS/Urbkx15y2ScrF/eVSx1VaVY5fLWXZb3iqIonww=="
"sha256": "IVeJrM2u2qn5TdABNivlAs5ZHhwNSjnlPqXF52NFWXE=",
"sha512": "yH+bmw43vFPXeFmyRrxpadOj3MQzHK4ym8QIh6mRKEd++4d3upNqJJNVypcfS+27AuxCSgIF11zZpiyxtCAsgw=="
},
"type": null,
"integrity": "sha256-jYF4nOaEwqkTJLU1wOR0i8npVgKRwlqzOTb6l64UnnQ= sha512-Ub9vUbOIAuiyF0yE7dQZTldjWEMiwU3LuATVQZEo8B8gbwS/Urbkx15y2ScrF/eVSx1VaVY5fLWXZb3iqIonww==",
"integrity": "sha256-IVeJrM2u2qn5TdABNivlAs5ZHhwNSjnlPqXF52NFWXE= sha512-yH+bmw43vFPXeFmyRrxpadOj3MQzHK4ym8QIh6mRKEd++4d3upNqJJNVypcfS+27AuxCSgIF11zZpiyxtCAsgw==",
"path": "dist/raven.js"
},
"@dist/raven.min.js": {
"hashes": {
"sha256": "T6xp+8yRcwkUpnayYg/Q4ghOycPeh+ERquJRxW408QU=",
"sha512": "J6EJyBgq/iIJKrjme9c/NGQOcEa63VZDLLP8Zx/D3KcZoS2H65CijyRzRMtozBZjGJlJOEbK/AjYzJH+zzgiyg=="
"sha256": "1oktImFY/vID/TOpBz36pYsYeu3U4r5B+cS7wJAAUhA=",
"sha512": "f1zGSrHh6eLj7gUIJdfO9p9Y9y5SXV7pf4GuRweDplVOw3f3DYk6Tc4GX/dGsEP+HKUKY5cPteLY13LkDxC6Yg=="
},
"type": null,
"integrity": "sha256-T6xp+8yRcwkUpnayYg/Q4ghOycPeh+ERquJRxW408QU= sha512-J6EJyBgq/iIJKrjme9c/NGQOcEa63VZDLLP8Zx/D3KcZoS2H65CijyRzRMtozBZjGJlJOEbK/AjYzJH+zzgiyg==",
"integrity": "sha256-1oktImFY/vID/TOpBz36pYsYeu3U4r5B+cS7wJAAUhA= sha512-f1zGSrHh6eLj7gUIJdfO9p9Y9y5SXV7pf4GuRweDplVOw3f3DYk6Tc4GX/dGsEP+HKUKY5cPteLY13LkDxC6Yg==",
"path": "dist/raven.min.js"
}
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,8 @@
"path": "./dist/raven.min.js",
"maxSize": "10 kB"
}
]
],
"dependencies": {
"whatwg-fetch": "^2.0.3"
}
}
Loading