expo / sentry-expo

MIT License
202 stars 83 forks source link

[Feature Request] Option to track errors only if the error is not device-network-related #344

Closed BrodaNoel closed 11 months ago

BrodaNoel commented 1 year ago

Summary

I have a LOT of code like this in my apps:

  try {
    const { users } = await actions.users.getSomeUser();

    setUser(user);
  } catch (error) {
    const isDeviceOffline = duix.get('isOffline');

    if (!isDeviceOffline) {
      Sentry.Native.captureException(error);
    }
  }

It would be REALLY NICE if we could, in some way, provide and option in the captureException that will allow me to say "only track this exception if it's not a network problem".

Something like this:

try {
  const { users } = await actions.users.getSomeUser();

  setUser(user);
} catch (error) {
  Sentry.Native.captureException(error, { ignoreNetworkError: true });
}

What do you think? Feel free to remove it if you think I'm crazy.

Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!

managed

What platform(s) does this occur on?

Android, iOS

SDK Version (managed workflow only)

SDK48

Environment

Not required

Reproducible demo or steps to reproduce from a blank project

Not required

BrodaNoel commented 1 year ago

Important point: Problem is, not always device seems to be offline (using NetInfo) and we still have some network issues on requests... I mean, sometimes you get Network request failed error, and NetInfo says device is online (because the user left home, WIFI connection lost, request cancelled, but mobile connection still ON).

So... The code to avoid tracking Network issues is even worst. Like...:

  try {
    const { users } = await actions.users.getSomeUser();

    setUser(user);
  } catch (error) {
    const isDeviceOffline = duix.get('isOffline');

    if (!isDeviceOffline && error.message !== 'Network request failed') {
      Sentry.Native.captureException(error);
    }
  }
github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 60 days with no activity. If there is no activity in the next 7 days, the issue will be closed.

BrodaNoel commented 1 year ago

Hold your horses GitHub bot

github-actions[bot] commented 11 months ago

This issue is stale because it has been open for 60 days with no activity. If there is no activity in the next 7 days, the issue will be closed.

github-actions[bot] commented 11 months ago

This issue was closed because it has been inactive for 7 days since being marked as stale. Please open a new issue if you believe you are encountering a related problem.