Skip to content

Commit

Permalink
Synacormedia Bid Adapter: ttl and eid update (#8006)
Browse files Browse the repository at this point in the history
* CAP-2474 Synacor Media Bid Adapter: Use OpenRTB parameters to populate bids' `ttl` values

* CAP-2474 Revised bid expiration/ttl code to conform to revised requirements w/ adserver tag expiration

* CAP-2474 Added tests and cleaned up tag expiration code

* feature/CAP-2516: Remove the filtering of eids for synacormediaBidAdapter

Co-authored-by: Andrew Fuchs <andrew.fuchs@synacor.com>
Co-authored-by: Timothy M. Ace <tace@imds.tv>
Co-authored-by: Tim Ace <tace@synacor.com>
  • Loading branch information
4 people authored Mar 23, 2022
1 parent 46306fe commit af4b71c
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 24 deletions.
34 changes: 16 additions & 18 deletions modules/synacormediaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ const BLOCKED_AD_SIZES = [
'1x1',
'1x2'
];
const SUPPORTED_USER_ID_SOURCES = [
'liveramp.com', // Liveramp IdentityLink
'nextroll.com', // NextRoll XID
'verizonmedia.com', // Verizon Media ConnectID
'pubcid.org' // PubCommon ID
];
const DEFAULT_MAX_TTL = 420; // 7 minutes
export const spec = {
code: 'synacormedia',
supportedMediaTypes: [ BANNER, VIDEO ],
Expand Down Expand Up @@ -95,7 +90,7 @@ export const spec = {

// User ID
if (validBidReqs[0] && validBidReqs[0].userIdAsEids && Array.isArray(validBidReqs[0].userIdAsEids)) {
const eids = this.processEids(validBidReqs[0].userIdAsEids);
const eids = validBidReqs[0].userIdAsEids;
if (eids.length) {
deepSetValue(openRtbBidRequest, 'user.ext.eids', eids);
}
Expand All @@ -114,16 +109,6 @@ export const spec = {
}
},

processEids: function(userIdAsEids) {
const eids = [];
userIdAsEids.forEach(function(eid) {
if (SUPPORTED_USER_ID_SOURCES.indexOf(eid.source) > -1) {
eids.push(eid);
}
});
return eids;
},

buildBannerImpressions: function (adSizes, bid, tagIdOrPlacementId, pos, videoOrBannerKey) {
let format = [];
let imps = [];
Expand Down Expand Up @@ -248,6 +233,19 @@ export const spec = {
}
});
}

let maxTtl = DEFAULT_MAX_TTL;
if (bid.ext && bid.ext['imds.tv'] && bid.ext['imds.tv'].ttl) {
const bidTtlMax = parseInt(bid.ext['imds.tv'].ttl, 10);
maxTtl = !isNaN(bidTtlMax) && bidTtlMax > 0 ? bidTtlMax : DEFAULT_MAX_TTL;
}

let ttl = maxTtl;
if (bid.exp) {
const bidTtl = parseInt(bid.exp, 10);
ttl = !isNaN(bidTtl) && bidTtl > 0 ? Math.min(bidTtl, maxTtl) : maxTtl;
}

const bidObj = {
requestId: impid,
cpm: parseFloat(bid.price),
Expand All @@ -258,7 +256,7 @@ export const spec = {
netRevenue: true,
mediaType: isVideo ? VIDEO : BANNER,
ad: creative,
ttl: 60
ttl,
};

if (bid.adomain != undefined || bid.adomain != null) {
Expand Down
73 changes: 67 additions & 6 deletions test/spec/modules/synacormediaBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,13 @@ describe('synacormediaBidAdapter ', function () {
rtiPartner: 'TDID'
}
}]
},
{
source: 'neustar.biz',
uids: [{
id: 'neustar809-044-23njhwer3',
atype: 1
}]
}
];

