Skip to content

Commit 0dec883

Browse files
authored
ref(svelte): use debug in svelte sdk (#16917)
resolves #16916
1 parent c7a1e9a commit 0dec883

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

packages/svelte/src/debug_build.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
declare const __DEBUG_BUILD__: boolean;
2+
3+
/**
4+
* 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.
5+
*
6+
* ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.
7+
*/
8+
export const DEBUG_BUILD = __DEBUG_BUILD__;

packages/svelte/src/performance.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/browser';
22
import type { Span } from '@sentry/core';
3-
import { logger, startInactiveSpan } from '@sentry/core';
3+
import { debug, startInactiveSpan } from '@sentry/core';
44
import { afterUpdate, beforeUpdate, onMount } from 'svelte';
5+
import { DEBUG_BUILD } from './debug_build';
56
import type { TrackComponentOptions } from './types';
67

78
const defaultTrackComponentOptions: {
@@ -37,9 +38,10 @@ export function trackComponent(options?: TrackComponentOptions): void {
3738
try {
3839
recordUpdateSpans(componentName);
3940
} catch {
40-
logger.warn(
41-
"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.",
42-
);
41+
DEBUG_BUILD &&
42+
debug.warn(
43+
"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.",
44+
);
4345
}
4446
}
4547
}

0 commit comments

Comments
 (0)