Skip to content

🐛 [RUM-13693] make sure click actions are flushed on page exit#4070

Merged
BenoitZugmeyer merged 1 commit intomainfrom
benoit/flush-click-actions-on-page-exit
Jan 12, 2026
Merged

🐛 [RUM-13693] make sure click actions are flushed on page exit#4070
BenoitZugmeyer merged 1 commit intomainfrom
benoit/flush-click-actions-on-page-exit

Conversation

@BenoitZugmeyer
Copy link
Copy Markdown
Member

@BenoitZugmeyer BenoitZugmeyer commented Jan 9, 2026

Motivation

When a click results in a page navigation (ex: clicking on a link), the click action is likely to be missing.

This is because whenever a click happens, we wait a bit before reporting it to compute frustration signals. As a reminder:

  • for ‘rage clicks’ we wait a bit (1 second) to see if there is another click quickly following the click
  • for ‘dead clicks’ we wait a bit (100ms) to see if there is any page activity following the click
  • for ‘error clicks' we wait a bit (100ms) to see if there is any error following the click

When the page is exiting, we don’t have time to wait for frustration signals: we should send the click action as soon as possible.

This looks like a regression brought by #3446 : since this PR, we don’t end the view anymore on unload, but we relied on the view ending to flush the click.

Changes

Stop/flush click actions whenever the page might exit.

Test instructions

To reproduce, in the sandbox, add the following:

 <script type="module">
      function getAnotherUrl() {
        const url = new URL(window.location.href)
        url.searchParams.set('foo', Math.random())
        return url.href
      }

      const button = document.createElement('button')
      button.innerText = 'Hard reload'
      button.addEventListener('click', () => {
        window.location.href = getAnotherUrl()
      })
      document.body.append(button)

      const button2 = document.createElement('button')
      button2.innerText = 'Soft reload'
      button2.addEventListener('click', () => {
        history.pushState(null, null, getAnotherUrl())
      })
      document.body.append(button2)
</script>

Click on the “Soft reload” button → the click action is correctly sent

Click on the “Hard reload” button → the click action isn’t sent. With this change, the click action should be sent.

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.

@BenoitZugmeyer BenoitZugmeyer force-pushed the benoit/flush-click-actions-on-page-exit branch from a362e2b to dfa55b5 Compare January 9, 2026 15:46
@datadog-official
Copy link
Copy Markdown

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage
Patch Coverage: 100.00%
Overall Coverage: 77.28% (+0.00%)

View detailed report

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: dfa55b5 | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@cit-pr-commenter
Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 164.29 KiB 164.31 KiB +24 B +0.01%
Rum Profiler 4.33 KiB 4.33 KiB 0 B 0.00%
Rum Recorder 20.01 KiB 20.01 KiB 0 B 0.00%
Logs 56.10 KiB 56.10 KiB 0 B 0.00%
Flagging 944 B 944 B 0 B 0.00%
Rum Slim 121.50 KiB 121.53 KiB +21 B +0.02%
Worker 23.63 KiB 23.63 KiB 0 B 0.00%
🚀 CPU Performance
Action Name Base CPU Time (ms) Local CPU Time (ms) 𝚫%
RUM - add global context 0.0041 0.0044 +7.32%
RUM - add action 0.0125 0.016 +28.00%
RUM - add error 0.0119 0.0168 +41.18%
RUM - add timing 0.0028 0.0049 +75.00%
RUM - start view 0.0034 0.0047 +38.24%
RUM - start/stop session replay recording 0.0007 0.0007 0.00%
Logs - log message 0.0136 0.0156 +14.71%
🧠 Memory Performance
Action Name Base Memory Consumption Local Memory Consumption 𝚫
RUM - add global context 26.42 KiB 25.99 KiB -445 B
RUM - add action 48.94 KiB 47.92 KiB -1.02 KiB
RUM - add timing 25.61 KiB 25.30 KiB -315 B
RUM - add error 54.78 KiB 54.39 KiB -408 B
RUM - start/stop session replay recording 24.18 KiB 23.98 KiB -214 B
RUM - start view 422.88 KiB 422.07 KiB -837 B
Logs - log message 46.21 KiB 43.31 KiB -2.90 KiB

🔗 RealWorld

@BenoitZugmeyer
Copy link
Copy Markdown
Member Author

/to-staging

@dd-devflow-routing-codex
Copy link
Copy Markdown

dd-devflow-routing-codex bot commented Jan 9, 2026

View all feedbacks in Devflow UI.

2026-01-09 16:25:18 UTC ℹ️ Start processing command /to-staging


2026-01-09 16:25:28 UTC ℹ️ Branch Integration: starting soon, merge expected in approximately 23m (p90)

Commit dfa55b5bfe will soon be integrated into staging-02.


2026-01-09 16:39:30 UTC ℹ️ Branch Integration: this commit was successfully integrated

Commit dfa55b5bfe has been merged into staging-02 in merge commit 4d8bdd0abd.

Check out the triggered pipeline on Gitlab 🦊

If you need to revert this integration, you can use the following command: /code revert-integration -b staging-02

@BenoitZugmeyer BenoitZugmeyer changed the title 🐛 [RUM-13693] make sure click actions are sent on page exit 🐛 [RUM-13693] make sure click actions are flushed on page exit Jan 9, 2026
dd-mergequeue bot added a commit that referenced this pull request Jan 9, 2026
…g-02

Integrated commit sha: dfa55b5

Co-authored-by: BenoitZugmeyer <benoit.zugmeyer@datadoghq.com>
@dd-devflow dd-devflow bot added the staging-02 label Jan 9, 2026
@BenoitZugmeyer
Copy link
Copy Markdown
Member Author

/to-staging

@dd-devflow-routing-codex
Copy link
Copy Markdown

dd-devflow-routing-codex bot commented Jan 12, 2026

View all feedbacks in Devflow UI.

2026-01-12 09:05:48 UTC ℹ️ Start processing command /to-staging


2026-01-12 09:05:55 UTC ℹ️ Branch Integration: starting soon, merge expected in approximately 0s (p90)

Commit dfa55b5bfe will soon be integrated into staging-03.


2026-01-12 09:20:03 UTC ℹ️ Branch Integration: this commit was successfully integrated

Commit dfa55b5bfe has been merged into staging-03 in merge commit 99604b2262.

Check out the triggered pipeline on Gitlab 🦊

If you need to revert this integration, you can use the following command: /code revert-integration -b staging-03

dd-mergequeue bot added a commit that referenced this pull request Jan 12, 2026
…g-03

Integrated commit sha: dfa55b5

Co-authored-by: BenoitZugmeyer <benoit.zugmeyer@datadoghq.com>
@BenoitZugmeyer BenoitZugmeyer marked this pull request as ready for review January 12, 2026 10:07
@BenoitZugmeyer BenoitZugmeyer requested a review from a team as a code owner January 12, 2026 10:07
@BenoitZugmeyer BenoitZugmeyer merged commit cbcc492 into main Jan 12, 2026
23 checks passed
@BenoitZugmeyer BenoitZugmeyer deleted the benoit/flush-click-actions-on-page-exit branch January 12, 2026 14:55
@github-actions github-actions bot locked and limited conversation to collaborators Jan 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants