captbaritone / raven-for-redux

A Raven middleware for Redux
295 stars 25 forks source link

User defined Extras #72

Closed atticoos closed 6 years ago

atticoos commented 6 years ago

This expands the interface to allow users to attach additional extra information.

createRavenMiddleware(Raven, {
  getExtra: state => ({
    foo: 'bar',
    bar: someCalculatedValue(state)
  })
})

Example

screen shot 2018-04-10 at 10 35 50 am

codecov-io commented 6 years ago

Codecov Report

Merging #72 into master will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #72   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           1      1           
  Lines          26     27    +1     
  Branches       10     11    +1     
=====================================
+ Hits           26     27    +1
Impacted Files Coverage Δ
index.js 100% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 899d8d8...914c446. Read the comment docs.

captbaritone commented 6 years ago

For information derived from your Redux state, I believe stateTransformer provide you a way to add data to your state (note, that it will be added to the state property of the state.

For setting non Redux state based extras, Raven has a number of of direct methods for setting extra data.

Do you have a use-case where these two options cannot be combined to solve your problem?

captbaritone commented 6 years ago

@ajwhite

atticoos commented 6 years ago

I think Raven.setExtraContext should work fine for my needs, as everything I was looking to report should be known at startup time. I forgot this is a capability, and that everything in the middleware is adding values, not replacing.

I'd imagine there are use cases that there might be values outside redux that one may want to include at the time of the report.

But let's not go down that rabbit hole right now and see if those needs come up in more real cases first.

PS: I appreciate your attention to detail on the public API and maintaining a small surface area. That always builds trust for me as I adopt a new dependency. Great work on this project 😃