core/events/click_naming library

Click analytics names — a port of Android 1.2.3 ClickNaming.kt (core/events), the wire authority, which RN 1.2.0 ports verbatim too.

  • the event name is <stem>_<suffix>, where the suffix says what happened to the control — pressed, toggled, selected, opened; the screen travels in the envelope's context.screen, never in the name;
  • the stem is the host's own identifier verbatim, else a slug of the control's label or visible text, else (RN and Flutter) the name of the icon, image or SVG it draws, else its role or component;
  • data carries element_id, type, kind, role, checked, source, click_sequence, component, legacy_event_name.

Only string work lives here. Finding the tapped control and reading its state is click_target_resolver.dart.

Classes

ClickChecked
checked as the wire spells it.
ClickName
A resolved name: the stem, and whether it is only the role or component fallback.
ClickRoles
The role vocabulary ClickTarget.role uses — the web tracker's data.role values.
ClickTarget
What one tap landed on, as the resolver found it. Every field is optional except component; resolveClickName decides which one names the event.

Enums

ClickKind
What a tap did, with the event-name suffix and the data.type the web SDK sends for it (typeForKind in click-element.ts).

Constants

kClickNameMaxTextChars → const int
Text beyond this is never read — the web, RN and Android cap.

Functions

buildClickEventData(ClickTarget target, int clickSequence, {String? checked}) → Map<String, String>
The analytics_data map for one tap. Keys in Android's order: event_name, element_id, type, kind, role, checked, source, click_sequence, component, legacy_event_name. A key whose value is unknown is omitted, never sent empty.
clickKindFor(String? role) → ClickKind
The kind a role implies. A control with no recognised role is a plain element.
identifiesSomeone(String text) → bool
True for text that identifies a person or their money: an e-mail or UPI id, a masked account or card number. Such text never becomes a name — not even slugged, because "rahul gmail com" still identifies Rahul.
looksSensitive(String text) → bool
True for text the backend should never receive as written: anything identifiesSomeone covers, plus long numbers and amounts. Gates the legacy name, which was sent as written.
normaliseClickText(String input) → String
Android's normaliseForMatch (NFD → strip combining marks → ASCII lowercase → every non-[a-z0-9] run to one space → trim), which the click names are defined against.
resolveClickName(ClickTarget target) → ClickName
The name a tap is reported under, first match wins:
slugClickName(String? text) → String
Human text to a name stem: lowercased, accents stripped, punctuation collapsed, words with a digit and currency words dropped, first four words, joined with _. "Pay ₹5,000 now" → pay_now, "Cart (3)" → cart. Empty for text that identifiesSomeone.
visualClickName(String? source) → String
An icon name or an image / SVG path or URL → a name stem, RN's visualName: the file name without folders, query, extension or @2x, separators to spaces, then slugClickName. assets/icons/ic_home.png → ic_home, https://cdn.x/img/gold-coin.svg?v=3 → gold_coin, account circle → account_circle. Empty for a generic name (icon, logo, placeholder …) or one that slugs to nothing (a hash, digits).