Skip to content
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
76 changes: 45 additions & 31 deletions MIGRATION.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import { sentryTest } from '../../../../utils/fixtures';
import { shouldSkipCdnBundleTest, shouldSkipTracingTest } from '../../../../utils/helpers';
import { getSpanOp, observeStreamedSpan, waitForStreamedSpan, waitForStreamedSpans } from '../../../../utils/spanUtils';

// Interaction spans are named after the component, so the element is on `browser.web_vital.inp.target`.
// The click handler adds the `clicked` class before the event timing entry is recorded.
const SPOTLIGHT_BUTTON = 'body > div#sentry-spotlight > button.clicked';
const REGULAR_BUTTON = 'body > button.clicked';

sentryTest(
'filters ui.interaction.click spans for spotlight elements via ignoreSpans in streaming mode',
async ({ getLocalTestUrl, page }) => {
Expand All @@ -16,7 +21,10 @@ sentryTest(
// Set up an observer that fails if a spotlight interaction span is ever sent
let sawSpotlightInteractionSpan = false;
await observeStreamedSpan(page, span => {
if (getSpanOp(span) === 'ui.interaction.click' && span.name?.includes('#sentry-spotlight')) {
if (
getSpanOp(span) === 'ui.interaction.click' &&
span.attributes['browser.web_vital.inp.target']?.value === SPOTLIGHT_BUTTON
) {
sawSpotlightInteractionSpan = true;
return true;
}
Expand All @@ -39,18 +47,17 @@ sentryTest(

// Click on the regular button — its ui.interaction.click child should be kept
const regularInteractionSpansPromise = waitForStreamedSpans(page, spans =>
spans.some(span => getSpanOp(span) === 'ui.interaction.click' && !span.name?.includes('#sentry-spotlight')),
spans.some(span => span.attributes['browser.web_vital.inp.target']?.value === REGULAR_BUTTON),
);

await page.locator('[data-test-id=regular-button]').click();
await page.locator('.clicked[data-test-id=regular-button]').isVisible();

const regularSpans = await regularInteractionSpansPromise;
const regularInteractionSpan = regularSpans.find(
span => getSpanOp(span) === 'ui.interaction.click' && !span.name?.includes('#sentry-spotlight'),
span => span.attributes['browser.web_vital.inp.target']?.value === REGULAR_BUTTON,
);
expect(regularInteractionSpan).toBeDefined();
expect(regularInteractionSpan!.name).toContain('button');
expect(getSpanOp(regularInteractionSpan!)).toBe('ui.interaction.click');

// Verify no spotlight interaction span was ever sent
expect(sawSpotlightInteractionSpan).toBe(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
SENTRY_SDK_VERSION,
SENTRY_TRACE_LIFECYCLE,
USER_AGENT_ORIGINAL,
URL_PATH,
} from '@sentry/conventions/attributes';
import { sentryTest } from '../../../../utils/fixtures';
import { shouldSkipTracingTest } from '../../../../utils/helpers';
Expand Down Expand Up @@ -70,6 +71,10 @@ sentryTest('captures streamed interaction span tree. @firefox', async ({ browser
type: 'string',
value: expect.any(String),
},
[URL_PATH]: {
type: 'string',
value: '/index.html',
},
[SEMANTIC_ATTRIBUTE_SENTRY_IDLE_SPAN_FINISH_REASON]: {
type: 'string',
value: 'idleTimeout',
Expand Down Expand Up @@ -100,11 +105,11 @@ sentryTest('captures streamed interaction span tree. @firefox', async ({ browser
},
[SENTRY_SEGMENT_NAME]: {
type: 'string',
value: 'Pageload',
value: 'Click',

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fixes a bug previously, since we took the "Pageload" low card. name from the active pageload span previously. "Click" is better than that IMHO

},
[SENTRY_SEGMENT_NAME_SOURCE]: {
type: 'string',
value: 'url',
value: 'custom',
},
[SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT]: {
type: 'string',
Expand All @@ -113,8 +118,7 @@ sentryTest('captures streamed interaction span tree. @firefox', async ({ browser
},
end_timestamp: expect.any(Number),
is_segment: true,
// Interaction spans are named after the current route, which is the pageload span's name.
name: 'Pageload',
name: 'Click',
span_id: interactionSegmentSpan!.span_id,
start_timestamp: expect.any(Number),
status: 'ok',
Expand Down Expand Up @@ -157,16 +161,20 @@ sentryTest('captures streamed interaction span tree. @firefox', async ({ browser
},
[SENTRY_SEGMENT_NAME]: {
type: 'string',
value: 'Pageload',
value: 'Click',
},
[SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT]: {
type: 'string',
value: 'production',
},
'browser.web_vital.inp.target': {
type: 'string',
value: 'body > button.clicked',
},
},
end_timestamp: expect.any(Number),
is_segment: false,
name: 'body > button.clicked',
name: 'Click',
parent_span_id: interactionSegmentSpan!.span_id,
span_id: expect.stringMatching(/^[\da-f]{16}$/),
start_timestamp: expect.any(Number),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ sentryTest(
attributes: {
'sentry.origin': { value: 'auto.http.browser.inp', type: 'string' },
'sentry.op': { value: 'ui.interaction.click', type: 'string' },
'ui.component_name': { value: 'NormalButton', type: 'string' },
'browser.web_vital.inp.target': { value: 'body > NormalButton', type: 'string' },
'sentry.exclusive_time': { value: inpValue, type: expect.stringMatching(/^(integer)|(double)$/) },
'browser.web_vital.inp.value': { value: inpValue, type: expect.stringMatching(/^(integer)|(double)$/) },
'browser.web_vital.inp.target': { value: 'body > NormalButton', type: 'string' },
'browser.web_vital.inp.interaction_type': { value: 'click', type: 'string' },
'browser.navigation.type': { value: 'navigate', type: 'string' },
'sentry.transaction': { value: 'test-url', type: 'string' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ sentryTest(
attributes: {
'sentry.origin': { value: 'auto.http.browser.inp', type: 'string' },
'sentry.op': { value: 'ui.interaction.click', type: 'string' },
'ui.component_name': { value: 'NavigationLink', type: 'string' },
'browser.web_vital.inp.target': { value: 'body > nav#navigation > NavigationLink', type: 'string' },
'sentry.exclusive_time': { value: inpValue, type: expect.stringMatching(/^(integer)|(double)$/) },
'browser.web_vital.inp.value': { value: inpValue, type: expect.stringMatching(/^(integer)|(double)$/) },
'browser.web_vital.inp.target': { value: 'body > nav#navigation > NavigationLink', type: 'string' },
'browser.web_vital.inp.interaction_type': { value: 'click', type: 'string' },
'browser.navigation.type': { value: 'navigate', type: 'string' },
'sentry.transaction': { value: 'test-url', type: 'string' },
Expand Down Expand Up @@ -163,9 +164,9 @@ sentryTest(
attributes: {
'sentry.origin': { value: 'auto.http.browser.inp', type: 'string' },
'sentry.op': { value: 'ui.interaction.click', type: 'string' },
'browser.web_vital.inp.target': { value: 'body > nav#navigation > NavigationLink', type: 'string' },
'sentry.exclusive_time': { value: inpValue, type: expect.stringMatching(/^(integer)|(double)$/) },
'browser.web_vital.inp.value': { value: inpValue, type: expect.stringMatching(/^(integer)|(double)$/) },
'browser.web_vital.inp.target': { value: 'body > nav#navigation > NavigationLink', type: 'string' },
'browser.web_vital.inp.interaction_type': { value: 'click', type: 'string' },
'browser.navigation.type': { value: 'navigate', type: 'string' },
'sentry.transaction': { value: 'test-url', type: 'string' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ sentryTest(
attributes: {
'sentry.origin': { value: 'auto.http.browser.inp', type: 'string' },
'sentry.op': { value: 'ui.interaction.click', type: 'string' },
'ui.component_name': { value: 'NormalButton', type: 'string' },
'browser.web_vital.inp.target': { value: 'body > NormalButton', type: 'string' },
'sentry.exclusive_time': { value: inpValue, type: expect.stringMatching(/^(integer)|(double)$/) },
'browser.web_vital.inp.value': { value: inpValue, type: expect.stringMatching(/^(integer)|(double)$/) },
'browser.web_vital.inp.target': { value: 'body > NormalButton', type: 'string' },
'browser.web_vital.inp.interaction_type': { value: 'click', type: 'string' },
'browser.navigation.type': { value: 'navigate', type: 'string' },
// the parametrized route name flows onto the INP span
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ sentryTest(
attributes: {
'sentry.origin': { value: 'auto.http.browser.inp', type: 'string' },
'sentry.op': { value: 'ui.interaction.click', type: 'string' },
'ui.component_name': { value: 'NormalButton', type: 'string' },
'browser.web_vital.inp.target': { value: 'body > NormalButton', type: 'string' },
'sentry.exclusive_time': { value: inpValue, type: expect.stringMatching(/^(integer)|(double)$/) },
'browser.web_vital.inp.value': { value: inpValue, type: expect.stringMatching(/^(integer)|(double)$/) },
'browser.web_vital.inp.target': { value: 'body > NormalButton', type: 'string' },
'browser.web_vital.inp.interaction_type': { value: 'click', type: 'string' },
'browser.navigation.type': { value: 'navigate', type: 'string' },
// the parametrized route name flows onto the INP span
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ sentryTest('captures INP click as a streamed span', async ({ getLocalTestUrl, pa

expect(inpSpan.attributes['sentry.exclusive_time']?.value).toBeGreaterThan(0);

expect(inpSpan.name).toBe('body > NormalButton');
expect(inpSpan.name).toBe('NormalButton');
expect(inpSpan.attributes['ui.component_name']).toEqual({ type: 'string', value: 'NormalButton' });
expect(inpSpan.attributes['browser.web_vital.inp.target']).toEqual({ type: 'string', value: 'body > NormalButton' });

expect(inpSpan.end_timestamp).toBeGreaterThan(inpSpan.start_timestamp);

Expand Down Expand Up @@ -75,7 +77,9 @@ sentryTest('captures the slowest interaction as streamed INP span', async ({ get

const inpSpan = await inpSpanPromise;

expect(inpSpan.name).toBe('body > SlowButton');
expect(inpSpan.name).toBe('SlowButton');
expect(inpSpan.attributes['ui.component_name']).toEqual({ type: 'string', value: 'SlowButton' });
expect(inpSpan.attributes['browser.web_vital.inp.target']).toEqual({ type: 'string', value: 'body > SlowButton' });
expect(inpSpan.attributes['sentry.exclusive_time']?.value).toBeGreaterThan(400);

const inpValue = inpSpan.attributes['browser.web_vital.inp.value']?.value as number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ sentryTest(
attributes: {
'sentry.origin': { value: 'auto.http.browser.inp', type: 'string' },
'sentry.op': { value: 'ui.interaction.click', type: 'string' },
'ui.component_name': { value: 'NormalButton', type: 'string' },
'browser.web_vital.inp.target': { value: 'body > NormalButton', type: 'string' },
'sentry.exclusive_time': { value: inpValue, type: expect.stringMatching(/^(integer)|(double)$/) },
'browser.web_vital.inp.value': { value: inpValue, type: expect.stringMatching(/^(integer)|(double)$/) },
'browser.web_vital.inp.target': { value: 'body > NormalButton', type: 'string' },
'browser.web_vital.inp.interaction_type': { value: 'click', type: 'string' },
'browser.navigation.type': { value: 'navigate', type: 'string' },
'sentry.transaction': { value: 'test-url', type: 'string' },
Expand Down Expand Up @@ -148,9 +149,10 @@ sentryTest(
attributes: {
'sentry.origin': { value: 'auto.http.browser.inp', type: 'string' },
'sentry.op': { value: 'ui.interaction.click', type: 'string' },
'ui.component_name': { value: 'SlowButton', type: 'string' },
'browser.web_vital.inp.target': { value: 'body > SlowButton', type: 'string' },
'sentry.exclusive_time': { value: inpValue, type: expect.stringMatching(/^(integer)|(double)$/) },
'browser.web_vital.inp.value': { value: inpValue, type: expect.stringMatching(/^(integer)|(double)$/) },
'browser.web_vital.inp.target': { value: 'body > SlowButton', type: 'string' },
'browser.web_vital.inp.interaction_type': { value: 'click', type: 'string' },
'browser.navigation.type': { value: 'navigate', type: 'string' },
'sentry.transaction': { value: 'test-url', type: 'string' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,17 +275,21 @@ test.describe('TraceDirective', () => {
expect(traceDirectiveSpans).toEqual(
expect.arrayContaining([
expect.objectContaining({
name: '<sample-component>', // custom component name passed to trace directive
name: 'sample-component', // custom component name passed to trace directive
attributes: expect.objectContaining({
'sentry.op': { type: 'string', value: 'ui.mount' },
'sentry.origin': { type: 'string', value: 'auto.ui.angular.trace_directive' },
'ui.component_name': { type: 'string', value: 'sample-component' },
'sentry.description': { type: 'string', value: '<sample-component>' },
}),
}),
expect.objectContaining({
name: '<app-sample-component>', // fallback selector name
name: 'app-sample-component', // fallback element tag name
attributes: expect.objectContaining({
'sentry.op': { type: 'string', value: 'ui.mount' },
'sentry.origin': { type: 'string', value: 'auto.ui.angular.trace_directive' },
'ui.component_name': { type: 'string', value: 'app-sample-component' },
'sentry.description': { type: 'string', value: '<app-sample-component>' },
}),
}),
]),
Expand Down Expand Up @@ -318,10 +322,12 @@ test.describe('TraceClass Decorator', () => {
expect(classDecoratorSpan).toBeDefined();
expect(classDecoratorSpan).toEqual(
expect.objectContaining({
name: '<ComponentTrackingComponent>',
name: 'ComponentTrackingComponent',
attributes: expect.objectContaining({
'sentry.op': { type: 'string', value: 'ui.mount' },
'sentry.origin': { type: 'string', value: 'auto.ui.angular.trace_class_decorator' },
'ui.component_name': { type: 'string', value: 'ComponentTrackingComponent' },
'sentry.description': { type: 'string', value: '<ComponentTrackingComponent>' },
}),
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,12 @@ test.describe('TraceDirective', () => {
expect(traceDirectiveSpan).toBeDefined();
expect(traceDirectiveSpan).toEqual(
expect.objectContaining({
name: '<sample-component>',
name: 'sample-component',
attributes: expect.objectContaining({
'sentry.op': { type: 'string', value: 'ui.mount' },
'sentry.origin': { type: 'string', value: 'auto.ui.angular.trace_directive' },
'ui.component_name': { type: 'string', value: 'sample-component' },
'sentry.description': { type: 'string', value: '<sample-component>' },
}),
}),
);
Expand Down Expand Up @@ -308,10 +310,12 @@ test.describe('TraceClass Decorator', () => {
expect(classDecoratorSpan).toBeDefined();
expect(classDecoratorSpan).toEqual(
expect.objectContaining({
name: '<ComponentTrackingComponent>',
name: 'ComponentTrackingComponent',
attributes: expect.objectContaining({
'sentry.op': { type: 'string', value: 'ui.mount' },
'sentry.origin': { type: 'string', value: 'auto.ui.angular.trace_class_decorator' },
'ui.component_name': { type: 'string', value: 'ComponentTrackingComponent' },
'sentry.description': { type: 'string', value: '<ComponentTrackingComponent>' },
}),
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ test.describe('TraceDirective', () => {
data: {
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'ui.mount',
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.angular.trace_directive',
'ui.component_name': 'sample-component',
},
description: '<sample-component>', // custom component name passed to trace directive
op: 'ui.mount',
Expand All @@ -278,6 +279,7 @@ test.describe('TraceDirective', () => {
data: {
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'ui.mount',
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.angular.trace_directive',
'ui.component_name': 'app-sample-component',
},
description: '<app-sample-component>', // fallback selector name
op: 'ui.mount',
Expand Down Expand Up @@ -311,6 +313,7 @@ test.describe('TraceClass Decorator', () => {
data: {
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'ui.mount',
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.angular.trace_class_decorator',
'ui.component_name': 'ComponentTrackingComponent',
},
description: '<ComponentTrackingComponent>',
op: 'ui.mount',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,17 +275,21 @@ test.describe('TraceDirective', () => {
expect(traceDirectiveSpans).toEqual(
expect.arrayContaining([
expect.objectContaining({
name: '<sample-component>', // custom component name passed to trace directive
name: 'sample-component', // custom component name passed to trace directive
attributes: expect.objectContaining({
'sentry.op': { type: 'string', value: 'ui.mount' },
'sentry.origin': { type: 'string', value: 'auto.ui.angular.trace_directive' },
'ui.component_name': { type: 'string', value: 'sample-component' },
'sentry.description': { type: 'string', value: '<sample-component>' },
}),
}),
expect.objectContaining({
name: '<app-sample-component>', // fallback selector name
name: 'app-sample-component', // fallback element tag name
attributes: expect.objectContaining({
'sentry.op': { type: 'string', value: 'ui.mount' },
'sentry.origin': { type: 'string', value: 'auto.ui.angular.trace_directive' },
'ui.component_name': { type: 'string', value: 'app-sample-component' },
'sentry.description': { type: 'string', value: '<app-sample-component>' },
}),
}),
]),
Expand Down Expand Up @@ -318,10 +322,12 @@ test.describe('TraceClass Decorator', () => {
expect(classDecoratorSpan).toBeDefined();
expect(classDecoratorSpan).toEqual(
expect.objectContaining({
name: '<ComponentTrackingComponent>',
name: 'ComponentTrackingComponent',
attributes: expect.objectContaining({
'sentry.op': { type: 'string', value: 'ui.mount' },
'sentry.origin': { type: 'string', value: 'auto.ui.angular.trace_class_decorator' },
'ui.component_name': { type: 'string', value: 'ComponentTrackingComponent' },
'sentry.description': { type: 'string', value: '<ComponentTrackingComponent>' },
}),
}),
);
Expand Down
Loading
Loading