feat(admob): track next-gen banner response loading - #4028
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## draft-banner-pr-alignment #4028 +/- ##
============================================================
Coverage ? 82.99%
============================================================
Files ? 437
Lines ? 17893
Branches ? 2684
============================================================
Hits ? 14851
Misses ? 2148
Partials ? 894 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
00dfb81 to
b6ed47a
Compare
Public API changes in feature:admob-next-gen (4 new declarations)+ method @KotlinOnly @com.revenuecat.purchases.ExperimentalPreviewRevenueCatPurchasesAPI @kotlin.jvm.JvmSynthetic public static suspend Object? loadAndTrackBannerAdFromResponse(com.revenuecat.purchas…
+ method @KotlinOnly @com.revenuecat.purchases.ExperimentalPreviewRevenueCatPurchasesAPI @kotlin.jvm.JvmSynthetic public static void loadAndTrackBannerAdFromResponse(com.revenuecat.purchases.ads.even…
+ method @KotlinOnly @com.revenuecat.purchases.ExperimentalPreviewRevenueCatPurchasesAPI @kotlin.jvm.JvmSynthetic public static suspend Object? loadAndTrackAdFromResponse(com.google.android.libraries…
+ method @KotlinOnly @com.revenuecat.purchases.ExperimentalPreviewRevenueCatPurchasesAPI @kotlin.jvm.JvmSynthetic public static void loadAndTrackAdFromResponse(com.google.android.libraries.ads.mobile…Generated by 🚫 Danger |
| adResponse: String, | ||
| adUnitId: String, | ||
| placement: String? = null, | ||
| loadCallback: AdLoadCallback<BannerAd>, |
There was a problem hiding this comment.
Minor: loadCallback is mandatory in this PR's signatures but optional in the parent PR. Unless there's something I'm missing, they should be nullable here too?
There was a problem hiding this comment.
The response API has a same-named suspending overload, so loadCallback is marked required to distinguish them. The regular loader has no suspending overload, so loadCallback can remain optional without requiring callers to pass loadCallback = null. I think the result fits the ergonomics for each case well. Let me know what do you think.
There was a problem hiding this comment.
Hmm that makes sense, hadn't noticed.
Not gonna block on this, but the typical SDK language for suspend variants is awaitXYZ when the non-suspend is XYZ ( awaitOfferings, awaitPurchase, etc). I'd argue to switch to it for three reasons:
- Same name overrides gated by a single param are brittle in that if e.g. we added a default value to
loadCallback, then a caller with no loadCallback would always be the suspend - Just consistency with the rest of the SDK
- Would allow nullability of
loadCallbackfor fire-and-forget usecases
There was a problem hiding this comment.
Sounds good. I'll do it in a follow up PR and against this and the native case as well. Thanks for the heads up
b6ed47a to
5f412e0
Compare
Motivation
Expose server-to-server Google Mobile Ads Next-Gen banner response loading through the RevenueCat tracking API.
This PR is stacked on #4014, which provides the core banner tracking integration and callback installation.
Description
AdView.loadAndTrackAdFromResponseandAdTracker.loadAndTrackBannerAdFromResponseAPIs.AdLoadResultunchanged.Tracking behavior
The supplied placement and ad unit ID are used for response load events and subsequent banner lifecycle events. RevenueCat tracking and callback installation happen before application callbacks or suspending results are returned.
Note
Low Risk
Additive experimental API on top of existing banner tracking patterns, with focused unit tests and no changes to core purchase or auth flows.
Overview
Adds server-to-server banner loading with RevenueCat tracking for Google Mobile Ads Next-Gen, matching the existing
FromResponseAPIs on other formats.New public entry points are
AdView.loadAndTrackAdFromResponseandAdTracker.loadAndTrackBannerAdFromResponse, each with callback and suspending overloads. Callers must pass an explicitadUnitId(and optional placement) so load success and failure events keep correct attribution when the opaque response does not expose it.Implementation wires
AdView.loadFromAdResponsethrough the same tracking path as request-based banner loads:TrackingAdLoadCallbackfor callbacks,trackAndConfigureAdLoadResultfor suspend, with lifecycle and refresh wrappers installed before app code sees the loadedBannerAd. Suspending APIs return Google’sAdLoadResultunchanged.README and
api.txtdocument the new surface;BannerAdResponseFlowTestcovers callback ordering, failure attribution, and suspending success/failure behavior.Reviewed by Cursor Bugbot for commit 9a172fc. Bugbot is set up for automated code reviews on this repo. Configure here.