Repository navigation
Conversation
mdanylov-sigma
left a comment
There was a problem hiding this comment.
Thanks, this fixes #1063. Resolving ${AUCTION_PRICE} and ${AUCTION_PRICE:B64} before the bare {AUCTION_PRICE} is the right order, because the old bare-first replace left the stray $. All four native paths (Original API through AdViewUtils, GAM rendering through NativeAdProvider, AdMob and MAX) go through PrebidNativeAd.create(), so this one change covers them all. Sharing auctionPriceMacros() with Bid keeps the two macro maps from drifting apart.
I ran PrebidNativeAdTest, MacrosResolutionHelperTest, BidTest, BidResponseTest, NativeAdUnitTest and MediationNativeAdUnitTest locally with Robolectric on 6404484, and all 59 tests pass. The description says the Gradle task didn't run on your machine, so that run covers it.
1. Conflicts with #1062
#1062 (approved, still open) replaces the same eventtrackers loop with parseImpressionTrackers(). It also starts reading the legacy imptrackers array, using its own bare-only withAuctionPrice(). A trial merge of the two heads conflicts in both PrebidNativeAd.java and PrebidNativeAdTest.java.
Whichever PR merges second has to make parseImpressionTrackers() call resolveNativePrice() for both arrays. Otherwise legacy imptrackers keep the bug this PR fixes ($0.05, and :B64 left unresolved). Could you note that in the description so the order is decided on purpose? Your test already uses event: 1, method: 1, so it should still pass after #1062's filtering.
2. Optional: resolve on the markup string, as iOS does
On iOS, NativeAd.create(cacheId:) builds a Bid, and Bid runs ORTBMacrosHelper over the whole adm before native parsing. So every field gets the price: assets, privacy, imptrackers, jstracker. Here, only three fields do. Resolving admStr once before new JSONObject(admStr) would:
- match iOS;
- cover
imptrackersfrom #1062 for free, so item 1 becomes a non-issue; - drop the per-field calls and the two-argument helper.
The price string and its Base64 form contain no JSON-special characters, so replacing in the raw text is safe. I'm fine with the per-field version too if you prefer to keep the change narrow. It just means every new URL field has to remember to call the helper.
3. Minor
resolveNativePrice(url, price, priceMacros)takespriceand a map built fromprice. Passing just the map, or building it once in a small holder, would avoid the two being out of sync. Not a blocker.- The issue also asked for a test through
NativeAdUnit→CacheManager→PrebidNativeAd.create(). The new test starts atCacheManager.save(). That's equivalent today, sinceNativeAdUnitcaches the rawgetWinningBidJson(). Please either add the end-to-end case or note in the description that it's intentionally left out. - The new test runs three scenarios in one method and mutates the same
JSONObjects between them. Splitting it into three@Tests (macros resolved, no price, no macros) would make failures easier to read.
Resolve auction price macros when reading a cached native bid. At a bid price of
0.05, click destinations, click trackers and impression trackers now receive0.05for the plain and legacy tokens andMC4wNQ==for the Base64 token.The regression uses the existing native bid fixture and checks URLs with no price and URLs without macros.
A focused JVM run passed for all three URL handlers. The Android Gradle test task stopped before running tests because this machine has no Android SDK.
Merge order and test coverage
If #1062 lands first, I will update this PR to use
resolveNativePrice()for botheventtrackersand legacyimptrackersinparseImpressionTrackers(). That keeps plain and Base64 auction prices working after the tracker changes. If this PR lands first, #1062 needs the same reconciliation before it merges.The regression starts at
CacheManager.save()with the raw winning bid JSON thatNativeAdUnitstores, then callsPrebidNativeAd.create(). The test exercises cache-to-native URL substitution. The fullNativeAdUnitsetup is outside this test.Fixes #1063.