section_position telemetry for newtab_content impression and click events comes back undefined after randomization
Categories
(Firefox :: New Tab Page, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox157 | --- | fixed |
People
(Reporter: ini, Assigned: ini)
Details
Attachments
(1 external file)
randomizeOrganicContentEvent sets section_position from the swapped-in recommendation, but recommendations carry no section_position, so every randomized record on the newtab_content ping ends up with section_position undefined. Because genuine records always have a valid section_position, this deterministically reveals which impression/click records were DP-randomized.
| Assignee | ||
Comment 1•2 months ago
|
||
Updated•2 months ago
|
Comment 2•2 months ago
|
||
| frontend-triage | ||
Confirmed by reading the code — the reporter's diagnosis holds.
Recommendation objects are built with an explicit key list in getComponentFeed: the top-stories branch at browser/extensions/newtab/lib/DiscoveryStreamFeed.sys.mjs carries no section at all, and the per-section branch at browser/extensions/newtab/lib/DiscoveryStreamFeed.sys.mjs carries section: sectionKey but no section_position. Nothing downstream (scoreItemsInferred, rotate, filterBlocked) adds one. Genuine section_position is a render-time index produced in the content process — filteredSections.map((section, sectionPosition) => ...) in browser/extensions/newtab/content-src/components/DiscoveryStreamComponents/CardSections/CardSections.jsx — and only ever reaches the parent on the impression/click action payload.
So at browser/extensions/newtab/lib/TelemetryFeed.sys.mjs, whenever the branch fires (resultItem.section set and not top_stories_section, and randomItem.section truthy) randomItem.section_position is unconditionally undefined. sanitizeEventData doesn't strip the key, so the randomized record reaches newtab_content impression/click with section_position missing while every genuine sectioned record has one — a deterministic marker for DP-randomized records. Introduced by the original randomization landing, changeset 1f301699 (bug 1990399).
Proposed fix, in randomizeOrganicContentEvent:
- Derive a real position for
randomItem.sectioninstead of copying a field that doesn't exist. TelemetryFeed hasthis.store, and everything CardSections uses to buildfilteredSectionsis parent-visible: thesectionsarray onDiscoveryStream.feeds.data[*].data,sectionPersonalization(isBlocked), andPrefs.values["discoverystream.sections.interestPicker.visibleSections"]. A smallgetSectionPosition(sectionKey)helper mirroring that filter/reorder gives the same index the content process rendered. A lighter alternative, if mirroring that logic is judged too fragile: keep asection -> section_positionmap on the feed populated from the genuine impression/click payloads it already handles. - Add a hard invariant: if no valid position can be resolved, leave
resultItem.sectionandresultItem.section_positionat the original item's values rather than swapping the section — never emit a record whosesection_positionisundefined. Same guard is worth applying to any other field copied offrandomItem.
Test anchor: test_randomizeOrganicContentEvent in browser/extensions/newtab/test/xpcshell/test_TelemetryFeed.js passes today only because its fixture recs are hand-built with section_id and section_position: 3 — keys real recommendations never carry. That fixture should be replaced with the actual shape from getComponentFeed (section, no section_position), plus an assertion that the returned record always has a defined section_position when the input had one.
I have not built or run anything; this is from reading the source.
Suggested severity: S2
The randomization exists to give plausible deniability about which content a user actually saw, and a field that is present on every genuine sectioned record but absent on every randomized one lets an analyst filter the randomized records back out, nullifying that guarantee for the newtab-content ping. There is no user-side workaround, and it affects all users with the private ping and a non-zero epsilon.
If you'd like to provide feedback on this comment, please use the 👍 or 👎 reaction.
If you want to categorize your feedback you can add one of the following tags: ai-triage-wrong-file, ai-triage-wrong-cause, ai-triage-hallucination, ai-triage-out-of-scope.
Comment 4•2 months ago
|
||
| bugherder | ||
Updated•2 months ago
|
Description
•