Skip to content

Commit eb35e54

Browse files
authored
ref(svelte): Use onlyIfParent for recording component update spans (#11809)
Small refactor; The previous guard also worked but using `onlyIfParent` instead of checking for `getActiveSpan` saves us a couple of bytes
1 parent 48995b1 commit eb35e54

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

packages/svelte/src/performance.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, getActiveSpan } from '@sentry/browser';
1+
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/browser';
22
import type { Span } from '@sentry/types';
33
import { afterUpdate, beforeUpdate, onMount } from 'svelte';
44
import { current_component } from 'svelte/internal';
@@ -59,13 +59,8 @@ function recordInitSpan(componentName: string): void {
5959
function recordUpdateSpans(componentName: string): void {
6060
let updateSpan: Span | undefined;
6161
beforeUpdate(() => {
62-
// If there is no active span, we skip
63-
const activeSpan = getActiveSpan();
64-
if (!activeSpan) {
65-
return;
66-
}
67-
6862
updateSpan = startInactiveSpan({
63+
onlyIfParent: true,
6964
op: UI_SVELTE_UPDATE,
7065
name: componentName,
7166
attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.svelte' },

0 commit comments

Comments
 (0)