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(js): Handle in_app detection for webpack namespace output #28859

Merged
merged 1 commit into from Sep 28, 2021

Conversation

kamilogorek
Copy link
Contributor

@kamilogorek kamilogorek commented Sep 27, 2021

This change fixes detection of InApp frames when webpack project is built using multiple namespaces.

This will produce a path in form of webpack://[namespace]/[path] which ends up being something like webpack://mylib/./some/file.js. Where previously, non-namespaced paths were in form of webpack:///./some/file.js, as namespace ended up being an empty string.

Currently, we use to allow a-zA-Z0-9.-_@ as namespace characters, as I don't expect anyone to use anything else. We can change it if anyone ever requests it.

I'd love to write tests for it, but it would require some more refactoring, as calling the whole process_frame is not trivial, and I didn't want to make this PR difficult to review.

webpack docs ref: https://webpack.js.org/configuration/output/#outputdevtoolnamespace
webpack docs ref: https://webpack.js.org/configuration/output/#outputdevtoolmodulefilenametemplate

ref: getsentry/sentry-javascript#3853
ref: getsentry/sentry-javascript#4012 (comment)

@SevenOutman
Copy link

Will this fix be backported into v9?

@kamilogorek
Copy link
Contributor Author

I don't believe so, sorry. You'd need to patch it yourself (or use stack trace rules).

@@ -62,6 +62,9 @@
)
VERSION_RE = re.compile(r"^[a-f0-9]{32}|[a-f0-9]{40}$", re.I)
NODE_MODULES_RE = re.compile(r"\bnode_modules/")
# Default Webpack output path using multiple namespace - https://webpack.js.org/configuration/output/#outputdevtoolmodulefilenametemplate
# eg. webpack://myproject/./src/lib/hellothere.js
WEBPACK_NAMESPACE_RE = re.compile(r"^webpack://[a-zA-Z0-9_\-@\.]+/\./")
Copy link
Member

Choose a reason for hiding this comment

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

Couldn't find any tests in the webpack repo around this, so I'm just going to assume this regex should be good enough.

@kamilogorek kamilogorek merged commit 535924a into master Sep 28, 2021
@kamilogorek kamilogorek deleted the webpack-namespaces-inapp branch September 28, 2021 07:36
@github-actions github-actions bot locked and limited conversation to collaborators Oct 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants