buildClickEventData function
Map<String, String>
buildClickEventData(
- ClickTarget target,
- int clickSequence, {
- String? checked,
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.
checked is the control's state AFTER the tap, from ClickChecked, or
null when it has none or it could not be read.
Implementation
Map<String, String> buildClickEventData(
ClickTarget target,
int clickSequence, {
String? checked,
}) {
final name = resolveClickName(target);
final kind = clickKindFor(target.role);
final eventName = '${name.stem}_${kind.suffix}';
final legacy = target.legacyEventName;
return {
'event_name': eventName,
'element_id': name.stem,
'type': kind.eventType,
'kind': kind.wire,
if (target.role != null) 'role': target.role!,
if (kind.hasCheckedState && checked != null) 'checked': checked,
// The tracker never reports the agent's own taps, so every event is the
// user's. Sent so the shape matches web, which has all three sources.
'source': 'user',
'click_sequence': '$clickSequence',
'component': target.component,
if (legacy != null && legacy != eventName && !looksSensitive(legacy))
'legacy_event_name': legacy,
};
}