Add immediate and data parameter templates to EventHub#8942
Open
mark-szabo wants to merge 2 commits into
Open
Conversation
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
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 69846a8. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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."
immediatetrigger type —trigger: { "type": "immediate", "source": "<event>" }. Fires one pixel per matchingwebEvent, immediately, with no period, persistence, dedup, or foreground gating.trigger.typedefaults to"period"when omitted, so existing configs are unaffected.dataparameter template —{ "template": "data", "dataKey": "<key>", "source": "<event>" }. Forwards a value fromwebEvent.dataas 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 matchingsource.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 readstrigger.period.seconds.Steps to test this PR
EventHub immediate + data templates
./gradlew :event-hub-impl:testDebugUnitTest --tests "com.duckduckgo.eventhub.impl.pixels.*"and confirm it passes, including the newEventHubImmediatePixelTestandEventHubDataParameterTest(ported from the Windows EventHub suites).RealEventHubPixelManagerTest,EventHubConfigParserTest).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
immediatetriggers anddataparameters, while keeping period/counter configs backward-compatible (trigger.typedefaults toperiod).Immediate pixels fire on each matching
webEventviafireImmediatePixels, 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 throughPixel.enqueueFireasencodedParameters(period aggregates keep the last value per matchingsource; immediate pixels use the triggering event’s payload).ParamStategainslastDataValue; period fires can proceed when only encoded data params are present.Config parsing/serialization now supports trigger
type/source, optional parametersource,dataKey, and thedatatemplate. 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.