-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Svelte Component Tracking doesn't pick up components without a <script>
tag
#5923
Comments
<script>
tag
Updated issue with To Do section |
Update: After actually implementing the 2nd pass preprocessor, I realized that the order in which preproc hooks are called is not as I thought. I thought that all hooks per preprocessor are executed, followed by the hooks of the next preproc: basically:
However, in reality, all
It's all in the Svelte docs btw, I should have just read this stuff more carefully :/ This means, our 2-pass approach won't work because for that, |
Make our Svelte component tracking feature track components without `<script>` tags. Previously these components would not be picked up by our preprocessor because its `script` hook is only called for components with script blocks. With this PR, we first leverage the `markup` hook to check if a script block exists. If it doesn't, we add an empty script tag which we later revisit in the `script hook` where we inject the component tracking code. Note: To determine if a script tag exists in the file, we use a regex check which has drawbacks, as it is not 100% bullet proof. However, we decided that for the lack of better options as explained in [#5923(comment)](#5923 (comment)) we'll go with this approach for now. Also, the svelte compiler internally uses the same regex to detect `<script>` tags. Add additional tests to check the new behaviour (brings up preprocessor coverage to 100%)
This was fixed (#5957) and will be released with the next SDK release |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which package are you using?
@sentry/svelte
SDK Version
7.15.0
Framework Version
Svelte 3
Link to Sentry event
No response
Steps to Reproduce
<script>
tags, some withoutExpected Result
The SDK should record spans for all components that should be tracked, regardless of if they have a
<script>
tag or not.Actual Result
The SDK only records spans for components with one (or multiple)
<script>
tag(s) (afaict, we handle the multiple script tags case fine).My suspicion is that components w/o
<script>
are not sent through thescript
preprocessor hook we use. If that is the case, we should consider switching to another hook or (if impossible/infeasible) update docs to inform people that they need to include a script tag.To Do:
After discussing this internally, we decided to make some (backwards-compatible) changes to how we handle sentry-specific
svelte.config.js
entries. We'll go with a more general,withSentryConfig
approach that allows us to have more freedom with adding future Svelte preprocessors or other compile-time specific sentry items.By taking this approach, we can also fix this specific bug in a more elegant and much safer way.
withSentryConfig
function to wrap around thesvelte.config.js
option object (with feature parity to our current component tracking preprocessor) (feat(svelte): AddwithSentryConfig
function to wrap User Svelte Configuration #5936)trackComponentPreprocessor
package export from the Svelte SDKcomponentTrackingPreprocessor
to detect no-script components (fix(svelte): Track components without <script> tags #5957)withSentryConfig
approach sentry-docs#5649)The text was updated successfully, but these errors were encountered: