From 6424b292fa451382cf4a596dcf93bd9c74b6359b Mon Sep 17 00:00:00 2001 From: "dev adxcg.com" <31470944+adxcgcom@users.noreply.github.com> Date: Thu, 28 Nov 2019 23:34:57 +0000 Subject: [PATCH 1/2] adxcgBidAdapter prebid 3.0 requirements compatibility --- modules/adxcgBidAdapter.js | 43 +++++---- test/spec/modules/adxcgBidAdapter_spec.js | 104 +++++++++++++++++++--- 2 files changed, 120 insertions(+), 27 deletions(-) diff --git a/modules/adxcgBidAdapter.js b/modules/adxcgBidAdapter.js index 34b5ea25fb0..e19c22b57f4 100644 --- a/modules/adxcgBidAdapter.js +++ b/modules/adxcgBidAdapter.js @@ -12,6 +12,7 @@ import includes from 'core-js/library/fn/array/includes' * updated to pass aditional auction and impression level parameters. added pass for video targeting parameters * updated to fix native support for image width/height and icon 2019.03.17 * updated support for userid - pubcid,ttid 2019.05.28 + * updated to support prebid 3.0 - remove non https, move to banner.xx.sizes, remove utils.getTopWindowLocation,remove utils.getTopWindowUrl(),remove utils.getTopWindowReferrer() */ const BIDDER_CODE = 'adxcg' @@ -20,7 +21,7 @@ const SOURCE = 'pbjs10' const VIDEO_TARGETING = ['id', 'mimes', 'minduration', 'maxduration', 'startdelay', 'skippable', 'playback_method', 'frameworks'] const USER_PARAMS_AUCTION = ['forcedDspIds', 'forcedCampaignIds', 'forcedCreativeIds', 'gender', 'dnt', 'language'] const USER_PARAMS_BID = ['lineparam1', 'lineparam2', 'lineparam3'] -const BIDADAPTERVERSION = 'r20180703PB10' +const BIDADAPTERVERSION = 'r20191128PB30' export const spec = { code: BIDDER_CODE, @@ -71,8 +72,6 @@ export const spec = { buildRequests: function (validBidRequests, bidderRequest) { utils.logMessage(`buildRequests: ${JSON.stringify(validBidRequests)}`) - let location = utils.getTopWindowLocation() - let secure = location.protocol === 'https:' let dt = new Date() let ratio = window.devicePixelRatio || 1 let iobavailable = window && window.IntersectionObserver && window.IntersectionObserverEntry && window.IntersectionObserverEntry.prototype && 'intersectionRatio' in window.IntersectionObserverEntry.prototype @@ -82,16 +81,11 @@ export const spec = { bt = Math.min(window.PREBID_TIMEOUT, bt) } - let requestUrl = url.parse(location.href) - requestUrl.search = null - requestUrl.hash = null - // add common parameters let beaconParams = { renderformat: 'javascript', ver: BIDADAPTERVERSION, - url: encodeURIComponent(utils.getTopWindowUrl()), - secure: secure ? '1' : '0', + secure: '1', source: SOURCE, uw: window.screen.width, uh: window.screen.height, @@ -106,9 +100,10 @@ export const spec = { rndid: Math.floor(Math.random() * (999999 - 100000 + 1)) + 100000 } - if (utils.getTopWindowReferrer()) { - beaconParams.ref = encodeURIComponent(utils.getTopWindowReferrer()) - } + const referrer = utils.deepAccess(bidderRequest, 'refererInfo.referer'); + const page = utils.deepAccess(bidderRequest, 'refererInfo.canonicalUrl') || config.getConfig('pageUrl') || utils.deepAccess(window, 'location.href'); + beaconParams.ref = encodeURIComponent(referrer); + beaconParams.url = encodeURIComponent(page); if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) { beaconParams.gdpr = bidderRequest.gdprConsent.gdprApplies ? '1' : '0' @@ -131,7 +126,10 @@ export const spec = { validBidRequests.forEach((bid, index) => { adZoneIds.push(utils.getBidIdParameter('adzoneid', bid.params)) prebidBidIds.push(bid.bidId) - sizes.push(utils.parseSizesInput(bid.sizes).join('|')) + + if (isBannerRequest(bid)) { + sizes.push(utils.parseSizesInput(bid.mediaTypes.banner.sizes).join('|')) + } let bidfloor = utils.getBidIdParameter('bidfloor', bid.params) || 0 bidfloors.push(bidfloor) @@ -144,6 +142,7 @@ export const spec = { } // copy video context params beaconParams['video.context' + '.' + index] = utils.deepAccess(bid, 'mediaTypes.video.context') + sizes.push(utils.parseSizesInput(bid.mediaTypes.video.playerSize).join('|')) } // copy all custom parameters impression level parameters not supported above @@ -168,9 +167,17 @@ export const spec = { beaconParams.tdid = validBidRequests[0].userId.tdid; } + if (utils.isStr(utils.deepAccess(validBidRequests, '0.userId.id5id'))) { + beaconParams.id5id = validBidRequests[0].userId.id5id; + } + + if (utils.isStr(utils.deepAccess(validBidRequests, '0.userId.idl_env'))) { + beaconParams.idl_env = validBidRequests[0].userId.idl_env; + } + let adxcgRequestUrl = url.format({ - protocol: secure ? 'https' : 'http', - hostname: secure ? 'hbps.adxcg.net' : 'hbp.adxcg.net', + protocol: 'https', + hostname: 'hbps.adxcg.net', pathname: '/get/adi', search: beaconParams }) @@ -272,7 +279,7 @@ export const spec = { if (syncOptions.iframeEnabled) { return [{ type: 'iframe', - url: '//cdn.adxcg.net/pb-sync.html' + url: 'https://cdn.adxcg.net/pb-sync.html' }] } } @@ -282,4 +289,8 @@ function isVideoRequest (bid) { return bid.mediaType === 'video' || !!utils.deepAccess(bid, 'mediaTypes.video') } +function isBannerRequest (bid) { + return bid.mediaType === 'banner' || !!utils.deepAccess(bid, 'mediaTypes.banner') +} + registerBidder(spec) diff --git a/test/spec/modules/adxcgBidAdapter_spec.js b/test/spec/modules/adxcgBidAdapter_spec.js index 5bac9523b18..8daad7a9f86 100644 --- a/test/spec/modules/adxcgBidAdapter_spec.js +++ b/test/spec/modules/adxcgBidAdapter_spec.js @@ -10,7 +10,11 @@ describe('AdxcgAdapter', function () { 'adzoneid': '1' }, 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [640, 360], [1, 1]], + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [640, 360], [1, 1]] + } + }, 'bidId': '84ab500420319d', 'bidderRequestId': '7101db09af0db2', 'auctionId': '1d1a030790a475', @@ -27,11 +31,11 @@ describe('AdxcgAdapter', function () { }, 'mediaTypes': { 'video': { - 'context': 'instream' + 'context': 'instream', + 'playerSize': [[640, 480]] } }, 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [640, 360], [1, 1]], 'bidId': '84ab500420319d', 'bidderRequestId': '7101db09af0db2', 'auctionId': '1d1a030790a475', @@ -70,7 +74,11 @@ describe('AdxcgAdapter', function () { 'adzoneid': '1' }, 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [640, 360], [1, 1]], + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [640, 360], [1, 1]] + } + }, 'bidId': '84ab500420319d', 'bidderRequestId': '7101db09af0db2', 'auctionId': '1d1a030790a475', @@ -81,12 +89,12 @@ describe('AdxcgAdapter', function () { expect(request).to.exist expect(request.method).to.equal('GET') let parsedRequestUrl = url.parse(request.url) - expect(parsedRequestUrl.hostname).to.equal('hbp.adxcg.net') + expect(parsedRequestUrl.hostname).to.equal('hbps.adxcg.net') expect(parsedRequestUrl.pathname).to.equal('/get/adi') let query = parsedRequestUrl.search expect(query.renderformat).to.equal('javascript') - expect(query.ver).to.equal('r20180703PB10') + expect(query.ver).to.equal('r20191128PB30') expect(query.source).to.equal('pbjs10') expect(query.pbjs).to.equal('$prebid.version$') expect(query.adzoneid).to.equal('1') @@ -103,7 +111,11 @@ describe('AdxcgAdapter', function () { 'adzoneid': '1' }, 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [640, 360], [1, 1]], + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [640, 360], [1, 1]] + } + }, 'bidId': '84ab500420319d', 'bidderRequestId': '7101db09af0db2', 'auctionId': '1d1a030790a475', @@ -140,7 +152,11 @@ describe('AdxcgAdapter', function () { 'adzoneid': '1' }, 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [640, 360], [1, 1]], + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [640, 360], [1, 1]] + } + }, 'bidId': '84ab500420319d', 'bidderRequestId': '7101db09af0db2', 'auctionId': '1d1a030790a475', @@ -165,7 +181,11 @@ describe('AdxcgAdapter', function () { 'adzoneid': '1' }, 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [640, 360], [1, 1]], + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [640, 360], [1, 1]] + } + }, 'bidId': '84ab500420319d', 'bidderRequestId': '7101db09af0db2', 'auctionId': '1d1a030790a475', @@ -183,6 +203,64 @@ describe('AdxcgAdapter', function () { }) }) + describe('userid id5id should be passed to querystring', function () { + let bid = [{ + 'bidder': 'adxcg', + 'params': { + 'adzoneid': '1' + }, + 'adUnitCode': 'adunit-code', + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [640, 360], [1, 1]] + } + }, + 'bidId': '84ab500420319d', + 'bidderRequestId': '7101db09af0db2', + 'auctionId': '1d1a030790a475', + }] + + let bidderRequests = {}; + + bid[0].userId = {'id5id': 'id5idsample'}; + + it('should send pubcid if available', function () { + let request = spec.buildRequests(bid, bidderRequests) + let parsedRequestUrl = url.parse(request.url) + let query = parsedRequestUrl.search + expect(query.id5id).to.equal('id5idsample'); + }) + }) + + describe('userid idl_env should be passed to querystring', function () { + let bid = [{ + 'bidder': 'adxcg', + 'params': { + 'adzoneid': '1' + }, + 'adUnitCode': 'adunit-code', + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [640, 360], [1, 1]] + } + }, + 'bidId': '84ab500420319d', + 'bidderRequestId': '7101db09af0db2', + 'auctionId': '1d1a030790a475', + }] + + let bidderRequests = {}; + + bid[0].userId = {'idl_env': 'idl_envsample'}; + + it('should send pubcid if available', function () { + let request = spec.buildRequests(bid, bidderRequests) + let parsedRequestUrl = url.parse(request.url) + let query = parsedRequestUrl.search + expect(query.idl_env).to.equal('idl_envsample'); + }) + }) + describe('response handler', function () { let BIDDER_REQUEST = { 'bidder': 'adxcg', @@ -190,7 +268,11 @@ describe('AdxcgAdapter', function () { 'adzoneid': '1' }, 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [640, 360], [1, 1]], + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [640, 360], [1, 1]] + } + }, 'bidId': '84ab500420319d', 'bidderRequestId': '7101db09af0db2', 'auctionId': '1d1a030790a475', @@ -394,7 +476,7 @@ describe('AdxcgAdapter', function () { it('should return iframe sync option', function () { expect(spec.getUserSyncs(syncoptionsIframe)[0].type).to.equal('iframe') - expect(spec.getUserSyncs(syncoptionsIframe)[0].url).to.equal('//cdn.adxcg.net/pb-sync.html') + expect(spec.getUserSyncs(syncoptionsIframe)[0].url).to.equal('https://cdn.adxcg.net/pb-sync.html') }) }) }) From f567212bc2c1a4689026ace447b44b4a162e7dde Mon Sep 17 00:00:00 2001 From: adxcgcom <31470944+adxcgcom@users.noreply.github.com> Date: Fri, 29 Nov 2019 21:49:08 +0000 Subject: [PATCH 2/2] Restarting CI test --- modules/adxcgBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/adxcgBidAdapter.js b/modules/adxcgBidAdapter.js index e19c22b57f4..f9cdeda536a 100644 --- a/modules/adxcgBidAdapter.js +++ b/modules/adxcgBidAdapter.js @@ -12,7 +12,7 @@ import includes from 'core-js/library/fn/array/includes' * updated to pass aditional auction and impression level parameters. added pass for video targeting parameters * updated to fix native support for image width/height and icon 2019.03.17 * updated support for userid - pubcid,ttid 2019.05.28 - * updated to support prebid 3.0 - remove non https, move to banner.xx.sizes, remove utils.getTopWindowLocation,remove utils.getTopWindowUrl(),remove utils.getTopWindowReferrer() + * updated to support prebid 3.0 -remove non https, move to banner.xx.sizes, remove utils.getTopWindowLocation,remove utils.getTopWindowUrl(),remove utils.getTopWindowReferrer() */ const BIDDER_CODE = 'adxcg'