Skip to content

Commit

Permalink
Merge branch 'master' into bid-attributes-validation
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/org/prebid/server/spring/config/ServiceConfiguration.java
  • Loading branch information
rpanchyk committed Dec 17, 2020
2 parents 7063718 + 5e331cb commit 6db8896
Show file tree
Hide file tree
Showing 44 changed files with 667 additions and 283 deletions.
3 changes: 3 additions & 0 deletions docs/config-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ Removes and downloads file again if depending service cant process probably corr
- `max-timeout-ms` - this setting controls maximum timeout for /auction endpoint.
- `timeout-adjustment-ms` - reduces timeout value passed in legacy Auction request so that Prebid Server can handle timeouts from adapters and respond to the request before it times out.

## Default bid request
- `default-request.file.path` - path to a JSON file containing the default request

## Auction (OpenRTB)
- `auction.blacklisted-accounts` - comma separated list of blacklisted account IDs.
- `auction.blacklisted-apps` - comma separated list of blacklisted applications IDs, requests from which should not be processed.
Expand Down
29 changes: 29 additions & 0 deletions docs/developers/default-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Server Based Global Default Request

This allows a default request to be defined that allows the server to set up some defaults for all incoming
requests. A stored request(s) referenced by a bid request override default request, and of course any options specified
directly in the bid request override both. The default request is only read on server startup, it is meant as an
installation static default rather than a dynamic tuning option.

## Config Options

Following config options are exposed to support this feature.
```yaml
default-request:
file:
path : path/to/default/request.json
```
The `path` option is the path to a JSON file containing the default request JSON.
```json
{
"tmax": "2000",
"regs": {
"ext": {
"gdpr": 1
}
}
}
```
This will be JSON merged into the incoming requests at the top level. These will be used as fallbacks which can be
overridden by both Stored Requests _and_ the incoming HTTP request payload.
3 changes: 3 additions & 0 deletions docs/endpoints/openrtb2/auction.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ to set these params on the response at `response.seatbid[i].bid[j].ext.prebid.ta
},
"includewinners": false, // Optional param defaulting to true
"includebidderkeys": false // Optional param defaulting to true
"includeformat": false // Optional param defaulting to false
}
}
}
Expand All @@ -178,6 +179,8 @@ For backwards compatibility the following strings will also be allowed as price

One of "includewinners" or "includebidderkeys" must be true (both default to true if unset). If both were false, then no targeting keys would be set, which is better configured by omitting targeting altogether.

The parameter "includeformat" indicates the type of the bid (banner, video, etc) for multiformat requests. It will add the key `hb_format` and/or `hb_format_{bidderName}` as per "includewinners" and "includebidderkeys" above.

MediaType PriceGranularity - when a single OpenRTB request contains multiple impressions with different mediatypes, or a single impression supports multiple formats, the different mediatypes may need different price granularities. If `mediatypepricegranularity` is present, `pricegranularity` would only be used for any mediatypes not specified.

```
Expand Down
2 changes: 0 additions & 2 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ where `[DATASOURCE]` is a data source name, `DEFAULT_DS` by defaul.
## General auction metrics
- `app_requests` - number of requests received from applications
- `no_cookie_requests` - number of requests without `uids` cookie or with one that didn't contain at least one live UID
- `safari_requests` - number of requests received from Safari browser
- `safari_no_cookie_requests` - number of requests received from Safari browser without `uids` cookie or with one that didn't contain at least one live UID
- `request_time` - timer tracking how long did it take for Prebid Server to serve a request
- `imps_requested` - number if impressions requested
- `imps_banner` - number of banner impressions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,11 +634,14 @@ private ExtRequestTargeting createTargetingWithDefaults(ExtRequestPrebid prebid)
final boolean includeBidderKeys = isTargetingNull || targeting.getIncludebidderkeys() == null
|| targeting.getIncludebidderkeys();

final Boolean includeFormat = !isTargetingNull ? targeting.getIncludeformat() : null;

