Skip to content

feat(replay): Consider user input in form field as "user activity" #7355

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

Merged
merged 4 commits into from
Mar 7, 2023
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
2 changes: 1 addition & 1 deletion packages/replay/src/coreHandlers/addBreadcrumbEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function addBreadcrumbEvent(replay: ReplayContainer, breadcrumb: Breadcru
return;
}

if (breadcrumb.category === 'ui.click') {
if (['ui.click', 'ui.input'].includes(breadcrumb.category as string)) {
replay.triggerUserActivity();
} else {
replay.checkAndHandleExpiredSession();
Expand Down
20 changes: 20 additions & 0 deletions packages/replay/test/integration/sendReplayEvent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,26 @@ describe('Integration | sendReplayEvent', () => {
expect(replay.session?.lastActivity).toBe(BASE_TIMESTAMP + ELAPSED);
});

it('update last activity when user uses keyboard input', async () => {
expect(replay.session?.lastActivity).toBe(BASE_TIMESTAMP);

domHandler({
name: 'input',
});

expect(replay.session?.lastActivity).toBe(BASE_TIMESTAMP);

// Pretend 5 seconds have passed
const ELAPSED = 5000;
jest.advanceTimersByTime(ELAPSED);

domHandler({
name: 'input',
});

expect(replay.session?.lastActivity).toBe(BASE_TIMESTAMP + ELAPSED);
});

it('uploads a replay event if 5 seconds have elapsed since the last replay event occurred', async () => {
const TEST_EVENT = { data: {}, timestamp: BASE_TIMESTAMP, type: 3 };
mockRecord._emitter(TEST_EVENT);
Expand Down