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

Cannot set issue title for messages or errors #1033

Closed
5 of 11 tasks
Xesme opened this issue Aug 20, 2020 · 8 comments
Closed
5 of 11 tasks

Cannot set issue title for messages or errors #1033

Xesme opened this issue Aug 20, 2020 · 8 comments

Comments

@Xesme
Copy link

Xesme commented Aug 20, 2020

OS:

  • Windows
  • MacOS
  • Linux

Platform:

  • iOS
  • Android

SDK:

  • @sentry/react-native (>= 1.0.0)
  • react-native-sentry (<= 0.43.2)

SDK version: 1.4.5

react-native version: 0.60.6

Are you using Expo?

  • Yes
  • No

Are you using sentry.io or on-premise?

  • sentry.io (SaaS)
  • on-premise

If you are using sentry.io, please post a link to your issue so we can take a look:

N/A this is a configuration issue. All issue titles are '' and I cannot for the life of me figure out how to manually set them.

Configuration:

(@sentry/react-native)

Sentry.init({
  dsn: 'https://...@sentry.io/...'
  // other options
});

or

(react-native-sentry)

    Sentry.init({ 
      dsn: dsn, 
      release: ---, 
      environment: ---, 
    });

I have following issue:

When error or messages are captured to Sentry the title is set to '' this is a regressing from our previous version. I have read through the docs and I cannot find mention of a title property anywhere, however I did find it within the JSON of a reported issue with this title.

Here is an example:

{"value":"Error checking for unprocessed payment"},"received":1597873045.391972,"sdk":{"version":"1.6.1","name":"sentry.javascript.react-native","packages":[{"version":"1.6.1","name":"npm:@sentry/react-native"}],"integrations":["ReactNativeErrorHandlers","Release","InboundFilters","FunctionToString","Breadcrumbs","LinkedErrors","UserAgent","RewriteFrames","DeviceContext"]},"timestamp":1597873044.711,"title":"<unknown>","type":"error","user":{"geo":{"city":"Columbus","region":"United 

Maybe I missed it in the documentation somewhere? Any and all help is greatly appreciated. Thanks!

Steps to reproduce:

  • Install and report a custom error

Actual result:

Attached is a screenshot of the behavior.

Screen Shot 2020-08-20 at 8 03 19 AM

Expected result:

The ability to set titles, so the Sentry logs are easily readable.

@jennmueng
Copy link
Member

jennmueng commented Sep 1, 2020

Hmm, which method are you using to capture the messages/errors? Sentry.captureMessage should automatically make that message the title, along with Sentry.captureException making the error type the title. There currently isn't a way to directly set the title, but the two above methods should correctly set the title otherwise.

@Xesme
Copy link
Author

Xesme commented Sep 1, 2020

No problem. I looked at our code and Sentry logs again and the issue is not with the captureMessage, it is just within the captureException. We recently upgraded* from react-native-sentry 0.43.2 to @sentry/react-native 1.4.5 and this just started happening after the upgrade. Our existing code for capturing errors looks like this (with an example):

export const captureException = (error, extra = null) => {
  if (extra) Sentry.setExtras(extra);
  if (error) Sentry.captureException(error);
};

...captureException('Error could not find room(s)');

image

The odd thing is the <unknown> tag as the title and a subtitle being set with the actual title. Thanks for much for your help. I have been stumped on this for weeks.

@jennmueng
Copy link
Member

Ah, so captureException actually only takes instances of Error. If you pass new Error('Error could not find room(s)') instead of just the string 'Error could not find room(s)' to captureException it should come out correctly! If you just want to capture the string, you would then use captureMessage.

@jennmueng
Copy link
Member

Closing this on the basis of being more than a year old with no updates. If the issue still persists, feel free to reopen.

@carlosen14
Copy link

Ah, so captureException actually only takes instances of Error. If you pass new Error('Error could not find room(s)') instead of just the string 'Error could not find room(s)' to captureException it should come out correctly! If you just want to capture the string, you would then use captureMessage.

I know is a bit late, but it is not 100% correct, I'm capturing this
image

and it shows "Error" as the title..
image

I thought it suppose to be as you did mention, or did I miss something?, I'll keep searching

@matheuscouto
Copy link

@carlosen14 if you find any solution please post here

@matheuscouto
Copy link

Actually, I figured it out. Sentry uses the Error class name as the title of the issue. If you change the error's name property, it should work:

const error = new Error("error message here");
error.name = "this is new";
Sentry.captureException(error);
image

@robertyulisman
Copy link

Actually, I figured it out. Sentry uses the Error class name as the title of the issue. If you change the error's name property, it should work:

const error = new Error("error message here");
error.name = "this is new";
Sentry.captureException(error);
image

its work, thanks @matheuscouto

Image

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

No branches or pull requests

5 participants