Skip to content
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

feat(browser): Add user agent to INP standalone span attributes #12896

Merged
merged 3 commits into from
Jul 16, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ sentryTest('should capture an INP click event span after pageload', async ({ bro
'sentry.sample_rate': 1,
'sentry.source': 'custom',
transaction: 'test-url',
'user_agent.original': expect.stringContaining('Chrome'),
},
measurements: {
inp: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ sentryTest(
'sentry.sample_rate': 1,
'sentry.source': 'custom',
transaction: 'test-route',
'user_agent.original': expect.stringContaining('Chrome'),
},
measurements: {
inp: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ sentryTest(
'sentry.op': 'ui.interaction.click',
'sentry.origin': 'auto.http.browser.inp',
transaction: 'test-route',
'user_agent.original': expect.stringContaining('Chrome'),
},
measurements: {
inp: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ sentryTest(
'sentry.op': 'ui.interaction.click',
'sentry.origin': 'auto.http.browser.inp',
transaction: 'test-url',
'user_agent.original': expect.stringContaining('Chrome'),
},
measurements: {
inp: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ test('sends an INP span during pageload', async ({ page }) => {
'sentry.sample_rate': 1,
'sentry.source': 'custom',
replay_id: expect.any(String),
'user_agent.original': expect.stringContaining('Chrome'),
},
description: 'body > div > input#exception-button[type="button"]',
op: 'ui.interaction.click',
Expand Down Expand Up @@ -81,6 +82,7 @@ test('sends an INP span after pageload', async ({ page }) => {
'sentry.sample_rate': 1,
'sentry.source': 'custom',
replay_id: expect.any(String),
'user_agent.original': expect.stringContaining('Chrome'),
},
description: 'body > div > input#exception-button[type="button"]',
op: 'ui.interaction.click',
Expand Down Expand Up @@ -125,6 +127,7 @@ test('sends an INP span during navigation', async ({ page }) => {
transaction: 'routes/user.$id',
'sentry.exclusive_time': expect.any(Number),
replay_id: expect.any(String),
'user_agent.original': expect.stringContaining('Chrome'),
},
description: '<unknown>',
op: 'ui.interaction.click',
Expand Down Expand Up @@ -178,6 +181,7 @@ test('sends an INP span after navigation', async ({ page }) => {
replay_id: expect.any(String),
'sentry.sample_rate': 1,
'sentry.source': 'custom',
'user_agent.original': expect.stringContaining('Chrome'),
},
description: '<unknown>',
op: 'ui.interaction.click',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ test('sends an INP span', async ({ page }) => {
transaction: '/',
'sentry.exclusive_time': expect.any(Number),
replay_id: expect.any(String),
'user_agent.original': expect.stringContaining('Chrome'),
},
description: 'body > div#root > input#exception-button[type="button"]',
op: 'ui.interaction.click',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ test('sends an INP span', async ({ page }) => {
transaction: '/',
'sentry.exclusive_time': expect.any(Number),
replay_id: expect.any(String),
'user_agent.original': expect.stringContaining('Chrome'),
},
description: 'body > div#root > input#exception-button[type="button"]',
op: 'ui.interaction.click',
Expand Down
4 changes: 4 additions & 0 deletions packages/browser-utils/src/metrics/inp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from '@sentry/core';
import type { Integration, Span, SpanAttributes } from '@sentry/types';
import { browserPerformanceTimeOrigin, dropUndefinedKeys, htmlTreeAsString } from '@sentry/utils';
import { WINDOW } from '../types';
import {
addInpInstrumentationHandler,
addPerformanceInstrumentationHandler,
Expand Down Expand Up @@ -129,6 +130,9 @@ function _trackINP(): () => void {
user: userDisplay || undefined,
profile_id: profileId || undefined,
replay_id: replayId || undefined,
// INP score calculation in the sentry backend relies on the user agent
// to account for different INP values being reported from different browsers
'user_agent.original': WINDOW.navigator && WINDOW.navigator.userAgent,
});

const span = startInactiveSpan({
Expand Down
Loading