Skip to content

Commit

Permalink
FeedAd Bid Adapter: add support for GDPR/TCF 2.0 & remove video suppo…
Browse files Browse the repository at this point in the history
…rt (#6538)

* added file scaffold

* added isBidRequestValid implementation

* added local prototype of ad integration

* added implementation for placement ID validation

* fixed video context filter

* applied lint to feedad bid adapter

* added unit test for bid request validation

* added buildRequest unit test

* added unit tests for timeout and bid won callbacks

* updated bid request to FeedAd API

* added parsing of feedad api bid response

* added transmisison of tracking events to FeedAd Api

* code cleanup

* updated feedad unit tests for buildRequest method

* added unit tests for event tracking implementation

* added unit test for interpretResponse method

* added adapter documentation

* added dedicated feedad example page

* updated feedad adapter to use live system

* updated FeedAd adapter placement ID regex

* removed groups from FeedAd adapter placement ID regex

* removed dedicated feedad example page

* updated imports in FeedAd adapter file to use relative paths

* updated FeedAd adapter unit test to use sinon.useFakeXMLHttpRequest()

* added GDPR fields to the FeedAd bid request

* removed video from supported media types of the FeedAd adapter

* increased version code of FeedAd adapter to 1.0.2

* removed unnecessary check of bidder request

* fixed unit test testing for old FeedAd version

* removed video media type example from documentation file

* added gvlid to FeedAd adapter
  • Loading branch information
couchcrew-thomas authored Apr 14, 2021
1 parent e256788 commit 5fbef60
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 8 deletions.
16 changes: 13 additions & 3 deletions modules/feedadBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as utils from '../src/utils.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER, VIDEO} from '../src/mediaTypes.js';
import {BANNER} from '../src/mediaTypes.js';
import {ajax} from '../src/ajax.js';

/**
* Version of the FeedAd bid adapter
* @type {string}
*/
const VERSION = '1.0.0';
const VERSION = '1.0.2';

/**
* @typedef {object} FeedAdApiBidRequest
Expand Down Expand Up @@ -61,6 +61,11 @@ const VERSION = '1.0.0';
* @property [device_platform] {1|2|3} 1 - Android | 2 - iOS | 3 - Windows
*/

/**
* The IAB TCF 2.0 vendor ID for the FeedAd GmbH
*/
const TCF_VENDOR_ID = 781;

/**
* Bidder network identity code
* @type {string}
Expand All @@ -71,7 +76,7 @@ const BIDDER_CODE = 'feedad';
* The media types supported by FeedAd
* @type {MediaType[]}
*/
const MEDIA_TYPES = [VIDEO, BANNER];
const MEDIA_TYPES = [BANNER];

/**
* Tag for logging
Expand Down Expand Up @@ -204,6 +209,10 @@ function buildRequests(validBidRequests, bidderRequest) {
referer: data.refererInfo.referer,
transactionId: bid.transactionId
});
if (bidderRequest.gdprConsent) {
data.consentIabTcf = bidderRequest.gdprConsent.consentString;
data.gdprApplies = bidderRequest.gdprConsent.gdprApplies;
}
return {
method: 'POST',
url: `${API_ENDPOINT}${API_PATH_BID_REQUEST}`,
Expand Down Expand Up @@ -279,6 +288,7 @@ function trackingHandlerFactory(klass) {
*/
export const spec = {
code: BIDDER_CODE,
gvlid: TCF_VENDOR_ID,
supportedMediaTypes: MEDIA_TYPES,
isBidRequestValid,
buildRequests,
Expand Down
3 changes: 0 additions & 3 deletions modules/feedadBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ Prebid.JS adapter that connects to the FeedAd demand sources.
mediaTypes: {
banner: { // supports all banner sizes
sizes: [[300, 250]],
},
video: { // supports only outstream video
context: 'outstream'
}
},
bids: [
Expand Down
41 changes: 39 additions & 2 deletions test/spec/modules/feedadBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('FeedAdAdapter', function () {
it('should only support video and banner ads', function () {
expect(spec.supportedMediaTypes).to.be.a('array');
expect(spec.supportedMediaTypes).to.include(BANNER);
expect(spec.supportedMediaTypes).to.include(VIDEO);
expect(spec.supportedMediaTypes).not.to.include(VIDEO);
expect(spec.supportedMediaTypes).not.to.include(NATIVE);
});
it('should export the BidderSpec functions', function () {
Expand All @@ -23,6 +23,9 @@ describe('FeedAdAdapter', function () {
expect(spec.onTimeout).to.be.a('function');
expect(spec.onBidWon).to.be.a('function');
});
it('should export the TCF vendor ID', function () {
expect(spec.gvlid).to.equal(781);
})
});

describe('isBidRequestValid', function () {
Expand Down Expand Up @@ -248,6 +251,40 @@ describe('FeedAdAdapter', function () {
let result = spec.buildRequests([bid, bid, bid]);
expect(result).to.be.empty;
});
it('should not include GDPR data if the bidder request has none available', function () {
let bid = {
code: 'feedad',
mediaTypes: {
banner: {
sizes: [[320, 250]]
}
},
params: {clientToken: 'clientToken', placementId: 'placement-id'}
};
let result = spec.buildRequests([bid], bidderRequest);
expect(result.data.gdprApplies).to.be.undefined;
expect(result.data.consentIabTcf).to.be.undefined;
});
it('should include GDPR data if the bidder requests contains it', function () {
let bid = {
code: 'feedad',
mediaTypes: {
banner: {
sizes: [[320, 250]]
}
},
params: {clientToken: 'clientToken', placementId: 'placement-id'}
};
let request = Object.assign({}, bidderRequest, {
gdprConsent: {
consentString: 'the consent string',
gdprApplies: true
}
});
let result = spec.buildRequests([bid], request);
expect(result.data.gdprApplies).to.equal(request.gdprConsent.gdprApplies);
expect(result.data.consentIabTcf).to.equal(request.gdprConsent.consentString);
});
});

describe('interpretResponse', function () {
Expand Down Expand Up @@ -404,7 +441,7 @@ describe('FeedAdAdapter', function () {
prebid_bid_id: bidId,
prebid_transaction_id: transactionId,
referer,
sdk_version: '1.0.0'
sdk_version: '1.0.2'
};
subject(data);
expect(server.requests.length).to.equal(1);
Expand Down

0 comments on commit 5fbef60

Please sign in to comment.