Closed Bug 2067937 Opened 2 months ago Closed 2 months ago

section_position telemetry for newtab_content impression and click events comes back undefined after randomization

Categories

(Firefox :: New Tab Page, defect)

defect

Tracking

()

RESOLVED FIXED
157 Branch
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: nobody → ini
Status: NEW → ASSIGNED

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:

  1. Derive a real position for randomItem.section instead of copying a field that doesn't exist. TelemetryFeed has this.store, and everything CardSections uses to build filteredSections is parent-visible: the sections array on DiscoveryStream.feeds.data[*].data, sectionPersonalization (isBlocked), and Prefs.values["discoverystream.sections.interestPicker.visibleSections"]. A small getSectionPosition(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 a section -> section_position map on the feed populated from the genuine impression/click payloads it already handles.
  2. Add a hard invariant: if no valid position can be resolved, leave resultItem.section and resultItem.section_position at the original item's values rather than swapping the section — never emit a record whose section_position is undefined. Same guard is worth applying to any other field copied off randomItem.

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.

Pushed by ini@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/bfda84aefc18 https://hg.mozilla.org/integration/autoland/rev/bcad397c3a7a Remove section_position telemetry from newtab_content impression and click events. r=thecount
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 157 Branch
QA Whiteboard: [qa-triage-done-c158/b157]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: