Skip to content

Commit e8792ef

Browse files
authored
Including ads-client in the megazord (#6966)
Including ads-client in iOS build Updating AdsClient API error name to avoid collisions Updating changelog Including ads_client to megazord_stub Resetting glean submodule Correct ordering of projects in buildconfig-android
1 parent 8e9c25b commit e8792ef

File tree

18 files changed

+74
-16
lines changed

18 files changed

+74
-16
lines changed

.buildconfig-android.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
groupId: org.mozilla.appservices
22
projects:
3+
ads-client:
4+
path: components/ads-client/android
5+
artifactId: ads-client
6+
publications:
7+
- name: ads-client
8+
type: aar
9+
description: for fetching ads via UAPI
310
autofill:
411
path: components/autofill/android
512
artifactId: autofill
@@ -165,3 +172,4 @@ projects:
165172
- name: relay
166173
type: aar
167174
description: Client for Firefox Relay.
175+

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
### Swift
66
- Added `@unchecked Sendable` to classes that conform to `FeatureManifestInterface`. ([#6963](https://github.com/mozilla/application-services/pull/6963)
7+
### Ads Client
8+
- Added the Ads Client component to the Megazord.
9+
- Updated the ApiError enum to AdsClientApiError to avoid naming collision.
710

811
# v144.0 (_2025-09-15_)
912

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apply from: "$appServicesRootDir/build-scripts/component-common.gradle"
2+
apply from: "$appServicesRootDir/publish.gradle"
3+
4+
android {
5+
namespace 'org.mozilla.appservices.ads_client'
6+
}
7+
8+
ext.configureUniFFIBindgen("ads_client")
9+
ext.dependsOnTheMegazord()
10+
ext.configurePublish()
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
22+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"/>
2+

components/ads-client/src/error.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
use error_support::{error, ErrorHandling, GetErrorHandling};
77
use viaduct::Response;
88

9-
pub type ApiResult<T> = std::result::Result<T, ApiError>;
9+
pub type AdsClientApiResult<T> = std::result::Result<T, AdsClientApiError>;
1010

1111
#[derive(Debug, thiserror::Error, uniffi::Error)]
12-
pub enum ApiError {
12+
pub enum AdsClientApiError {
1313
#[error("Something unexpected occurred.")]
1414
Other { reason: String },
1515
}
@@ -30,10 +30,10 @@ pub enum ComponentError {
3030
}
3131

3232
impl GetErrorHandling for ComponentError {
33-
type ExternalError = ApiError;
33+
type ExternalError = AdsClientApiError;
3434

3535
fn get_error_handling(&self) -> ErrorHandling<Self::ExternalError> {
36-
ErrorHandling::convert(ApiError::Other {
36+
ErrorHandling::convert(AdsClientApiError::Other {
3737
reason: self.to_string(),
3838
})
3939
}

components/ads-client/src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
use std::collections::{HashMap, HashSet};
77

8-
use error::ApiResult;
8+
use error::AdsClientApiResult;
99
use error::{
1010
BuildPlacementsError, BuildRequestError, ComponentError, RecordClickError,
1111
RecordImpressionError, ReportAdError, RequestAdsError,
@@ -24,7 +24,7 @@ mod models;
2424
#[cfg(test)]
2525
mod test_utils;
2626

27-
uniffi::setup_scaffolding!("adsclient");
27+
uniffi::setup_scaffolding!("ads_client");
2828

2929
/// Top-level API for the mac component
3030
#[derive(uniffi::Object)]
@@ -51,7 +51,7 @@ impl MozAdsClient {
5151
pub fn request_ads(
5252
&self,
5353
moz_ad_configs: Vec<MozAdsPlacementConfig>,
54-
) -> ApiResult<HashMap<String, MozAdsPlacement>> {
54+
) -> AdsClientApiResult<HashMap<String, MozAdsPlacement>> {
5555
let inner = self.inner.lock();
5656
let placements = inner
5757
.request_ads(&moz_ad_configs)
@@ -60,7 +60,7 @@ impl MozAdsClient {
6060
}
6161

6262
#[handle_error(ComponentError)]
63-
pub fn record_impression(&self, placement: MozAdsPlacement) -> ApiResult<()> {
63+
pub fn record_impression(&self, placement: MozAdsPlacement) -> AdsClientApiResult<()> {
6464
let inner = self.inner.lock();
6565
inner
6666
.record_impression(&placement)
@@ -69,7 +69,7 @@ impl MozAdsClient {
6969
}
7070

7171
#[handle_error(ComponentError)]
72-
pub fn record_click(&self, placement: MozAdsPlacement) -> ApiResult<()> {
72+
pub fn record_click(&self, placement: MozAdsPlacement) -> AdsClientApiResult<()> {
7373
let inner = self.inner.lock();
7474
inner
7575
.record_click(&placement)
@@ -78,21 +78,21 @@ impl MozAdsClient {
7878
}
7979

8080
#[handle_error(ComponentError)]
81-
pub fn report_ad(&self, placement: MozAdsPlacement) -> ApiResult<()> {
81+
pub fn report_ad(&self, placement: MozAdsPlacement) -> AdsClientApiResult<()> {
8282
let inner = self.inner.lock();
8383
inner
8484
.report_ad(&placement)
8585
.map_err(ComponentError::ReportAd)
8686
.emit_telemetry_if_error()
8787
}
8888

89-
pub fn cycle_context_id(&self) -> ApiResult<String> {
89+
pub fn cycle_context_id(&self) -> AdsClientApiResult<String> {
9090
let mut inner = self.inner.lock();
9191
let previous_context_id = inner.cycle_context_id();
9292
Ok(previous_context_id)
9393
}
9494

95-
pub fn clear_cache(&self) -> ApiResult<()> {
95+
pub fn clear_cache(&self) -> AdsClientApiResult<()> {
9696
let mut inner = self.inner.lock();
9797
inner.clear_cache();
9898
Ok(())

components/ads-client/uniffi.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[bindings.kotlin]
2-
package_name = "mozilla.appservices.adsclient"
2+
package_name = "mozilla.appservices.ads_client"
33

44
[bindings.swift]
55
ffi_module_name = "MozillaRustComponents"
6-
ffi_module_filename = "adsclientFFI"
6+
ffi_module_filename = "ads_clientFFI"

megazords/fenix-dylib/megazord_stub.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
// but here we are.
1111
// To get the symbols from our static lib we need to refer to a symbol from each crate within it.
1212
// This is an arbitrary choice - any symbol will do, but we chose these because every uniffi crate has it.
13+
extern int MOZ_EXPORT ffi_ads_client_uniffi_contract_version();
1314
extern int MOZ_EXPORT ffi_autofill_uniffi_contract_version();
1415
extern int MOZ_EXPORT ffi_crashtest_uniffi_contract_version();
1516
extern int MOZ_EXPORT ffi_fxa_client_uniffi_contract_version();
@@ -37,6 +38,7 @@ extern int MOZ_EXPORT ffi_tabs_uniffi_contract_version();
3738
extern int MOZ_EXPORT uniffi_search_checksum_constructor_searchengineselector_new();
3839

3940
void _local_megazord_dummy_symbol() {
41+
ffi_ads_client_uniffi_contract_version();
4042
ffi_autofill_uniffi_contract_version();
4143
ffi_crashtest_uniffi_contract_version();
4244
ffi_fxa_client_uniffi_contract_version();

0 commit comments

Comments
 (0)