-
-
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.
feat(replay): Rework slow click & multi click detection (#8322)
This PR reworks the slow click detection to accommodate rage click detection as well. This required substantial changes, as we need to keep track of stuff much more. Now, we keep a list of clicks that come in in a new class. We register a single set of listeners (mutation observer, click listener, scroll listener), and then try to route things to the correct clicks as much as possible. Any clicks within 1 second count as "multi click", so are not considered for slow clicks at all, but counted on the first click. After a second, a click (even on the same element) will be treated as a "new" click. ref #8300
- Loading branch information
Showing
17 changed files
with
1,142 additions
and
237 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
60 changes: 60 additions & 0 deletions
60
packages/browser-integration-tests/suites/replay/slowClick/multiClick/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,60 @@ | ||
import { expect } from '@playwright/test'; | ||
|
||
import { sentryTest } from '../../../../utils/fixtures'; | ||
import { getCustomRecordingEvents, shouldSkipReplayTest, waitForReplayRequest } from '../../../../utils/replayHelpers'; | ||
|
||
sentryTest('captures multi click when not detecting slow click', async ({ getLocalTestUrl, page }) => { | ||
if (shouldSkipReplayTest()) { | ||
sentryTest.skip(); | ||
} | ||
|
||
const reqPromise0 = waitForReplayRequest(page, 0); | ||
|
||
await page.route('https://dsn.ingest.sentry.io/**/*', route => { | ||
return route.fulfill({ | ||
status: 200, | ||
contentType: 'application/json', | ||
body: JSON.stringify({ id: 'test-id' }), | ||
}); | ||
}); | ||
|
||
const url = await getLocalTestUrl({ testDir: __dirname }); | ||
|
||
await page.goto(url); | ||
await reqPromise0; | ||
|
||
const reqPromise1 = waitForReplayRequest(page, (event, res) => { | ||
const { breadcrumbs } = getCustomRecordingEvents(res); | ||
|
||
return breadcrumbs.some(breadcrumb => breadcrumb.category === 'ui.multiClick'); | ||
}); | ||
|
||
await page.click('#mutationButtonImmediately', { clickCount: 4 }); | ||
|
||
const { breadcrumbs } = getCustomRecordingEvents(await reqPromise1); | ||
|
||
const slowClickBreadcrumbs = breadcrumbs.filter(breadcrumb => breadcrumb.category === 'ui.multiClick'); | ||
|
||
expect(slowClickBreadcrumbs).toEqual([ | ||
{ | ||
category: 'ui.multiClick', | ||
type: 'default', | ||
data: { | ||
clickCount: 4, | ||
metric: true, | ||
node: { | ||
attributes: { | ||
id: 'mutationButtonImmediately', | ||
}, | ||
id: expect.any(Number), | ||
tagName: 'button', | ||
textContent: '******* ******** ***********', | ||
}, | ||
nodeId: expect.any(Number), | ||
url: 'http://sentry-test.io/index.html', | ||
}, | ||
message: 'body > button#mutationButtonImmediately', | ||
timestamp: expect.any(Number), | ||
}, | ||
]); | ||
}); |
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
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
Oops, something went wrong.