Skip to content

Add immediate and data parameter templates to EventHub#8942

Open
mark-szabo wants to merge 2 commits into
duckduckgo:developfrom
mark-szabo:feature/mark-szabo/eventhub-immediate-data-templates
Open

Add immediate and data parameter templates to EventHub#8942
mark-szabo wants to merge 2 commits into
duckduckgo:developfrom
mark-szabo:feature/mark-szabo/eventhub-immediate-data-templates

Conversation

@mark-szabo

@mark-szabo mark-szabo commented Jun 19, 2026

Copy link
Copy Markdown

Task/Issue URL: https://app.asana.com/1/137249556945/project/45878998844068/task/1213690772916070
Tech Design URL (if applicable): https://app.asana.com/1/137249556945/project/481882893211075/task/1215327441118832

Description

Brings the Android EventHub framework up to the cross-platform spec additions made while implementing EventHub on Windows. Closes the postmortem action item: "Implement data property and immediate templates on Android."

  • immediate trigger typetrigger: { "type": "immediate", "source": "<event>" }. Fires one pixel per matching webEvent, immediately, with no period, persistence, dedup, or foreground gating. trigger.type defaults to "period" when omitted, so existing configs are unaffected.
  • data parameter template{ "template": "data", "dataKey": "<key>", "source": "<event>" }. Forwards a value from webEvent.data as its compact JSON, percent-encoded once (RFC 3986) and sent as an already-encoded pixel parameter to avoid double-encoding. Absent keys are omitted. Immediate pixels use the triggering message's data; aggregate (period) pixels keep the last value seen on a matching source.

The third spec change (config-generation collapsing durations to integer seconds) needs no Android change — it already lands for all platforms in privacy-configuration, and Android already reads trigger.period.seconds.

Steps to test this PR

EventHub immediate + data templates

  • Run ./gradlew :event-hub-impl:testDebugUnitTest --tests "com.duckduckgo.eventhub.impl.pixels.*" and confirm it passes, including the new EventHubImmediatePixelTest and EventHubDataParameterTest (ported from the Windows EventHub suites).
  • Confirm existing counter/period EventHub behaviour is unchanged (RealEventHubPixelManagerTest, EventHubConfigParserTest).

UI changes

Before After
No UI changes No UI changes

Note

Medium Risk
Changes telemetry firing paths and pixel parameter encoding for web-derived event data; behavior is well-tested but affects privacy/statistics payloads when remote configs enable the new templates.

Overview
Aligns Android EventHub with the cross-platform spec by adding immediate triggers and data parameters, while keeping period/counter configs backward-compatible (trigger.type defaults to period).

Immediate pixels fire on each matching webEvent via fireImmediatePixels, with no period state, dedup, persistence, or foreground gating. Period-only setup paths (initMissingPixels, onConfigChanged, startNewPeriod) now skip non-period configs.

Data parameters read webEvent.data[dataKey], serialize to compact JSON, RFC 3986 percent-encode once, and pass values through Pixel.enqueueFire as encodedParameters (period aggregates keep the last value per matching source; immediate pixels use the triggering event’s payload). ParamState gains lastDataValue; period fires can proceed when only encoded data params are present.

Config parsing/serialization now supports trigger type/source, optional parameter source, dataKey, and the data template. New unit tests cover immediate behavior and data encoding (ported from Windows).

Reviewed by Cursor Bugbot for commit 69846a8. Bugbot is set up for automated code reviews on this repo. Configure here.

Bring the Android EventHub framework up to the cross-platform spec
additions made while implementing it on Windows (postmortem action
item to implement the data property and immediate templates on Android).

- New "immediate" trigger type: fires one pixel per matching event with
  no period, persistence, dedup, or foreground gating. trigger.type
  defaults to "period" when omitted, so existing configs are unaffected.
- New "data" parameter template: forwards a webEvent.data value as its
  compact JSON, percent-encoded once (RFC 3986) and sent as an already
  encoded pixel parameter to avoid double-encoding. Absent keys are
  omitted. Immediate pixels use the triggering message's data; aggregate
  pixels keep the last value seen on a matching source.

Tests port the Windows EventHub immediate and data-parameter suites.

Tech design: https://app.asana.com/1/137249556945/project/481882893211075/task/1215327441118832
A data-template parameter with dataKey "" was previously accepted (only a null dataKey was rejected), unlike the immediate trigger source which already rejects empty strings via takeIf { isNotEmpty() }. Apply the same check so an empty dataKey drops the parameter rather than producing a config that can never match a key. This also matches the Windows EventHub parser's string.IsNullOrEmpty(dataKey) validation.

Tech design: https://app.asana.com/1/137249556945/project/481882893211075/task/1215327441118832
@mark-szabo mark-szabo marked this pull request as ready for review June 20, 2026 13:51

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 69846a8. Configure here.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant