From 80364ce42af5db937c164a91689dc3c89c8161b4 Mon Sep 17 00:00:00 2001 From: wojciech-bialy-wpm <67895844+wojciech-bialy-wpm@users.noreply.github.com> Date: Fri, 6 Dec 2024 21:06:09 +0100 Subject: [PATCH] sspBC Bid Adapter : added support for transactionID and update tests (#12547) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update tests for sspBC adapter Update tests for sspBC adapter: - change userSync test (due to tcf param appended in v4.6) - add tests for onBidWon and onTimeout * [sspbc-adapter] 5.3 updates: content-type for notifications * [sspbc-adapter] pass CTA to native bid * [sspbc-5.3] keep pbsize for detected adunits * [maintenance] - remove old test for sspBc bid adaptor * [sspbc-5.3] increment adaptor ver * [sspbc-adapter] maintenance update to sspBCBidAdapter * remove yarn.lock * Delete package-lock.json * remove package-lock.jsonfrom pull request * [sspbc-adapter] send pageViewId in request * [sspbc-adapter] update pageViewId test * [sspbc-adapter] add viewabiility tracker to native ads * [sspbc-adapter] add support for bid.admNative property * [sspbc-adapter] ensure that placement id length is always 3 (improves matching response to request) * [sspbc-adapter] read publisher id and custom ad label, then send them to banner creative * [sspbc-adapter] adlabel and pubid are set as empty strings, if not present in bid response * [sspbc-adapter] jstracker data fix * [sspbc-adapter] jstracker data fix * [sspbc-adapter] send tagid in notifications * [sspbc-adapter] add gvlid to spec; prepare getUserSyncs for iframe + image sync * update remote repo * cleanup of grupawp/prebid master branch * update sspBC adapter to v 5.9 * update tests for sspBC bid adapter * [sspbc-adapter] add support for topicsFPD module * [sspbc-adapter] change topic segment ids to int * sspbc adapter -> update to v6 * [sspbc-adapter] update to v6.1 - add image sync, transactionId & schain support, improve test coverage * [sspbc-adapter] fix typos --------- Co-authored-by: Wojciech Biały Co-authored-by: decemberWP <155962474+decemberWP@users.noreply.github.com> --- modules/sspBCBidAdapter.js | 41 ++++++++++++++++++----- test/spec/modules/sspBCBidAdapter_spec.js | 35 ++++++++++++++++--- 2 files changed, 63 insertions(+), 13 deletions(-) diff --git a/modules/sspBCBidAdapter.js b/modules/sspBCBidAdapter.js index 1227b6fdc76..03a9f5a1da9 100644 --- a/modules/sspBCBidAdapter.js +++ b/modules/sspBCBidAdapter.js @@ -8,11 +8,12 @@ import { getCurrencyFromBidderRequest } from '../libraries/ortb2Utils/currency.j const BIDDER_CODE = 'sspBC'; const BIDDER_URL = 'https://ssp.wp.pl/bidder/'; -const SYNC_URL = 'https://ssp.wp.pl/bidder/usersync'; +const SYNC_URL_IFRAME = 'https://ssp.wp.pl/bidder/usersync'; +const SYNC_URL_IMAGE = 'https://ssp.wp.pl/v1/sync/pixel'; const NOTIFY_URL = 'https://ssp.wp.pl/bidder/notify'; const GVLID = 676; const TMAX = 450; -const BIDDER_VERSION = '6.00'; +const BIDDER_VERSION = '6.10'; const DEFAULT_CURRENCY = 'PLN'; const W = window; const { navigator } = W; @@ -70,7 +71,20 @@ const getContentLanguage = () => { const topWindow = getWindowTop(); return topWindow.document.body.parentNode.lang; } catch (err) { - logWarn('Could not read language form top-level html', err); + logWarn('Could not read language from top-level html', err); + } +}; + +/** + * Get host name of the top level html object + * @returns {string} host name + */ +const getTopHost = () => { + try { + const topWindow = getWindowTop(); + return topWindow.location.host; + } catch (err) { + logWarn('Could not read host from top-level window', err); } }; @@ -604,7 +618,9 @@ const spec = { const pbver = '$prebid.version$'; const testMode = setOnAny(validBidRequests, 'params.test') ? 1 : undefined; const ref = bidderRequest.refererInfo.ref; - const { regs = {} } = ortb2 || {}; + const { source = {}, regs = {} } = ortb2 || {}; + + source.schain = setOnAny(validBidRequests, 'schain'); const payload = { id: bidderRequest.bidderRequestId, @@ -621,6 +637,7 @@ const spec = { tmax, user: {}, regs, + source, device: { language: getBrowserLanguage(), w: screen.width, @@ -764,14 +781,22 @@ const spec = { return fledgeAuctionConfigs.length ? { bids, fledgeAuctionConfigs } : bids; }, - getUserSyncs(syncOptions) { + + getUserSyncs(syncOptions, _, gdprConsent = {}) { + const {iframeEnabled, pixelEnabled} = syncOptions; + const {gdprApplies, consentString = ''} = gdprConsent; let mySyncs = []; - if (syncOptions.iframeEnabled) { + if (iframeEnabled) { mySyncs.push({ type: 'iframe', - url: `${SYNC_URL}?tcf=2&pvid=${pageView.id}&sn=${pageView.sn}`, + url: `${SYNC_URL_IFRAME}?tcf=2&pvid=${pageView.id}&sn=${pageView.sn}`, }); - }; + } else if (pixelEnabled) { + mySyncs.push({ + type: 'image', + url: `${SYNC_URL_IMAGE}?inver=0&platform=wpartner&host=${getTopHost() || ''}&gdpr=${gdprApplies ? 1 : 0}&gdpr_consent=${consentString}`, + }); + } return mySyncs; }, diff --git a/test/spec/modules/sspBCBidAdapter_spec.js b/test/spec/modules/sspBCBidAdapter_spec.js index 623faab5f1e..ceaad85faac 100644 --- a/test/spec/modules/sspBCBidAdapter_spec.js +++ b/test/spec/modules/sspBCBidAdapter_spec.js @@ -4,7 +4,8 @@ import * as utils from 'src/utils.js'; const BIDDER_CODE = 'sspBC'; const BIDDER_URL = 'https://ssp.wp.pl/bidder/'; -const SYNC_URL = 'https://ssp.wp.pl/bidder/usersync'; +const SYNC_URL_IFRAME = 'https://ssp.wp.pl/bidder/usersync'; +const SYNC_URL_IMAGE = 'https://ssp.wp.pl/v1/sync/pixel'; describe('SSPBC adapter', function () { function prepareTestData() { @@ -649,6 +650,25 @@ describe('SSPBC adapter', function () { expect(extAssets1).to.have.property('pbsize').that.equals('750x200_1') expect(extAssets2).to.have.property('pbsize').that.equals('750x200_1') }); + + it('should send supply chain data', function () { + const supplyChain = { + ver: '1.0', + complete: 1, + nodes: [ + { + asi: 'first-seller.com', + sid: '00001', + hp: 1 + }, + ] + } + const bidWithSupplyChain = Object.assign(bids[0], { schain: supplyChain }); + const requestWithSupplyChain = spec.buildRequests([bidWithSupplyChain], bidRequest); + const payloadWithSupplyChain = requestWithSupplyChain ? JSON.parse(requestWithSupplyChain.data) : { site: false, imp: false }; + + expect(payloadWithSupplyChain.source).to.have.property('schain').that.has.keys('ver', 'complete', 'nodes'); + }); }); describe('interpretResponse', function () { @@ -741,13 +761,18 @@ describe('SSPBC adapter', function () { let syncResultImage = spec.getUserSyncs({ iframeEnabled: false, pixelEnabled: true }); let syncResultNone = spec.getUserSyncs({ iframeEnabled: false, pixelEnabled: false }); - it('should provide correct url, if frame sync is allowed', function () { + it('should provide correct iframe url, if frame sync is allowed', function () { expect(syncResultAll).to.have.length(1); - expect(syncResultAll[0].url).to.have.string(SYNC_URL); + expect(syncResultAll[0].url).to.have.string(SYNC_URL_IFRAME); + }); + + it('should provide correct image url, if image sync is allowed', function () { + expect(syncResultImage).to.have.length(1); + expect(syncResultImage[0].url).to.have.string(SYNC_URL_IMAGE); }); - it('should send no syncs, if frame sync is not allowed', function () { - expect(syncResultImage).to.have.length(0); + it('should send no syncs, if no sync is allowed', function () { + expect(syncResultNone).to.have.length(0); expect(syncResultNone).to.have.length(0); }); });