-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Add application-services/ads-client #29737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
💪 Quality guardian1 tests files modified. You're a champion of test coverage! 🚀 🥇 Perfect PR sizeSmaller PRs are easier to review. Thanks for making life easy for reviewers! ✨ ❌ Per-file test coverage gateThe following changed file(s) are below 35.0% coverage:
Client.app: Coverage: 37.28
Generated by 🚫 Danger Swift against e0d37ad |
firefox-ios/Client/Frontend/Home/TopSites/DataManagement/UnifiedAds/UnifiedAdsProvider.swift
Outdated
Show resolved
Hide resolved
firefox-ios/Client/Frontend/Home/TopSites/DataManagement/UnifiedAds/UnifiedAdsProvider.swift
Outdated
Show resolved
Hide resolved
firefox-ios/Client/Frontend/Home/TopSites/DataManagement/UnifiedAds/UnifiedAdsProvider.swift
Outdated
Show resolved
Hide resolved
|
This pull request has conflicts when rebasing. Could you fix it @Almaju? 🙏 |
ad0128f to
3ccaa74
Compare
541f314 to
c6c2e74
Compare
|
This pull request has conflicts when rebasing. Could you fix it @Almaju? 🙏 |
f210bd4 to
0257558
Compare
|
This pull request has conflicts when rebasing. Could you fix it @Almaju? 🙏 |
|
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! |
|
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? |
|
Hi @lmarceau |
0257558 to
398d25e
Compare
|
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! |
|
This pull request has conflicts when rebasing. Could you fix it @Almaju? 🙏 |
9d91fd6 to
1154a62
Compare
| if featureFlags.isFeatureEnabled(.adsClient, checking: .buildOnly) { | ||
| fetchTilesWithAdsClient(completion: completion) | ||
| } else { |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
| func fetchTiles(timestamp: Shared.Timestamp, completion: @escaping @Sendable (UnifiedTileResult) -> Void) | |
| func fetchTiles(timestamp: Timestamp, completion: @escaping @Sendable (UnifiedTileResult) -> Void) |
There was a problem hiding this comment.
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 = Int64inMozillaRustComponents/Sources/MozillaRustComponentsWrapper/Generated/tabs.swiftpublic typealias Timestamp = UInt64inBrowserKit/Sources/Shared/Date/TimeConstants.swift
| 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)) |
There was a problem hiding this comment.
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
| 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)) |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebased ✅
|
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! |
|
This pull request has conflicts when rebasing. Could you fix it @Almaju? 🙏 |
84df90b to
c8a2ac6
Compare
|
@lmarceau @issammani happy new year! This should be ready for final review! 🥳 |
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.