Skip to content
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

Merged
merged 3 commits into from
Jun 29, 2017
Merged

add back lastError on the rollbar instance #318

merged 3 commits into from
Jun 29, 2017

Conversation

rokob
Copy link
Contributor

@rokob rokob commented Jun 20, 2017

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.

@rokob
Copy link
Contributor Author

rokob commented Jun 20, 2017

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 lastError a function instead of a property. Then I could push things down to the shared client, do the deduping there and just expose the lastError function from that shared client as a method on the browser/server rollbar instances.

@@ -371,6 +399,14 @@ Rollbar.prototype._createItem = function(args) {
return item;
};

Rollbar.prototype._sameAsLastError = function(item) {
if (this.lastError === item.err && this.lastError) {
Copy link
Contributor

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.

Copy link
Contributor Author

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

@@ -87,6 +91,9 @@ Rollbar.log = function() {
Rollbar.prototype.debug = function() {
var item = this._createItem(arguments);
var uuid = item.uuid;
if (this._sameAsLastError(item)) {
Copy link
Contributor

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.

Copy link
Contributor Author

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

@rokob rokob merged commit 350af47 into master Jun 29, 2017
@rokob rokob deleted the add-last-error branch October 31, 2017 23:13
mudetroit pushed a commit that referenced this pull request Mar 14, 2024
add back lastError on the rollbar instance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants