-
Notifications
You must be signed in to change notification settings - Fork 48
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
feat: Add options to ignore specific urls and regex patterns #70
Conversation
I think I liked your idea of just letting us pass a callback in #68 as it would simplify your code and we can do whatever we need.
But those can be done later. |
@@ -152,6 +166,23 @@ export default class Logger { | |||
this.ignoredHosts = new Set(options.ignoredHosts); | |||
} | |||
|
|||
if (options?.ignoredPatterns) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.ignoredPatterns = options?.ignoredPatterns ?? [];
Would shrink the code down
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code above where it gets used actually relies on it being undefined. I might just leave it to keep it consistent with the ignoredHosts
option.
!Array.isArray(options.ignoredUrls) || | ||
typeof options.ignoredUrls[0] !== 'string' | ||
) { | ||
warn( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this may be better as a throw Error()
rather than a warning. This will prompt the developer to fix their code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I can't remember why I did the warning as it was a while ago when I set it up. I would probably accept a PR updating it.
Yeah that's a good point. I'm thinking it might be good to add this option as a prop in the react component. That way you can still collect all requests but then add your own filters based on things like response time. |
Released in |
Closes #68
Adds new
ignoredUrls
andignoredPatterns
to provide full urls to ignore or regex patterns to ignore.The regex patterns will be slightly slower but gives more control to ignore certain methods or partial urls.