-
Notifications
You must be signed in to change notification settings - Fork 243
Port FeedAd: New Adapter #3869
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
Merged
Merged
Port FeedAd: New Adapter #3869
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
69a8df9
New adapter: FeedAd (#3718)
9e7f95f
FeedAd integration test (#3718)
ef23c25
Checkstyle compliance (#3718)
53605ea
Codestyle compliance (#3718)
e96f8b8
Removed unused extension (#3718)
451480f
Expanded test cases (#3718)
81d0da9
Merge branch 'refs/heads/master' into port-3718-feedAd-adapter
eb8358a
Changed Function occurencies to UnaryOperator (#3718)
18fb5df
Post-review test improvement (#3718)
d013474
Post-review style improvement (#3718)
8ddb703
Merge branch 'refs/heads/master' into port-3718-feedAd-adapter
b1d77d1
Fixed integration test fixture (#3718)
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
src/main/java/org/prebid/server/bidder/feedad/FeedAdBidder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| package org.prebid.server.bidder.feedad; | ||
|
|
||
| import com.iab.openrtb.request.BidRequest; | ||
| import com.iab.openrtb.request.Device; | ||
| import com.iab.openrtb.response.BidResponse; | ||
| import com.iab.openrtb.response.SeatBid; | ||
| import io.vertx.core.MultiMap; | ||
| import org.apache.commons.collections4.CollectionUtils; | ||
| import org.prebid.server.bidder.Bidder; | ||
| import org.prebid.server.bidder.model.BidderBid; | ||
| import org.prebid.server.bidder.model.BidderCall; | ||
| import org.prebid.server.bidder.model.BidderError; | ||
| import org.prebid.server.bidder.model.HttpRequest; | ||
| import org.prebid.server.bidder.model.Result; | ||
| import org.prebid.server.json.DecodeException; | ||
| import org.prebid.server.json.JacksonMapper; | ||
| import org.prebid.server.proto.openrtb.ext.response.BidType; | ||
| import org.prebid.server.util.BidderUtil; | ||
| import org.prebid.server.util.HttpUtil; | ||
|
|
||
| import java.util.Collection; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
| import java.util.Objects; | ||
|
|
||
| public class FeedAdBidder implements Bidder<BidRequest> { | ||
|
|
||
| private static final String OPENRTB_VERSION = "2.5"; | ||
| private static final String X_FA_PBS_ADAPTER_VERSION_HEADER = "X-FA-PBS-Adapter-Version"; | ||
| private static final String FEED_AD_ADAPTER_VERSION = "1.0.0"; | ||
|
|
||
| private final String endpointUrl; | ||
| private final JacksonMapper mapper; | ||
|
|
||
| public FeedAdBidder(String endpointUrl, JacksonMapper mapper) { | ||
| this.endpointUrl = HttpUtil.validateUrl(endpointUrl); | ||
| this.mapper = Objects.requireNonNull(mapper); | ||
| } | ||
|
|
||
| @Override | ||
| public Result<List<HttpRequest<BidRequest>>> makeHttpRequests(BidRequest bidRequest) { | ||
| final MultiMap headers = resolveHeaders(bidRequest.getDevice()); | ||
| return Result.withValue(BidderUtil.defaultRequest(bidRequest, headers, endpointUrl, mapper)); | ||
| } | ||
|
|
||
| private MultiMap resolveHeaders(Device device) { | ||
| final MultiMap headers = HttpUtil.headers() | ||
| .add(X_FA_PBS_ADAPTER_VERSION_HEADER, FEED_AD_ADAPTER_VERSION) | ||
| .add(HttpUtil.X_OPENRTB_VERSION_HEADER, OPENRTB_VERSION); | ||
| if (device != null) { | ||
| HttpUtil.addHeaderIfValueIsNotEmpty(headers, HttpUtil.X_FORWARDED_FOR_HEADER, device.getIpv6()); | ||
| HttpUtil.addHeaderIfValueIsNotEmpty(headers, HttpUtil.X_FORWARDED_FOR_HEADER, device.getIp()); | ||
| } | ||
| return headers; | ||
| } | ||
|
|
||
| @Override | ||
| public Result<List<BidderBid>> makeBids(BidderCall<BidRequest> httpCall, BidRequest bidRequest) { | ||
| try { | ||
| final BidResponse bidResponse = mapper.decodeValue(httpCall.getResponse().getBody(), BidResponse.class); | ||
| return Result.withValues(extractBids(bidResponse)); | ||
| } catch (DecodeException e) { | ||
| return Result.withError(BidderError.badServerResponse(e.getMessage())); | ||
| } | ||
| } | ||
|
|
||
| private static List<BidderBid> extractBids(BidResponse bidResponse) { | ||
| if (bidResponse == null || CollectionUtils.isEmpty(bidResponse.getSeatbid())) { | ||
| return Collections.emptyList(); | ||
| } | ||
| return bidsFromResponse(bidResponse); | ||
| } | ||
|
|
||
| private static List<BidderBid> bidsFromResponse(BidResponse bidResponse) { | ||
| return bidResponse.getSeatbid().stream() | ||
| .filter(Objects::nonNull) | ||
| .map(SeatBid::getBid) | ||
| .filter(Objects::nonNull) | ||
| .flatMap(Collection::stream) | ||
| .map(bid -> BidderBid.of(bid, BidType.banner, bidResponse.getCur())) | ||
| .toList(); | ||
| } | ||
| } |
22 changes: 22 additions & 0 deletions
22
src/main/java/org/prebid/server/proto/openrtb/ext/request/feedad/ExtImpFeedAd.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package org.prebid.server.proto.openrtb.ext.request.feedad; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Value; | ||
|
|
||
| @Value | ||
| @AllArgsConstructor(staticName = "of") | ||
| public class ExtImpFeedAd { | ||
|
|
||
| @JsonProperty("clientToken") | ||
| String clientToken; | ||
|
|
||
| @JsonProperty("decoration") | ||
| String decoration; | ||
|
|
||
| @JsonProperty("placementId") | ||
| String placementId; | ||
|
|
||
| @JsonProperty("sdkOptions") | ||
| ExtImpFeedAdSdkOptions sdkOptions; | ||
| } |
28 changes: 28 additions & 0 deletions
28
src/main/java/org/prebid/server/proto/openrtb/ext/request/feedad/ExtImpFeedAdSdkOptions.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package org.prebid.server.proto.openrtb.ext.request.feedad; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Value; | ||
|
|
||
| @Value | ||
| @AllArgsConstructor(staticName = "of") | ||
| public class ExtImpFeedAdSdkOptions { | ||
|
|
||
| @JsonProperty("advertising_id") | ||
| String advertisingId; | ||
|
|
||
| @JsonProperty("app_name") | ||
| String appName; | ||
|
|
||
| @JsonProperty("bundle_id") | ||
| String bundleId; | ||
|
|
||
| @JsonProperty("hybrid_app") | ||
| boolean hybridApp; | ||
|
|
||
| @JsonProperty("hybrid_platform") | ||
| String hybridPlatform; | ||
|
|
||
| @JsonProperty("limit_ad_tracking") | ||
| boolean limitAdTracking; | ||
| } |
41 changes: 41 additions & 0 deletions
41
src/main/java/org/prebid/server/spring/config/bidder/FeedAdConfiguration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package org.prebid.server.spring.config.bidder; | ||
|
|
||
| import org.prebid.server.bidder.BidderDeps; | ||
| import org.prebid.server.bidder.feedad.FeedAdBidder; | ||
| import org.prebid.server.json.JacksonMapper; | ||
| import org.prebid.server.spring.config.bidder.model.BidderConfigurationProperties; | ||
| import org.prebid.server.spring.config.bidder.util.BidderDepsAssembler; | ||
| import org.prebid.server.spring.config.bidder.util.UsersyncerCreator; | ||
| import org.prebid.server.spring.env.YamlPropertySourceFactory; | ||
| import org.springframework.beans.factory.annotation.Value; | ||
| import org.springframework.boot.context.properties.ConfigurationProperties; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.context.annotation.PropertySource; | ||
|
|
||
| import jakarta.validation.constraints.NotBlank; | ||
|
|
||
| @Configuration | ||
| @PropertySource(value = "classpath:/bidder-config/feedad.yaml", factory = YamlPropertySourceFactory.class) | ||
| public class FeedAdConfiguration { | ||
|
|
||
| private static final String BIDDER_NAME = "feedad"; | ||
|
|
||
| @Bean("feedadConfigurationProperties") | ||
| @ConfigurationProperties("adapters.feedad") | ||
| BidderConfigurationProperties configurationProperties() { | ||
| return new BidderConfigurationProperties(); | ||
| } | ||
|
|
||
| @Bean | ||
| BidderDeps feedadBidderDeps(BidderConfigurationProperties feedadConfigurationProperties, | ||
| @NotBlank @Value("${external-url}") String externalUrl, | ||
| JacksonMapper mapper) { | ||
|
|
||
| return BidderDepsAssembler.forBidder(BIDDER_NAME) | ||
| .withConfig(feedadConfigurationProperties) | ||
| .usersyncerCreator(UsersyncerCreator.create(externalUrl)) | ||
| .bidderCreator(config -> new FeedAdBidder(config.getEndpoint(), mapper)) | ||
| .assemble(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| adapters: | ||
| feedad: | ||
| endpoint: https://ortb.feedad.com/1/prebid/requests | ||
| endpoint-compression: gzip | ||
| modifying-vast-xml-allowed: true | ||
| meta-info: | ||
| maintainer-email: support@feedad.com | ||
| app-media-types: | ||
| - banner | ||
| site-media-types: | ||
| - banner | ||
| vendor-id: 781 | ||
| usersync: | ||
| cookie-family-name: feedad | ||
| iframe: | ||
| url: https://ortb.feedad.com/1/usersyncs/supply?gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&gpp={{gpp}}&gpp_sid={{gpp_sid}}&us_privacy={{us_privacy}}&redirect={{redirect_url}} | ||
| support-cors: false | ||
| uid-macro: $UID |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| { | ||
| "$schema": "http://json-schema.org/draft-04/schema#", | ||
| "title": "FeedAd Adapter Params", | ||
| "description": "A schema which validates params accepted by the FeedAd adapter", | ||
| "properties": { | ||
| "clientToken": { | ||
| "description": "Your FeedAd client token. Check your FeedAd admin panel.", | ||
| "minLength": 1, | ||
| "type": "string" | ||
| }, | ||
| "decoration": { | ||
| "description": "A decoration to apply to the ad slot. See our documentation at https://docs.feedad.com/web/feed_ad/#decorations", | ||
| "type": "string" | ||
| }, | ||
| "placementId": { | ||
| "description": "A FeedAd placement ID of your choice", | ||
| "minLength": 1, | ||
| "pattern": "^(([a-z0-9])+[-_]?)+$", | ||
| "type": "string" | ||
| }, | ||
| "sdkOptions": { | ||
| "description": "Optional: Only required if you are using Prebid.JS in an app environment (aka hybrid app). See our documentation at https://docs.feedad.com/web/configuration/#hybrid-app-config-parameters", | ||
| "properties": { | ||
| "advertising_id": { | ||
| "type": "string", | ||
| "description": "Optional: The advertising id of the device or user (e.g. Apple IDFA, Google Advertising Client Id). We highly recommend setting this parameter to maximize your fill rate." | ||
| }, | ||
| "app_name": { | ||
| "type": "string", | ||
| "description": "The name of your app. This name will identify your app within the FeedAd admin dashboard." | ||
| }, | ||
| "bundle_id": { | ||
| "type": "string", | ||
| "description": "The unique package name or bundle id of your app." | ||
| }, | ||
| "hybrid_app": { | ||
| "type": "boolean", | ||
| "description": "Boolean indicating that the SDK is loaded within a hybrid app." | ||
| }, | ||
| "hybrid_platform": { | ||
| "description": "String identifying the device platform.", | ||
| "enum": [ | ||
| "", | ||
| "android", | ||
| "ios", | ||
| "windows" | ||
| ] | ||
| }, | ||
| "limit_ad_tracking": { | ||
| "type": "boolean", | ||
| "description": "Whether the app's user has limited ad tracking enabled." | ||
| } | ||
| }, | ||
| "type": [ | ||
| "object", | ||
| "null" | ||
| ] | ||
| } | ||
| }, | ||
| "required": [ | ||
| "clientToken", | ||
| "placementId" | ||
| ], | ||
| "type": "object" | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.