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
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/svelte/src/performance.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, getActiveSpan } from '@sentry/browser';
import type { Span } 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?


import { getRootSpan, startInactiveSpan, withActiveSpan } from '@sentry/core';
import { DEFAULT_COMPONENT_NAME, UI_SVELTE_INIT, UI_SVELTE_UPDATE } from './constants';
Expand Down Expand Up @@ -32,7 +31,7 @@ export function trackComponent(options?: TrackComponentOptions): void {

// current_component.ctor.name is likely to give us the component's name automatically
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
const componentName = `<${customComponentName || current_component.constructor.name || DEFAULT_COMPONENT_NAME}>`;
const componentName = `<${customComponentName || DEFAULT_COMPONENT_NAME}>`;

let initSpan: Span | undefined = undefined;
if (mergedOptions.trackInit) {
Expand Down