You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(ads-client): add OHTTP support (AC-94) (#7315)
* feat(ads-client): add per-request OHTTP support
Add per-request OHTTP support via the `ohttp` flag on `MozAdsRequestOptions`
and `MozAdsCallbackOptions`. When enabled, individual MARS requests are routed
through viaduct's OHTTP layer with automatic preflight for geo/user-agent
override headers.
- Add `ohttp: bool` parameter to fetch_ads, record_click, record_impression,
report_ad and all public API methods
- Add `MozAdsCallbackOptions` FFI type for callback OHTTP support
- Add `mars/preflight.rs` with PreflightRequest/PreflightResponse types
- Preflight responses cached via HttpCache (CacheFirst with default TTL)
- Add `FetchAdsError::Preflight` variant for preflight failures
- Add OHTTP integration test against prod
- Update usage docs for all platforms (JavaScript, Kotlin, Swift)
* refactor(ads-client): extract transport layer from MARSClient
Isolate HTTP/cache/OHTTP concerns into MARSTransport, keeping
MARSClient focused on MARS domain logic (request building, response
parsing, preflight headers, callbacks).
- Add MARSTransport with send() (cached + deserialized) and fire()
(direct, no cache, no body) methods
- Move client_for, OHTTP_CHANNEL_ID, cache management into transport
- Add ohttp flag to AdRequest Hash impl for distinct cache keys
- Rename check_http_status_for_error to HTTPError::check
- Introduce TransportError, sort error enums alphabetically
- Add clear_cache back to AdsClient after accidental removal
Copy file name to clipboardExpand all lines: CHANGELOG.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,9 @@
11
11
12
12
## ✨ What's New ✨
13
13
14
+
### Ads Client
15
+
- Add per-request OHTTP support via the `ohttp` flag on `MozAdsRequestOptions` and `MozAdsCallbackOptions`. When enabled, individual MARS requests are routed through viaduct's OHTTP layer with automatic preflight for geo/user-agent override headers.
16
+
14
17
### Logins
15
18
- New `allow_empty_passwords` feature flag to allow storing logins with empty passwords. This feature is intended to be enabled on desktop during the migration.
16
19
- Add `ignore_form_action_origin_validation_errors` feature flag that allows logins with non-URL `form_action_origin` values (e.g. "email", "UserCode") to be imported without error. URL normalization for valid URLs is still applied.
|`clearCache()`|`void`| Clears the client's HTTP cache. Throws on failure. |
40
-
|`recordClick(clickUrl)`|`void`| Records a click using the provided callback URL (typically from `ad.callbacks.click`). |
41
-
|`recordImpression(impressionUrl)`|`void`| Records an impression using the provided callback URL (typically from `ad.callbacks.impression`). |
42
-
|`reportAd(reportUrl)`|`void`| Reports an ad using the provided callback URL (typically from `ad.callbacks.report`). |
40
+
|`recordClick(clickUrl, options?)`|`void`| Records a click using the provided callback URL (typically from `ad.callbacks.click`). Optional `MozAdsCallbackOptions` can enable OHTTP.|
41
+
|`recordImpression(impressionUrl, options?)`|`void`| Records an impression using the provided callback URL (typically from `ad.callbacks.impression`). Optional `MozAdsCallbackOptions` can enable OHTTP.|
42
+
|`reportAd(reportUrl, reason, options?)`|`void`| Reports an ad using the provided callback URL (typically from `ad.callbacks.report`). Optional `MozAdsCallbackOptions` can enable OHTTP.|
43
43
|`requestImageAds(mozAdRequests, options?)`|`Object.<string, MozAdsImage>`| Requests one image ad per placement. Optional `MozAdsRequestOptions` can adjust caching behavior. Returns an object keyed by `placementId`. |
44
44
|`requestSpocAds(mozAdRequests, options?)`|`Object.<string, Array.<MozAdsSpoc>>`| Requests spoc ads per placement. Each placement request specifies its own count. Optional `MozAdsRequestOptions` can adjust caching behavior. Returns an object keyed by `placementId`. |
45
45
|`requestTileAds(mozAdRequests, options?)`|`Object.<string, MozAdsTile>`| Requests one tile ad per placement. Optional `MozAdsRequestOptions` can adjust caching behavior. Returns an object keyed by `placementId`. |
@@ -246,12 +246,48 @@ Options passed when making a single ad request.
> **Note:** OHTTP must be configured at the viaduct level before use. When `ohttp` is `true`, the client automatically performs a preflight request to obtain geo-location and user-agent headers, which are injected into the MARS request.
|`clearCache()`|`Unit`| Clears the client's HTTP cache. Throws on failure. |
37
-
|`recordClick(clickUrl: String)`|`Unit`| Records a click using the provided callback URL (typically from `ad.callbacks.click`). |
38
-
|`recordImpression(impressionUrl: String)`|`Unit`| Records an impression using the provided callback URL (typically from `ad.callbacks.impression`). |
39
-
|`reportAd(reportUrl: String)`|`Unit`| Reports an ad using the provided callback URL (typically from `ad.callbacks.report`). |
37
+
|`recordClick(clickUrl: String, options: MozAdsCallbackOptions?)`|`Unit`| Records a click using the provided callback URL (typically from `ad.callbacks.click`). |
38
+
|`recordImpression(impressionUrl: String, options: MozAdsCallbackOptions?)`|`Unit`| Records an impression using the provided callback URL (typically from `ad.callbacks.impression`). |
39
+
|`reportAd(reportUrl: String, reason: MozAdsReportReason, options: MozAdsCallbackOptions?)`|`Unit`| Reports an ad using the provided callback URL (typically from `ad.callbacks.report`). |
40
40
|`requestImageAds(mozAdRequests: List<MozAdsPlacementRequest>, options: MozAdsRequestOptions?)`|`Map<String, MozAdsImage>`| Requests one image ad per placement. Optional `MozAdsRequestOptions` can adjust caching behavior. Returns a map keyed by `placementId`. |
41
41
|`requestSpocAds(mozAdRequests: List<MozAdsPlacementRequestWithCount>, options: MozAdsRequestOptions?)`|`Map<String, List<MozAdsSpoc>>`| Requests spoc ads per placement. Each placement request specifies its own count. Optional `MozAdsRequestOptions` can adjust caching behavior. Returns a map keyed by `placementId`. |
42
42
|`requestTileAds(mozAdRequests: List<MozAdsPlacementRequest>, options: MozAdsRequestOptions?)`|`Map<String, MozAdsTile>`| Requests one tile ad per placement. Optional `MozAdsRequestOptions` can adjust caching behavior. Returns a map keyed by `placementId`. |
@@ -219,13 +219,46 @@ Options passed when making a single ad request.
> **Note:** OHTTP must be configured at the viaduct level before use. When `ohttp` is `true`, the client automatically performs a preflight request to obtain geo-location and user-agent headers, which are injected into the MARS request.
0 commit comments