-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(inp): Ensure INP spans have correct transaction
- Loading branch information
Showing
7 changed files
with
239 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 14 additions & 1 deletion
15
dev-packages/e2e-tests/test-applications/create-remix-app/app/routes/user.$id.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
export default function User() { | ||
return <div>I am a blank page</div>; | ||
return ( | ||
<div> | ||
<div>I am a blank page</div> | ||
<button | ||
type="button" | ||
id="button" | ||
onClick={() => { | ||
console.log('Button clicked'); | ||
}} | ||
> | ||
Click button | ||
</button> | ||
</div> | ||
); | ||
} |
194 changes: 194 additions & 0 deletions
194
dev-packages/e2e-tests/test-applications/create-remix-app/tests/client-inp.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,194 @@ | ||
import { expect, test } from '@playwright/test'; | ||
import { waitForEnvelopeItem, waitForTransaction } from '@sentry-internal/test-utils'; | ||
|
||
test('sends an INP span during pageload', async ({ page }) => { | ||
const inpSpanPromise = waitForEnvelopeItem('create-remix-app', item => { | ||
return item[0].type === 'span'; | ||
}); | ||
|
||
await page.goto(`/`); | ||
|
||
await page.click('#exception-button'); | ||
|
||
await page.waitForTimeout(500); | ||
|
||
// Page hide to trigger INP | ||
await page.evaluate(() => { | ||
window.dispatchEvent(new Event('pagehide')); | ||
}); | ||
|
||
const inpSpan = await inpSpanPromise; | ||
|
||
expect(inpSpan[1]).toEqual({ | ||
data: { | ||
'sentry.origin': 'auto.http.browser.inp', | ||
'sentry.op': 'ui.interaction.click', | ||
release: 'e2e-test', | ||
environment: 'qa', | ||
transaction: 'routes/_index', | ||
'sentry.exclusive_time': expect.any(Number), | ||
'sentry.sample_rate': 1, | ||
'sentry.source': 'custom', | ||
replay_id: expect.any(String), | ||
}, | ||
description: 'body > div > input#exception-button[type="button"]', | ||
op: 'ui.interaction.click', | ||
parent_span_id: expect.any(String), | ||
is_segment: true, | ||
span_id: expect.any(String), | ||
start_timestamp: expect.any(Number), | ||
timestamp: expect.any(Number), | ||
trace_id: expect.any(String), | ||
origin: 'auto.http.browser.inp', | ||
exclusive_time: expect.any(Number), | ||
measurements: { inp: { unit: 'millisecond', value: expect.any(Number) } }, | ||
segment_id: expect.any(String), | ||
}); | ||
}); | ||
|
||
test('sends an INP span after pageload', async ({ page }) => { | ||
const transactionPromise = waitForTransaction('create-remix-app', transactionEvent => { | ||
return transactionEvent.contexts?.trace?.op === 'pageload' && transactionEvent.transaction === 'routes/_index'; | ||
}); | ||
|
||
await page.goto(`/`); | ||
|
||
await transactionPromise; | ||
|
||
const inpSpanPromise1 = waitForEnvelopeItem('create-remix-app', item => { | ||
return item[0].type === 'span'; | ||
}); | ||
|
||
await page.click('#exception-button'); | ||
|
||
await page.waitForTimeout(500); | ||
|
||
// Page hide to trigger INP | ||
await page.evaluate(() => { | ||
window.dispatchEvent(new Event('pagehide')); | ||
}); | ||
|
||
const inpSpan1 = await inpSpanPromise1; | ||
|
||
expect(inpSpan1[1]).toEqual({ | ||
data: { | ||
'sentry.origin': 'auto.http.browser.inp', | ||
'sentry.op': 'ui.interaction.click', | ||
release: 'e2e-test', | ||
environment: 'qa', | ||
transaction: 'routes/_index', | ||
'sentry.exclusive_time': expect.any(Number), | ||
'sentry.sample_rate': 1, | ||
'sentry.source': 'custom', | ||
replay_id: expect.any(String), | ||
}, | ||
description: 'body > div > input#exception-button[type="button"]', | ||
op: 'ui.interaction.click', | ||
parent_span_id: expect.any(String), | ||
is_segment: true, | ||
span_id: expect.any(String), | ||
start_timestamp: expect.any(Number), | ||
timestamp: expect.any(Number), | ||
trace_id: expect.any(String), | ||
origin: 'auto.http.browser.inp', | ||
exclusive_time: expect.any(Number), | ||
measurements: { inp: { unit: 'millisecond', value: expect.any(Number) } }, | ||
segment_id: expect.any(String), | ||
}); | ||
}); | ||
|
||
test('sends an INP span during navigation', async ({ page }) => { | ||
page.on('console', msg => console.log(msg.text())); | ||
const inpSpanPromise = waitForEnvelopeItem('create-remix-app', item => { | ||
return item[0].type === 'span'; | ||
}); | ||
|
||
await page.goto(`/`); | ||
|
||
await page.click('#navigation'); | ||
|
||
await page.waitForTimeout(500); | ||
|
||
// Page hide to trigger INP | ||
await page.evaluate(() => { | ||
window.dispatchEvent(new Event('pagehide')); | ||
}); | ||
|
||
const inpSpan = await inpSpanPromise; | ||
|
||
expect(inpSpan[1]).toEqual({ | ||
data: { | ||
'sentry.origin': 'auto.http.browser.inp', | ||
'sentry.op': 'ui.interaction.click', | ||
release: 'e2e-test', | ||
environment: 'qa', | ||
transaction: 'routes/user.$id', | ||
'sentry.exclusive_time': expect.any(Number), | ||
replay_id: expect.any(String), | ||
}, | ||
description: '<unknown>', | ||
op: 'ui.interaction.click', | ||
parent_span_id: expect.any(String), | ||
span_id: expect.any(String), | ||
start_timestamp: expect.any(Number), | ||
timestamp: expect.any(Number), | ||
trace_id: expect.any(String), | ||
origin: 'auto.http.browser.inp', | ||
exclusive_time: expect.any(Number), | ||
measurements: { inp: { unit: 'millisecond', value: expect.any(Number) } }, | ||
segment_id: expect.any(String), | ||
}); | ||
}); | ||
|
||
test('sends an INP span after navigation', async ({ page }) => { | ||
page.on('console', msg => console.log(msg.text())); | ||
const transactionPromise = waitForTransaction('create-remix-app', transactionEvent => { | ||
return transactionEvent.contexts?.trace?.op === 'navigation' && transactionEvent.transaction === 'routes/user.$id'; | ||
}); | ||
|
||
await page.goto(`/`); | ||
|
||
await page.click('#navigation'); | ||
|
||
await transactionPromise; | ||
|
||
const inpSpanPromise = waitForEnvelopeItem('create-remix-app', item => { | ||
return item[0].type === 'span'; | ||
}); | ||
|
||
await page.click('#button'); | ||
|
||
await page.waitForTimeout(500); | ||
|
||
// Page hide to trigger INP | ||
await page.evaluate(() => { | ||
window.dispatchEvent(new Event('pagehide')); | ||
}); | ||
|
||
const inpSpan = await inpSpanPromise; | ||
|
||
expect(inpSpan[1]).toEqual({ | ||
data: { | ||
'sentry.origin': 'auto.http.browser.inp', | ||
'sentry.op': 'ui.interaction.click', | ||
release: 'e2e-test', | ||
environment: 'qa', | ||
transaction: 'routes/user.$id', | ||
'sentry.exclusive_time': expect.any(Number), | ||
replay_id: expect.any(String), | ||
'sentry.sample_rate': 1, | ||
'sentry.source': 'custom', | ||
}, | ||
description: '<unknown>', | ||
op: 'ui.interaction.click', | ||
is_segment: true, | ||
span_id: expect.any(String), | ||
start_timestamp: expect.any(Number), | ||
timestamp: expect.any(Number), | ||
trace_id: expect.any(String), | ||
origin: 'auto.http.browser.inp', | ||
exclusive_time: expect.any(Number), | ||
measurements: { inp: { unit: 'millisecond', value: expect.any(Number) } }, | ||
segment_id: expect.any(String), | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters