Skip to content

ref(svelte): use debug in svelte sdk #16917

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 1 commit into from
Jul 11, 2025
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions packages/svelte/src/debug_build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
declare const __DEBUG_BUILD__: boolean;

/**
* This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.
*
* ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.
*/
export const DEBUG_BUILD = __DEBUG_BUILD__;
10 changes: 6 additions & 4 deletions packages/svelte/src/performance.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/browser';
import type { Span } from '@sentry/core';
import { logger, startInactiveSpan } from '@sentry/core';
import { debug, startInactiveSpan } from '@sentry/core';
import { afterUpdate, beforeUpdate, onMount } from 'svelte';
import { DEBUG_BUILD } from './debug_build';
import type { TrackComponentOptions } from './types';

const defaultTrackComponentOptions: {
Expand Down Expand Up @@ -37,9 +38,10 @@ export function trackComponent(options?: TrackComponentOptions): void {
try {
recordUpdateSpans(componentName);
} catch {
logger.warn(
"Cannot track component updates. This is likely because you're using Svelte 5 in Runes mode. Set `trackUpdates: false` in `withSentryConfig` or `trackComponent` to disable this warning.",
);
DEBUG_BUILD &&
debug.warn(
"Cannot track component updates. This is likely because you're using Svelte 5 in Runes mode. Set `trackUpdates: false` in `withSentryConfig` or `trackComponent` to disable this warning.",
);
}
}
}
Expand Down
Loading