Skip to content
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

Merged
merged 1 commit into from
Jan 5, 2023

Conversation

alexbrazier
Copy link
Owner

Closes #68

Adds new ignoredUrls and ignoredPatterns 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.

@trajano
Copy link

trajano commented Jan 3, 2023

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.
such as

  • ignore anything that's less than 100ms so we can focus on slow API responses.
  • ignore if we pass something in the header.

But those can be done later.

@@ -152,6 +166,23 @@ export default class Logger {
this.ignoredHosts = new Set(options.ignoredHosts);
}

if (options?.ignoredPatterns) {
Copy link

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

Copy link
Owner Author

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(
Copy link

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.

Copy link
Owner Author

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.

@alexbrazier
Copy link
Owner Author

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. such as

  • ignore anything that's less than 100ms so we can focus on slow API responses.
  • ignore if we pass something in the header.

But those can be done later.

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.

@alexbrazier alexbrazier merged commit 5ee6c3e into master Jan 5, 2023
@alexbrazier alexbrazier deleted the ignored-urls-patterns branch January 5, 2023 21:42
@alexbrazier
Copy link
Owner Author

Released in 1.14.0

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.

Changed ignoredHosts to ignoredPatterns
2 participants