Expand Down Expand Up @@ -989,7 +996,7 @@ describe('synacormediaBidAdapter ', function () {
netRevenue: true,
mediaType: 'video',
ad: '<?xml version="1.0" encoding="UTF-8"?>\n<VAST version="3.0">\n<Ad id="11339128001692337~9999~0">\n<Wrapper>\n<AdSystem>Synacor Media Ad Server - 9999</AdSystem>\n<VASTAdTagURI>https://uat-net.technoratimedia.com/openrtb/tags?ID=QVVDVElPTl9JRD1lOTBhYWU1My1hZDkwLTRkNDEtYTQxMC1lZDY1MjIxMDc0ZGMmQVVDVElPTl9CSURfSUQ9MTEzMzkxMjgwMDE2OTIzMzd-OTk5OX4wJkFVQ1RJT05fU0VBVF9JRD05OTk5JkFVQ1RJT05fSU1QX0lEPXYyZGE3MzIyYjJkZjYxZi02NDB4NDgwJkFDVE9SX1JFRj1ha2thLnRjcDovL2F3cy1lYXN0MUBhZHMxMy5jYXAtdXNlMS5zeW5hY29yLmNvbToyNTUxL3VzZXIvJGNMYmZiIy0xOTk4NTIzNTk3JlNFQVRfSUQ9cHJlYmlk&AUCTION_PRICE=0.45</VASTAdTagURI>\n</Wrapper>\n</Ad>\n</VAST>',
ttl: 60,
ttl: 420,
meta: { advertiserDomains: ['psacentral.org'] },
videoCacheKey: 'QVVDVElPTl9JRD1lOTBhYWU1My1hZDkwLTRkNDEtYTQxMC1lZDY1MjIxMDc0ZGMmQVVDVElPTl9CSURfSUQ9MTEzMzkxMjgwMDE2OTIzMzd-OTk5OX4wJkFVQ1RJT05fU0VBVF9JRD05OTk5JkFVQ1RJT05fSU1QX0lEPXYyZGE3MzIyYjJkZjYxZi02NDB4NDgwJkFDVE9SX1JFRj1ha2thLnRjcDovL2F3cy1lYXN0MUBhZHMxMy5jYXAtdXNlMS5zeW5hY29yLmNvbToyNTUxL3VzZXIvJGNMYmZiIy0xOTk4NTIzNTk3JlNFQVRfSUQ9cHJlYmlk',
vastUrl: 'https://uat-net.technoratimedia.com/openrtb/tags?ID=QVVDVElPTl9JRD1lOTBhYWU1My1hZDkwLTRkNDEtYTQxMC1lZDY1MjIxMDc0ZGMmQVVDVElPTl9CSURfSUQ9MTEzMzkxMjgwMDE2OTIzMzd-OTk5OX4wJkFVQ1RJT05fU0VBVF9JRD05OTk5JkFVQ1RJT05fSU1QX0lEPXYyZGE3MzIyYjJkZjYxZi02NDB4NDgwJkFDVE9SX1JFRj1ha2thLnRjcDovL2F3cy1lYXN0MUBhZHMxMy5jYXAtdXNlMS5zeW5hY29yLmNvbToyNTUxL3VzZXIvJGNMYmZiIy0xOTk4NTIzNTk3JlNFQVRfSUQ9cHJlYmlk&AUCTION_PRICE=0.45'
Expand All @@ -1010,7 +1017,7 @@ describe('synacormediaBidAdapter ', function () {
netRevenue: true,
mediaType: BANNER,
ad: '<script src=\"//uat-net.technoratimedia.com/openrtb/tags?ID=k5JkFVQ1RJT05fSU1QX0lEPXYyZjczN&AUCTION_PRICE=0.13\"></script>',
ttl: 60
ttl: 420
});
});

