Skip to content

RUNE-99: Add opt-in capture of UI button clicks - #839

Open
nattb8 wants to merge 2 commits into
mainfrom
feat/rune-99-button-click-capture
Open

nattb8 wants to merge 2 commits into
mainfrom
feat/rune-99-button-click-capture

Conversation

@nattb8

@nattb8 nattb8 commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Menu and button clicks show how players move through a game, and many studios hand write them. They are also the easiest way to flood the product with events, so this is opt-in and uses the same switches, caps, sampling and consent as the other automatic events.

What studios get

Event Sent when Properties
button_clicked A player presses a Unity UI button or a UI Toolkit button element_id (the button's name), element_type (always button), scene_name (the scene the button is in)

button_clicked, element_id and element_type are the names the web SDK and the event catalog already use, so one chart reads both. The web SDK also sends the label as button_text. This one never does. The scene tells apart generic names such as Back that repeat across screens, and uses the same key as the scene events. A button kept with DontDestroyOnLoad reports the active scene, because that pseudo-scene says nothing.

Set AudienceConfig.Autocapture.ButtonClicks.Enabled = true to switch it on. It is off by default. Up to 50 events per session and a sampling rate, like the other groups, and Anonymous consent or higher.

How it stays safe

  • Names only. The label text is never read. Button names can reveal unreleased content, and the docs say so.
  • Off costs nothing. With the group off, no hook is installed and nothing is scanned.
  • No new dependency. The uGUI half and the UI Toolkit half are separate assemblies that only compile when that package or module is in the project, so a game with neither still builds.
  • Never throws into the game. A hook that throws logs a warning and the game's own handlers still run.
  • Name clash warning. A game that sends button_clicked itself gets the existing one-time warning once the group is on.

How buttons are found

UI system How Not captured
UI Toolkit One callback on each panel sees every click and keyboard or gamepad submit, so buttons made later are covered A button with no name is skipped, because the click would say nothing about which button it was
uGUI A listener on each button's onClick, added at Init and on each scene load, including inactive buttons in closed panels A button created after the scene loaded, such as an instantiated prefab, waits for the next scene load

Testing

  • Dotnet: 622 pass, 0 fail.
  • Unity 2021.3 and 6000.4: 644 tests, the same 4 failures and 2 skips as on main. 22 of the new tests drive real uGUI buttons and real UI Toolkit events, including a scene loaded on top of another and a canvas kept across scenes.
  • The sample app gets a switch for the group. Its end-to-end tests send real click events through the panel: one checks the event carries the button name and never the label, one checks nothing is sent while the group is off, and one clicks 120 times and checks exactly 50 are queued and the cap is logged once.
  • The sample project now lists com.unity.ugui, so CI compiles the uGUI half for every platform and Unity version. Unity 6 upgrades it to 2.0.0 by itself.
  • Mutation checks: each new test failed when the code it covers was broken.

🤖 Generated with Claude Code

Adds a ButtonClicks autocapture group, off by default, that sends
button_clicked with the button's name and type when a Unity UI or UI
Toolkit button is pressed. The label text is never read. It follows the
group switch, minimum consent, session sampling and per session cap like
the other groups, and a game that sends the same name by hand gets the
existing name clash warning once the group is on.

The uGUI and UI Toolkit hooks are separate assemblies that only compile
when that package or module is in the project, so a project with
neither still builds. The sample project now lists com.unity.ugui so CI
compiles the uGUI half on every platform and Unity version.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@nattb8
nattb8 requested review from a team as code owners December 2, 2026 03:56
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Audience SDK — Build Size

Platform SDK Size Change
Android 1.35 / 20.00 MB +0.99 MB ✅
Windows 0.61 / 20.00 MB +0.45 MB ✅
iOS 11.39 / 20.00 MB +2.87 MB ✅
macOS 3.57 / 20.00 MB +2.67 MB ✅

SDK Size = build minus empty app. Change = vs baseline. Fails if any platform exceeds its absolute size limit.

A generic button name such as Back repeats across screens, so
button_clicked now also carries scene_name, the same key the scene
events use. A uGUI button reports the scene of its GameObject and a UI
Toolkit button the scene of its UIDocument. A button kept with
DontDestroyOnLoad reports the active scene, since that pseudo-scene says
nothing, and the property is left out when the name is empty.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant