-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Trim URLs in breadcrumbs; add maxUrlLength
config opt
#906
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 all commits
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 |
---|---|---|
|
@@ -50,6 +50,9 @@ function Raven() { | |
crossOrigin: 'anonymous', | ||
collectWindowErrors: true, | ||
maxMessageLength: 0, | ||
|
||
// By default, truncates URL values to 250 chars | ||
maxUrlLength: 250, | ||
stackTraceLimit: 50, | ||
autoBreadcrumbs: true, | ||
sampleRate: 1 | ||
|
@@ -1320,9 +1323,46 @@ Raven.prototype = { | |
exception.value = truncate(exception.value, max); | ||
} | ||
|
||
var request = data.request; | ||
if (request) { | ||
if (request.url) { | ||
request.url = truncate(request.url, this._globalOptions.maxUrlLength); | ||
} | ||
if (request.Referer) { | ||
request.Referer = truncate(request.Referer, this._globalOptions.maxUrlLength); | ||
} | ||
} | ||
|
||
if (data.breadcrumbs && data.breadcrumbs.values) | ||
this._trimBreadcrumbs(data.breadcrumbs); | ||
|
||
return data; | ||
}, | ||
|
||
/** | ||
* Truncate breadcrumb values (right now just URLs) | ||
*/ | ||
_trimBreadcrumbs: function (breadcrumbs) { | ||
// known breadcrumb properties with urls | ||
// TODO: also consider arbitrary prop values that start with (https?)?:// | ||
var urlprops = {to: 1, from: 1, url: 1}, | ||
crumb, | ||
data; | ||
|
||
for (var i = 0; i < breadcrumbs.values.length; i++) { | ||
crumb = breadcrumbs.values[i]; | ||
if (!crumb.hasOwnProperty('data')) | ||
continue; | ||
|
||
data = crumb.data; | ||
for (var prop in urlprops) { | ||
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. @benvinegar late to the party here but this is slightly unsafe - if 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. Seems low risk, but yeah, I agree.
I was feeling fancy. Let's just go with array. |
||
if (data.hasOwnProperty(prop)) { | ||
data[prop] = truncate(data[prop], this._globalOptions.maxUrlLength); | ||
} | ||
} | ||
} | ||
}, | ||
|
||
_getHttpData: function() { | ||
if (!this._hasNavigator && !this._hasDocument) return; | ||
var httpData = {}; | ||
|
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.
possible improvement would be truncating differently based on how many total breadcrumbs there are (maxurl length = (12500 / breadcrumbs.values.length)) but definitely not a big deal
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.
this would make it harder to search for exact matches in breadcrumb urls though so shrug
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.
Nah we're not gonna get that fancy. I'd sooner drop the
maxBreadcrumbs
default to 50.