-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add Raven.showReportDialog (experimental) #456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,7 @@ | |
<head> | ||
<title>Scratch Disk</title> | ||
</head> | ||
<script src="../vendor/TraceKit/tracekit.js"></script> | ||
<script src="../src/raven.js"></script> | ||
<script src="../dist/raven.js"></script> | ||
<!-- <script src="scratch.min.js"></script> --> | ||
<script src="scratch.js" crossorigin></script> | ||
<script src="file.min.js" crossorigin></script> | ||
|
@@ -14,7 +13,8 @@ | |
//awesome | ||
Raven.config('http://50dbe04cd1224d439e9c49bf1d0464df@localhost:8000/1', { | ||
whitelistUrls: [ | ||
/localhost/ | ||
/localhost/, | ||
/127\.0\.0\.1/ | ||
], | ||
dataCallback: function(data) { | ||
console.log(data); | ||
|
@@ -25,7 +25,8 @@ | |
Raven.setUserContext({ | ||
email: '[email protected]', | ||
id: 5 | ||
}) | ||
}); | ||
|
||
|
||
</script> | ||
<body> | ||
|
@@ -36,6 +37,7 @@ | |
<button onclick="derp()">window.onerror</button> | ||
<button onclick="testOptions()">test options</button> | ||
<button onclick="throwString()">throw string</button> | ||
<button onclick="showDialog()">show dialog</button> | ||
|
||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,6 +107,8 @@ Raven.prototype = { | |
}); | ||
} | ||
|
||
this._dsn = dsn; | ||
|
||
// "Script error." is hard coded into browsers for errors that it can't read. | ||
// this is the result of a script being pulled in from an external domain and CORS. | ||
this._globalOptions.ignoreErrors.push(/^Script error\.?$/); | ||
|
@@ -123,12 +125,13 @@ Raven.prototype = { | |
|
||
// assemble the endpoint from the uri pieces | ||
this._globalServer = '//' + uri.host + | ||
(uri.port ? ':' + uri.port : '') + | ||
'/' + path + 'api/' + this._globalProject + '/store/'; | ||
(uri.port ? ':' + uri.port : ''); | ||
|
||
if (uri.protocol) { | ||
this._globalServer = uri.protocol + ':' + this._globalServer; | ||
} | ||
this._globalEndpoint = this._globalServer + | ||
'/' + path + 'api/' + this._globalProject + '/store/'; | ||
|
||
if (this._globalOptions.fetchContext) { | ||
TraceKit.remoteFetching = true; | ||
|
@@ -498,6 +501,35 @@ Raven.prototype = { | |
} | ||
}, | ||
|
||
showReportDialog: function (options) { | ||
if (!window.document) // doesn't work without a document (React native) | ||
return; | ||
|
||
options = options || {}; | ||
|
||
var lastEventId = options.eventId || this.lastEventId(); | ||
if (!lastEventId) | ||
return; | ||
|
||
var encode = encodeURIComponent; | ||
var qs = ''; | ||
qs += '?eventId=' + encode(lastEventId); | ||
qs += '&dsn=' + encode(this._dsn || ''); | ||
|
||
var user = this._globalContext.user; | ||
if (user) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. needs to be configurable via options There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why would the DSN differ from what's specified via There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because the DSN contains the project, and the eventID is bound to the project often server side project != client side project |
||
if (user.name) | ||
qs += '&name=' + encode(user.name); | ||
if (user.email) | ||
qs += '&email=' + encode(user.email); | ||
} | ||
|
||
var script = document.createElement('script'); | ||
script.async = true; | ||
script.src = this._globalServer + '/api/embed/error-page/' + qs; | ||
document.getElementsByTagName('body')[0].appendChild(script); | ||
}, | ||
|
||
/**** Private functions ****/ | ||
_ignoreNextOnError: function () { | ||
var self = this; | ||
|
@@ -933,8 +965,9 @@ Raven.prototype = { | |
|
||
if (!this.isSetup()) return; | ||
|
||
var url = this._globalEndpoint; | ||
(globalOptions.transport || this._makeRequest).call(this, { | ||
url: this._globalServer, | ||
url: url, | ||
auth: { | ||
sentry_version: '7', | ||
sentry_client: 'raven-js/' + this.VERSION, | ||
|
@@ -945,13 +978,13 @@ Raven.prototype = { | |
onSuccess: function success() { | ||
self._triggerEvent('success', { | ||
data: data, | ||
src: self._globalServer | ||
src: url | ||
}); | ||
}, | ||
onError: function failure() { | ||
self._triggerEvent('failure', { | ||
data: data, | ||
src: self._globalServer | ||
src: url | ||
}); | ||
} | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1013,7 +1013,7 @@ describe('globals', function() { | |
maxMessageLength: 100, | ||
release: 'abc123', | ||
}; | ||
Raven._globalServer = 'http://localhost/store/'; | ||
Raven._globalEndpoint = 'http://localhost/store/'; | ||
Raven._globalOptions = globalOptions; | ||
|
||
Raven._send({message: 'bar'}); | ||
|
@@ -1226,7 +1226,7 @@ describe('globals', function() { | |
|
||
it('should populate crossOrigin based on options', function() { | ||
Raven._makeImageRequest({ | ||
url: Raven._globalServer, | ||
url: Raven._globalEndpoint, | ||
auth: {lol: '1'}, | ||
data: {foo: 'bar'}, | ||
options: { | ||
|
@@ -1239,7 +1239,7 @@ describe('globals', function() { | |
|
||
it('should populate crossOrigin if empty string', function() { | ||
Raven._makeImageRequest({ | ||
url: Raven._globalServer, | ||
url: Raven._globalEndpoint, | ||
auth: {lol: '1'}, | ||
data: {foo: 'bar'}, | ||
options: { | ||
|
@@ -1252,7 +1252,7 @@ describe('globals', function() { | |
|
||
it('should not populate crossOrigin if falsey', function() { | ||
Raven._makeImageRequest({ | ||
url: Raven._globalServer, | ||
url: Raven._globalEndpoint, | ||
auth: {lol: '1'}, | ||
data: {foo: 'bar'}, | ||
options: { | ||
|
@@ -1487,7 +1487,7 @@ describe('Raven (public API)', function() { | |
Raven.afterLoad(); | ||
|
||
assert.equal(Raven._globalKey, 'random'); | ||
assert.equal(Raven._globalServer, 'http://some.other.server:80/api/2/store/'); | ||
assert.equal(Raven._globalEndpoint, 'http://some.other.server:80/api/2/store/'); | ||
|
||
assert.equal(Raven._globalOptions.some, 'config'); | ||
assert.equal(Raven._globalProject, '2'); | ||
|
@@ -1504,7 +1504,7 @@ describe('Raven (public API)', function() { | |
assert.equal(Raven, Raven.config(SENTRY_DSN, {foo: 'bar'}), 'it should return Raven'); | ||
|
||
assert.equal(Raven._globalKey, 'abc'); | ||
assert.equal(Raven._globalServer, 'http://example.com:80/api/2/store/'); | ||
assert.equal(Raven._globalEndpoint, 'http://example.com:80/api/2/store/'); | ||
assert.equal(Raven._globalOptions.foo, 'bar'); | ||
assert.equal(Raven._globalProject, '2'); | ||
assert.isTrue(Raven.isSetup()); | ||
|
@@ -1514,15 +1514,15 @@ describe('Raven (public API)', function() { | |
Raven.config('//[email protected]/2'); | ||
|
||
assert.equal(Raven._globalKey, 'abc'); | ||
assert.equal(Raven._globalServer, '//example.com/api/2/store/'); | ||
assert.equal(Raven._globalEndpoint, '//example.com/api/2/store/'); | ||
assert.equal(Raven._globalProject, '2'); | ||
assert.isTrue(Raven.isSetup()); | ||
}); | ||
|
||
it('should work should work at a non root path', function() { | ||
Raven.config('//[email protected]/sentry/2'); | ||
assert.equal(Raven._globalKey, 'abc'); | ||
assert.equal(Raven._globalServer, '//example.com/sentry/api/2/store/'); | ||
assert.equal(Raven._globalEndpoint, '//example.com/sentry/api/2/store/'); | ||
assert.equal(Raven._globalProject, '2'); | ||
assert.isTrue(Raven.isSetup()); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dsn needs to be configurable via options