From af4b71c0f34ddecfb0a34ad6c505b4b7933cb3c5 Mon Sep 17 00:00:00 2001 From: Timothy Ace Date: Wed, 23 Mar 2022 15:28:49 -0400 Subject: [PATCH] Synacormedia Bid Adapter: ttl and eid update (#8006) * 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 Co-authored-by: Timothy M. Ace Co-authored-by: Tim Ace --- modules/synacormediaBidAdapter.js | 34 ++++----- .../modules/synacormediaBidAdapter_spec.js | 73 +++++++++++++++++-- 2 files changed, 83 insertions(+), 24 deletions(-) diff --git a/modules/synacormediaBidAdapter.js b/modules/synacormediaBidAdapter.js index 5f0057276a7..4cc648a2e04 100644 --- a/modules/synacormediaBidAdapter.js +++ b/modules/synacormediaBidAdapter.js @@ -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 ], @@ -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); } @@ -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 = []; @@ -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), @@ -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) { diff --git a/test/spec/modules/synacormediaBidAdapter_spec.js b/test/spec/modules/synacormediaBidAdapter_spec.js index c053771c296..b9a02799219 100644 --- a/test/spec/modules/synacormediaBidAdapter_spec.js +++ b/test/spec/modules/synacormediaBidAdapter_spec.js @@ -244,6 +244,13 @@ describe('synacormediaBidAdapter ', function () { rtiPartner: 'TDID' } }] + }, + { + source: 'neustar.biz', + uids: [{ + id: 'neustar809-044-23njhwer3', + atype: 1 + }] } ]; @@ -989,7 +996,7 @@ describe('synacormediaBidAdapter ', function () { netRevenue: true, mediaType: 'video', ad: '\n\n\n\nSynacor Media Ad Server - 9999\nhttps://uat-net.technoratimedia.com/openrtb/tags?ID=QVVDVElPTl9JRD1lOTBhYWU1My1hZDkwLTRkNDEtYTQxMC1lZDY1MjIxMDc0ZGMmQVVDVElPTl9CSURfSUQ9MTEzMzkxMjgwMDE2OTIzMzd-OTk5OX4wJkFVQ1RJT05fU0VBVF9JRD05OTk5JkFVQ1RJT05fSU1QX0lEPXYyZGE3MzIyYjJkZjYxZi02NDB4NDgwJkFDVE9SX1JFRj1ha2thLnRjcDovL2F3cy1lYXN0MUBhZHMxMy5jYXAtdXNlMS5zeW5hY29yLmNvbToyNTUxL3VzZXIvJGNMYmZiIy0xOTk4NTIzNTk3JlNFQVRfSUQ9cHJlYmlk&AUCTION_PRICE=0.45\n\n\n', - 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' @@ -1010,7 +1017,7 @@ describe('synacormediaBidAdapter ', function () { netRevenue: true, mediaType: BANNER, ad: '', - ttl: 60 + ttl: 420 }); }); @@ -1032,7 +1039,7 @@ describe('synacormediaBidAdapter ', function () { netRevenue: true, mediaType: BANNER, ad: '', - ttl: 60 + ttl: 420 }); expect(resp[1]).to.eql({ @@ -1045,7 +1052,7 @@ describe('synacormediaBidAdapter ', function () { netRevenue: true, mediaType: BANNER, ad: '', - ttl: 60 + ttl: 420 }); }); @@ -1156,7 +1163,7 @@ describe('synacormediaBidAdapter ', function () { netRevenue: true, mediaType: 'video', ad: '\n\n\n\nSynacor Media Ad Server - 9999\nhttps://uat-net.technoratimedia.com/openrtb/tags?ID=QVVDVElPTl9JRD1lOTBhYWU1My1hZDkwLTRkNDEtYTQxMC1lZDY1MjIxMDc0ZGMmQVVDVElPTl9CSURfSUQ9MTEzMzkxMjgwMDE2OTIzMzd-OTk5OX4wJkFVQ1RJT05fU0VBVF9JRD05OTk5JkFVQ1RJT05fSU1QX0lEPXYyZGE3MzIyYjJkZjYxZi02NDB4NDgwJkFDVE9SX1JFRj1ha2thLnRjcDovL2F3cy1lYXN0MUBhZHMxMy5jYXAtdXNlMS5zeW5hY29yLmNvbToyNTUxL3VzZXIvJGNMYmZiIy0xOTk4NTIzNTk3JlNFQVRfSUQ9cHJlYmlk&AUCTION_PRICE=0.45\n\n\n', - 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' @@ -1209,9 +1216,63 @@ describe('synacormediaBidAdapter ', function () { netRevenue: true, mediaType: BANNER, ad: '', - 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 () {