Skip to content

Conversation

@Almaju
Copy link
Collaborator

@Almaju Almaju commented Oct 1, 2025

Replace existing HTTP requests using the Rust AdsClient in UnifiedAdsProvider from application-services.
For now this is behind a feature flag and only in developer while we iterate.
We will need to implement the cache in our Rust component.

@Almaju Almaju requested a review from luc-lisi October 1, 2025 21:48
@Almaju Almaju requested a review from a team as a code owner October 1, 2025 21:48
@issammani issammani requested review from issammani and lmarceau and removed request for FilippoZazzeroni October 2, 2025 15:49
@issammani
Copy link
Collaborator

Thanks @Almaju. I can take a look at the AS bits next week. Tagging @lmarceau since she did touch the ads code a while back and has context.

@mobiletest-ci-bot
Copy link

mobiletest-ci-bot commented Oct 2, 2025

Messages
📖 Project coverage: 38.83%

💪 Quality guardian

1 tests files modified. You're a champion of test coverage! 🚀

🥇 Perfect PR size

Smaller PRs are easier to review. Thanks for making life easy for reviewers! ✨

❌ Per-file test coverage gate

The following changed file(s) are below 35.0% coverage:

File Coverage Required
MozillaRustComponents/Sources/MozillaRustComponentsWrapper/AdsClient/AdsClient.swift 0.0% 35.0%

Client.app: Coverage: 37.28

File Coverage
UnifiedAdsProvider.swift 89.66%
UnifiedTile.swift 100.0%
NimbusFlaggableFeature.swift 99.47%
NimbusFeatureFlagLayer.swift 76.61%

Generated by 🚫 Danger Swift against e0d37ad

@lmarceau lmarceau self-requested a review October 8, 2025 00:58
@mergify
Copy link
Contributor

mergify bot commented Oct 15, 2025

This pull request has conflicts when rebasing. Could you fix it @Almaju? 🙏

@Almaju Almaju force-pushed the add-ads-client branch 3 times, most recently from 541f314 to c6c2e74 Compare October 28, 2025 21:26
@mergify
Copy link
Contributor

mergify bot commented Oct 28, 2025

This pull request has conflicts when rebasing. Could you fix it @Almaju? 🙏

@Almaju Almaju force-pushed the add-ads-client branch 2 times, most recently from f210bd4 to 0257558 Compare October 30, 2025 21:16
@mergify
Copy link
Contributor

mergify bot commented Nov 6, 2025

This pull request has conflicts when rebasing. Could you fix it @Almaju? 🙏

@github-actions
Copy link
Contributor

This PR has been automatically marked as stale. Please leave any comment to keep this PR opened. It will be closed automatically if no further update occurs in the next 7 days. Thank you for your contributions!

@github-actions github-actions bot added the stale Stalebot use this label to stale issues and PRs label Nov 21, 2025
@lmarceau
Copy link
Contributor

Hello @Almaju! Realized this has been sitting for a while sorry about that. Do we have any blockers? I think this needs to be rebase to fix conflicts and we can move forward with it?

@lmarceau lmarceau self-requested a review November 21, 2025 19:05
@github-actions github-actions bot removed the stale Stalebot use this label to stale issues and PRs label Nov 22, 2025
@Almaju
Copy link
Collaborator Author

Almaju commented Nov 25, 2025

Hi @lmarceau
Thanks for pinging!
We are finalizing how we want to use telemetry using glean and then we will be ready to move forward!

@github-actions
Copy link
Contributor

This PR has been automatically marked as stale. Please leave any comment to keep this PR opened. It will be closed automatically if no further update occurs in the next 7 days. Thank you for your contributions!

@github-actions github-actions bot added the stale Stalebot use this label to stale issues and PRs label Dec 10, 2025
@mergify
Copy link
Contributor

mergify bot commented Dec 10, 2025

This pull request has conflicts when rebasing. Could you fix it @Almaju? 🙏

