From d17c44bc98b88423882b4befa8baf414780cecd3 Mon Sep 17 00:00:00 2001 From: jxdeveloper1 <71084096+jxdeveloper1@users.noreply.github.com> Date: Fri, 15 Mar 2024 22:47:25 +0800 Subject: [PATCH] jixie Bid Adapter : adding handling of userSync urls sent from server side (#11217) * Adapter does not seem capable of supporting advertiserDomains #6650 added response comment and some trivial code. * removed a blank line at the end of file added a space behind the // in comments * in response to comment from reviewer. add the aspect of advertiserdomain in unit tests * added the code to get the keywords from the meta tags if available. * WIP * cleaned up * correcting formatting errors from circleci * sending floor to our backend for each bid, when available, changed one of the 1st party cookies that we want to send to backend * fixed spacing issues in code * 1/ provide the possibility of using the jixie section of the config object to determine what ids to read from cookie and to send 2/ removed ontimeout handling 3/ bidwon just ping the trackingUrl, if any 4/ misc: sending aid (from jixie config if any), prebid version etc * corrected formatting mistakes * adding support of handling usersync array from the server side * add back registerBidder line dropped accidentally * fixed some formatting flaws * correcting more formatting issues * more formatting corrections --- modules/jixieBidAdapter.js | 15 ++++++ test/spec/modules/jixieBidAdapter_spec.js | 63 +++++++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/modules/jixieBidAdapter.js b/modules/jixieBidAdapter.js index 75268e9d168..1e07ce6b5d8 100644 --- a/modules/jixieBidAdapter.js +++ b/modules/jixieBidAdapter.js @@ -295,6 +295,21 @@ export const spec = { } return bidResponses; } else { return []; } + }, + + getUserSyncs: function(syncOptions, serverResponses) { + if (!serverResponses.length || !serverResponses[0].body || !serverResponses[0].body.userSyncs) { + return false; + } + let syncs = []; + serverResponses[0].body.userSyncs.forEach(function(sync) { + if (syncOptions.iframeEnabled) { + syncs.push(sync.uf ? { url: sync.uf, type: 'iframe' } : { url: sync.up, type: 'image' }); + } else if (syncOptions.pixelEnabled && sync.up) { + syncs.push({url: sync.up, type: 'image'}) + } + }) + return syncs; } } diff --git a/test/spec/modules/jixieBidAdapter_spec.js b/test/spec/modules/jixieBidAdapter_spec.js index fa7618814f8..5428fd0db0f 100644 --- a/test/spec/modules/jixieBidAdapter_spec.js +++ b/test/spec/modules/jixieBidAdapter_spec.js @@ -707,4 +707,67 @@ describe('jixie Adapter', function () { expect(jixieaux.ajax.calledWith(TRACKINGURL_)).to.equal(true); }) }); // describe + + describe('getUserSyncs', function () { + it('it should favour iframe over pixel if publisher allows iframe usersync', function () { + const syncOptions = { + 'iframeEnabled': true, + 'pixelEnabled': true, + } + const response = { + 'userSyncs': [ + { + 'uf': 'https://syncstuff.jixie.io/', + 'up': 'https://syncstuff.jixie.io/image.gif' + }, + { + 'up': 'https://syncstuff.jixie.io/image1.gif' + } + ] + } + let result = spec.getUserSyncs(syncOptions, [{ body: response }]); + expect(result[0].type).to.equal('iframe') + expect(result[1].type).to.equal('image') + }) + + it('it should pick pixel if publisher not allow iframe', function () { + const syncOptions = { + 'iframeEnabled': false, + 'pixelEnabled': true, + } + const response = { + 'userSyncs': [ + { + 'uf': 'https://syncstuff.jixie.io/', + 'up': 'https://syncstuff.jixie.io/image.gif' + }, + { + 'up': 'https://syncstuff.jixie.io/image1.gif' + } + ] + } + let result = spec.getUserSyncs(syncOptions, [{ body: response }]); + expect(result[0].type).to.equal('image') + expect(result[1].type).to.equal('image') + }) + + it('it should return nothing if pub only allow pixel but all usersyncs are iframe only', function () { + const syncOptions = { + 'iframeEnabled': false, + 'pixelEnabled': true, + } + const response = { + 'userSyncs': [ + { + 'uf': 'https://syncstuff.jixie.io/', + }, + { + 'uf': 'https://syncstuff2.jixie.io/', + } + ] + } + let result = spec.getUserSyncs(syncOptions, [{ body: response }]); + expect(result.length).to.equal(0) + }) + }) });