Skip to content

Add filterBreadcrumbActions option #39

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

Merged
merged 6 commits into from
Oct 3, 2017

Conversation

bjudson
Copy link
Contributor

@bjudson bjudson commented Oct 3, 2017

filterBreadcrumbActions is a function that returns true if an action should be added to the breadcrumbs.

The rationale for this is that some Redux apps use some actions internally to trigger state changes that are both prolific and not directly connected to user behavior. They can overwhelm the logs and have essentially no value for debugging purposes.

@codecov-io
Copy link

codecov-io commented Oct 3, 2017

Codecov Report

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

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #39   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           1      1           
  Lines          18     21    +3     
  Branches        6      8    +2     
=====================================
+ Hits           18     21    +3
Impacted Files Coverage Δ
index.js 100% <100%> (ø) ⬆️

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 94272f0...3a61ff2. Read the comment docs.

@captbaritone
Copy link
Owner

How about instead of an array of types, we allow the user to supply a filterBreadcrumbActions function?

Also, I think the action should still be set as the lastAction even if it has been filtered out. Could you add a test to confirm that?

Thanks for the PR, I think this will be a great improvement.

@bjudson bjudson changed the title Add ignoreActions option Add filterBreadcrumbActions option Oct 3, 2017
@bjudson
Copy link
Contributor Author

bjudson commented Oct 3, 2017

@captbaritone Good idea. Updated PR with your suggestion. The test I added now confirms that the filtered action was omitted from breadcrumbs, but still included in lastAction. Thanks!

index.js Outdated
message: action.type,
data: breadcrumbDataFromAction(action)
});
if (filterBreadcrumbActions(action) === true) {
Copy link
Owner

Choose a reason for hiding this comment

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

I think it would be less confusing for this to just check for truthy values.

if (filterBreadcrumbActions(action)) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I did that at first, but thought being explicit might catch some bugs in the user-supplied function.

Copy link
Owner

Choose a reason for hiding this comment

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

I think truths/falsy is a perfectly valid return value from a filter predicate. Not nessesarily a bug.

@@ -128,6 +128,16 @@ Each breadcrumb is assigned a category. By default all action breadcrumbs are
given the category `"redux-action"`. If you would prefer a different category
name, specify it here.

#### `filterBreadcrumbActions` _(Function)_
Copy link
Owner

Choose a reason for hiding this comment

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

This might also be worth adding to the "improvements" section above.

Copy link
Owner

@captbaritone captbaritone left a comment

Choose a reason for hiding this comment

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

Just one small thing. Thanks for the quick turn around.

index.test.js Outdated
extra,
breadcrumbs
} = context.mockTransport.mock.calls[0][0].data;
// Even though the action isn't added to breadcrumbs, it should be sent with extra data
Copy link
Owner

Choose a reason for hiding this comment

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

I think this would be better as a separate it() block, that way if it fails, we get a nice error message, but don't worry about it. I can always clean this up later.

@captbaritone captbaritone merged commit e09114d into captbaritone:master Oct 3, 2017
@captbaritone
Copy link
Owner

Looks good! I'll cut a point release.

@bjudson
Copy link
Contributor Author

bjudson commented Oct 3, 2017

Thanks for the quick feedback & merge! This is definitely going to improve our debugging process.

@captbaritone
Copy link
Owner

Okay. Should be available in v1.1.0

Thanks again for your work on this!

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.

3 participants