Skip to content

Commit

Permalink
send attributes conditionally
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinL10 committed Jul 8, 2024
1 parent 4335bea commit 5b9ba4b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ sentryTest(
parent_span_id: eventData.contexts?.trace?.span_id,
data: {
'code.filepath': 'https://example.com/path/to/script.js',
'code.function': '',
'browser.script.source_char_position': 0,
'browser.script.invoker': 'https://example.com/path/to/script.js',
'browser.script.invoker_type': 'classic-script',
Expand Down Expand Up @@ -92,9 +91,6 @@ sentryTest(
description: 'Main UI thread blocked',
parent_span_id: eventData.contexts?.trace?.span_id,
data: {
'code.filepath': '',
'code.function': '',
'browser.script.source_char_position': -1,
'browser.script.invoker': 'BUTTON#clickme.onclick',
'browser.script.invoker_type': 'event-listener',
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'ui.long-animation-frame',
Expand Down
12 changes: 9 additions & 3 deletions packages/browser-utils/src/metrics/browserMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,17 @@ export function startTrackingLongAnimationFrames(): void {
startTime,
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.browser.metrics',
'code.filepath': entry.scripts[0].sourceURL,
'code.function': entry.scripts[0].sourceFunctionName,
'browser.script.source_char_position': entry.scripts[0].sourceCharPosition,
'browser.script.invoker': entry.scripts[0].invoker,
'browser.script.invoker_type': entry.scripts[0].invokerType,
...(entry.scripts[0].sourceURL && {
'code.filepath': entry.scripts[0].sourceURL,
}),
...(entry.scripts[0].sourceFunctionName && {
'code.function': entry.scripts[0].sourceFunctionName,
}),
...(entry.scripts[0].sourceCharPosition !== -1 && {
'browser.script.source_char_position': entry.scripts[0].sourceCharPosition,
}),
},
});
if (span) {
Expand Down

0 comments on commit 5b9ba4b

Please sign in to comment.