-
Notifications
You must be signed in to change notification settings - Fork 211
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
add back lastError on the rollbar instance #318
Conversation
I admit I don't like the repetition here. Part of the problem is how things are currently constructed, another problem is that I can't do property level delegation in JS. One alternative would be to make |
src/browser/rollbar.js
Outdated
@@ -371,6 +399,14 @@ Rollbar.prototype._createItem = function(args) { | |||
return item; | |||
}; | |||
|
|||
Rollbar.prototype._sameAsLastError = function(item) { | |||
if (this.lastError === item.err && this.lastError) { |
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.
Should these two conditions be swapped? I imagine the second is more common than the first.
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.
Yeah, either way for the purposes of this, but yeah the second is probably more common
src/browser/rollbar.js
Outdated
@@ -87,6 +91,9 @@ Rollbar.log = function() { | |||
Rollbar.prototype.debug = function() { | |||
var item = this._createItem(arguments); | |||
var uuid = item.uuid; | |||
if (this._sameAsLastError(item)) { |
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.
If we transition to having all of the debug/info/warn/...
methods always call this.client.log(item, level)
we can abstract this code into the client.log()
method.
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.
Even if we did, the client would then have to track the lastError, but then lastError couldn't be a property on the top level instance, unless we returned lastError from client.log
or converted lastError to a function
add back lastError on the rollbar instance
lastError
used to be a property that was stored on the notifier instance, this was used for a very simple form of deduping of errors; add this functionality back.