Skip to content

fix(svelte): Make component tracking compatible with Svelte 5 #10312

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

Closed
wants to merge 2 commits into from

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Jan 24, 2024

depends on #10311

This PR adds compatibility for Svelte 5 by adjusting our component tracking functionality to work with Svelte 5.

TLDR: This change entails a minor behaviour "breaking" change for a subset of Svelte component tracking users.

Our previous implementation relied on an exported internal API (current_component) to automatically detect the name of the component name for the respective spans. This API was removed in Svelte 5, so we can no longer use it. Importing it causes a build error. This means that going forward, calls to trackComponent need to set the componentName option or the span will get the fallback <Svelte Component> name. However, this only applies if the function is called manually.

In case users use our withSentryConfig wrapper in their svelte.config.js, we inject a preprocessor that already creates passes the component name from the component file name to the injected trackComponent call. So nothing changes in this use case - component spans will still automatically get the correct name. We recommend this approach in our docs.

ref #10275

@Lms24 Lms24 changed the base branch from develop to lms/ref-svelte-pkgjson-exports January 24, 2024 10:27
@Lms24 Lms24 self-assigned this Jan 24, 2024
@Lms24
Copy link
Member Author

Lms24 commented Jan 24, 2024

in addition blocked on jest (#10318) - moving to draft

@Lms24 Lms24 marked this pull request as draft January 24, 2024 13:13
@@ -1,7 +1,6 @@
import { getCurrentScope } from '@sentry/browser';
import type { Span, Transaction } from '@sentry/types';
import { afterUpdate, beforeUpdate, onMount } from 'svelte';
import { current_component } from 'svelte/internal';
Copy link
Member

Choose a reason for hiding this comment

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

Can we not conditionally access this via a version check?

In SvelteKit we can inject stuff via vite plugin so we can inject a version into the bundle in if Svelte themselves does not expose it. Or is that problematic for other reasons?

@JonathonRP
Copy link
Contributor

@Lms24 anymore progress on this?

@Lms24 Lms24 force-pushed the lms/ref-svelte-component-tracking-svelte-5 branch from e3bf653 to b6f7fa8 Compare April 2, 2024 13:53
@Lms24 Lms24 changed the base branch from lms/ref-svelte-pkgjson-exports to develop April 2, 2024 13:55
Copy link

codecov bot commented Apr 2, 2024

Bundle Report

Changes will decrease total bundle size by 3.37MB ⬇️

Bundle name Size Change
@sentry/svelte-cjs 13.75kB 92 bytes ⬇️
@sentry/svelte-esm 12.63kB 91 bytes ⬇️
@sentry/sveltekit-cjs 69.31kB 0 bytes
@sentry/sveltekit-esm 61.08kB 0 bytes
@sentry/types-cjs (removed) 35 bytes ⬇️
@sentry/utils-cjs (removed) 178.63kB ⬇️
@sentry/opentelemetry-esm (removed) 69.19kB ⬇️
@sentry-internal/tracing-esm (removed) 107.26kB ⬇️
@sentry/utils-esm (removed) 174.02kB ⬇️
@sentry/types-esm (removed) 35 bytes ⬇️
@sentry-internal/integration-shims-cjs (removed) 3.65kB ⬇️
@sentry/node-esm (removed) 333.56kB ⬇️
@sentry/core-cjs (removed) 240.44kB ⬇️
@sentry-internal/replay-esm (removed) 306.46kB ⬇️
@sentry/node-cjs (removed) 336.97kB ⬇️
@sentry-internal/replay-canvas-cjs (removed) 29.51kB ⬇️
@sentry/bun-cjs (removed) 13.5kB ⬇️
@sentry/core-esm (removed) 236.82kB ⬇️
@sentry/browser-cjs (removed) 107.36kB ⬇️
@sentry/vercel-edge-cjs (removed) 18.23kB ⬇️
@sentry/aws-serverless-cjs (removed) 14.62kB ⬇️
@sentry-internal/node-integration-tests-cjs (removed) 1.04kB ⬇️
@sentry/wasm-cjs (removed) 5.2kB ⬇️
@sentry/gatsby-cjs (removed) 905 bytes ⬇️
@sentry/vue-esm (removed) 18.85kB ⬇️
@sentry/gatsby-esm (removed) 385 bytes ⬇️
@sentry-internal/replay-cjs (removed) 306.35kB ⬇️
@sentry/remix-cjs (removed) 53.62kB ⬇️
@sentry/nextjs-cjs (removed) 20.52kB ⬇️
@sentry/browser-esm (removed) 104.53kB ⬇️
@sentry/google-cloud-serverless-cjs (removed) 23.0kB ⬇️
@sentry-internal/integration-shims-esm (removed) 2.99kB ⬇️
@sentry/nextjs-esm (removed) 20.02kB ⬇️
@sentry/remix-esm (removed) 48.23kB ⬇️
@sentry-internal/node-integration-tests-esm (removed) 888 bytes ⬇️
@sentry/bun-esm (removed) 10.05kB ⬇️
@sentry-internal/feedback-cjs (removed) 65.81kB ⬇️
@sentry-internal/replay-canvas-esm (removed) 29.43kB ⬇️
@sentry/google-cloud-serverless-esm (removed) 19.16kB ⬇️
@sentry/profiling-node-cjs (removed) 25.5kB ⬇️
@sentry/vercel-edge-esm (removed) 16.13kB ⬇️
@sentry/wasm-esm (removed) 4.85kB ⬇️
@sentry/opentelemetry-cjs (removed) 70.22kB ⬇️
@sentry/profiling-node-esm (removed) 25.52kB ⬇️
@sentry/react-cjs (removed) 45.04kB ⬇️
@sentry-internal/tracing-cjs (removed) 108.01kB ⬇️
@sentry-internal/feedback-esm (removed) 65.5kB ⬇️
@sentry/astro-cjs (removed) 27.13kB ⬇️
@sentry/vue-cjs (removed) 20.19kB ⬇️
@sentry/astro-esm (removed) 23.39kB ⬇️
@sentry/react-esm (removed) 41.18kB ⬇️

Copy link
Contributor

github-actions bot commented Apr 2, 2024

size-limit report 📦

Path Size
@sentry/browser (incl. Tracing, Replay, Feedback) 80.38 KB (added)
@sentry/browser (incl. Tracing, Replay) 71.73 KB (added)
@sentry/browser (incl. Tracing, Replay with Canvas) 75.55 KB (added)
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 65.3 KB (added)
@sentry/browser (incl. Tracing) 36.57 KB (added)
@sentry/browser (incl. browserTracingIntegration) 36.57 KB (added)
@sentry/browser (incl. feedbackIntegration) 31.53 KB (added)
@sentry/browser (incl. feedbackModalIntegration) 31.63 KB (added)
@sentry/browser (incl. feedbackScreenshotIntegration) 31.64 KB (added)
@sentry/browser (incl. sendFeedback) 27.59 KB (added)
@sentry/browser 22.75 KB (added)
CDN Bundle (incl. Tracing, Replay, Feedback) 74.93 KB (added)
CDN Bundle (incl. Tracing, Replay) 69.72 KB (added)
CDN Bundle (incl. Tracing) 36.26 KB (added)
CDN Bundle 24.01 KB (added)
CDN Bundle (incl. Tracing, Replay) - uncompressed 218.82 KB (added)
CDN Bundle (incl. Tracing) - uncompressed 109.47 KB (added)
CDN Bundle - uncompressed 71.09 KB (added)
@sentry/react (incl. Tracing, Replay) 71.71 KB (added)
@sentry/react 22.78 KB (added)

@Lms24
Copy link
Member Author

Lms24 commented Apr 26, 2024

Superseded by #11807

@Lms24 Lms24 closed this Apr 26, 2024
@Lms24 Lms24 deleted the lms/ref-svelte-component-tracking-svelte-5 branch December 3, 2024 09:31
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