Define Desktop's preserved targeting keys in Firefox instead of Experimenter?

Open
#18,295 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
20/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
javascript, python

Research direction

Start with experimenter/targeting/constants.py (PRESERVED_TARGETING_KEYS_BY_APPLICATION) and targeting_context_parser.py, then follow how ATTRIBUTE_TRANSFORMS is imported from Firefox's TargetingContextRecorder.sys.mjs. Read test_validate_targeting_config_fields to see how allowed attributes are enforced. Done means Firefox exports the Desktop exception list, Experimenter parses it the same way, the DESKTOP entry is removed, and the docs can list all allowed attributes dynamically.

Written by the indexing model from the issue text.

Description

Experimenter decides which attributes a Desktop targeting config may use from two sources:

test_validate_targeting_config_fields fails any config that uses an attribute in neither.

In Firefox, we're documenting which attributes Nimbus recipe targeting can use (bug 2095839). We have multiple targeting contexts, but only one is documented. It makes it difficult for users to know which attributes will be available in the environment they're writing a targeting expression for. So we're adding a doc for each targeting context that has different attributes, and linking them together so it's easy to find the docs appropriate for whatever expression you're working on.

The Nimbus targeting context "inherits" many targeting attributes from ASRouterTargeting (documented in targeting-attributes.md), in addition to providing its own. So the plan is to have Sphinx import the list of "inherited" attributes from targeting-attributes.md and filter it with ATTRIBUTE_TRANSFORMS, so it stays up to date automatically, and the document structure matches the actual targeting context structure.

Otherwise, we would have to manually maintain the shared targeting attributes in two separate docs, one for message-level targeting (the one that already exists) and one for Nimbus targeting. The latter would certainly fall out of date. By filtering the attributes dynamically, the documentation for every shared attribute would automatically be drawn from the OMC doc (where these attributes are most assiduously maintained) into the Nimbus targeting doc, without including any of the attributes that are disallowed in Nimbus targeting.

But the exceptions in PRESERVED_TARGETING_KEYS_BY_APPLICATION live here on the Experimenter repo, not in the Firefox source code. So the Firefox source doc can't include them, and copying them between repos would very likely go stale. So for now, we'll have to make a note at the top of the doc mentioning that there are exceptions, linking to that list, and telling users to search targeting-attributes.md for any excepted attributes. That's better than docs falling out of sync, but it makes it more difficult to see at a glance what's available to you.

Proposal: move the Desktop exceptions into Firefox, e.g. as an exported list next to ATTRIBUTE_TRANSFORMS in TargetingContextRecorder.sys.mjs. Experimenter would then parse them the same way it parses ATTRIBUTE_TRANSFORMS, and the DESKTOP entry would go away from PRESERVED_TARGETING_KEYS_BY_APPLICATION. Firefox would then be the single source of truth for which attributes Desktop targeting can use, and the docs could list all of them dynamically.

The Desktop exceptions today are defaultProfile, newtabAddonVersion, newtabSettings, userId, searchEngines, isBackgroundTaskMode, isNonStubFirstRun, localeLanguageCode, attachedFxAOAuthClients and isFxASignedInMozilla.

Doing it this way seemed ideal, because Sphinx is not really capable of importing remote data like that, whereas Experimenter is already importing the TargetingContextRecorder stuff from Firefox source for essentially the same purpose. So adding one more fx source import didn't seem like it would be too drastic a step. But is there any reason the exceptions would have to live in the Experimenter repo, or can we move them?

┆Issue is synchronized with this Jira Task

Dominant language
Python
Stars
152
Forks
231
Avg merge
23h 54m
Merged PRs (30d)
201

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mozilla/experimenter

All issues in mozilla/experimenter

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.