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

FeedAd bidder adapter #3891

Merged
merged 24 commits into from
Jun 18, 2019
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6813398
added file scaffold
couchcrew-thomas May 2, 2019
030a709
added isBidRequestValid implementation
couchcrew-thomas May 7, 2019
1ac46eb
added local prototype of ad integration
couchcrew-thomas May 8, 2019
fdcee20
added implementation for placement ID validation
couchcrew-thomas May 20, 2019
1938094
fixed video context filter
couchcrew-thomas May 20, 2019
478b00d
applied lint to feedad bid adapter
couchcrew-thomas May 20, 2019
494258e
added unit test for bid request validation
couchcrew-thomas May 20, 2019
c7111e8
added buildRequest unit test
couchcrew-thomas May 20, 2019
e57779c
added unit tests for timeout and bid won callbacks
couchcrew-thomas May 22, 2019
0af865c
updated bid request to FeedAd API
couchcrew-thomas Jun 3, 2019
4d21899
added parsing of feedad api bid response
couchcrew-thomas Jun 3, 2019
3185358
added transmisison of tracking events to FeedAd Api
couchcrew-thomas Jun 5, 2019
d7673e4
code cleanup
couchcrew-thomas Jun 7, 2019
79a3cbc
updated feedad unit tests for buildRequest method
couchcrew-thomas Jun 7, 2019
d446300
added unit tests for event tracking implementation
couchcrew-thomas Jun 7, 2019
766f23c
added unit test for interpretResponse method
couchcrew-thomas Jun 7, 2019
2d469c0
added adapter documentation
couchcrew-thomas Jun 7, 2019
138d1ff
added dedicated feedad example page
couchcrew-thomas Jun 7, 2019
e4c7214
updated feedad adapter to use live system
couchcrew-thomas Jun 7, 2019
0eabd34
updated FeedAd adapter placement ID regex
couchcrew-thomas Jun 10, 2019
1ff7caa
removed groups from FeedAd adapter placement ID regex
couchcrew-thomas Jun 11, 2019
748590e
removed dedicated feedad example page
couchcrew-thomas Jun 14, 2019
98e422a
updated imports in FeedAd adapter file to use relative paths
couchcrew-thomas Jun 14, 2019
f2836f3
updated FeedAd adapter unit test to use sinon.useFakeXMLHttpRequest()
couchcrew-thomas Jun 14, 2019
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
Prev Previous commit
Next Next commit
added isBidRequestValid implementation
  • Loading branch information
couchcrew-thomas committed May 7, 2019
commit 030a70979df5b255653b67ef87b101c99eb0bc43
79 changes: 76 additions & 3 deletions modules/feedadBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,91 @@
import * as utils from 'src/utils';
import {registerBidder} from 'src/adapters/bidderFactory';
couchcrew-thomas marked this conversation as resolved.
Show resolved Hide resolved
import {config} from 'src/config';
import {BANNER, VIDEO} from '../src/mediaTypes';

/**
* Bidder network identity code
* @type {string}
*/
const BIDDER_CODE = 'feedad';

/**
* The media types supported by FeedAd
* @type {MediaType[]}
*/
const MEDIA_TYPES = [VIDEO, BANNER];

/**
* Tag for logging
* @type {string}
*/
const TAG = '[FeedAd]';

/**
* Checks if the bid is compatible with FeedAd.
*
* @param {BidRequest} bid - the bid to check
* @return {boolean} true if the bid is valid
*/
function isBidRequestValid(bid) {
const clientToken = utils.deepAccess(bid, 'params.clientToken');
if (!clientToken || !isValidClientToken(clientToken)) {
utils.logWarn(TAG, "missing or invalid parameter 'clientToken'. found value:", clientToken);
return false;
}

const placementId = utils.deepAccess(bid, 'params.placementId');
if (!placementId || !isValidPlacementId(placementId)) {
utils.logWarn(TAG, "missing or invalid parameter 'placementId'. found value:", placementId);
return false;
}

return true;
}

/**
* Checks if a client token is valid
* @param {string} clientToken - the client token
* @return {boolean} true if the token is valid
*/
function isValidClientToken(clientToken) {
return typeof clientToken === 'string' && clientToken.length > 0;
}

/**
* Checks if the placement id is a valid FeedAd placement ID
*
* @param {string} placementId - the placement id
* @return {boolean} if the id is valid
*/
function isValidPlacementId(placementId) {
return placementId.length > 0; // TODO: add placement ID regex or convert any string to valid ID?
}

/**
* Checks if the given media types contain unsupported settings
* @param {MediaTypes} mediaTypes - the media types to check
* @return {string[]} the unsupported settings, empty when all types are supported
*/
function checkMediaTypes(mediaTypes) {
const errors = [];
if (mediaTypes.native) {
errors.push("'native' ads are not supported");
}
if (mediaTypes.video && mediaTypes.video.any(video => video.context !== 'outstream')) {
errors.push("only 'outstream' video context's are supported");
}
return errors;
}

/**
* @type {BidderSpec}
*/
export const spec = {
code: BIDDER_CODE,
isBidRequestValid: function (bid) {
},
supportedMediaTypes: MEDIA_TYPES,
isBidRequestValid,
buildRequests: function (validBidRequests, bidderRequest) {
utils.logMessage('buildRequests', JSON.stringify(validBidRequests), JSON.stringify(bidderRequest));
},
interpretResponse: function (serverResponse, request) {
},