Expand All @@ -1032,7 +1039,7 @@ describe('synacormediaBidAdapter ', function () {
netRevenue: true,
mediaType: BANNER,
ad: '<script src=\"//uat-net.technoratimedia.com/openrtb/tags?ID=k5JkFVQ1RJT05fSU1QX0lEPXYyZjczN&AUCTION_PRICE=0.13\"></script>',
ttl: 60
ttl: 420
});

expect(resp[1]).to.eql({
Expand All @@ -1045,7 +1052,7 @@ describe('synacormediaBidAdapter ', function () {
netRevenue: true,
mediaType: BANNER,
ad: '<script src=\"//uat-net.technoratimedia.com/openrtb/tags?ID=OTk5OX4wJkFVQ1RJT05fU0VBVF9JR&AUCTION_PRICE=1.99\"></script>',
ttl: 60
ttl: 420
});
});

Expand Down Expand Up @@ -1156,7 +1163,7 @@ describe('synacormediaBidAdapter ', function () {
netRevenue: true,
mediaType: 'video',
ad: '<?xml version="1.0" encoding="UTF-8"?>\n<VAST version="3.0">\n<Ad id="11339128001692337~9999~0">\n<Wrapper>\n<AdSystem>Synacor Media Ad Server - 9999</AdSystem>\n<VASTAdTagURI>https://uat-net.technoratimedia.com/openrtb/tags?ID=QVVDVElPTl9JRD1lOTBhYWU1My1hZDkwLTRkNDEtYTQxMC1lZDY1MjIxMDc0ZGMmQVVDVElPTl9CSURfSUQ9MTEzMzkxMjgwMDE2OTIzMzd-OTk5OX4wJkFVQ1RJT05fU0VBVF9JRD05OTk5JkFVQ1RJT05fSU1QX0lEPXYyZGE3MzIyYjJkZjYxZi02NDB4NDgwJkFDVE9SX1JFRj1ha2thLnRjcDovL2F3cy1lYXN0MUBhZHMxMy5jYXAtdXNlMS5zeW5hY29yLmNvbToyNTUxL3VzZXIvJGNMYmZiIy0xOTk4NTIzNTk3JlNFQVRfSUQ9cHJlYmlk&AUCTION_PRICE=0.45</VASTAdTagURI>\n</Wrapper>\n</Ad>\n</VAST>',
ttl: 60,
ttl: 420,
meta: { advertiserDomains: ['psacentral.org'] },
videoCacheKey: 'QVVDVElPTl9JRD1lOTBhYWU1My1hZDkwLTRkNDEtYTQxMC1lZDY1MjIxMDc0ZGMmQVVDVElPTl9CSURfSUQ9MTEzMzkxMjgwMDE2OTIzMzd-OTk5OX4wJkFVQ1RJT05fU0VBVF9JRD05OTk5JkFVQ1RJT05fSU1QX0lEPXYyZGE3MzIyYjJkZjYxZi02NDB4NDgwJkFDVE9SX1JFRj1ha2thLnRjcDovL2F3cy1lYXN0MUBhZHMxMy5jYXAtdXNlMS5zeW5hY29yLmNvbToyNTUxL3VzZXIvJGNMYmZiIy0xOTk4NTIzNTk3JlNFQVRfSUQ9cHJlYmlk',
vastUrl: 'https://uat-net.technoratimedia.com/openrtb/tags?ID=QVVDVElPTl9JRD1lOTBhYWU1My1hZDkwLTRkNDEtYTQxMC1lZDY1MjIxMDc0ZGMmQVVDVElPTl9CSURfSUQ9MTEzMzkxMjgwMDE2OTIzMzd-OTk5OX4wJkFVQ1RJT05fU0VBVF9JRD05OTk5JkFVQ1RJT05fSU1QX0lEPXYyZGE3MzIyYjJkZjYxZi02NDB4NDgwJkFDVE9SX1JFRj1ha2thLnRjcDovL2F3cy1lYXN0MUBhZHMxMy5jYXAtdXNlMS5zeW5hY29yLmNvbToyNTUxL3VzZXIvJGNMYmZiIy0xOTk4NTIzNTk3JlNFQVRfSUQ9cHJlYmlk&AUCTION_PRICE=0.45'
Expand Down Expand Up @@ -1209,9 +1216,63 @@ describe('synacormediaBidAdapter ', function () {
netRevenue: true,
mediaType: BANNER,
ad: '<script src=\"//uat-net.technoratimedia.com/openrtb/tags?ID=k5JkFVQ1RJT05fSU1QX0lEPXYyZjczN&AUCTION_PRICE=0.13\"></script>',
ttl: 60
ttl: 420
});
});