@Almaju Almaju force-pushed the add-ads-client branch 2 times, most recently from 9d91fd6 to 1154a62 Compare December 10, 2025 19:41
@github-actions github-actions bot removed the stale Stalebot use this label to stale issues and PRs label Dec 11, 2025
Comment on lines 70 to 72
if featureFlags.isFeatureEnabled(.adsClient, checking: .buildOnly) {
fetchTilesWithAdsClient(completion: completion)
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation seems off here 👀 If you're using Xcode, I am a fan of the keyboard shortcut Ctrl + i to automatically indent code (you need to select the block of code you want to auto-indent, then do the shortcut).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh indeed nice! ✅

/// - timestamp: The timestamp to retrieve from cache, useful for tests. Default is Date.now()
/// - completion: Returns an array of Tiles, can be empty
func fetchTiles(timestamp: Timestamp, completion: @escaping @Sendable (UnifiedTileResult) -> Void)
func fetchTiles(timestamp: Shared.Timestamp, completion: @escaping @Sendable (UnifiedTileResult) -> Void)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit; It's not necessary to add the package on Timestamp. Same comment to lines 23 and 32.

Suggested change
func fetchTiles(timestamp: Shared.Timestamp, completion: @escaping @Sendable (UnifiedTileResult) -> Void)
func fetchTiles(timestamp: Timestamp, completion: @escaping @Sendable (UnifiedTileResult) -> Void)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It says it is ambiguous because of two candidates:

  • public typealias Timestamp = Int64 in MozillaRustComponents/Sources/MozillaRustComponentsWrapper/Generated/tabs.swift
  • public typealias Timestamp = UInt64 in BrowserKit/Sources/Shared/Date/TimeConstants.swift

Comment on lines 146 to 160
self.logger.log("Fetching tiles with ads client", level: .info, category: .homepage)
let mozAdRequests = [
MozAdsPlacementRequest(placementId: TileOrder.position1.rawValue, iabContent: nil),
MozAdsPlacementRequest(placementId: TileOrder.position2.rawValue, iabContent: nil)
]
do {
let mozAdsImages = try self.adsClient.requestImageAds(mozAdRequests: mozAdRequests, options: nil)
let unifiedTiles: [UnifiedTile] = mozAdsImages.map { name, mozAdsImage in
UnifiedTile.from(name: name, mozAdsImage: mozAdsImage)
}
self.logger.log("Ads client request successful", level: .info, category: .homepage)
completion(.success(unifiedTiles))
} catch let error {
self.logger.log("Ads client request failed: \(error)", level: .warning, category: .homepage)
completion(.failure(Error.noDataAvailable))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit; it's not needed to use self. in this case. We prefer to keep self. usage where it's needed like in closures

Suggested change
self.logger.log("Fetching tiles with ads client", level: .info, category: .homepage)
let mozAdRequests = [
MozAdsPlacementRequest(placementId: TileOrder.position1.rawValue, iabContent: nil),
MozAdsPlacementRequest(placementId: TileOrder.position2.rawValue, iabContent: nil)
]
do {
let mozAdsImages = try self.adsClient.requestImageAds(mozAdRequests: mozAdRequests, options: nil)
let unifiedTiles: [UnifiedTile] = mozAdsImages.map { name, mozAdsImage in
UnifiedTile.from(name: name, mozAdsImage: mozAdsImage)
}
self.logger.log("Ads client request successful", level: .info, category: .homepage)
completion(.success(unifiedTiles))
} catch let error {
self.logger.log("Ads client request failed: \(error)", level: .warning, category: .homepage)
completion(.failure(Error.noDataAvailable))
logger.log("Fetching tiles with ads client", level: .info, category: .homepage)
let mozAdRequests = [
MozAdsPlacementRequest(placementId: TileOrder.position1.rawValue, iabContent: nil),
MozAdsPlacementRequest(placementId: TileOrder.position2.rawValue, iabContent: nil)
]
do {
let mozAdsImages = try self.adsClient.requestImageAds(mozAdRequests: mozAdRequests, options: nil)
let unifiedTiles: [UnifiedTile] = mozAdsImages.map { name, mozAdsImage in
UnifiedTile.from(name: name, mozAdsImage: mozAdsImage)
}
logger.log("Ads client request successful", level: .info, category: .homepage)
completion(.success(unifiedTiles))
} catch let error {
logger.log("Ads client request failed: \(error)", level: .warning, category: .homepage)
completion(.failure(Error.noDataAvailable))

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh okay I did not know that about Swift, this is done ✅

public static let info = BuildInfo(buildDate: DateComponents(calendar: Calendar.current, timeZone: TimeZone(abbreviation: "UTC"), year: 2025, month: 12, day: 9, hour: 5, minute: 18, second: 29))
}

enum AdsClient {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes should come from the AS. I suppose this will come in once we have merged: mozilla/application-services#7111

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely, I did the rebase ✅


// Public interface members begin here.

// Magic number for the Rust proxy to call using the same mechanism as every other method,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. If you rebase you shouldn't need these changes. Anything under Generated should come directly from uniffi generated files.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased ✅

@issammani
Copy link
Collaborator

@Almaju merged #31310. You shouldn't need the changes in the Generated/ files anymore

@github-actions
Copy link
Contributor

This PR has been automatically marked as stale. Please leave any comment to keep this PR opened. It will be closed automatically if no further update occurs in the next 7 days. Thank you for your contributions!

@github-actions github-actions bot added the stale Stalebot use this label to stale issues and PRs label Dec 31, 2025
@mergify
Copy link
Contributor

mergify bot commented Dec 31, 2025

This pull request has conflicts when rebasing. Could you fix it @Almaju? 🙏

@github-actions github-actions bot removed the stale Stalebot use this label to stale issues and PRs label Jan 1, 2026
@Almaju Almaju force-pushed the add-ads-client branch 2 times, most recently from 84df90b to c8a2ac6 Compare January 5, 2026 18:01
@Almaju
Copy link
Collaborator Author

Almaju commented Jan 5, 2026

@lmarceau @issammani happy new year! This should be ready for final review! 🥳

@Almaju Almaju requested review from issammani and lmarceau January 5, 2026 18:07
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.

5 participants