Skip to content

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

Merged
merged 2 commits into from
Apr 21, 2022
Merged

Conversation

AbhiPrasad
Copy link
Member

As stackParser will always be defined in client options, we can remove
the usage of stackParserFromOptions outside of SDK init.

cc @timfish

@AbhiPrasad AbhiPrasad requested review from a team, lforst and Lms24 and removed request for a team April 19, 2022 18:46
@AbhiPrasad AbhiPrasad force-pushed the v7-abhi-stack-parser branch 2 times, most recently from f6a0477 to b9af9dc Compare April 19, 2022 18:58
@github-actions
Copy link
Contributor

github-actions bot commented Apr 19, 2022

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 20.19 KB (+0.61% 🔺)
@sentry/browser - ES5 CDN Bundle (minified) 64.26 KB (-0.44% 🔽)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.82 KB (+0.23% 🔺)
@sentry/browser - ES6 CDN Bundle (minified) 57.91 KB (-0.08% 🔽)
@sentry/browser - Webpack (gzipped + minified) 23.36 KB (+0.65% 🔺)
@sentry/browser - Webpack (minified) 81.14 KB (-1.59% 🔽)
@sentry/react - Webpack (gzipped + minified) 23.41 KB (+0.67% 🔺)
@sentry/nextjs Client - Webpack (gzipped + minified) 47.95 KB (-0.1% 🔽)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 26.03 KB (+0.2% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 24.4 KB (-0.03% 🔽)

@AbhiPrasad AbhiPrasad force-pushed the v7-abhi-stack-parser branch from b9af9dc to 7f366db Compare April 19, 2022 19:03
Copy link
Member

@lobsterkatie lobsterkatie left a 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!

Comment on lines +34 to +39
* 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 {
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Collaborator

@timfish timfish Apr 20, 2022

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.
@AbhiPrasad AbhiPrasad force-pushed the v7-abhi-stack-parser branch from f5a86ee to 503ea25 Compare April 21, 2022 16:06
@AbhiPrasad AbhiPrasad merged commit 7fb13d7 into 7.x Apr 21, 2022
@AbhiPrasad AbhiPrasad deleted the v7-abhi-stack-parser branch April 21, 2022 17:31
@AbhiPrasad AbhiPrasad added this to the 7.0.0 milestone Apr 25, 2022
Lms24 pushed a commit that referenced this pull request Apr 26, 2022
As stackParser will always be defined in client options, we can remove
the usage of `stackParserFromOptions` outside of SDK init.
lobsterkatie pushed a commit that referenced this pull request Apr 26, 2022
As stackParser will always be defined in client options, we can remove
the usage of `stackParserFromOptions` outside of SDK init.
lobsterkatie pushed a commit that referenced this pull request Apr 26, 2022
As stackParser will always be defined in client options, we can remove
the usage of `stackParserFromOptions` outside of SDK init.
AbhiPrasad added a commit that referenced this pull request May 30, 2022
As stackParser will always be defined in client options, we can remove
the usage of `stackParserFromOptions` outside of SDK init.
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