-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
ref: Enforce stackParser through options. #4953
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
Conversation
f6a0477
to
b9af9dc
Compare
size-limit report 📦
|
b9af9dc
to
7f366db
Compare
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.
Two small things, but otherwise looks good!
* Gets a stack parser implementation from Options.stackParser | ||
* @see Options | ||
* | ||
* If options contains an array of line parsers, it is converted into a parser | ||
*/ | ||
export function stackParserFromOptions(options: StackParserOptions | undefined): StackParser { | ||
if (options) { | ||
if (Array.isArray(options.stackParser)) { | ||
options.stackParser = createStackParser(...options.stackParser); | ||
} | ||
|
||
if (typeof options.stackParser === 'function') { | ||
return options.stackParser; | ||
} | ||
export function stackParserFromOptions(stackParser: StackParser | StackLineParser[]): StackParser { |
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.
After this change, seems like it's not being gotten from options
anymore. Can we change the name to reflect that?
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 is a good point, and has got me thinking if we even should expose passing in a StackLineParser[]
, and enforce that it is always an (optional) StackParser
.
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 only plus to allow passing of StackLineParser[]
is that users can configure stack parsing without needing to import and use createStackParser
from @sentry/utils
.
Some common lints warn if you use modules that are not direct dependencies so users would also need to add @sentry/utils
to their depndencies or we would need to be re-export it from every sdk.
Allowing user passing of StackParser
allows completely overridding the entire stack parsing logic. I'm not sure we have a use case for this yet.
As stackParser will always be defined in client options, we can remove the usage of `stackParserFromOptions` outside of SDK init.
f5a86ee
to
503ea25
Compare
As stackParser will always be defined in client options, we can remove the usage of `stackParserFromOptions` outside of SDK init.
As stackParser will always be defined in client options, we can remove the usage of `stackParserFromOptions` outside of SDK init.
As stackParser will always be defined in client options, we can remove the usage of `stackParserFromOptions` outside of SDK init.
As stackParser will always be defined in client options, we can remove the usage of `stackParserFromOptions` outside of SDK init.
As stackParser will always be defined in client options, we can remove
the usage of
stackParserFromOptions
outside of SDK init.cc @timfish