captbaritone / raven-for-redux

A Raven middleware for Redux
295 stars 25 forks source link

Using with Axios (Cannot read property 'hasOwnProperty' of undefined) #4

Closed ChrisSargent closed 7 years ago

ChrisSargent commented 7 years ago

Hi,

Thanks for this package, I'm looking forward to getting it implemented.

I have a React / Redux universal application that's using Axios to get data from various endpoints. I'm using an Axios interceptor (https://github.com/mzabriskie/axios#interceptors) to catch any network errors like so:

axios.interceptors.response.use((response) => {
    return response;
  }, (error) => {
    Raven.captureException(error)
    return Promise.reject(error);
  });

If I run it like this with a default configuration, I get a number of Cannot read property 'hasOwnProperty' of undefined errors relating to Raven._trimBreadcrumbs.

screen shot 2017-04-10 at 18 45 53

On debugging I could see that in the _trimBreadcrumbs function in raven.js, crumb.data was 'undefined' and therefore it couldn't have the hasOwnProperty method. If I add this to the configuration line (it can in fact return any string and it still works okay)

const _ravenBreadcrumbData = (action) => {
  return action.type
}

and

createRavenMiddleware(Raven, {breadcrumbDataFromAction: _ravenBreadcrumbData})

then it all works okay. So I'm wondering if there's a better way of handling this?

Thanks!

Chris

svanzoest commented 7 years ago

This is related to https://github.com/getsentry/raven-js/issues/925

captbaritone commented 7 years ago

Looks like this fix will be merged in Raven. I have a working fix for raven-for-redux but at this point, I think it's best to just wait for the next release of Raven (or downgrade to raven@3.13.1).

You can see the fix on my feature branch here: https://github.com/captbaritone/raven-for-redux/commit/78097c6a4a85bdb2e16c46cad0ebab5c1cc602c2

If anyone would find value in having raven-for-redux solve this issue (maybe you can't upgrade/downgrade Raven?) let me know and I can add that commit. In the mean time, I'm going to close this issue.

captbaritone commented 7 years ago

In the mean time, I've added a note to the readme: https://github.com/captbaritone/raven-for-redux/commit/137d0c52d895c9d73c861f14054a8a867f663f90

svanzoest commented 7 years ago

For now, I just downgraded to raven-js 3.13.1 until getsentry/raven-js#929 gets released.

captbaritone commented 7 years ago

Looks like Raven 3.14.1 has been released. Thanks for the fast turn around @benvinegar!

ChrisSargent commented 7 years ago

Yip, this is fixed for me after updating to 3.14.1. Thanks!