diff --git a/modules/33acrossBidAdapter.js b/modules/33acrossBidAdapter.js index 15792240fdd..7b26f66331f 100644 --- a/modules/33acrossBidAdapter.js +++ b/modules/33acrossBidAdapter.js @@ -1,11 +1,12 @@ -import { userSync } from 'src/userSync' +import { uniques } from 'src/utils'; const { registerBidder } = require('../src/adapters/bidderFactory'); const { config } = require('../src/config'); - const BIDDER_CODE = '33across'; const END_POINT = 'https://ssc.33across.com/api/v1/hb'; const SYNC_ENDPOINT = 'https://de.tynt.com/deb/v2?m=xch&rt=html'; +const adapterState = {}; + // All this assumes that only one bid is ever returned by ttx function _createBidResponse(response) { return { @@ -42,19 +43,21 @@ function _createServerRequest(bidRequest) { } } ttxRequest.site = { id: params.siteId }; + // Go ahead send the bidId in request to 33exchange so it's kept track of in the bid response and // therefore in ad targetting process ttxRequest.id = bidRequest.bidId; + // Finally, set the openRTB 'test' param if this is to be a test bid if (params.test === 1) { ttxRequest.test = 1; } /* - * Now construt the full server request + * Now construct the full server request */ const options = { - contentType: 'application/json', + contentType: 'text/plain', withCredentials: true }; // Allow the ability to configure the HB endpoint for testing purposes. @@ -70,6 +73,17 @@ function _createServerRequest(bidRequest) { } } +// Sync object will always be of type iframe for TTX +function _createSync(siteId) { + const ttxSettings = config.getConfig('ttxSettings'); + const syncUrl = (ttxSettings && ttxSettings.syncUrl) || SYNC_ENDPOINT; + + return { + type: 'iframe', + url: `${syncUrl}&id=${siteId}` + } +} + function _getFormatSize(sizeArr) { return { w: sizeArr[0], @@ -78,24 +92,6 @@ function _getFormatSize(sizeArr) { } } -// Register one sync per bid since each ad unit may potenitally be linked to a uniqe guid -// Sync type will always be 'iframe' for 33Across -function _registerUserSyncs(requestData) { - let ttxRequest; - try { - ttxRequest = JSON.parse(requestData); - } catch (err) { - // No point in trying to register sync since the requisite data cannot be parsed. - return; - } - const ttxSettings = config.getConfig('ttxSettings'); - - let syncUrl = (ttxSettings && ttxSettings.syncUrl) || SYNC_ENDPOINT; - - syncUrl = `${syncUrl}&id=${ttxRequest.site.id}`; - userSync.registerSync('iframe', BIDDER_CODE, syncUrl); -} - function isBidRequestValid(bid) { if (bid.bidder !== BIDDER_CODE || typeof bid.params === 'undefined') { return false; @@ -108,18 +104,15 @@ function isBidRequestValid(bid) { return true; } -// NOTE: At this point, 33exchange only accepts request for a single impression +// NOTE: At this point, TTX only accepts request for a single impression function buildRequests(bidRequests) { + adapterState.uniqueSiteIds = bidRequests.map(req => req.params.siteId).filter(uniques); + return bidRequests.map(_createServerRequest); } // NOTE: At this point, the response from 33exchange will only ever contain one bid i.e. the highest bid function interpretResponse(serverResponse, bidRequest) { - // Register user sync first - if (bidRequest && bidRequest.data) { - _registerUserSyncs(bidRequest.data); - } - const bidResponses = []; // If there are bids, look at the first bid of the first seatbid (see NOTE above for assumption about ttx) @@ -130,11 +123,17 @@ function interpretResponse(serverResponse, bidRequest) { return bidResponses; } +// Register one sync per unique guid +function getUserSyncs(syncOptions) { + return (syncOptions.iframeEnabled) ? adapterState.uniqueSiteIds.map(_createSync) : ([]); +} + const spec = { code: BIDDER_CODE, isBidRequestValid, buildRequests, - interpretResponse + interpretResponse, + getUserSyncs } registerBidder(spec); diff --git a/modules/33acrossBidAdapter.md b/modules/33acrossBidAdapter.md index c4eb319c157..bdb2b944861 100644 --- a/modules/33acrossBidAdapter.md +++ b/modules/33acrossBidAdapter.md @@ -3,7 +3,7 @@ ``` Module Name: 33Across Bid Adapter Module Type: Bidder Adapter -Maintainer: aparna.hegde@33across.com +Maintainer: headerbidding@33across.com ``` # Description @@ -24,72 +24,9 @@ var adUnits = [ bids: [{ bidder: '33across', params: { - siteId: 'pub1234', - productId: 'infeed' + siteId: 'examplePub1234', + productId: 'siab' } }] } ``` - -# Ad Unit and Setup: For Testing -In order to receive bids please map localhost to (any) test domain. - -``` -<--! Prebid Config section > - -