it('should return ttl equal to DEFAULT_TTL_MAX if bid.exp and bid.ext["imds.tv"].ttl are both undefined', function() {
const br = { ...bidResponse };
serverResponse.body.seatbid[0].bid.push(br);
const resp = spec.interpretResponse(serverResponse, bidRequest);
expect(resp).to.be.an('array').to.have.lengthOf(1);
expect(resp[0]).to.have.property('ttl');
expect(resp[0].ttl).to.equal(420);
});

it('should return ttl equal to bid.ext["imds.tv"].ttl if it is defined but bid.exp is undefined', function() {
let br = { ext: { 'imds.tv': { ttl: 4321 } }, ...bidResponse };
serverResponse.body.seatbid[0].bid.push(br);
let resp = spec.interpretResponse(serverResponse, bidRequest);
expect(resp).to.be.an('array').to.have.lengthOf(1);
expect(resp[0]).to.have.property('ttl');
expect(resp[0].ttl).to.equal(4321);
});

it('should return ttl equal to bid.exp if bid.exp is less than or equal to DEFAULT_TTL_MAX and bid.ext["imds.tv"].ttl is undefined', function() {
const br = { exp: 123, ...bidResponse };
serverResponse.body.seatbid[0].bid.push(br);
const resp = spec.interpretResponse(serverResponse, bidRequest);
expect(resp).to.be.an('array').to.have.lengthOf(1);
expect(resp[0]).to.have.property('ttl');
expect(resp[0].ttl).to.equal(123);
});

it('should return ttl equal to DEFAULT_TTL_MAX if bid.exp is greater than DEFAULT_TTL_MAX and bid.ext["imds.tv"].ttl is undefined', function() {
const br = { exp: 4321, ...bidResponse };
serverResponse.body.seatbid[0].bid.push(br);
const resp = spec.interpretResponse(serverResponse, bidRequest);
expect(resp).to.be.an('array').to.have.lengthOf(1);
expect(resp[0]).to.have.property('ttl');
expect(resp[0].ttl).to.equal(420);
});

it('should return ttl equal to bid.exp if bid.exp is less than or equal to bid.ext["imds.tv"].ttl', function() {
const br = { exp: 1234, ext: { 'imds.tv': { ttl: 4321 } }, ...bidResponse };
serverResponse.body.seatbid[0].bid.push(br);
const resp = spec.interpretResponse(serverResponse, bidRequest);
expect(resp).to.be.an('array').to.have.lengthOf(1);
expect(resp[0]).to.have.property('ttl');
expect(resp[0].ttl).to.equal(1234);
});

it('should return ttl equal to bid.ext["imds.tv"].ttl if bid.exp is greater than bid.ext["imds.tv"].ttl', function() {
const br = { exp: 4321, ext: { 'imds.tv': { ttl: 1234 } }, ...bidResponse };
serverResponse.body.seatbid[0].bid.push(br);
const resp = spec.interpretResponse(serverResponse, bidRequest);
expect(resp).to.be.an('array').to.have.lengthOf(1);
expect(resp[0]).to.have.property('ttl');
expect(resp[0].ttl).to.equal(1234);
});
});
describe('getUserSyncs', function () {
it('should return a usersync when iframes is enabled', function () {
Expand Down

0 comments on commit af4b71c

Please sign in to comment.