Skip to content

Resolve auction price macros in native click and tracking URLs - #1064

Open
aleksUIX wants to merge 1 commit into
prebid:masterfrom
aleksUIX:fix/native-price-macros
Open

aleksUIX wants to merge 1 commit into
prebid:masterfrom
aleksUIX:fix/native-price-macros

Conversation

@aleksUIX

@aleksUIX aleksUIX commented Nov 29, 2026 •

Copy link
Copy Markdown

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 receive 0.05 for the plain and legacy tokens and MC4wNQ== 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 both eventtrackers and legacy imptrackers in parseImpressionTrackers(). 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 that NativeAdUnit stores, then calls PrebidNativeAd.create(). The test exercises cache-to-native URL substitution. The full NativeAdUnit setup is outside this test.

Fixes #1063.

@mdanylov-sigma mdanylov-sigma left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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 imptrackers from #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) takes price and a map built from price. 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 at CacheManager.save(). That's equivalent today, since NativeAdUnit caches the raw getWinningBidJson(). 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.

This branch has not been deployed

No deployments
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.

Resolve ${AUCTION_PRICE} and ${AUCTION_PRICE:B64} in native ads

2 participants