Skip to content
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

Revise event urls creation conditions #915

Merged
merged 8 commits into from
Sep 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ Future<AuctionContext> toAuctionContext(RoutingContext routingContext,
.map(account -> AuctionContext.builder()
.routingContext(routingContext)
.uidsCookie(uidsCookieService.parseFromRequest(routingContext))
.bidRequest(bidRequest)
.bidRequest(enrichBidRequestWithAccountBasedData(bidRequest, account))
.timeout(timeout)
.account(account)
.prebidErrors(errors)
Expand Down Expand Up @@ -837,4 +837,34 @@ private Future<Account> responseForUnknownAccount(String accountId) {
String.format("Unauthorized account id: %s", accountId), accountId))
: Future.succeededFuture(Account.empty(accountId));
}

private BidRequest enrichBidRequestWithAccountBasedData(BidRequest bidRequest, Account account) {
final ExtRequest requestExt = bidRequest.getExt();
final ExtRequest enrichedRequestExt = enrichExtRequest(requestExt, account);

if (enrichedRequestExt != null) {
return bidRequest.toBuilder()
.ext(enrichedRequestExt)
.build();
}

return bidRequest;
}

private ExtRequest enrichExtRequest(ExtRequest ext, Account account) {
final ExtRequestPrebid prebidExt = getIfNotNull(ext, ExtRequest::getPrebid);
final String integration = getIfNotNull(prebidExt, ExtRequestPrebid::getIntegration);
final String accountDefaultIntegration = account.getDefaultIntegration();

if (StringUtils.isBlank(integration) && StringUtils.isNotBlank(accountDefaultIntegration)) {
final ExtRequestPrebid.ExtRequestPrebidBuilder prebidExtBuilder =
prebidExt != null ? prebidExt.toBuilder() : ExtRequestPrebid.builder();

prebidExtBuilder.integration(accountDefaultIntegration);

return ExtRequest.of(prebidExtBuilder.build());
}

return null;
}
}
159 changes: 93 additions & 66 deletions src/main/java/org/prebid/server/auction/BidResponseCreator.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ public class TargetingKeywordsCreator {
* Name of the Bidder. For example, "appnexus" or "rubicon".
*/
private static final String HB_BIDDER_KEY = "hb_bidder";
/**
* Stores bid ID.
*/
private static final String HB_BIDID_KEY = "hb_bidid";
/**
* Respects rounded CPM value.
*/
Expand Down Expand Up @@ -184,35 +180,35 @@ private static PriceGranularity convertToCustomPriceGranularity(String stringPri
public Map<String, String> makeFor(Bid bid, boolean winningBid) {
return truncateKeys(makeFor(
bid.getBidder(),
bid.getBidId(),
winningBid,
bid.getPrice(),
StringUtils.EMPTY,
bid.getWidth(),
bid.getHeight(),
bid.getCacheId(),
null,
bid.getDealId(),
null));
bid.getDealId()));
}

/**
* Creates map of keywords for the given {@link com.iab.openrtb.response.Bid}.
*/
Map<String, String> makeFor(com.iab.openrtb.response.Bid bid, String bidder, boolean winningBid, String cacheId,
String vastCacheId, String winUrl) {
Map<String, String> makeFor(com.iab.openrtb.response.Bid bid,
String bidder,
boolean winningBid,
String cacheId,
String vastCacheId) {

final Map<String, String> keywords = makeFor(
bidder,
bid.getId(),
winningBid,
bid.getPrice(),
"0.0",
bid.getW(),
bid.getH(),
cacheId,
vastCacheId,
bid.getDealid(),
winUrl);
bid.getDealid());

if (resolver == null) {
return truncateKeys(keywords);
Expand All @@ -229,16 +225,14 @@ Map<String, String> makeFor(com.iab.openrtb.response.Bid bid, String bidder, boo
*/
private Map<String, String> makeFor(
String bidder,
String bidId,
boolean winningBid,
BigDecimal price,
String defaultCpm,
Integer width,
Integer height,
String cacheId,
String vastCacheId,
String dealId,
String winUrl) {
String dealId) {

final KeywordMap keywordMap = new KeywordMap(bidder, winningBid, includeWinners, includeBidderKeys,
EXCLUDED_BIDDER_KEYS);
Expand Down Expand Up @@ -269,10 +263,6 @@ private Map<String, String> makeFor(
if (isApp) {
keywordMap.put(HB_ENV_KEY, HB_ENV_APP_VALUE);
}
if (winningBid && winUrl != null) {
keywordMap.put(HB_WINURL_KEY, winUrl);
keywordMap.put(HB_BIDID_KEY, bidId);
}

return keywordMap.asMap();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,11 @@ private String makeUri(BidRequest bidRequest) {
}

private String tkXintValue(BidRequest bidRequest) {
final RubiconExtPrebidBiddersBidder rubicon = extPrebidBiddersRubicon(bidRequest.getExt());
final String integration = rubicon == null ? null : rubicon.getIntegration();
return StringUtils.isBlank(integration) ? null : integration;
final ExtRequest requestExt = bidRequest.getExt();
final ExtRequestPrebid prebidExt = requestExt != null ? requestExt.getPrebid() : null;
final String integration = prebidExt != null ? prebidExt.getIntegration() : null;

return StringUtils.stripToNull(integration);
}

private RubiconExtPrebidBiddersBidder extPrebidBiddersRubicon(ExtRequest extRequest) {
Expand Down
Loading