Skip to content

feat(ads-client): support content categories on ad requests (AC-109)#7390

Open
Almaju wants to merge 1 commit into
mozilla:mainfrom
Almaju:ads-client-content-categories
Open

feat(ads-client): support content categories on ad requests (AC-109)#7390
Almaju wants to merge 1 commit into
mozilla:mainfrom
Almaju:ads-client-content-categories

Conversation

@Almaju
Copy link
Copy Markdown
Contributor

@Almaju Almaju commented Jun 2, 2026

Summary

Implements AC-109: support ad requests with content categories on HNT.

  • Adds a request-level flags.contextual_placement flag, exposed via MozAdsRequestOptions.contextualPlacement (default false).
  • Per-placement IAB content (taxonomy + category IDs) was already wired; the outgoing JSON now omits content when unset to match the schema in the ticket exactly.
  • The flag is included in the cache hash only when set, so non-contextual callers keep their existing cache entries.

Wire format produced when a caller passes both:

{
  "context_id": "",
  "flags": {"contextual_placement": true},
  "placements": [
    {"placement": "newtab_stories_v2_1", "count": 1},
    {"placement": "newtab_stories_v2_3", "count": 1, "content": {"taxonomy": "IAB-3.0", "categories": ["338"]}}
  ]
}

Pull Request checklist

  • Breaking changes: This PR follows our breaking change policy
    • This PR follows the breaking change policy:
      • This PR has no breaking API changes — MozAdsRequestOptions.contextualPlacement has a UniFFI default of false, so existing callers compile and behave as before.
  • Quality: This PR builds and tests run cleanly (cargo test -p ads-client, cargo clippy -p ads-client --all-targets -- -D warnings, cargo fmt --check).
  • Tests: This PR includes thorough tests
    • Unit tests covering: flag-on serialization matching the AC-109 example, flag-off omits flags, mixed-content placements, flag participates in the cache hash.
    • Added a manual integration contract test (test_contract_image_with_categories_prod) that hits the prod MARS endpoint with iabContent + contextualPlacement: true. Run with cargo test -p ads-client-integration-tests -- --ignored.
  • Changelog: CHANGELOG.md entry added under v153.0 → Ads Client.
  • Dependencies: No new dependencies.

@Almaju Almaju force-pushed the ads-client-content-categories branch 3 times, most recently from 5b17e36 to 44bd6ae Compare June 2, 2026 20:46
@Almaju Almaju marked this pull request as ready for review June 2, 2026 20:51
@Almaju Almaju force-pushed the ads-client-content-categories branch 4 times, most recently from c333f0f to 9cb7ffe Compare June 3, 2026 18:48
Add per-placement IAB content (taxonomy + category IDs) and a request-level
`flags` object plumbed through MARSClient/AdsClient. Callers opt into flags
via `MozAdsRequestOptions.flags: MozAdsRequestFlags?` (currently exposing
`contextualPlacement`), with room to grow as new flags are added. The
`flags` object is included in the cache key only when at least one flag
opts away from its default, so non-contextual callers keep their existing
cache entries.
@Almaju Almaju force-pushed the ads-client-content-categories branch from 9cb7ffe to 943fcfe Compare June 3, 2026 18:51
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