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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Use contexts to handle ExtraErrorData #2208

Merged
merged 4 commits into from
Sep 23, 2019

Conversation

CPatchane
Copy link
Contributor

Hi here 馃憢

We used to have a custom event processor to add extra data to our events and we saw that there is now an integration to handle that: ExtraErrorData which is cool to remove our custom processor :)

The thing is that (I don't know if it was wanted), this integration extracts all information into an object using the event name like:

...
extra: {
  MyErrorName: {
    extra1: "info1",
    extra2: "info2",
  }
}
...

UI Preview:
Screenshot 2019-08-16 at 19 34 12

This object is less well formatted on the Sentry interface compared to having all information at the extra object root like:

...
extra: {
  extra1: "info1",
  extra2: "info2",
}
...

UI Preview:
Screenshot 2019-08-16 at 19 31 47

So this PR adds a new option toRoot (I am clearly opened if you have a better option name, I was not inspired), disabled by default, to allow putting all extra information to the event object root and overwriting if there were already existing extra information the same attributes.

@kamilogorek
Copy link
Contributor

Hey! Looks really nice! I think it may be a useful addition :)
The only thing I'd ask for is, can you change /** JSDoc */ clause to correct one now as we have more than one possible config option? depth was rather self-explanatory, but toRoot may not be so much, especially overriding behavior.

@kamilogorek
Copy link
Contributor

@kamilogorek
Copy link
Contributor

Possible names: merge, mergeToParent, mergeAttributes, toParent, raw, flat, mergeFlat, hard to choose 馃槄

Copy link
Member

@HazAT HazAT left a comment

Choose a reason for hiding this comment

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

We slowly want to discourage the usage of extra.
WDYT @kamilogorek if we create a new context containing all the data of the error object?
like:

contexts: {
  error: {
  ....
  }
}

@kamilogorek
Copy link
Contributor

@HazAT that'd work as well!

image

@CPatchane
Copy link
Contributor Author

@kamilogorek with this new context usage then is this PR still relevant? Do you plan to use this new context soon in a next version?

@kamilogorek
Copy link
Contributor

@CPatchane it's already available in the Sentry and in the SDK. We can change this PR to reflect it.

What has to be done is:
_extractErrorData should always return extraErrorInfo directly (just as you'd apply toRoot to it)

  • toRoot option becomes then obsolete, as it'll always create a new context, so can be safely removed
  • enhanceEventWithErrorData should be modified to return a new context instead. So instead of:
return {
  ...event,
  extra,
};

it should be

return {
  ...event,
  contexts,
};

where contexts is:

contexts = {
  ...event.contexts,
  ...normalizedErrorData,
};

@CPatchane CPatchane changed the title feat: toRoot option for ExtraErrorData integration feat: Use contexts to handle ExtraErrorData Sep 12, 2019
@kamilogorek
Copy link
Contributor

kamilogorek commented Sep 12, 2019

@CPatchane context still has to have a name (my bad by explaining it incorrectly, sorry)

{
  contexts: {
    error: {
      // extra data goes here
    }
  }
}

The name will be used to well "name" the UI block as shown in my screenshot above.

@CPatchane
Copy link
Contributor Author

Ok I was wondering myself about this part also, I change that 馃憤

@@ -35,7 +35,7 @@ describe('ExtraErrorData()', () => {
originalException: error,
});

expect(enhancedEvent.extra).toEqual({
expect(enhancedEvent.contexts).toEqual({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this test still relevant?

@CPatchane
Copy link
Contributor Author

馃 The tests all pass green in my local environment, do you see what's wrong?

@kamilogorek
Copy link
Contributor

kamilogorek commented Sep 12, 2019

They work just fine locally for me as well.

Can you try to add this snippet to .travis.yml and push it to the PR?

addons:
  chrome: stable

Current version Travis use by default is 15 versions old.

@kamilogorek
Copy link
Contributor

@CPatchane actually nevermind, just update a whole ubuntu distro :)

Change dist: trusty to dist: bionic in .travis.yml and push the commit.

@kamilogorek
Copy link
Contributor

Fixed :) I wonder what happened that it broke all of a sudden.

Code looks good to me. WDYT @HazAT?

@CPatchane
Copy link
Contributor Author

Any news @kamilogorek / @HazAT ?

Copy link
Member

@HazAT HazAT left a comment

Choose a reason for hiding this comment

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

Thx 馃檹

@kamilogorek kamilogorek merged commit d64568a into getsentry:master Sep 23, 2019
@kamilogorek
Copy link
Contributor

Thanks for the ping :) Will make a release at the end of the week. Cheers!

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.

None yet

3 participants