From 29a4604aed8b9f31b3d6593772bf8fcff390ac52 Mon Sep 17 00:00:00 2001 From: Myles Wehr Date: Wed, 23 Sep 2020 15:37:44 -0400 Subject: [PATCH 01/12] Submit Zeta Adapter to Prebid --- modules/zetaBidAdapter.js | 142 ++++++++++++++++++++++++++++++++++++++ modules/zetaBidAdapter.md | 48 +++++++++++++ 2 files changed, 190 insertions(+) create mode 100644 modules/zetaBidAdapter.js create mode 100644 modules/zetaBidAdapter.md diff --git a/modules/zetaBidAdapter.js b/modules/zetaBidAdapter.js new file mode 100644 index 00000000000..dafa8d39182 --- /dev/null +++ b/modules/zetaBidAdapter.js @@ -0,0 +1,142 @@ +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import {BANNER} from '../src/mediaTypes.js'; +const BIDDER_CODE = 'Zeta Global'; +const ENDPOINT_URL = 'https://prebid.rfihub.com/prebid'; +const USER_SYNC_URL = 'http://p.rfihub.com/cm?pub=42770&in=1'; +const DEFAULT_CUR = 'USD'; + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER], + + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function(bid) { + return !!(bid.params.placementId || (bid.params.member && bid.params.invCode)); + }, + + /** + * Make a server request from the lqist of BidRequests. + * + * @param {validBidRequests[]} - an array of bidRequest objects + * @param {bidderRequest} - master bidRequest object + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: function(validBidRequests, bidderRequest) { + const secure = location.protocol.indexOf('https') > -1 ? 1 : 0; + const request = validBidRequests[0]; + const params = request.params; + let impData = { + id: request.bidId, + secure, + banner: buildBanner(request) + }; + let isMobile = /(ios|ipod|ipad|iphone|android)/i.test(navigator.userAgent) ? 1 : 0; + let payload = { + id: bidderRequest.auctionId, + cur: [DEFAULT_CUR], + imp: [impData], + site: { + mobile: isMobile, + page: bidderRequest.refererInfo.referer + }, + device: { + ua: navigator.userAgent, + ip: params.ip + }, + user: { + buyeruid: params.user.buyeruid, + uid: params.user.uid + }, + }; + if (params.test) { + payload.test = params.test; + } + if (request.gdprConsent) { + payload.regs = { + ext: { + gdpr: request.gdprConsent.gdprApplies === true ? 1 : 0 + } + }; + } + if (request.gdprConsent && request.gdprConsent.gdprApplies) { + payload.user = { + ext: { + consent: request.gdprConsent.consentString + } + }; + } + return { + method: 'POST', + url: ENDPOINT_URL, + data: JSON.stringify(payload), + }; + }, + + /** + * Unpack the response from the server into a list of bids. + * + * @param {ServerResponse} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function(serverResponse, bidRequest) { + const ttl = 200; + const netRev = true; + let bidResponse = []; + if (serverResponse.body !== {}) { + let zetaResponse = serverResponse.body; + let cur = zetaResponse.cur; + let zetaBid = zetaResponse.seatbid[0].bid[0]; + let bid = { + requestId: zetaResponse.id, + cpm: zetaBid.price, + currency: cur, + width: zetaBid.w, + height: zetaBid.h, + ad: zetaBid.adm, + ttl: ttl, + creativeId: zetaBid.crid, + netRevenue: netRev + }; + bidResponse.push(bid); + } + return bidResponse; + }, + + /** + * Register the user sync pixels which should be dropped after the auction. + * + * @param {SyncOptions} syncOptions Which user syncs are allowed? + * @param {ServerResponse[]} serverResponses List of server's responses. + * @return {UserSync[]} The user syncs which should be dropped. + */ + getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent) { + const syncs = [] + if (syncOptions.iframeEnabled) { + syncs.push({ + type: 'iframe', + url: USER_SYNC_URL + }); + } + return syncs; + } +} + +function buildBanner(request) { + let sizes; + request.mediaTypes && + request.mediaTypes.banner && + request.mediaTypes.banner.sizes + ? sizes = request.mediaTypes.banner.sizes + : sizes = request.sizes; + return { + w: sizes[0][0], + h: sizes[0][1] + }; +} + +registerBidder(spec); diff --git a/modules/zetaBidAdapter.md b/modules/zetaBidAdapter.md new file mode 100644 index 00000000000..083bef903c1 --- /dev/null +++ b/modules/zetaBidAdapter.md @@ -0,0 +1,48 @@ +# Overview + +``` +Module Name: Zeta Bidder Adapter +Module Type: Bidder Adapter +Maintainer: DL-ZetaDSP-Supply-Engineering@zetaglobal.com +``` + +# Description + +Module that connects to Zeta's demand sources + +# Test Parameters +``` + var adUnits = [ + { + code: 'test-div', + mediaTypes: { + banner: { + sizes: [[300, 250]], // a display size + } + }, + bids: [ + { + bidder: "example", + params: { + placement: '12345' + } + } + ] + },{ + code: 'test-div', + mediaTypes: { + banner: { + sizes: [[320, 50]], // a mobile size + } + }, + bids: [ + { + bidder: "example", + params: { + placement: 67890 + } + } + ] + } + ]; +``` \ No newline at end of file From c01475b175ebd5954dc37fe61267fc5e278f3cd8 Mon Sep 17 00:00:00 2001 From: Myles Wehr Date: Thu, 24 Sep 2020 14:52:09 -0400 Subject: [PATCH 02/12] comments addressed --- modules/zetaBidAdapter.js | 30 +++++++++++++++++++----------- modules/zetaBidAdapter.md | 28 ++++++++++------------------ 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/modules/zetaBidAdapter.js b/modules/zetaBidAdapter.js index dafa8d39182..c4e6cd65212 100644 --- a/modules/zetaBidAdapter.js +++ b/modules/zetaBidAdapter.js @@ -2,7 +2,7 @@ import { registerBidder } from '../src/adapters/bidderFactory.js'; import {BANNER} from '../src/mediaTypes.js'; const BIDDER_CODE = 'Zeta Global'; const ENDPOINT_URL = 'https://prebid.rfihub.com/prebid'; -const USER_SYNC_URL = 'http://p.rfihub.com/cm?pub=42770&in=1'; +const USER_SYNC_URL = 'https://p.rfihub.com/cm?pub=42770&in=1'; const DEFAULT_CUR = 'USD'; export const spec = { @@ -16,7 +16,15 @@ export const spec = { * @return boolean True if this is a valid bid, and false otherwise. */ isBidRequestValid: function(bid) { - return !!(bid.params.placementId || (bid.params.member && bid.params.invCode)); + //check for all required bid fields + return !!( + bid + && bid.bidId + && bid.params + && bid.params.ip + && bid.params.user + && bid.params.user.buyeruid + ); }, /** @@ -27,12 +35,12 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: function(validBidRequests, bidderRequest) { - const secure = location.protocol.indexOf('https') > -1 ? 1 : 0; + const secure = 1; //treat all requests as secure const request = validBidRequests[0]; const params = request.params; let impData = { id: request.bidId, - secure, + secure: secure, banner: buildBanner(request) }; let isMobile = /(ios|ipod|ipad|iphone|android)/i.test(navigator.userAgent) ? 1 : 0; @@ -115,7 +123,7 @@ export const spec = { * @return {UserSync[]} The user syncs which should be dropped. */ getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent) { - const syncs = [] + const syncs = []; if (syncOptions.iframeEnabled) { syncs.push({ type: 'iframe', @@ -127,12 +135,12 @@ export const spec = { } function buildBanner(request) { - let sizes; - request.mediaTypes && - request.mediaTypes.banner && - request.mediaTypes.banner.sizes - ? sizes = request.mediaTypes.banner.sizes - : sizes = request.sizes; + let sizes = request.sizes; + if(request.mediaTypes + && request.mediaTypes.banner + && request.mediaTypes.banner.sizes) { + sizes = request.mediaTypes.banner.sizes; + } return { w: sizes[0][0], h: sizes[0][1] diff --git a/modules/zetaBidAdapter.md b/modules/zetaBidAdapter.md index 083bef903c1..7d0ddd738c5 100644 --- a/modules/zetaBidAdapter.md +++ b/modules/zetaBidAdapter.md @@ -22,27 +22,19 @@ Module that connects to Zeta's demand sources }, bids: [ { - bidder: "example", + bidder: 'Zeta Global', + bidId: 12345 params: { - placement: '12345' - } - } - ] - },{ - code: 'test-div', - mediaTypes: { - banner: { - sizes: [[320, 50]], // a mobile size - } - }, - bids: [ - { - bidder: "example", - params: { - placement: 67890 + placement: 12345 + user: { + uid: 12345, + buyeruid: 12345 + }, + ip: 0.0.0.0 + test: 1 } } ] } ]; -``` \ No newline at end of file +``` From 0bcfe08caf38341f22662ef3a308df9ca7a2a8db Mon Sep 17 00:00:00 2001 From: Myles Wehr Date: Fri, 25 Sep 2020 12:54:42 -0400 Subject: [PATCH 03/12] demo changes --- integrationExamples/gpt/hello_world.html | 43 +- modules/zetaBidAdapter.js | 50 +- modules/zetaBidAdapter.md | 48 +- .../modules/fintezaAnalyticsAdapter_spec.js | 470 +++++++++--------- 4 files changed, 313 insertions(+), 298 deletions(-) diff --git a/integrationExamples/gpt/hello_world.html b/integrationExamples/gpt/hello_world.html index 47ba5b8f18a..7ddee6a390d 100755 --- a/integrationExamples/gpt/hello_world.html +++ b/integrationExamples/gpt/hello_world.html @@ -15,22 +15,31 @@ var FAILSAFE_TIMEOUT = 3300; var PREBID_TIMEOUT = 1000; - var adUnits = [{ - code: 'div-gpt-ad-1460505748561-0', - mediaTypes: { - banner: { - sizes: [[300, 250], [300,600]], - } - }, - // Replace this object to test a new Adapter! - bids: [{ - bidder: 'appnexus', - params: { - placementId: 13144370 - } - }] - - }]; + var adUnits = [ + { + code: 'test-div', + mediaTypes: { + banner: { + sizes: [[300, 250]], // a display size + } + }, + bids: [ + { + bidder: 'Zeta Global', + bidId: 12345, + params: { + placement: 12345, + user: { + uid: 12345, + buyeruid: 12345 + }, + ip: '111.222.33.44', + test: 1 + } + } + ] + } + ]; var pbjs = pbjs || {}; pbjs.que = pbjs.que || []; @@ -88,4 +97,4 @@
Div-1
- \ No newline at end of file + diff --git a/modules/zetaBidAdapter.js b/modules/zetaBidAdapter.js index c4e6cd65212..1ee532b24e9 100644 --- a/modules/zetaBidAdapter.js +++ b/modules/zetaBidAdapter.js @@ -1,9 +1,13 @@ +import * as utils from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import {BANNER} from '../src/mediaTypes.js'; const BIDDER_CODE = 'Zeta Global'; -const ENDPOINT_URL = 'https://prebid.rfihub.com/prebid'; +// const ENDPOINT_URL = 'https://prebid.rfihub.com/prebid'; +const ENDPOINT_URL = 'https://ewr-337.ewr-rtb1.rfihub.com/prebid'; const USER_SYNC_URL = 'https://p.rfihub.com/cm?pub=42770&in=1'; const DEFAULT_CUR = 'USD'; +const TTL = 200; +const NET_REV = true; export const spec = { code: BIDDER_CODE, @@ -16,15 +20,19 @@ export const spec = { * @return boolean True if this is a valid bid, and false otherwise. */ isBidRequestValid: function(bid) { - //check for all required bid fields - return !!( - bid - && bid.bidId - && bid.params - && bid.params.ip - && bid.params.user - && bid.params.user.buyeruid + // check for all required bid fields + let isValid = !!( + bid && + bid.bidId && + bid.params && + bid.params.ip && + bid.params.user && + bid.params.user.buyeruid ); + if (!isValid) { + utils.logWarn('Invalid bid request'); + } + return isValid; }, /** @@ -35,7 +43,7 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: function(validBidRequests, bidderRequest) { - const secure = 1; //treat all requests as secure + const secure = 1; // treat all requests as secure const request = validBidRequests[0]; const params = request.params; let impData = { @@ -61,7 +69,7 @@ export const spec = { uid: params.user.uid }, }; - if (params.test) { + if (!!params.test) { payload.test = params.test; } if (request.gdprConsent) { @@ -92,23 +100,21 @@ export const spec = { * @return {Bid[]} An array of bids which were nested inside the server. */ interpretResponse: function(serverResponse, bidRequest) { - const ttl = 200; - const netRev = true; let bidResponse = []; if (serverResponse.body !== {}) { let zetaResponse = serverResponse.body; - let cur = zetaResponse.cur; let zetaBid = zetaResponse.seatbid[0].bid[0]; let bid = { - requestId: zetaResponse.id, - cpm: zetaBid.price, - currency: cur, + requestId: zetaBid.impid, + // cpm: zetaBid.price, + cpm: 10.0, + currency: zetaResponse.cur, width: zetaBid.w, height: zetaBid.h, ad: zetaBid.adm, - ttl: ttl, + ttl: TTL, creativeId: zetaBid.crid, - netRevenue: netRev + netRevenue: NET_REV }; bidResponse.push(bid); } @@ -136,9 +142,9 @@ export const spec = { function buildBanner(request) { let sizes = request.sizes; - if(request.mediaTypes - && request.mediaTypes.banner - && request.mediaTypes.banner.sizes) { + if (request.mediaTypes && + request.mediaTypes.banner && + request.mediaTypes.banner.sizes) { sizes = request.mediaTypes.banner.sizes; } return { diff --git a/modules/zetaBidAdapter.md b/modules/zetaBidAdapter.md index 7d0ddd738c5..9e713ccc5d7 100644 --- a/modules/zetaBidAdapter.md +++ b/modules/zetaBidAdapter.md @@ -12,29 +12,29 @@ Module that connects to Zeta's demand sources # Test Parameters ``` - var adUnits = [ - { - code: 'test-div', - mediaTypes: { - banner: { - sizes: [[300, 250]], // a display size - } - }, - bids: [ - { - bidder: 'Zeta Global', - bidId: 12345 - params: { - placement: 12345 - user: { - uid: 12345, - buyeruid: 12345 - }, - ip: 0.0.0.0 - test: 1 + var adUnits = [ + { + code: 'test-div', + mediaTypes: { + banner: { + sizes: [[300, 250]], // a display size } - } - ] - } - ]; + }, + bids: [ + { + bidder: 'Zeta Global', + bidId: 12345, + params: { + placement: 12345, + user: { + uid: 12345, + buyeruid: 12345 + }, + ip: '111.222.33.44', + test: 1 + } + } + ] + } + ]; ``` diff --git a/test/spec/modules/fintezaAnalyticsAdapter_spec.js b/test/spec/modules/fintezaAnalyticsAdapter_spec.js index 29136c85241..5ea3702f98d 100644 --- a/test/spec/modules/fintezaAnalyticsAdapter_spec.js +++ b/test/spec/modules/fintezaAnalyticsAdapter_spec.js @@ -1,235 +1,235 @@ -import fntzAnalyticsAdapter from 'modules/fintezaAnalyticsAdapter.js'; -import includes from 'core-js-pure/features/array/includes.js'; -import { expect } from 'chai'; -import { parseUrl } from 'src/utils.js'; -import { server } from 'test/mocks/xhr.js'; - -let adapterManager = require('src/adapterManager').default; -let events = require('src/events'); -let constants = require('src/constants.json'); - -function setCookie(name, value, expires) { - document.cookie = name + '=' + value + - '; path=/' + - (expires ? ('; expires=' + expires.toUTCString()) : '') + - '; SameSite=None'; -} - -describe('finteza analytics adapter', function () { - const clientId = 'fntz-client-32145'; - const uniqCookie = '5045380421580287382'; - - beforeEach(function () { - setCookie('_fz_uniq', uniqCookie); - sinon.stub(events, 'getEvents').returns([]); - sinon.spy(fntzAnalyticsAdapter, 'track'); - - adapterManager.registerAnalyticsAdapter({ - code: 'finteza', - adapter: fntzAnalyticsAdapter - }); - - adapterManager.enableAnalytics({ - provider: 'finteza', - options: { - id: clientId, // Client ID (required) - bidRequestTrack: 'Bid Request %BIDDER%', - bidResponseTimeTrack: 'Bid Response Time %bidder%', - bidResponsePriceTrack: 'Bid Response Price %bidder%', - bidTimeoutTrack: 'Bid Timeout %Bidder%', - bidWonTrack: 'Bid Won %BIDDER%', - } - }); - }); - - afterEach(function () { - setCookie('_fz_uniq', '', new Date(0)); - events.getEvents.restore(); - fntzAnalyticsAdapter.track.restore(); - fntzAnalyticsAdapter.disableAnalytics(); - }); - - describe('track', () => { - describe('bid request', () => { - it('builds and sends data', function () { - const bidderCode = 'Bidder789'; - const pauctionId = '5018eb39-f900-4370-b71e-3bb5b48d324f'; - - const bidRequest = { - bidderCode: bidderCode, - auctionId: pauctionId, - bidderRequestId: '1a6fc81528d0f6', - bids: [{ - bidder: bidderCode, - placementCode: 'container-1', - bidId: '208750227436c1', - bidderRequestId: '1a6fc81528d0f6', - auctionId: pauctionId, - startTime: 1509369418389, - sizes: [[300, 250]], - }], - auctionStart: 1509369418387, - timeout: 3000, - start: 1509369418389 - }; - - // Emit the events with the "real" arguments - events.emit(constants.EVENTS.BID_REQUESTED, bidRequest); - - expect(server.requests.length).to.equal(1); - - expect(server.requests[0].method).to.equal('GET'); - expect(server.requests[0].withCredentials).to.equal(true); - - const url = parseUrl(server.requests[0].url); - - expect(url.protocol).to.equal('https'); - expect(url.hostname).to.equal('content.mql5.com'); - expect(url.pathname).to.equal('/tr'); - expect(url.search.id).to.equal(clientId); - expect(url.search.fz_uniq).to.equal(uniqCookie); - expect(decodeURIComponent(url.search.event)).to.equal(`Bid Request ${bidderCode.toUpperCase()}`); - - sinon.assert.callCount(fntzAnalyticsAdapter.track, 1); - }); - }); - - describe('bid response', () => { - it('builds and sends data', function () { - const bidderCode = 'Bidder789'; - const pauctionId = '5018eb39-f900-4370-b71e-3bb5b48d324f'; - - const timeToRespond = 443; - const cpm = 0.015; - - const bidResponse = { - bidderCode: bidderCode, - adId: '208750227436c1', - cpm: cpm, - auctionId: pauctionId, - responseTimestamp: 1509369418832, - requestTimestamp: 1509369418389, - bidder: bidderCode, - timeToRespond: timeToRespond, - size: '300x250', - width: 300, - height: 250, - }; - - // Emit the events with the "real" arguments - events.emit(constants.EVENTS.BID_RESPONSE, bidResponse); - - expect(server.requests.length).to.equal(2); - - expect(server.requests[0].method).to.equal('GET'); - expect(server.requests[0].withCredentials).to.equal(true); - - let url = parseUrl(server.requests[0].url); - - expect(url.protocol).to.equal('https'); - expect(url.hostname).to.equal('content.mql5.com'); - expect(url.pathname).to.equal('/tr'); - expect(url.search.id).to.equal(clientId); - expect(url.search.fz_uniq).to.equal(uniqCookie); - expect(decodeURIComponent(url.search.event)).to.equal(`Bid Response Price ${bidderCode.toLowerCase()}`); - expect(url.search.value).to.equal(String(cpm)); - expect(url.search.unit).to.equal('usd'); - - expect(server.requests[1].method).to.equal('GET'); - expect(server.requests[1].withCredentials).to.equal(true); - - url = parseUrl(server.requests[1].url); - - expect(url.protocol).to.equal('https'); - expect(url.hostname).to.equal('content.mql5.com'); - expect(url.pathname).to.equal('/tr'); - expect(url.search.id).to.equal(clientId); - expect(url.search.fz_uniq).to.equal(uniqCookie); - expect(decodeURIComponent(url.search.event)).to.equal(`Bid Response Time ${bidderCode.toLowerCase()}`); - expect(url.search.value).to.equal(String(timeToRespond)); - expect(url.search.unit).to.equal('ms'); - - sinon.assert.callCount(fntzAnalyticsAdapter.track, 1); - }); - }); - - describe('bid won', () => { - it('builds and sends data', function () { - const bidderCode = 'Bidder789'; - const pauctionId = '5018eb39-f900-4370-b71e-3bb5b48d324f'; - - const cpm = 0.015; - - const bidWon = { - bidderCode: bidderCode, - cpm: cpm, - adId: 'adIdData', - ad: 'adContent', - auctionId: pauctionId, - width: 300, - height: 250 - } - - // Emit the events with the "real" arguments - events.emit(constants.EVENTS.BID_WON, bidWon); - - expect(server.requests.length).to.equal(1); - - expect(server.requests[0].method).to.equal('GET'); - expect(server.requests[0].withCredentials).to.equal(true); - - const url = parseUrl(server.requests[0].url); - - expect(url.protocol).to.equal('https'); - expect(url.hostname).to.equal('content.mql5.com'); - expect(url.pathname).to.equal('/tr'); - expect(url.search.id).to.equal(clientId); - expect(url.search.fz_uniq).to.equal(uniqCookie); - expect(decodeURIComponent(url.search.event)).to.equal(`Bid Won ${bidderCode.toUpperCase()}`); - expect(url.search.value).to.equal(String(cpm)); - expect(url.search.unit).to.equal('usd'); - - sinon.assert.callCount(fntzAnalyticsAdapter.track, 1); - }); - }); - - describe('bid timeout', () => { - it('builds and sends data', function () { - const bidderCode = 'biDDer789'; - const pauctionId = '5018eb39-f900-4370-b71e-3bb5b48d324f'; - - const timeout = 2540; - - const bidTimeout = [ - { - bidId: '208750227436c1', - bidder: bidderCode, - auctionId: pauctionId, - timeout: timeout, - } - ]; - - // Emit the events with the "real" arguments - events.emit(constants.EVENTS.BID_TIMEOUT, bidTimeout); - - expect(server.requests.length).to.equal(1); - - expect(server.requests[0].method).to.equal('GET'); - expect(server.requests[0].withCredentials).to.equal(true); - - const url = parseUrl(server.requests[0].url); - - expect(url.protocol).to.equal('https'); - expect(url.hostname).to.equal('content.mql5.com'); - expect(url.pathname).to.equal('/tr'); - expect(url.search.id).to.equal(clientId); - expect(url.search.fz_uniq).to.equal(uniqCookie); - expect(decodeURIComponent(url.search.event)).to.equal(`Bid Timeout Bidder789`); - expect(url.search.value).to.equal(String(timeout)); - expect(url.search.unit).to.equal('ms'); - - sinon.assert.callCount(fntzAnalyticsAdapter.track, 1); - }); - }); - }); -}); +// import fntzAnalyticsAdapter from 'modules/fintezaAnalyticsAdapter.js'; +// import includes from 'core-js-pure/features/array/includes.js'; +// import { expect } from 'chai'; +// import { parseUrl } from 'src/utils.js'; +// import { server } from 'test/mocks/xhr.js'; +// +// let adapterManager = require('src/adapterManager').default; +// let events = require('src/events'); +// let constants = require('src/constants.json'); +// +// function setCookie(name, value, expires) { +// document.cookie = name + '=' + value + +// '; path=/' + +// (expires ? ('; expires=' + expires.toUTCString()) : '') + +// '; SameSite=None'; +// } +// +// describe('finteza analytics adapter', function () { +// const clientId = 'fntz-client-32145'; +// const uniqCookie = '5045380421580287382'; +// +// beforeEach(function () { +// setCookie('_fz_uniq', uniqCookie); +// sinon.stub(events, 'getEvents').returns([]); +// sinon.spy(fntzAnalyticsAdapter, 'track'); +// +// adapterManager.registerAnalyticsAdapter({ +// code: 'finteza', +// adapter: fntzAnalyticsAdapter +// }); +// +// adapterManager.enableAnalytics({ +// provider: 'finteza', +// options: { +// id: clientId, // Client ID (required) +// bidRequestTrack: 'Bid Request %BIDDER%', +// bidResponseTimeTrack: 'Bid Response Time %bidder%', +// bidResponsePriceTrack: 'Bid Response Price %bidder%', +// bidTimeoutTrack: 'Bid Timeout %Bidder%', +// bidWonTrack: 'Bid Won %BIDDER%', +// } +// }); +// }); +// +// afterEach(function () { +// setCookie('_fz_uniq', '', new Date(0)); +// events.getEvents.restore(); +// fntzAnalyticsAdapter.track.restore(); +// fntzAnalyticsAdapter.disableAnalytics(); +// }); +// +// describe('track', () => { +// describe('bid request', () => { +// it('builds and sends data', function () { +// const bidderCode = 'Bidder789'; +// const pauctionId = '5018eb39-f900-4370-b71e-3bb5b48d324f'; +// +// const bidRequest = { +// bidderCode: bidderCode, +// auctionId: pauctionId, +// bidderRequestId: '1a6fc81528d0f6', +// bids: [{ +// bidder: bidderCode, +// placementCode: 'container-1', +// bidId: '208750227436c1', +// bidderRequestId: '1a6fc81528d0f6', +// auctionId: pauctionId, +// startTime: 1509369418389, +// sizes: [[300, 250]], +// }], +// auctionStart: 1509369418387, +// timeout: 3000, +// start: 1509369418389 +// }; +// +// // Emit the events with the "real" arguments +// events.emit(constants.EVENTS.BID_REQUESTED, bidRequest); +// +// expect(server.requests.length).to.equal(1); +// +// expect(server.requests[0].method).to.equal('GET'); +// expect(server.requests[0].withCredentials).to.equal(true); +// +// const url = parseUrl(server.requests[0].url); +// +// expect(url.protocol).to.equal('https'); +// expect(url.hostname).to.equal('content.mql5.com'); +// expect(url.pathname).to.equal('/tr'); +// expect(url.search.id).to.equal(clientId); +// expect(url.search.fz_uniq).to.equal(uniqCookie); +// expect(decodeURIComponent(url.search.event)).to.equal(`Bid Request ${bidderCode.toUpperCase()}`); +// +// sinon.assert.callCount(fntzAnalyticsAdapter.track, 1); +// }); +// }); +// +// describe('bid response', () => { +// it('builds and sends data', function () { +// const bidderCode = 'Bidder789'; +// const pauctionId = '5018eb39-f900-4370-b71e-3bb5b48d324f'; +// +// const timeToRespond = 443; +// const cpm = 0.015; +// +// const bidResponse = { +// bidderCode: bidderCode, +// adId: '208750227436c1', +// cpm: cpm, +// auctionId: pauctionId, +// responseTimestamp: 1509369418832, +// requestTimestamp: 1509369418389, +// bidder: bidderCode, +// timeToRespond: timeToRespond, +// size: '300x250', +// width: 300, +// height: 250, +// }; +// +// // Emit the events with the "real" arguments +// events.emit(constants.EVENTS.BID_RESPONSE, bidResponse); +// +// expect(server.requests.length).to.equal(2); +// +// expect(server.requests[0].method).to.equal('GET'); +// expect(server.requests[0].withCredentials).to.equal(true); +// +// let url = parseUrl(server.requests[0].url); +// +// expect(url.protocol).to.equal('https'); +// expect(url.hostname).to.equal('content.mql5.com'); +// expect(url.pathname).to.equal('/tr'); +// expect(url.search.id).to.equal(clientId); +// expect(url.search.fz_uniq).to.equal(uniqCookie); +// expect(decodeURIComponent(url.search.event)).to.equal(`Bid Response Price ${bidderCode.toLowerCase()}`); +// expect(url.search.value).to.equal(String(cpm)); +// expect(url.search.unit).to.equal('usd'); +// +// expect(server.requests[1].method).to.equal('GET'); +// expect(server.requests[1].withCredentials).to.equal(true); +// +// url = parseUrl(server.requests[1].url); +// +// expect(url.protocol).to.equal('https'); +// expect(url.hostname).to.equal('content.mql5.com'); +// expect(url.pathname).to.equal('/tr'); +// expect(url.search.id).to.equal(clientId); +// expect(url.search.fz_uniq).to.equal(uniqCookie); +// expect(decodeURIComponent(url.search.event)).to.equal(`Bid Response Time ${bidderCode.toLowerCase()}`); +// expect(url.search.value).to.equal(String(timeToRespond)); +// expect(url.search.unit).to.equal('ms'); +// +// sinon.assert.callCount(fntzAnalyticsAdapter.track, 1); +// }); +// }); +// +// describe('bid won', () => { +// it('builds and sends data', function () { +// const bidderCode = 'Bidder789'; +// const pauctionId = '5018eb39-f900-4370-b71e-3bb5b48d324f'; +// +// const cpm = 0.015; +// +// const bidWon = { +// bidderCode: bidderCode, +// cpm: cpm, +// adId: 'adIdData', +// ad: 'adContent', +// auctionId: pauctionId, +// width: 300, +// height: 250 +// } +// +// // Emit the events with the "real" arguments +// events.emit(constants.EVENTS.BID_WON, bidWon); +// +// expect(server.requests.length).to.equal(1); +// +// expect(server.requests[0].method).to.equal('GET'); +// expect(server.requests[0].withCredentials).to.equal(true); +// +// const url = parseUrl(server.requests[0].url); +// +// expect(url.protocol).to.equal('https'); +// expect(url.hostname).to.equal('content.mql5.com'); +// expect(url.pathname).to.equal('/tr'); +// expect(url.search.id).to.equal(clientId); +// expect(url.search.fz_uniq).to.equal(uniqCookie); +// expect(decodeURIComponent(url.search.event)).to.equal(`Bid Won ${bidderCode.toUpperCase()}`); +// expect(url.search.value).to.equal(String(cpm)); +// expect(url.search.unit).to.equal('usd'); +// +// sinon.assert.callCount(fntzAnalyticsAdapter.track, 1); +// }); +// }); +// +// describe('bid timeout', () => { +// it('builds and sends data', function () { +// const bidderCode = 'biDDer789'; +// const pauctionId = '5018eb39-f900-4370-b71e-3bb5b48d324f'; +// +// const timeout = 2540; +// +// const bidTimeout = [ +// { +// bidId: '208750227436c1', +// bidder: bidderCode, +// auctionId: pauctionId, +// timeout: timeout, +// } +// ]; +// +// // Emit the events with the "real" arguments +// events.emit(constants.EVENTS.BID_TIMEOUT, bidTimeout); +// +// expect(server.requests.length).to.equal(1); +// +// expect(server.requests[0].method).to.equal('GET'); +// expect(server.requests[0].withCredentials).to.equal(true); +// +// const url = parseUrl(server.requests[0].url); +// +// expect(url.protocol).to.equal('https'); +// expect(url.hostname).to.equal('content.mql5.com'); +// expect(url.pathname).to.equal('/tr'); +// expect(url.search.id).to.equal(clientId); +// expect(url.search.fz_uniq).to.equal(uniqCookie); +// expect(decodeURIComponent(url.search.event)).to.equal(`Bid Timeout Bidder789`); +// expect(url.search.value).to.equal(String(timeout)); +// expect(url.search.unit).to.equal('ms'); +// +// sinon.assert.callCount(fntzAnalyticsAdapter.track, 1); +// }); +// }); +// }); +// }); From 22ade3c2852abbf890eecea03cfb7ca7ef26b7bc Mon Sep 17 00:00:00 2001 From: Myles Wehr Date: Fri, 25 Sep 2020 17:55:53 -0400 Subject: [PATCH 04/12] additional polishing --- modules/zetaBidAdapter.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/zetaBidAdapter.js b/modules/zetaBidAdapter.js index 1ee532b24e9..25770a3e34c 100644 --- a/modules/zetaBidAdapter.js +++ b/modules/zetaBidAdapter.js @@ -2,8 +2,7 @@ import * as utils from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import {BANNER} from '../src/mediaTypes.js'; const BIDDER_CODE = 'Zeta Global'; -// const ENDPOINT_URL = 'https://prebid.rfihub.com/prebid'; -const ENDPOINT_URL = 'https://ewr-337.ewr-rtb1.rfihub.com/prebid'; +const ENDPOINT_URL = 'https://prebid.rfihub.com/prebid'; const USER_SYNC_URL = 'https://p.rfihub.com/cm?pub=42770&in=1'; const DEFAULT_CUR = 'USD'; const TTL = 200; @@ -106,8 +105,7 @@ export const spec = { let zetaBid = zetaResponse.seatbid[0].bid[0]; let bid = { requestId: zetaBid.impid, - // cpm: zetaBid.price, - cpm: 10.0, + cpm: zetaBid.price, currency: zetaResponse.cur, width: zetaBid.w, height: zetaBid.h, From f8d0b43ea9da5b4508243a2e66d767620420177b Mon Sep 17 00:00:00 2001 From: Myles Wehr Date: Fri, 25 Sep 2020 18:32:11 -0400 Subject: [PATCH 05/12] additional polishing --- integrationExamples/gpt/hello_world.html | 41 +- .../modules/fintezaAnalyticsAdapter_spec.js | 470 +++++++++--------- 2 files changed, 251 insertions(+), 260 deletions(-) diff --git a/integrationExamples/gpt/hello_world.html b/integrationExamples/gpt/hello_world.html index 7ddee6a390d..d68e65011be 100755 --- a/integrationExamples/gpt/hello_world.html +++ b/integrationExamples/gpt/hello_world.html @@ -15,31 +15,22 @@ var FAILSAFE_TIMEOUT = 3300; var PREBID_TIMEOUT = 1000; - var adUnits = [ - { - code: 'test-div', - mediaTypes: { - banner: { - sizes: [[300, 250]], // a display size - } - }, - bids: [ - { - bidder: 'Zeta Global', - bidId: 12345, - params: { - placement: 12345, - user: { - uid: 12345, - buyeruid: 12345 - }, - ip: '111.222.33.44', - test: 1 - } - } - ] - } - ]; + var adUnits = [{ + code: 'div-gpt-ad-1460505748561-0', + mediaTypes: { + banner: { + sizes: [[300, 250], [300,600]], + } + }, + // Replace this object to test a new Adapter! + bids: [{ + bidder: 'appnexus', + params: { + placementId: 13144370 + } + }] + + }]; var pbjs = pbjs || {}; pbjs.que = pbjs.que || []; diff --git a/test/spec/modules/fintezaAnalyticsAdapter_spec.js b/test/spec/modules/fintezaAnalyticsAdapter_spec.js index 5ea3702f98d..29136c85241 100644 --- a/test/spec/modules/fintezaAnalyticsAdapter_spec.js +++ b/test/spec/modules/fintezaAnalyticsAdapter_spec.js @@ -1,235 +1,235 @@ -// import fntzAnalyticsAdapter from 'modules/fintezaAnalyticsAdapter.js'; -// import includes from 'core-js-pure/features/array/includes.js'; -// import { expect } from 'chai'; -// import { parseUrl } from 'src/utils.js'; -// import { server } from 'test/mocks/xhr.js'; -// -// let adapterManager = require('src/adapterManager').default; -// let events = require('src/events'); -// let constants = require('src/constants.json'); -// -// function setCookie(name, value, expires) { -// document.cookie = name + '=' + value + -// '; path=/' + -// (expires ? ('; expires=' + expires.toUTCString()) : '') + -// '; SameSite=None'; -// } -// -// describe('finteza analytics adapter', function () { -// const clientId = 'fntz-client-32145'; -// const uniqCookie = '5045380421580287382'; -// -// beforeEach(function () { -// setCookie('_fz_uniq', uniqCookie); -// sinon.stub(events, 'getEvents').returns([]); -// sinon.spy(fntzAnalyticsAdapter, 'track'); -// -// adapterManager.registerAnalyticsAdapter({ -// code: 'finteza', -// adapter: fntzAnalyticsAdapter -// }); -// -// adapterManager.enableAnalytics({ -// provider: 'finteza', -// options: { -// id: clientId, // Client ID (required) -// bidRequestTrack: 'Bid Request %BIDDER%', -// bidResponseTimeTrack: 'Bid Response Time %bidder%', -// bidResponsePriceTrack: 'Bid Response Price %bidder%', -// bidTimeoutTrack: 'Bid Timeout %Bidder%', -// bidWonTrack: 'Bid Won %BIDDER%', -// } -// }); -// }); -// -// afterEach(function () { -// setCookie('_fz_uniq', '', new Date(0)); -// events.getEvents.restore(); -// fntzAnalyticsAdapter.track.restore(); -// fntzAnalyticsAdapter.disableAnalytics(); -// }); -// -// describe('track', () => { -// describe('bid request', () => { -// it('builds and sends data', function () { -// const bidderCode = 'Bidder789'; -// const pauctionId = '5018eb39-f900-4370-b71e-3bb5b48d324f'; -// -// const bidRequest = { -// bidderCode: bidderCode, -// auctionId: pauctionId, -// bidderRequestId: '1a6fc81528d0f6', -// bids: [{ -// bidder: bidderCode, -// placementCode: 'container-1', -// bidId: '208750227436c1', -// bidderRequestId: '1a6fc81528d0f6', -// auctionId: pauctionId, -// startTime: 1509369418389, -// sizes: [[300, 250]], -// }], -// auctionStart: 1509369418387, -// timeout: 3000, -// start: 1509369418389 -// }; -// -// // Emit the events with the "real" arguments -// events.emit(constants.EVENTS.BID_REQUESTED, bidRequest); -// -// expect(server.requests.length).to.equal(1); -// -// expect(server.requests[0].method).to.equal('GET'); -// expect(server.requests[0].withCredentials).to.equal(true); -// -// const url = parseUrl(server.requests[0].url); -// -// expect(url.protocol).to.equal('https'); -// expect(url.hostname).to.equal('content.mql5.com'); -// expect(url.pathname).to.equal('/tr'); -// expect(url.search.id).to.equal(clientId); -// expect(url.search.fz_uniq).to.equal(uniqCookie); -// expect(decodeURIComponent(url.search.event)).to.equal(`Bid Request ${bidderCode.toUpperCase()}`); -// -// sinon.assert.callCount(fntzAnalyticsAdapter.track, 1); -// }); -// }); -// -// describe('bid response', () => { -// it('builds and sends data', function () { -// const bidderCode = 'Bidder789'; -// const pauctionId = '5018eb39-f900-4370-b71e-3bb5b48d324f'; -// -// const timeToRespond = 443; -// const cpm = 0.015; -// -// const bidResponse = { -// bidderCode: bidderCode, -// adId: '208750227436c1', -// cpm: cpm, -// auctionId: pauctionId, -// responseTimestamp: 1509369418832, -// requestTimestamp: 1509369418389, -// bidder: bidderCode, -// timeToRespond: timeToRespond, -// size: '300x250', -// width: 300, -// height: 250, -// }; -// -// // Emit the events with the "real" arguments -// events.emit(constants.EVENTS.BID_RESPONSE, bidResponse); -// -// expect(server.requests.length).to.equal(2); -// -// expect(server.requests[0].method).to.equal('GET'); -// expect(server.requests[0].withCredentials).to.equal(true); -// -// let url = parseUrl(server.requests[0].url); -// -// expect(url.protocol).to.equal('https'); -// expect(url.hostname).to.equal('content.mql5.com'); -// expect(url.pathname).to.equal('/tr'); -// expect(url.search.id).to.equal(clientId); -// expect(url.search.fz_uniq).to.equal(uniqCookie); -// expect(decodeURIComponent(url.search.event)).to.equal(`Bid Response Price ${bidderCode.toLowerCase()}`); -// expect(url.search.value).to.equal(String(cpm)); -// expect(url.search.unit).to.equal('usd'); -// -// expect(server.requests[1].method).to.equal('GET'); -// expect(server.requests[1].withCredentials).to.equal(true); -// -// url = parseUrl(server.requests[1].url); -// -// expect(url.protocol).to.equal('https'); -// expect(url.hostname).to.equal('content.mql5.com'); -// expect(url.pathname).to.equal('/tr'); -// expect(url.search.id).to.equal(clientId); -// expect(url.search.fz_uniq).to.equal(uniqCookie); -// expect(decodeURIComponent(url.search.event)).to.equal(`Bid Response Time ${bidderCode.toLowerCase()}`); -// expect(url.search.value).to.equal(String(timeToRespond)); -// expect(url.search.unit).to.equal('ms'); -// -// sinon.assert.callCount(fntzAnalyticsAdapter.track, 1); -// }); -// }); -// -// describe('bid won', () => { -// it('builds and sends data', function () { -// const bidderCode = 'Bidder789'; -// const pauctionId = '5018eb39-f900-4370-b71e-3bb5b48d324f'; -// -// const cpm = 0.015; -// -// const bidWon = { -// bidderCode: bidderCode, -// cpm: cpm, -// adId: 'adIdData', -// ad: 'adContent', -// auctionId: pauctionId, -// width: 300, -// height: 250 -// } -// -// // Emit the events with the "real" arguments -// events.emit(constants.EVENTS.BID_WON, bidWon); -// -// expect(server.requests.length).to.equal(1); -// -// expect(server.requests[0].method).to.equal('GET'); -// expect(server.requests[0].withCredentials).to.equal(true); -// -// const url = parseUrl(server.requests[0].url); -// -// expect(url.protocol).to.equal('https'); -// expect(url.hostname).to.equal('content.mql5.com'); -// expect(url.pathname).to.equal('/tr'); -// expect(url.search.id).to.equal(clientId); -// expect(url.search.fz_uniq).to.equal(uniqCookie); -// expect(decodeURIComponent(url.search.event)).to.equal(`Bid Won ${bidderCode.toUpperCase()}`); -// expect(url.search.value).to.equal(String(cpm)); -// expect(url.search.unit).to.equal('usd'); -// -// sinon.assert.callCount(fntzAnalyticsAdapter.track, 1); -// }); -// }); -// -// describe('bid timeout', () => { -// it('builds and sends data', function () { -// const bidderCode = 'biDDer789'; -// const pauctionId = '5018eb39-f900-4370-b71e-3bb5b48d324f'; -// -// const timeout = 2540; -// -// const bidTimeout = [ -// { -// bidId: '208750227436c1', -// bidder: bidderCode, -// auctionId: pauctionId, -// timeout: timeout, -// } -// ]; -// -// // Emit the events with the "real" arguments -// events.emit(constants.EVENTS.BID_TIMEOUT, bidTimeout); -// -// expect(server.requests.length).to.equal(1); -// -// expect(server.requests[0].method).to.equal('GET'); -// expect(server.requests[0].withCredentials).to.equal(true); -// -// const url = parseUrl(server.requests[0].url); -// -// expect(url.protocol).to.equal('https'); -// expect(url.hostname).to.equal('content.mql5.com'); -// expect(url.pathname).to.equal('/tr'); -// expect(url.search.id).to.equal(clientId); -// expect(url.search.fz_uniq).to.equal(uniqCookie); -// expect(decodeURIComponent(url.search.event)).to.equal(`Bid Timeout Bidder789`); -// expect(url.search.value).to.equal(String(timeout)); -// expect(url.search.unit).to.equal('ms'); -// -// sinon.assert.callCount(fntzAnalyticsAdapter.track, 1); -// }); -// }); -// }); -// }); +import fntzAnalyticsAdapter from 'modules/fintezaAnalyticsAdapter.js'; +import includes from 'core-js-pure/features/array/includes.js'; +import { expect } from 'chai'; +import { parseUrl } from 'src/utils.js'; +import { server } from 'test/mocks/xhr.js'; + +let adapterManager = require('src/adapterManager').default; +let events = require('src/events'); +let constants = require('src/constants.json'); + +function setCookie(name, value, expires) { + document.cookie = name + '=' + value + + '; path=/' + + (expires ? ('; expires=' + expires.toUTCString()) : '') + + '; SameSite=None'; +} + +describe('finteza analytics adapter', function () { + const clientId = 'fntz-client-32145'; + const uniqCookie = '5045380421580287382'; + + beforeEach(function () { + setCookie('_fz_uniq', uniqCookie); + sinon.stub(events, 'getEvents').returns([]); + sinon.spy(fntzAnalyticsAdapter, 'track'); + + adapterManager.registerAnalyticsAdapter({ + code: 'finteza', + adapter: fntzAnalyticsAdapter + }); + + adapterManager.enableAnalytics({ + provider: 'finteza', + options: { + id: clientId, // Client ID (required) + bidRequestTrack: 'Bid Request %BIDDER%', + bidResponseTimeTrack: 'Bid Response Time %bidder%', + bidResponsePriceTrack: 'Bid Response Price %bidder%', + bidTimeoutTrack: 'Bid Timeout %Bidder%', + bidWonTrack: 'Bid Won %BIDDER%', + } + }); + }); + + afterEach(function () { + setCookie('_fz_uniq', '', new Date(0)); + events.getEvents.restore(); + fntzAnalyticsAdapter.track.restore(); + fntzAnalyticsAdapter.disableAnalytics(); + }); + + describe('track', () => { + describe('bid request', () => { + it('builds and sends data', function () { + const bidderCode = 'Bidder789'; + const pauctionId = '5018eb39-f900-4370-b71e-3bb5b48d324f'; + + const bidRequest = { + bidderCode: bidderCode, + auctionId: pauctionId, + bidderRequestId: '1a6fc81528d0f6', + bids: [{ + bidder: bidderCode, + placementCode: 'container-1', + bidId: '208750227436c1', + bidderRequestId: '1a6fc81528d0f6', + auctionId: pauctionId, + startTime: 1509369418389, + sizes: [[300, 250]], + }], + auctionStart: 1509369418387, + timeout: 3000, + start: 1509369418389 + }; + + // Emit the events with the "real" arguments + events.emit(constants.EVENTS.BID_REQUESTED, bidRequest); + + expect(server.requests.length).to.equal(1); + + expect(server.requests[0].method).to.equal('GET'); + expect(server.requests[0].withCredentials).to.equal(true); + + const url = parseUrl(server.requests[0].url); + + expect(url.protocol).to.equal('https'); + expect(url.hostname).to.equal('content.mql5.com'); + expect(url.pathname).to.equal('/tr'); + expect(url.search.id).to.equal(clientId); + expect(url.search.fz_uniq).to.equal(uniqCookie); + expect(decodeURIComponent(url.search.event)).to.equal(`Bid Request ${bidderCode.toUpperCase()}`); + + sinon.assert.callCount(fntzAnalyticsAdapter.track, 1); + }); + }); + + describe('bid response', () => { + it('builds and sends data', function () { + const bidderCode = 'Bidder789'; + const pauctionId = '5018eb39-f900-4370-b71e-3bb5b48d324f'; + + const timeToRespond = 443; + const cpm = 0.015; + + const bidResponse = { + bidderCode: bidderCode, + adId: '208750227436c1', + cpm: cpm, + auctionId: pauctionId, + responseTimestamp: 1509369418832, + requestTimestamp: 1509369418389, + bidder: bidderCode, + timeToRespond: timeToRespond, + size: '300x250', + width: 300, + height: 250, + }; + + // Emit the events with the "real" arguments + events.emit(constants.EVENTS.BID_RESPONSE, bidResponse); + + expect(server.requests.length).to.equal(2); + + expect(server.requests[0].method).to.equal('GET'); + expect(server.requests[0].withCredentials).to.equal(true); + + let url = parseUrl(server.requests[0].url); + + expect(url.protocol).to.equal('https'); + expect(url.hostname).to.equal('content.mql5.com'); + expect(url.pathname).to.equal('/tr'); + expect(url.search.id).to.equal(clientId); + expect(url.search.fz_uniq).to.equal(uniqCookie); + expect(decodeURIComponent(url.search.event)).to.equal(`Bid Response Price ${bidderCode.toLowerCase()}`); + expect(url.search.value).to.equal(String(cpm)); + expect(url.search.unit).to.equal('usd'); + + expect(server.requests[1].method).to.equal('GET'); + expect(server.requests[1].withCredentials).to.equal(true); + + url = parseUrl(server.requests[1].url); + + expect(url.protocol).to.equal('https'); + expect(url.hostname).to.equal('content.mql5.com'); + expect(url.pathname).to.equal('/tr'); + expect(url.search.id).to.equal(clientId); + expect(url.search.fz_uniq).to.equal(uniqCookie); + expect(decodeURIComponent(url.search.event)).to.equal(`Bid Response Time ${bidderCode.toLowerCase()}`); + expect(url.search.value).to.equal(String(timeToRespond)); + expect(url.search.unit).to.equal('ms'); + + sinon.assert.callCount(fntzAnalyticsAdapter.track, 1); + }); + }); + + describe('bid won', () => { + it('builds and sends data', function () { + const bidderCode = 'Bidder789'; + const pauctionId = '5018eb39-f900-4370-b71e-3bb5b48d324f'; + + const cpm = 0.015; + + const bidWon = { + bidderCode: bidderCode, + cpm: cpm, + adId: 'adIdData', + ad: 'adContent', + auctionId: pauctionId, + width: 300, + height: 250 + } + + // Emit the events with the "real" arguments + events.emit(constants.EVENTS.BID_WON, bidWon); + + expect(server.requests.length).to.equal(1); + + expect(server.requests[0].method).to.equal('GET'); + expect(server.requests[0].withCredentials).to.equal(true); + + const url = parseUrl(server.requests[0].url); + + expect(url.protocol).to.equal('https'); + expect(url.hostname).to.equal('content.mql5.com'); + expect(url.pathname).to.equal('/tr'); + expect(url.search.id).to.equal(clientId); + expect(url.search.fz_uniq).to.equal(uniqCookie); + expect(decodeURIComponent(url.search.event)).to.equal(`Bid Won ${bidderCode.toUpperCase()}`); + expect(url.search.value).to.equal(String(cpm)); + expect(url.search.unit).to.equal('usd'); + + sinon.assert.callCount(fntzAnalyticsAdapter.track, 1); + }); + }); + + describe('bid timeout', () => { + it('builds and sends data', function () { + const bidderCode = 'biDDer789'; + const pauctionId = '5018eb39-f900-4370-b71e-3bb5b48d324f'; + + const timeout = 2540; + + const bidTimeout = [ + { + bidId: '208750227436c1', + bidder: bidderCode, + auctionId: pauctionId, + timeout: timeout, + } + ]; + + // Emit the events with the "real" arguments + events.emit(constants.EVENTS.BID_TIMEOUT, bidTimeout); + + expect(server.requests.length).to.equal(1); + + expect(server.requests[0].method).to.equal('GET'); + expect(server.requests[0].withCredentials).to.equal(true); + + const url = parseUrl(server.requests[0].url); + + expect(url.protocol).to.equal('https'); + expect(url.hostname).to.equal('content.mql5.com'); + expect(url.pathname).to.equal('/tr'); + expect(url.search.id).to.equal(clientId); + expect(url.search.fz_uniq).to.equal(uniqCookie); + expect(decodeURIComponent(url.search.event)).to.equal(`Bid Timeout Bidder789`); + expect(url.search.value).to.equal(String(timeout)); + expect(url.search.unit).to.equal('ms'); + + sinon.assert.callCount(fntzAnalyticsAdapter.track, 1); + }); + }); + }); +}); From 90a034040745c68839ed4ef5907e023a9b8dd9cb Mon Sep 17 00:00:00 2001 From: mwehr-zeta <70167335+mwehr-zeta@users.noreply.github.com> Date: Fri, 25 Sep 2020 18:35:21 -0400 Subject: [PATCH 06/12] Update hello_world.html From 45b87e005cb0c1cbfb2675c3212ebe80d094e1e7 Mon Sep 17 00:00:00 2001 From: Myles Wehr Date: Tue, 29 Sep 2020 13:17:38 -0400 Subject: [PATCH 07/12] remove extraneous changes to hello_world.html --- integrationExamples/gpt/hello_world.html | 41 +++++++++++++++--------- modules/zetaBidAdapter.js | 2 +- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/integrationExamples/gpt/hello_world.html b/integrationExamples/gpt/hello_world.html index d68e65011be..7f981c91390 100755 --- a/integrationExamples/gpt/hello_world.html +++ b/integrationExamples/gpt/hello_world.html @@ -15,22 +15,31 @@ var FAILSAFE_TIMEOUT = 3300; var PREBID_TIMEOUT = 1000; - var adUnits = [{ - code: 'div-gpt-ad-1460505748561-0', - mediaTypes: { - banner: { - sizes: [[300, 250], [300,600]], - } - }, - // Replace this object to test a new Adapter! - bids: [{ - bidder: 'appnexus', - params: { - placementId: 13144370 - } - }] - - }]; + var adUnits = [ + { + code: 'div-gpt-ad-1460505748561-0', + mediaTypes: { + banner: { + sizes: [[300, 250]], // a display size + } + }, + bids: [ + { + bidder: 'Zeta Global', + bidId: 12345, + params: { + placement: 12345, + user: { + uid: 12345, + buyeruid: 12345 + }, + ip: '111.222.33.44', + test: 1 + } + } + ] + } + ]; var pbjs = pbjs || {}; pbjs.que = pbjs.que || []; diff --git a/modules/zetaBidAdapter.js b/modules/zetaBidAdapter.js index 25770a3e34c..1399b96b3a3 100644 --- a/modules/zetaBidAdapter.js +++ b/modules/zetaBidAdapter.js @@ -68,7 +68,7 @@ export const spec = { uid: params.user.uid }, }; - if (!!params.test) { + if (params.test) { payload.test = params.test; } if (request.gdprConsent) { From 4ed0dd49c93e27e40859fcb65bc380f713ccc3ac Mon Sep 17 00:00:00 2001 From: Myles Wehr Date: Tue, 29 Sep 2020 13:25:58 -0400 Subject: [PATCH 08/12] no, really this time --- integrationExamples/gpt/hello_world.html | 43 ++++++++++-------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/integrationExamples/gpt/hello_world.html b/integrationExamples/gpt/hello_world.html index 7f981c91390..47ba5b8f18a 100755 --- a/integrationExamples/gpt/hello_world.html +++ b/integrationExamples/gpt/hello_world.html @@ -15,31 +15,22 @@ var FAILSAFE_TIMEOUT = 3300; var PREBID_TIMEOUT = 1000; - var adUnits = [ - { - code: 'div-gpt-ad-1460505748561-0', - mediaTypes: { - banner: { - sizes: [[300, 250]], // a display size - } - }, - bids: [ - { - bidder: 'Zeta Global', - bidId: 12345, - params: { - placement: 12345, - user: { - uid: 12345, - buyeruid: 12345 - }, - ip: '111.222.33.44', - test: 1 - } - } - ] - } - ]; + var adUnits = [{ + code: 'div-gpt-ad-1460505748561-0', + mediaTypes: { + banner: { + sizes: [[300, 250], [300,600]], + } + }, + // Replace this object to test a new Adapter! + bids: [{ + bidder: 'appnexus', + params: { + placementId: 13144370 + } + }] + + }]; var pbjs = pbjs || {}; pbjs.que = pbjs.que || []; @@ -97,4 +88,4 @@
Div-1
- + \ No newline at end of file From 50352b2a0460cd4804da1a1be029623fa76bf1a4 Mon Sep 17 00:00:00 2001 From: Myles Wehr Date: Tue, 29 Sep 2020 16:02:28 -0400 Subject: [PATCH 09/12] additional polishing --- modules/zetaBidAdapter.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/zetaBidAdapter.js b/modules/zetaBidAdapter.js index 1399b96b3a3..612e86aced0 100644 --- a/modules/zetaBidAdapter.js +++ b/modules/zetaBidAdapter.js @@ -35,10 +35,10 @@ export const spec = { }, /** - * Make a server request from the lqist of BidRequests. + * Make a server request from the list of BidRequests. * - * @param {validBidRequests[]} - an array of bidRequest objects - * @param {bidderRequest} - master bidRequest object + * @param {Bids[]} validBidRequests - an array of bidRequest objects + * @param {BidderRequest} bidderRequest - master bidRequest object * @return ServerRequest Info describing the request to the server. */ buildRequests: function(validBidRequests, bidderRequest) { @@ -68,7 +68,7 @@ export const spec = { uid: params.user.uid }, }; - if (params.test) { + if (!!params.test) { payload.test = params.test; } if (request.gdprConsent) { @@ -96,11 +96,12 @@ export const spec = { * Unpack the response from the server into a list of bids. * * @param {ServerResponse} serverResponse A successful response from the server. + * @param bidRequest The payload from the server's response. * @return {Bid[]} An array of bids which were nested inside the server. */ interpretResponse: function(serverResponse, bidRequest) { let bidResponse = []; - if (serverResponse.body !== {}) { + if (Object.keys(serverResponse.body).length !== 0) { let zetaResponse = serverResponse.body; let zetaBid = zetaResponse.seatbid[0].bid[0]; let bid = { @@ -124,6 +125,8 @@ export const spec = { * * @param {SyncOptions} syncOptions Which user syncs are allowed? * @param {ServerResponse[]} serverResponses List of server's responses. + * @param gdprConsent The GDPR consent parameters + * @param uspConsent The USP consent parameters * @return {UserSync[]} The user syncs which should be dropped. */ getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent) { From 859338890b663ec65dbff384613c17437beae429 Mon Sep 17 00:00:00 2001 From: Myles Wehr Date: Wed, 30 Sep 2020 16:30:05 -0400 Subject: [PATCH 10/12] add unit test --- modules/zetaBidAdapter.js | 2 +- package-lock.json | 38 +++++++++--- test/spec/modules/zetaBidAdapter_spec.js | 78 ++++++++++++++++++++++++ 3 files changed, 110 insertions(+), 8 deletions(-) create mode 100644 test/spec/modules/zetaBidAdapter_spec.js diff --git a/modules/zetaBidAdapter.js b/modules/zetaBidAdapter.js index 612e86aced0..4377c2cd94f 100644 --- a/modules/zetaBidAdapter.js +++ b/modules/zetaBidAdapter.js @@ -68,7 +68,7 @@ export const spec = { uid: params.user.uid }, }; - if (!!params.test) { + if (params.test) { payload.test = params.test; } if (request.gdprConsent) { diff --git a/package-lock.json b/package-lock.json index 4f3d2120d72..aa4acfb3e97 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "prebid.js", - "version": "3.27.0-pre", + "version": "4.5.0-pre", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -7796,13 +7796,13 @@ "function-bind": "^1.1.1", "has": "^1.0.3", "has-symbols": "^1.0.1", - "is-callable": "^1.2.0", - "is-regex": "^1.1.0", + "is-callable": "^1.1.5", + "is-regex": "^1.0.5", "object-inspect": "^1.7.0", "object-keys": "^1.1.1", "object.assign": "^4.1.0", - "string.prototype.trimend": "^1.0.1", - "string.prototype.trimstart": "^1.0.1" + "string.prototype.trimleft": "^2.1.1", + "string.prototype.trimright": "^2.1.1" } }, "es-array-method-boxes-properly": { @@ -7838,6 +7838,7 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "dev": true, "requires": { "is-callable": "^1.1.4", "is-date-object": "^1.0.1", @@ -12076,7 +12077,7 @@ "integrity": "sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ==", "dev": true, "requires": { - "has-symbols": "^1.0.1" + "has": "^1.0.3" } }, "is-relative": { @@ -17484,7 +17485,8 @@ "object-inspect": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.8.0.tgz", - "integrity": "sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA==" + "integrity": "sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA==", + "dev": true }, "object-is": { "version": "1.1.2", @@ -20706,6 +20708,28 @@ "es-abstract": "^1.17.5" } }, + "string.prototype.trimleft": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.2.tgz", + "integrity": "sha512-gCA0tza1JBvqr3bfAIFJGqfdRTyPae82+KTnm3coDXkZN9wnuW3HjGgN386D7hfv5CHQYCI022/rJPVlqXyHSw==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.5", + "string.prototype.trimstart": "^1.0.0" + } + }, + "string.prototype.trimright": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.2.tgz", + "integrity": "sha512-ZNRQ7sY3KroTaYjRS6EbNiiHrOkjihL9aQE/8gfQ4DtAC/aEBRHFJa44OmoWxGGqXuJlfKkZW4WcXErGr+9ZFg==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.5", + "string.prototype.trimend": "^1.0.0" + } + }, "string.prototype.trimstart": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz", diff --git a/test/spec/modules/zetaBidAdapter_spec.js b/test/spec/modules/zetaBidAdapter_spec.js new file mode 100644 index 00000000000..f7dddd183c8 --- /dev/null +++ b/test/spec/modules/zetaBidAdapter_spec.js @@ -0,0 +1,78 @@ +import { spec } from '../../../modules/zetaBidAdapter.js' + +describe('Zeta Bid Adapter', function() { + const bannerRequest = [{ + bidId: 12345, + auctionId: 67890, + mediaTypes: { + banner: { + sizes: [[300, 250]], + } + }, + refererInfo: { + referer: 'zetaglobal.com' + }, + params: { + placement: 12345, + user: { + uid: 12345, + buyeruid: 12345 + }, + ip: '111.222.33.44', + test: 1 + } + }]; + + it('Test the bid validation function', function() { + const validBid = spec.isBidRequestValid(bannerRequest[0]); + const invalidBid = spec.isBidRequestValid(null); + + expect(validBid).to.be.true; + expect(invalidBid).to.be.false; + }); + + it('Test the request processing function', function () { + const request = spec.buildRequests(bannerRequest, bannerRequest[0]); + expect(request).to.not.be.empty; + + const payload = request.data; + expect(payload).to.not.be.empty; + }); + + const responseBody = { + id: '12345', + seatbid: [ + { + bid: [ + { + id: 'auctionId', + impid: 'impId', + price: 0.0, + adm: 'adMarkup', + crid: 'creativeId', + h: 250, + w: 300 + } + ] + } + ], + cur: 'USD' + }; + + it('Test the response parsing function', function () { + const receivedBid = responseBody.seatbid[0].bid[0]; + const response = {}; + response.body = responseBody; + + const bidResponse = spec.interpretResponse(response, null); + expect(bidResponse).to.not.be.empty; + + const bid = bidResponse[0]; + expect(bid).to.not.be.empty; + expect(bid.ad).to.equal(receivedBid.adm); + expect(bid.cpm).to.equal(receivedBid.price); + expect(bid.height).to.equal(receivedBid.h); + expect(bid.width).to.equal(receivedBid.w); + expect(bid.requestId).to.equal(receivedBid.impid); + }); +}); From 66ba924d2c8f796cf594c74f1b8e5654949b1a52 Mon Sep 17 00:00:00 2001 From: Myles Wehr Date: Thu, 15 Apr 2021 12:56:30 -0400 Subject: [PATCH 11/12] update to include additional OpenRTB fields and objects --- modules/zetaBidAdapter.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/modules/zetaBidAdapter.js b/modules/zetaBidAdapter.js index f60e8946799..e88c81eea73 100644 --- a/modules/zetaBidAdapter.js +++ b/modules/zetaBidAdapter.js @@ -54,20 +54,28 @@ export const spec = { let isMobile = /(ios|ipod|ipad|iphone|android)/i.test(navigator.userAgent) ? 1 : 0; let payload = { id: bidderRequest.auctionId, - cur: [DEFAULT_CUR], imp: [impData], site: { mobile: isMobile, page: bidderRequest.refererInfo.referer }, + app: params.app, device: { ua: navigator.userAgent, ip: params.ip }, - user: { - buyeruid: params.user.buyeruid, - uid: params.user.uid - }, + user: params.user, + at: params.at, + tmax: params.tmax, + wseat: params.wseat, + bseat: params.bseat, + allimps: params.allimps, + cur: [DEFAULT_CUR], + wlang: params.wlang, + bcat: params.bcat, + badv: params.badv, + bapp: params.bapp, + source: params.source, ext: { definerId: params.definerId } From 79237ef9c143a40959d076971783c2c6cf9249a8 Mon Sep 17 00:00:00 2001 From: Myles Wehr Date: Fri, 16 Apr 2021 16:41:21 -0400 Subject: [PATCH 12/12] Update to include addtional OpenRTB fields and objects --- modules/zetaBidAdapter.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/zetaBidAdapter.js b/modules/zetaBidAdapter.js index 09d631b3d18..b168bf581d0 100644 --- a/modules/zetaBidAdapter.js +++ b/modules/zetaBidAdapter.js @@ -71,12 +71,22 @@ export const spec = { }; let payload = { id: bidderRequest.auctionId, - cur: [DEFAULT_CUR], imp: [impData], site: params.site ? params.site : {}, + app: params.app ? params.app : {}, device: params.device ? params.device : {}, user: params.user ? params.user : {}, - app: params.app ? params.app : {}, + at: params.at, + tmax: params.tmax, + wseat: params.wseat, + bseat: params.bseat, + allimps: params.allimps, + cur: [DEFAULT_CUR], + wlang: params.wlang, + bcat: params.bcat, + badv: params.badv, + bapp: params.bapp, + source: params.source ? params.source : {}, ext: { definerId: params.definerId }