return ExtRequestTargeting.builder()
.pricegranularity(outgoingPriceGranularityNode)
.mediatypepricegranularity(mediaTypePriceGranularity)
.includewinners(includeWinners)
.includebidderkeys(includeBidderKeys)
.includeformat(includeFormat)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ private ExtRequestTargeting targetingOrNull(ExtRequestPrebid prebid, Set<BidType
.includebidderkeys(isIncludeBidderKeysNull
? !isWinningOnly(prebid.getCache())
: targeting.getIncludebidderkeys())
.includeformat(targeting.getIncludeformat())
.build();
} else {
result = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,8 @@ private Bid toBid(BidderBid bidderBid,
final TargetingKeywordsCreator keywordsCreator = resolveKeywordsCreator(bidType, targeting, isApp,
bidRequest, account);

targetingKeywords = keywordsCreator.makeFor(bid, bidder, isWinningBid, cacheId, videoCacheId);
targetingKeywords = keywordsCreator.makeFor(bid, bidder, isWinningBid, cacheId, bidType.getName(),
videoCacheId);
} else {
targetingKeywords = null;
}
Expand Down Expand Up @@ -1053,6 +1054,7 @@ private TargetingKeywordsCreator createKeywordsCreator(ExtRequestTargeting targe
parsePriceGranularity(priceGranularity),
targeting.getIncludewinners(),
targeting.getIncludebidderkeys(),
BooleanUtils.isTrue(targeting.getIncludeformat()),
isApp,
resolveTruncateAttrChars(targeting, account),
cacheHost,
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/org/prebid/server/auction/FpdResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.apache.commons.collections4.CollectionUtils;
import org.prebid.server.exception.InvalidRequestException;
import org.prebid.server.json.JacksonMapper;
import org.prebid.server.json.JsonMerger;
import org.prebid.server.proto.openrtb.ext.request.ExtApp;
import org.prebid.server.proto.openrtb.ext.request.ExtBidderConfig;
import org.prebid.server.proto.openrtb.ext.request.ExtBidderConfigFpd;
Expand All @@ -21,7 +22,6 @@
import org.prebid.server.proto.openrtb.ext.request.ExtSite;
import org.prebid.server.proto.openrtb.ext.request.ExtUser;
import org.prebid.server.proto.request.Targeting;
import org.prebid.server.util.JsonMergeUtil;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -53,12 +53,11 @@ public class FpdResolver {
"privacypolicy", "mobile"));

private final JacksonMapper jacksonMapper;
private final JsonMergeUtil jsonMergeUtil;
private final JsonMerger jsonMerger;

public FpdResolver(JacksonMapper jacksonMapper) {
public FpdResolver(JacksonMapper jacksonMapper, JsonMerger jsonMerger) {
this.jacksonMapper = Objects.requireNonNull(jacksonMapper);

this.jsonMergeUtil = new JsonMergeUtil(jacksonMapper);
this.jsonMerger = Objects.requireNonNull(jsonMerger);
}

public User resolveUser(User originUser, ObjectNode fpdUser) {
Expand Down Expand Up @@ -183,7 +182,7 @@ public ObjectNode resolveImpExt(ObjectNode impExt, ObjectNode targeting) {
: null;

final ObjectNode resolvedData = extImpContextData != null
? (ObjectNode) jsonMergeUtil.merge(targeting, extImpContextData)
? (ObjectNode) jsonMerger.merge(targeting, extImpContextData)
: targeting;

return extImpContext != null && extImpContext.isObject()
Expand Down Expand Up @@ -253,7 +252,7 @@ private ObjectNode mergeExtData(JsonNode fpdData, JsonNode originData) {
}

if (originData != null && originData.isObject()) {
return (ObjectNode) jsonMergeUtil.merge(fpdData, originData);
return (ObjectNode) jsonMerger.merge(fpdData, originData);
}
return fpdData.isObject() ? (ObjectNode) fpdData : null;
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/prebid/server/auction/OrtbTypesResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.apache.commons.lang3.StringUtils;
import org.prebid.server.exception.InvalidRequestException;
import org.prebid.server.json.JacksonMapper;
import org.prebid.server.util.JsonMergeUtil;
import org.prebid.server.json.JsonMerger;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -69,11 +69,11 @@ public class OrtbTypesResolver {
}

private final JacksonMapper jacksonMapper;
private final JsonMergeUtil jsonMergeUtil;
private final JsonMerger jsonMerger;

public OrtbTypesResolver(JacksonMapper jacksonMapper) {
public OrtbTypesResolver(JacksonMapper jacksonMapper, JsonMerger jsonMerger) {
this.jacksonMapper = Objects.requireNonNull(jacksonMapper);
this.jsonMergeUtil = new JsonMergeUtil(jacksonMapper);
this.jsonMerger = Objects.requireNonNull(jsonMerger);
}

/**
Expand Down Expand Up @@ -254,7 +254,7 @@ public void normalizeDataExtension(ObjectNode containerNode, String containerNam
final JsonNode extData = containerNode.path(EXT).path(DATA);
final JsonNode ext = containerNode.get(EXT);
if (!extData.isNull() && !extData.isMissingNode()) {
final JsonNode resolvedExtData = jsonMergeUtil.merge(extData, data);
final JsonNode resolvedExtData = jsonMerger.merge(extData, data);
((ObjectNode) ext).set(DATA, resolvedExtData);
} else {
copyDataToExtData(containerNode, containerName, nodePrefix, warnings, data);
Expand Down
Loading

0 comments on commit 6db8896

Please sign in to comment.