From 5e48d3b5df34db28862f3358e5253584ef7d75e3 Mon Sep 17 00:00:00 2001 From: Ilia Medvedev Date: Thu, 11 Apr 2024 16:34:39 +0400 Subject: [PATCH 01/12] Limelight Digital Bid Adapter : add page field (#11312) * Limelight Digital Bid Adapter: Add page field * fix typo * add referrer field * remove referrer field --- modules/limelightDigitalBidAdapter.js | 3 ++- .../modules/limelightDigitalBidAdapter_spec.js | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/modules/limelightDigitalBidAdapter.js b/modules/limelightDigitalBidAdapter.js index acc76014abe..5cccf5300b3 100644 --- a/modules/limelightDigitalBidAdapter.js +++ b/modules/limelightDigitalBidAdapter.js @@ -169,7 +169,8 @@ function buildPlacement(bidRequest) { custom2: bidRequest.params.custom2, custom3: bidRequest.params.custom3, custom4: bidRequest.params.custom4, - custom5: bidRequest.params.custom5 + custom5: bidRequest.params.custom5, + page: bidRequest.refererInfo.page } } } diff --git a/test/spec/modules/limelightDigitalBidAdapter_spec.js b/test/spec/modules/limelightDigitalBidAdapter_spec.js index 0e6f4817e5e..6348d6a1ac6 100644 --- a/test/spec/modules/limelightDigitalBidAdapter_spec.js +++ b/test/spec/modules/limelightDigitalBidAdapter_spec.js @@ -17,6 +17,9 @@ describe('limelightDigitalAdapter', function () { custom4: 'custom4', custom5: 'custom5' }, + refererInfo: { + page: 'https://publisher.com/page1' + }, placementCode: 'placement_0', auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2', mediaTypes: { @@ -65,6 +68,9 @@ describe('limelightDigitalAdapter', function () { custom4: 'custom4', custom5: 'custom5' }, + refererInfo: { + page: 'https://publisher.com/page2' + }, placementCode: 'placement_1', auctionId: '482f88de-29ab-45c8-981a-d25e39454a34', sizes: [[350, 200]], @@ -115,6 +121,9 @@ describe('limelightDigitalAdapter', function () { custom4: 'custom4', custom5: 'custom5' }, + refererInfo: { + page: 'https://publisher.com/page3' + }, placementCode: 'placement_2', auctionId: 'e4771143-6aa7-41ec-8824-ced4342c96c8', sizes: [[800, 600]], @@ -162,6 +171,9 @@ describe('limelightDigitalAdapter', function () { custom4: 'custom4', custom5: 'custom5' }, + refererInfo: { + page: 'https://publisher.com/page4' + }, placementCode: 'placement_2', auctionId: 'e4771143-6aa7-41ec-8824-ced4342c96c8', video: { @@ -237,7 +249,8 @@ describe('limelightDigitalAdapter', function () { 'custom2', 'custom3', 'custom4', - 'custom5' + 'custom5', + 'page' ); expect(adUnit.id).to.be.a('number'); expect(adUnit.bidId).to.be.a('string'); @@ -251,6 +264,7 @@ describe('limelightDigitalAdapter', function () { expect(adUnit.custom3).to.be.a('string'); expect(adUnit.custom4).to.be.a('string'); expect(adUnit.custom5).to.be.a('string'); + expect(adUnit.page).to.be.a('string'); }) }) }) @@ -685,4 +699,5 @@ function validateAdUnit(adUnit, bid) { expect(adUnit.publisherId).to.equal(bid.params.publisherId); expect(adUnit.userIdAsEids).to.deep.equal(bid.userIdAsEids); expect(adUnit.supplyChain).to.deep.equal(bid.schain); + expect(adUnit.page).to.equal(bid.refererInfo.page); } From 3aed8aa09e829893241875bb113f306a88700737 Mon Sep 17 00:00:00 2001 From: Antonios Sarhanis Date: Thu, 11 Apr 2024 22:52:28 +1000 Subject: [PATCH 02/12] Adnuntius Bid Adapter: change ad request format (#11321) --- modules/adnuntiusBidAdapter.js | 2 +- test/spec/modules/adnuntiusBidAdapter_spec.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/adnuntiusBidAdapter.js b/modules/adnuntiusBidAdapter.js index eb5f3c19dea..97419fb94bd 100644 --- a/modules/adnuntiusBidAdapter.js +++ b/modules/adnuntiusBidAdapter.js @@ -182,7 +182,7 @@ export const spec = { buildRequests: function (validBidRequests, bidderRequest) { const queryParamsAndValues = []; queryParamsAndValues.push('tzo=' + new Date().getTimezoneOffset()) - queryParamsAndValues.push('format=json') + queryParamsAndValues.push('format=prebid') const gdprApplies = deepAccess(bidderRequest, 'gdprConsent.gdprApplies'); const consentString = deepAccess(bidderRequest, 'gdprConsent.consentString'); if (gdprApplies !== undefined) { diff --git a/test/spec/modules/adnuntiusBidAdapter_spec.js b/test/spec/modules/adnuntiusBidAdapter_spec.js index 71f0a6a3a6c..0e0206c2933 100644 --- a/test/spec/modules/adnuntiusBidAdapter_spec.js +++ b/test/spec/modules/adnuntiusBidAdapter_spec.js @@ -37,12 +37,12 @@ describe('adnuntiusBidAdapter', function() { }); const tzo = new Date().getTimezoneOffset(); - const ENDPOINT_URL_BASE = `${URL}${tzo}&format=json`; + const ENDPOINT_URL_BASE = `${URL}${tzo}&format=prebid`; const ENDPOINT_URL = `${ENDPOINT_URL_BASE}&userId=${usi}`; const ENDPOINT_URL_VIDEO = `${ENDPOINT_URL_BASE}&userId=${usi}&tt=vast4`; const ENDPOINT_URL_NOCOOKIE = `${ENDPOINT_URL_BASE}&userId=${usi}&noCookies=true`; const ENDPOINT_URL_SEGMENTS = `${ENDPOINT_URL_BASE}&segments=segment1,segment2,segment3&userId=${usi}`; - const ENDPOINT_URL_CONSENT = `${EURO_URL}${tzo}&format=json&consentString=consentString&gdpr=1&userId=${usi}`; + const ENDPOINT_URL_CONSENT = `${EURO_URL}${tzo}&format=prebid&consentString=consentString&gdpr=1&userId=${usi}`; const adapter = newBidder(spec); const bidderRequests = [ From 007a3b0e2e1e3d21965fb9355fbf7f1de77b0c21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Leclerc?= Date: Thu, 11 Apr 2024 15:04:18 +0200 Subject: [PATCH 03/12] teads: Add more device information to payload (#11316) --- modules/teadsBidAdapter.js | 2 ++ test/spec/modules/teadsBidAdapter_spec.js | 35 +++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/modules/teadsBidAdapter.js b/modules/teadsBidAdapter.js index 1108c12c822..a3c8d3e24dc 100644 --- a/modules/teadsBidAdapter.js +++ b/modules/teadsBidAdapter.js @@ -62,6 +62,8 @@ export const spec = { timeToFirstByte: getTimeToFirstByte(window), data: bids, deviceWidth: screen.width, + deviceHeight: screen.height, + devicePixelRatio: topWindow.devicePixelRatio, screenOrientation: screen.orientation?.type, historyLength: topWindow.history?.length, viewportHeight: topWindow.visualViewport?.height, diff --git a/test/spec/modules/teadsBidAdapter_spec.js b/test/spec/modules/teadsBidAdapter_spec.js index 1e044651315..81e09b09d08 100644 --- a/test/spec/modules/teadsBidAdapter_spec.js +++ b/test/spec/modules/teadsBidAdapter_spec.js @@ -255,6 +255,33 @@ describe('teadsBidAdapter', () => { expect(payload.pageReferrer).to.deep.equal(document.referrer); }); + it('should add width info to payload', function () { + const request = spec.buildRequests(bidRequests, bidderRequestDefault); + const payload = JSON.parse(request.data); + const deviceWidth = screen.width + + expect(payload.deviceWidth).to.exist; + expect(payload.deviceWidth).to.deep.equal(deviceWidth); + }); + + it('should add height info to payload', function () { + const request = spec.buildRequests(bidRequests, bidderRequestDefault); + const payload = JSON.parse(request.data); + const deviceHeight = screen.height + + expect(payload.deviceHeight).to.exist; + expect(payload.deviceHeight).to.deep.equal(deviceHeight); + }); + + it('should add pixelRatio info to payload', function () { + const request = spec.buildRequests(bidRequests, bidderRequestDefault); + const payload = JSON.parse(request.data); + const pixelRatio = window.top.devicePixelRatio + + expect(payload.devicePixelRatio).to.exist; + expect(payload.devicePixelRatio).to.deep.equal(pixelRatio); + }); + it('should add screenOrientation info to payload', function () { const request = spec.buildRequests(bidRequests, bidderRequestDefault); const payload = JSON.parse(request.data); @@ -290,6 +317,14 @@ describe('teadsBidAdapter', () => { expect(payload.viewportWidth).to.deep.equal(window.top.visualViewport.width); }); + it('should add viewportHeight info to payload', function () { + const request = spec.buildRequests(bidRequests, bidderRequestDefault); + const payload = JSON.parse(request.data); + + expect(payload.viewportHeight).to.exist; + expect(payload.viewportHeight).to.deep.equal(window.top.visualViewport.height); + }); + it('should add hardwareConcurrency info to payload', function () { const request = spec.buildRequests(bidRequests, bidderRequestDefault); const payload = JSON.parse(request.data); From e51046edd5daddb902a12d821bdc6aa0073d94bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9onard=20Labat?= Date: Thu, 11 Apr 2024 15:20:26 +0200 Subject: [PATCH 04/12] Grid Bid Adapter : fix invalid DSA adrender field mapping (#11313) * Criteo Bid Adapter: Fix invalid DSA adrender field mapping * Grid Bid Adapter: Fix invalid DSA adrender field mapping --- modules/gridBidAdapter.js | 4 ++-- test/spec/modules/gridBidAdapter_spec.js | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/gridBidAdapter.js b/modules/gridBidAdapter.js index d56639ed714..f7db6d878f1 100644 --- a/modules/gridBidAdapter.js +++ b/modules/gridBidAdapter.js @@ -554,8 +554,8 @@ function _addBidResponse(serverBid, bidRequest, bidResponses, RendererConst, bid bidResponse.meta.demandSource = serverBid.ext.bidder.grid.demandSource; } - if (serverBid.ext && serverBid.ext.dsa && serverBid.ext.dsa.adrender) { - bidResponse.meta.adrender = serverBid.ext.dsa.adrender; + if (serverBid.ext && serverBid.ext.dsa) { + bidResponse.meta.dsa = serverBid.ext.dsa; } if (serverBid.content_type === 'video') { diff --git a/test/spec/modules/gridBidAdapter_spec.js b/test/spec/modules/gridBidAdapter_spec.js index abaa4b37fcd..efd7b06685f 100644 --- a/test/spec/modules/gridBidAdapter_spec.js +++ b/test/spec/modules/gridBidAdapter_spec.js @@ -1430,7 +1430,9 @@ describe('TheMediaGrid Adapter', function () { 'netRevenue': true, 'ttl': 360, 'meta': { - adrender: 1, + dsa: { + adrender: 1 + }, advertiserDomains: [] }, }, From 9aff4adeab156a5ecc5949fd24e4c4facd49fc33 Mon Sep 17 00:00:00 2001 From: teqblaze <162988436+teqblaze@users.noreply.github.com> Date: Thu, 11 Apr 2024 18:42:59 +0300 Subject: [PATCH 05/12] Loyal Bid Adapter: initial release (#11253) * init loyal adapter * fix linter * upd * fix linter --------- Co-authored-by: loyal --- modules/loyalBidAdapter.js | 190 +++++++++++ modules/loyalBidAdapter.md | 79 +++++ test/spec/modules/loyalBidAdapter_spec .js | 375 +++++++++++++++++++++ 3 files changed, 644 insertions(+) create mode 100644 modules/loyalBidAdapter.js create mode 100644 modules/loyalBidAdapter.md create mode 100644 test/spec/modules/loyalBidAdapter_spec .js diff --git a/modules/loyalBidAdapter.js b/modules/loyalBidAdapter.js new file mode 100644 index 00000000000..30fdeb44233 --- /dev/null +++ b/modules/loyalBidAdapter.js @@ -0,0 +1,190 @@ +import { logMessage, logError } from '../src/utils.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; + +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import { config } from '../src/config.js'; + +const BIDDER_CODE = 'loyal'; +const AD_URL = 'https://us-east-1.loyal.app/pbjs'; + +function isBidResponseValid(bid) { + if (!bid.requestId || !bid.cpm || !bid.creativeId || !bid.ttl || !bid.currency) { + return false; + } + + switch (bid.mediaType) { + case BANNER: + return Boolean(bid.width && bid.height && bid.ad); + case VIDEO: + return Boolean(bid.vastUrl || bid.vastXml); + case NATIVE: + return Boolean(bid.native && bid.native.impressionTrackers && bid.native.impressionTrackers.length); + default: + return false; + } +} + +function getPlacementReqData(bid) { + const { params, bidId, mediaTypes } = bid; + const schain = bid.schain || {}; + const { placementId, endpointId } = params; + const bidfloor = getBidFloor(bid); + + const placement = { + bidId, + schain, + bidfloor, + eids: [] + }; + + if (placementId) { + placement.placementId = placementId; + placement.type = 'publisher'; + } else if (endpointId) { + placement.endpointId = endpointId; + placement.type = 'network'; + } + + if (mediaTypes && mediaTypes[BANNER]) { + placement.adFormat = BANNER; + placement.sizes = mediaTypes[BANNER].sizes; + } else if (mediaTypes && mediaTypes[VIDEO]) { + placement.adFormat = VIDEO; + placement.playerSize = mediaTypes[VIDEO].playerSize; + placement.minduration = mediaTypes[VIDEO].minduration; + placement.maxduration = mediaTypes[VIDEO].maxduration; + placement.mimes = mediaTypes[VIDEO].mimes; + placement.protocols = mediaTypes[VIDEO].protocols; + placement.startdelay = mediaTypes[VIDEO].startdelay; + placement.placement = mediaTypes[VIDEO].placement; + placement.skip = mediaTypes[VIDEO].skip; + placement.skipafter = mediaTypes[VIDEO].skipafter; + placement.minbitrate = mediaTypes[VIDEO].minbitrate; + placement.maxbitrate = mediaTypes[VIDEO].maxbitrate; + placement.delivery = mediaTypes[VIDEO].delivery; + placement.playbackmethod = mediaTypes[VIDEO].playbackmethod; + placement.api = mediaTypes[VIDEO].api; + placement.linearity = mediaTypes[VIDEO].linearity; + } else if (mediaTypes && mediaTypes[NATIVE]) { + placement.native = mediaTypes[NATIVE]; + placement.adFormat = NATIVE; + } + + return placement; +} + +function getBidFloor(bid) { + try { + const bidFloor = bid.getFloor({ + currency: 'USD', + mediaType: '*', + size: '*', + }); + return bidFloor.floor; + } catch (err) { + logError(err); + return 0; + } +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER, VIDEO, NATIVE], + + isBidRequestValid: (bid = {}) => { + const { params, bidId, mediaTypes } = bid; + let valid = Boolean(bidId && params && (params.placementId || params.endpointId)); + + if (mediaTypes && mediaTypes[BANNER]) { + valid = valid && Boolean(mediaTypes[BANNER] && mediaTypes[BANNER].sizes); + } else if (mediaTypes && mediaTypes[VIDEO]) { + valid = valid && Boolean(mediaTypes[VIDEO] && mediaTypes[VIDEO].playerSize); + } else if (mediaTypes && mediaTypes[NATIVE]) { + valid = valid && Boolean(mediaTypes[NATIVE]); + } else { + valid = false; + } + return valid; + }, + + buildRequests: (validBidRequests = [], bidderRequest = {}) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + + let deviceWidth = 0; + let deviceHeight = 0; + + let winLocation; + try { + const winTop = window.top; + deviceWidth = winTop.screen.width; + deviceHeight = winTop.screen.height; + winLocation = winTop.location; + } catch (e) { + logMessage(e); + winLocation = window.location; + } + + const refferUrl = bidderRequest.refererInfo && bidderRequest.refererInfo.page; + let refferLocation; + try { + refferLocation = refferUrl && new URL(refferUrl); + } catch (e) { + logMessage(e); + } + // TODO: does the fallback make sense here? + let location = refferLocation || winLocation; + const language = (navigator && navigator.language) ? navigator.language.split('-')[0] : ''; + const host = location.host; + const page = location.pathname; + const secure = location.protocol === 'https:' ? 1 : 0; + const placements = []; + const request = { + deviceWidth, + deviceHeight, + language, + secure, + host, + page, + placements, + coppa: config.getConfig('coppa') === true ? 1 : 0, + ccpa: bidderRequest.uspConsent || undefined, + tmax: bidderRequest.timeout + }; + + if (bidderRequest.gdprConsent?.consentString) { + request.gdpr = { + consentString: bidderRequest.gdprConsent.consentString + }; + } + + const len = validBidRequests.length; + for (let i = 0; i < len; i++) { + const bid = validBidRequests[i]; + placements.push(getPlacementReqData(bid)); + } + + return { + method: 'POST', + url: AD_URL, + data: request + }; + }, + + interpretResponse: (serverResponse) => { + let response = []; + for (let i = 0; i < serverResponse.body.length; i++) { + let resItem = serverResponse.body[i]; + if (isBidResponseValid(resItem)) { + const advertiserDomains = resItem.adomain && resItem.adomain.length ? resItem.adomain : []; + resItem.meta = { ...resItem.meta, advertiserDomains }; + + response.push(resItem); + } + } + return response; + }, +}; + +registerBidder(spec); diff --git a/modules/loyalBidAdapter.md b/modules/loyalBidAdapter.md new file mode 100644 index 00000000000..db77c04c34f --- /dev/null +++ b/modules/loyalBidAdapter.md @@ -0,0 +1,79 @@ +# Overview + +``` +Module Name: Loyal Bidder Adapter +Module Type: Loyal Bidder Adapter +Maintainer: hello@loyal.app +``` + +# Description + +Connects to Loyal exchange for bids. +Loyal bid adapter supports Banner, Video (instream and outstream) and Native. + +# Test Parameters +``` + var adUnits = [ + // Will return static test banner + { + code: 'adunit1', + mediaTypes: { + banner: { + sizes: [ [300, 250], [320, 50] ], + } + }, + bids: [ + { + bidder: 'loyal', + params: { + placementId: 'testBanner', + } + } + ] + }, + { + code: 'addunit2', + mediaTypes: { + video: { + playerSize: [ [640, 480] ], + context: 'instream', + minduration: 5, + maxduration: 60, + } + }, + bids: [ + { + bidder: 'loyal', + params: { + placementId: 'testVideo', + } + } + ] + }, + { + code: 'addunit3', + mediaTypes: { + native: { + title: { + required: true + }, + body: { + required: true + }, + icon: { + required: true, + size: [64, 64] + } + } + }, + bids: [ + { + bidder: 'loyal', + params: { + placementId: 'testNative', + } + } + ] + } + ]; +``` \ No newline at end of file diff --git a/test/spec/modules/loyalBidAdapter_spec .js b/test/spec/modules/loyalBidAdapter_spec .js new file mode 100644 index 00000000000..28e87fc7047 --- /dev/null +++ b/test/spec/modules/loyalBidAdapter_spec .js @@ -0,0 +1,375 @@ +import { expect } from 'chai'; +import { spec } from '../../../modules/loyalBidAdapter.js'; +import { BANNER, VIDEO, NATIVE } from '../../../src/mediaTypes.js'; +import { getUniqueIdentifierStr } from '../../../src/utils.js'; + +const bidder = 'loyal' + +describe('LoyalBidAdapter', function () { + const bids = [ + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [BANNER]: { + sizes: [[300, 250]] + } + }, + params: { + placementId: 'testBanner', + } + }, + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [VIDEO]: { + playerSize: [[300, 300]], + minduration: 5, + maxduration: 60 + } + }, + params: { + placementId: 'testVideo', + } + }, + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [NATIVE]: { + native: { + title: { + required: true + }, + body: { + required: true + }, + icon: { + required: true, + size: [64, 64] + } + } + } + }, + params: { + placementId: 'testNative', + } + } + ]; + + const invalidBid = { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [BANNER]: { + sizes: [[300, 250]] + } + }, + params: { + + } + } + + const bidderRequest = { + uspConsent: '1---', + gdprConsent: { + consentString: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw' + }, + refererInfo: { + referer: 'https://test.com' + }, + timeout: 500 + }; + + describe('isBidRequestValid', function () { + it('Should return true if there are bidId, params and key parameters present', function () { + expect(spec.isBidRequestValid(bids[0])).to.be.true; + }); + it('Should return false if at least one of parameters is not present', function () { + expect(spec.isBidRequestValid(invalidBid)).to.be.false; + }); + }); + + describe('buildRequests', function () { + let serverRequest = spec.buildRequests(bids, bidderRequest); + + it('Creates a ServerRequest object with method, URL and data', function () { + expect(serverRequest).to.exist; + expect(serverRequest.method).to.exist; + expect(serverRequest.url).to.exist; + expect(serverRequest.data).to.exist; + }); + + it('Returns POST method', function () { + expect(serverRequest.method).to.equal('POST'); + }); + + it('Returns valid URL', function () { + expect(serverRequest.url).to.equal('https://us-east-1.loyal.app/pbjs'); + }); + + it('Returns general data valid', function () { + let data = serverRequest.data; + expect(data).to.be.an('object'); + expect(data).to.have.all.keys('deviceWidth', + 'deviceHeight', + 'language', + 'secure', + 'host', + 'page', + 'placements', + 'coppa', + 'ccpa', + 'gdpr', + 'tmax' + ); + expect(data.deviceWidth).to.be.a('number'); + expect(data.deviceHeight).to.be.a('number'); + expect(data.language).to.be.a('string'); + expect(data.secure).to.be.within(0, 1); + expect(data.host).to.be.a('string'); + expect(data.page).to.be.a('string'); + expect(data.coppa).to.be.a('number'); + expect(data.gdpr).to.be.a('object'); + expect(data.ccpa).to.be.a('string'); + expect(data.tmax).to.be.a('number'); + expect(data.placements).to.have.lengthOf(3); + }); + + it('Returns valid placements', function () { + const { placements } = serverRequest.data; + for (let i = 0, len = placements.length; i < len; i++) { + const placement = placements[i]; + expect(placement.placementId).to.be.oneOf(['testBanner', 'testVideo', 'testNative']); + expect(placement.adFormat).to.be.oneOf([BANNER, VIDEO, NATIVE]); + expect(placement.bidId).to.be.a('string'); + expect(placement.schain).to.be.an('object'); + expect(placement.bidfloor).to.exist.and.to.equal(0); + expect(placement.type).to.exist.and.to.equal('publisher'); + expect(placement.eids).to.exist.and.to.be.an('array'); + + if (placement.adFormat === BANNER) { + expect(placement.sizes).to.be.an('array'); + } + switch (placement.adFormat) { + case BANNER: + expect(placement.sizes).to.be.an('array'); + break; + case VIDEO: + expect(placement.playerSize).to.be.an('array'); + expect(placement.minduration).to.be.an('number'); + expect(placement.maxduration).to.be.an('number'); + break; + case NATIVE: + expect(placement.native).to.be.an('object'); + break; + } + } + }); + + it('Returns data with gdprConsent and without uspConsent', function () { + delete bidderRequest.uspConsent; + serverRequest = spec.buildRequests(bids, bidderRequest); + let data = serverRequest.data; + expect(data.gdpr).to.exist; + expect(data.gdpr).to.be.a('object'); + expect(data.ccpa).to.not.exist; + delete bidderRequest.gdprConsent; + }); + + it('Returns data with uspConsent and without gdprConsent', function () { + bidderRequest.uspConsent = '1---'; + delete bidderRequest.gdprConsent; + serverRequest = spec.buildRequests(bids, bidderRequest); + let data = serverRequest.data; + expect(data.ccpa).to.exist; + expect(data.ccpa).to.be.a('string'); + expect(data.ccpa).to.equal(bidderRequest.uspConsent); + expect(data.gdpr).to.not.exist; + }); + + it('Returns empty data if no valid requests are passed', function () { + serverRequest = spec.buildRequests([], bidderRequest); + let data = serverRequest.data; + expect(data.placements).to.be.an('array').that.is.empty; + }); + }); + + describe('interpretResponse', function () { + it('Should interpret banner response', function () { + const banner = { + body: [{ + mediaType: 'banner', + width: 300, + height: 250, + cpm: 0.4, + ad: 'Test', + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let bannerResponses = spec.interpretResponse(banner); + expect(bannerResponses).to.be.an('array').that.is.not.empty; + let dataItem = bannerResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta'); + expect(dataItem.requestId).to.equal(banner.body[0].requestId); + expect(dataItem.cpm).to.equal(banner.body[0].cpm); + expect(dataItem.width).to.equal(banner.body[0].width); + expect(dataItem.height).to.equal(banner.body[0].height); + expect(dataItem.ad).to.equal(banner.body[0].ad); + expect(dataItem.ttl).to.equal(banner.body[0].ttl); + expect(dataItem.creativeId).to.equal(banner.body[0].creativeId); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal(banner.body[0].currency); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + }); + it('Should interpret video response', function () { + const video = { + body: [{ + vastUrl: 'test.com', + mediaType: 'video', + cpm: 0.5, + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let videoResponses = spec.interpretResponse(video); + expect(videoResponses).to.be.an('array').that.is.not.empty; + + let dataItem = videoResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta'); + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.5); + expect(dataItem.vastUrl).to.equal('test.com'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + }); + it('Should interpret native response', function () { + const native = { + body: [{ + mediaType: 'native', + native: { + clickUrl: 'test.com', + title: 'Test', + image: 'test.com', + impressionTrackers: ['test.com'], + }, + ttl: 120, + cpm: 0.4, + requestId: '23fhj33i987f', + creativeId: '2', + netRevenue: true, + currency: 'USD', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let nativeResponses = spec.interpretResponse(native); + expect(nativeResponses).to.be.an('array').that.is.not.empty; + + let dataItem = nativeResponses[0]; + expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native', 'meta'); + expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image') + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.4); + expect(dataItem.native.clickUrl).to.equal('test.com'); + expect(dataItem.native.title).to.equal('Test'); + expect(dataItem.native.image).to.equal('test.com'); + expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty; + expect(dataItem.native.impressionTrackers[0]).to.equal('test.com'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + }); + it('Should return an empty array if invalid banner response is passed', function () { + const invBanner = { + body: [{ + width: 300, + cpm: 0.4, + ad: 'Test', + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + + let serverResponses = spec.interpretResponse(invBanner); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid video response is passed', function () { + const invVideo = { + body: [{ + mediaType: 'video', + cpm: 0.5, + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let serverResponses = spec.interpretResponse(invVideo); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid native response is passed', function () { + const invNative = { + body: [{ + mediaType: 'native', + clickUrl: 'test.com', + title: 'Test', + impressionTrackers: ['test.com'], + ttl: 120, + requestId: '23fhj33i987f', + creativeId: '2', + netRevenue: true, + currency: 'USD', + }] + }; + let serverResponses = spec.interpretResponse(invNative); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid response is passed', function () { + const invalid = { + body: [{ + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let serverResponses = spec.interpretResponse(invalid); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + }); +}); From 19fce05a2ee0c6fc4f7d6c2217ba19feb5dc220e Mon Sep 17 00:00:00 2001 From: ecoeco163 <147788250+ecoeco163@users.noreply.github.com> Date: Fri, 12 Apr 2024 21:17:36 +0800 Subject: [PATCH 06/12] Discovery Bid Adapter : build UTM tag data (#11317) * feat(isBidRequestValid): just filter token once. not filter publisher and tagid * feat(isBidRequestValid): add unit test * feat(spec): fix eslint * feat(spec): fix unit test * feat(spec): fix unit test * feat(ext): change default value * feat(utm): build UTMTag data * feat(spec): fix utm test --------- Co-authored-by: yubei01 --- modules/discoveryBidAdapter.js | 21 +++++++++++ test/spec/modules/discoveryBidAdapter_spec.js | 36 ++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/modules/discoveryBidAdapter.js b/modules/discoveryBidAdapter.js index de2fd3c3a94..7493dcb9af4 100644 --- a/modules/discoveryBidAdapter.js +++ b/modules/discoveryBidAdapter.js @@ -25,6 +25,9 @@ const COOKIE_RETENTION_TIME = 365 * 24 * 60 * 60 * 1000; // 1 year const COOKY_SYNC_IFRAME_URL = 'https://asset.popin.cc/js/cookieSync.html'; export const THIRD_PARTY_COOKIE_ORIGIN = 'https://asset.popin.cc'; +const UTM_KEY = '_ss_pp_utm'; +let UTMValue = {}; + const NATIVERET = { id: 'id', bidfloor: 0, @@ -409,6 +412,20 @@ function getItems(validBidRequests, bidderRequest) { return items; } +export const buildUTMTagData = (url) => { + if (!storage.cookiesAreEnabled()) return; + const urlParams = utils.parseUrl(url).search; + const UTMParams = {}; + Object.keys(urlParams).forEach(key => { + if (/^utm_/.test(key)) { + UTMParams[key] = urlParams[key]; + } + }); + UTMValue = JSON.parse(storage.getCookie(UTM_KEY) || '{}'); + Object.assign(UTMValue, UTMParams); + storage.setCookie(UTM_KEY, JSON.stringify(UTMValue), getCurrentTimeToUTCString()); +} + /** * get rtb qequest params * @@ -443,6 +460,10 @@ function getParam(validBidRequests, bidderRequest) { const desc = getPageDescription(); const keywords = getPageKeywords(); + try { + buildUTMTagData(page); + } catch (error) { } + if (items && items.length) { let c = { // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 diff --git a/test/spec/modules/discoveryBidAdapter_spec.js b/test/spec/modules/discoveryBidAdapter_spec.js index f1475ec3739..d148d5062a4 100644 --- a/test/spec/modules/discoveryBidAdapter_spec.js +++ b/test/spec/modules/discoveryBidAdapter_spec.js @@ -9,7 +9,8 @@ import { getConnectionDownLink, THIRD_PARTY_COOKIE_ORIGIN, COOKIE_KEY_MGUID, - getCurrentTimeToUTCString + getCurrentTimeToUTCString, + buildUTMTagData } from 'modules/discoveryBidAdapter.js'; import * as utils from 'src/utils.js'; @@ -252,6 +253,39 @@ describe('discovery:BidAdapterTests', function () { expect(storage.setCookie.calledOnce).to.be.false; }); }) + describe('buildUTMTagData function', function() { + let sandbox; + + beforeEach(() => { + sandbox = sinon.sandbox.create(); + sandbox.stub(storage, 'getCookie'); + sandbox.stub(storage, 'setCookie'); + sandbox.stub(utils, 'parseUrl').returns({ + search: { + utm_source: 'example.com' + } + }); + sandbox.stub(storage, 'cookiesAreEnabled'); + }) + + afterEach(() => { + sandbox.restore(); + }); + + it('should set UTM cookie', () => { + storage.cookiesAreEnabled.callsFake(() => true); + storage.getCookie.callsFake(() => null); + buildUTMTagData(); + expect(storage.setCookie.calledOnce).to.be.true; + }); + + it('should not set UTM when cookies are not enabled', () => { + storage.cookiesAreEnabled.callsFake(() => false); + storage.getCookie.callsFake(() => null); + buildUTMTagData(); + expect(storage.setCookie.calledOnce).to.be.false; + }); + }) }); it('discovery:validate_response_params', function () { From bee8ce7d041c2f90b1fec0a48b08070eb8a980c3 Mon Sep 17 00:00:00 2001 From: "Prebid.js automated release" Date: Fri, 12 Apr 2024 17:15:41 +0000 Subject: [PATCH 07/12] Prebid 8.44.0 release --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index b65a43a197e..a641f81805c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "prebid.js", - "version": "8.44.0-pre", + "version": "8.44.0", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index b7a1e1bafab..463c0aed8ec 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prebid.js", - "version": "8.44.0-pre", + "version": "8.44.0", "description": "Header Bidding Management Library", "main": "src/prebid.js", "scripts": { From eb9b407b3056e333111c48c9477bf619f66262cb Mon Sep 17 00:00:00 2001 From: "Prebid.js automated release" Date: Fri, 12 Apr 2024 17:15:41 +0000 Subject: [PATCH 08/12] Increment version to 8.45.0-pre --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index a641f81805c..6fb87a7dcdd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "prebid.js", - "version": "8.44.0", + "version": "8.45.0-pre", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index 463c0aed8ec..88a72f3c258 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prebid.js", - "version": "8.44.0", + "version": "8.45.0-pre", "description": "Header Bidding Management Library", "main": "src/prebid.js", "scripts": { From 32eebd03e987483933475e46edb11fe7c4e1c75e Mon Sep 17 00:00:00 2001 From: kapil-tuptewar <91458408+kapil-tuptewar@users.noreply.github.com> Date: Mon, 15 Apr 2024 16:41:59 +0530 Subject: [PATCH 09/12] removed transformbidparams from pubmaticbidadapter (#11328) --- modules/pubmaticBidAdapter.js | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/modules/pubmaticBidAdapter.js b/modules/pubmaticBidAdapter.js index f28feaa534d..846c59c1ae5 100644 --- a/modules/pubmaticBidAdapter.js +++ b/modules/pubmaticBidAdapter.js @@ -5,7 +5,6 @@ import { config } from '../src/config.js'; import { Renderer } from '../src/Renderer.js'; import { bidderSettings } from '../src/bidderSettings.js'; import CONSTANTS from '../src/constants.json'; -import {convertTypes} from '../libraries/transformParamsUtils/convertTypes.js'; /** * @typedef {import('../src/adapters/bidderFactory.js').BidRequest} BidRequest @@ -1448,20 +1447,6 @@ export const spec = { url: USER_SYNC_URL_IMAGE + syncurl }]; } - }, - - /** - * Covert bid param types for S2S - * @param {Object} params bid params - * @param {Boolean} isOpenRtb boolean to check openrtb2 protocol - * @return {Object} params bid params - */ - - transformBidParams: function (params, isOpenRtb, adUnit, bidRequests) { - return convertTypes({ - 'publisherId': 'string', - 'adSlot': 'string' - }, params); } }; From 7cbc29b74f60231cd3af29b0392dcd047d918912 Mon Sep 17 00:00:00 2001 From: Tachfine Date: Mon, 15 Apr 2024 13:23:22 +0200 Subject: [PATCH 10/12] Criteo Bid Adapter : add support for grid bid parameters (#11315) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ✨ Support optional pubid bid parameter * 🩹 Fix publisher id in test * ✨ Support optional uid bid parameter * 🩹 Bidder param uid is an integer --- modules/criteoBidAdapter.js | 9 +++++ test/spec/modules/criteoBidAdapter_spec.js | 47 ++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/modules/criteoBidAdapter.js b/modules/criteoBidAdapter.js index 2c0cacb7909..968a847708e 100644 --- a/modules/criteoBidAdapter.js +++ b/modules/criteoBidAdapter.js @@ -473,6 +473,7 @@ function checkNativeSendId(bidRequest) { */ function buildCdbRequest(context, bidRequests, bidderRequest) { let networkId; + let pubid; let schain; let userIdAsEids; let regs = Object.assign({}, { @@ -490,6 +491,7 @@ function buildCdbRequest(context, bidRequests, bidderRequest) { userIdAsEids = bidRequest.userIdAsEids; } networkId = bidRequest.params.networkId || networkId; + pubid = bidRequest.params.pubid || pubid; schain = bidRequest.schain || schain; const slot = { slotid: bidRequest.bidId, @@ -513,6 +515,10 @@ function buildCdbRequest(context, bidRequests, bidderRequest) { if (bidRequest.nativeOrtbRequest?.assets) { slot.ext = Object.assign({}, slot.ext, { assets: bidRequest.nativeOrtbRequest.assets }); } + if (bidRequest.params.uid) { + slot.ext = Object.assign({}, slot.ext, { bidder: { uid: bidRequest.params.uid } }); + } + if (bidRequest.params.publisherSubId) { slot.publishersubid = bidRequest.params.publisherSubId; } @@ -581,6 +587,9 @@ function buildCdbRequest(context, bidRequests, bidderRequest) { if (networkId) { request.publisher.networkid = networkId; } + if (pubid) { + request.publisher.id = pubid; + } request.source = { tid: bidderRequest.ortb2?.source?.tid diff --git a/test/spec/modules/criteoBidAdapter_spec.js b/test/spec/modules/criteoBidAdapter_spec.js index 2cdb09f2098..083ae368afb 100755 --- a/test/spec/modules/criteoBidAdapter_spec.js +++ b/test/spec/modules/criteoBidAdapter_spec.js @@ -1949,6 +1949,53 @@ describe('The Criteo bidding adapter', function () { expect(request.data.slots[0].ext).to.not.have.property('ae'); }); + it('should properly transmit the pubid and slot uid if available', function () { + const bidderRequest = {}; + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + ortb2Imp: { + ext: { + tid: 'transaction-123', + }, + }, + mediaTypes: { + banner: { + sizes: [[728, 90]] + } + }, + params: { + zoneId: 123, + }, + }, + { + bidder: 'criteo', + adUnitCode: 'bid-234', + ortb2Imp: { + ext: { + tid: 'transaction-234', + }, + }, + mediaTypes: { + banner: { + sizes: [[300, 250], [728, 90]] + } + }, + params: { + networkId: 456, + pubid: 'pub-888', + uid: 888 + }, + }, + ]; + const request = spec.buildRequests(bidRequests, bidderRequest); + const ortbRequest = request.data; + expect(ortbRequest.publisher.id).to.equal('pub-888'); + expect(request.data.slots[0].ext.bidder).to.be.undefined; + expect(request.data.slots[1].ext.bidder.uid).to.equal(888); + }); + it('should properly transmit device.ext.cdep if available', function () { const bidderRequest = { ortb2: { From 216c690cc54fa4163c13e05b68514c9b19bd97ce Mon Sep 17 00:00:00 2001 From: decemberWP <155962474+decemberWP@users.noreply.github.com> Date: Mon, 15 Apr 2024 14:41:03 +0200 Subject: [PATCH 11/12] Piridsystem: New ID System for WPM (#11267) 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 * add pirIdSystem * pirIdSystem * piridSystem - preCR * fix after CR --------- Co-authored-by: wojciech-bialy-wpm <67895844+wojciech-bialy-wpm@users.noreply.github.com> Co-authored-by: Wojciech Biały Co-authored-by: Wojciech Biały --- modules/pirIdSystem.js | 62 +++++++++++++++++++++ modules/pirIdSystem.md | 27 ++++++++++ test/spec/modules/pirIdSystem_spec.js | 77 +++++++++++++++++++++++++++ 3 files changed, 166 insertions(+) create mode 100644 modules/pirIdSystem.js create mode 100644 modules/pirIdSystem.md create mode 100644 test/spec/modules/pirIdSystem_spec.js diff --git a/modules/pirIdSystem.js b/modules/pirIdSystem.js new file mode 100644 index 00000000000..b891e1d362a --- /dev/null +++ b/modules/pirIdSystem.js @@ -0,0 +1,62 @@ +/** + * This module adds pirId to the User ID module + * The {@link module:modules/userId} module is required + * @module modules/pirId + * @requires module:modules/userId + */ + +import { MODULE_TYPE_UID } from '../src/activities/modules.js'; +import { getStorageManager } from '../src/storageManager.js'; +import { submodule } from '../src/hook.js'; +import {domainOverrideToRootDomain} from '../libraries/domainOverrideToRootDomain/index.js'; + +/** + * @typedef {import('../modules/userId/index.js').Submodule} Submodule + * @typedef {import('../modules/userId/index.js').IdResponse} IdResponse + */ + +const MODULE_NAME = 'pirId'; +const ID_TOKEN = 'WPxid'; +export const storage = getStorageManager({ moduleName: MODULE_NAME, moduleType: MODULE_TYPE_UID }); + +/** + * Reads the ID token from local storage or cookies. + * @returns {string|undefined} The ID token, or undefined if not found. + */ +export const readId = () => storage.getDataFromLocalStorage(ID_TOKEN) || storage.getCookie(ID_TOKEN); + +/** @type {Submodule} */ +export const pirIdSubmodule = { + name: MODULE_NAME, + gvlid: 676, + + /** + * decode the stored id value for passing to bid requests + * @function decode + * @param {string} value + * @returns {(Object|undefined)} + */ + decode(value) { + return typeof value === 'string' ? { 'pirId': value } : undefined; + }, + + /** + * performs action to obtain id and return a value + * @function + * @returns {(IdResponse|undefined)} + */ + getId() { + const pirIdToken = readId(); + + return pirIdToken ? { id: pirIdToken } : undefined; + }, + domainOverride: domainOverrideToRootDomain(storage, MODULE_NAME), + eids: { + 'pirId': { + source: 'pir.wp.pl', + atype: 1 + }, + }, +}; + +submodule('userId', pirIdSubmodule); diff --git a/modules/pirIdSystem.md b/modules/pirIdSystem.md new file mode 100644 index 00000000000..913804f85c4 --- /dev/null +++ b/modules/pirIdSystem.md @@ -0,0 +1,27 @@ +# Overview + +Module Name: pirIDSystem +Module Type: UserID Module +Maintainer: pawel.grudzien@grupawp.pl + +# Description + +User identification system for WPM + +### Prebid Params example + +``` +pbjs.setConfig({ + userSync: { + userIds: [{ + name: 'pirID', + storage: { + type: 'cookie', + name: 'pirIdToken', + expires: 7, + refreshInSeconds: 360 + }, + }] + } +}); +``` diff --git a/test/spec/modules/pirIdSystem_spec.js b/test/spec/modules/pirIdSystem_spec.js new file mode 100644 index 00000000000..5acc5a5eb9c --- /dev/null +++ b/test/spec/modules/pirIdSystem_spec.js @@ -0,0 +1,77 @@ +import { pirIdSubmodule, storage, readId } from 'modules/pirIdSystem.js'; +import sinon from 'sinon'; + +describe('pirIdSystem', () => { + let sandbox; + let getCookieStub; + let getDataFromLocalStorageStub; + + beforeEach(() => { + sandbox = sinon.createSandbox(); + getCookieStub = sandbox.stub(storage, 'getCookie'); + getDataFromLocalStorageStub = sandbox.stub(storage, 'getDataFromLocalStorage'); + }); + + afterEach(() => { + sandbox.restore(); + }); + + describe('getId', () => { + it('should return an object with id when pirIdToken is found', () => { + getDataFromLocalStorageStub.returns('testToken'); + getCookieStub.returns('testToken'); + + const result = pirIdSubmodule.getId(); + + expect(result).to.deep.equal({ id: 'testToken' }); + }); + + it('should return undefined when pirIdToken is not found', () => { + const result = pirIdSubmodule.getId(); + + expect(result).to.be.undefined; + }); + }); + + describe('decode', () => { + it('should return an object with pirId when value is a string', () => { + const result = pirIdSubmodule.decode('testId'); + + expect(result).to.deep.equal({ pirId: 'testId' }); + }); + + it('should return undefined when value is not a string', () => { + const result = pirIdSubmodule.decode({}); + + expect(result).to.be.undefined; + }); + }); + + describe('readId', () => { + it('should return data from local storage when it exists', () => { + getDataFromLocalStorageStub.returns('local_storage_data'); + + const result = readId(); + + expect(result).to.equal('local_storage_data'); + }); + + it('should return data from cookie when local storage data does not exist', () => { + getDataFromLocalStorageStub.returns(null); + getCookieStub.returns('cookie_data'); + + const result = readId(); + + expect(result).to.equal('cookie_data'); + }); + + it('should return null when neither local storage data nor cookie data exists', () => { + getDataFromLocalStorageStub.returns(null); + getCookieStub.returns(null); + + const result = readId(); + + expect(result).to.be.null; + }); + }); +}); From cf8cf49a7a3349f5aa984031d342f0a18a6da789 Mon Sep 17 00:00:00 2001 From: dalmenarDevST <116064809+dalmenarDevST@users.noreply.github.com> Date: Mon, 15 Apr 2024 15:46:15 +0200 Subject: [PATCH 12/12] add topics and eids to payload (#11338) --- modules/seedtagBidAdapter.js | 15 ++++-- test/spec/modules/seedtagBidAdapter_spec.js | 59 +++++++++++++++++++-- 2 files changed, 68 insertions(+), 6 deletions(-) diff --git a/modules/seedtagBidAdapter.js b/modules/seedtagBidAdapter.js index 6f36c8a191e..e17ff1301a3 100644 --- a/modules/seedtagBidAdapter.js +++ b/modules/seedtagBidAdapter.js @@ -1,7 +1,7 @@ -import { isArray, _map, triggerPixel } from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { VIDEO, BANNER } from '../src/mediaTypes.js'; import { config } from '../src/config.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import { _map, isArray, triggerPixel } from '../src/utils.js'; /** * @typedef {import('../src/adapters/bidderFactory.js').BidRequest} BidRequest @@ -125,7 +125,7 @@ function buildBidRequest(validBidRequest) { adUnitCode: validBidRequest.adUnitCode, geom: geom(validBidRequest.adUnitCode), placement: params.placement, - requestCount: validBidRequest.bidderRequestsCount || 1, // FIXME : in unit test the parameter bidderRequestsCount is undefined + requestCount: validBidRequest.bidderRequestsCount || 1, // FIXME : in unit test the parameter bidderRequestsCount is undefinedt }; if (hasVideoMediaType(validBidRequest)) { @@ -284,6 +284,7 @@ export const spec = { auctionStart: bidderRequest.auctionStart || Date.now(), ttfb: ttfb(), bidRequests: _map(validBidRequests, buildBidRequest), + user: { topics: [], eids: [] } }; if (payload.cmp) { @@ -316,7 +317,15 @@ export const spec = { } } + if (bidderRequest.ortb2?.user?.data) { + payload.user.topics = bidderRequest.ortb2.user.data + } + if (validBidRequests[0] && validBidRequests[0].userIdAsEids) { + payload.user.eids = validBidRequests[0].userIdAsEids + } + const payloadString = JSON.stringify(payload); + return { method: 'POST', url: SEEDTAG_SSP_ENDPOINT, diff --git a/test/spec/modules/seedtagBidAdapter_spec.js b/test/spec/modules/seedtagBidAdapter_spec.js index 516c5ec933a..2012c78d239 100644 --- a/test/spec/modules/seedtagBidAdapter_spec.js +++ b/test/spec/modules/seedtagBidAdapter_spec.js @@ -1,8 +1,8 @@ import { expect } from 'chai'; -import { spec, getTimeoutUrl } from 'modules/seedtagBidAdapter.js'; +import { getTimeoutUrl, spec } from 'modules/seedtagBidAdapter.js'; import * as utils from 'src/utils.js'; -import { config } from '../../../src/config.js'; import * as mockGpt from 'test/spec/integration/faker/googletag.js'; +import { config } from '../../../src/config.js'; const PUBLISHER_ID = '0000-0000-01'; const ADUNIT_ID = '000000'; @@ -536,8 +536,61 @@ describe('Seedtag Adapter', function () { expect(data.gppConsent).to.be.undefined; }); }); - }); + describe('User param', function () { + it('should be added to payload user data param when bidderRequest has ortb2 user info', function () { + var ortb2 = { + + user: { + + data: [ + { + ext: { + segtax: 601, + segclass: '4' + }, + segment: [ + { + id: '149' + } + ], + name: 'randomname' + } + + ] + } + } + bidderRequest['ortb2'] = ortb2 + const request = spec.buildRequests(validBidRequests, bidderRequest); + const data = JSON.parse(request.data); + + expect(data.user).to.exist; + expect(data.user.topics).to.exist; + expect(data.user.topics).to.be.an('array').that.is.not.empty; + expect(data.user.topics[0].ext).to.eql(ortb2.user.data[0].ext); + expect(data.user.topics[0].segment).to.eql(ortb2.user.data[0].segment); + expect(data.user.topics[0].name).to.eql(ortb2.user.data[0].name); + }) + + it('should be added to payload user eids param when validRequest has userId info', function () { + var userIdAsEids = [{ + source: 'sourceid', + uids: [{ + atype: 1, + id: 'randomId' + }] + }] + validBidRequests[0]['userIdAsEids'] = userIdAsEids + const request = spec.buildRequests(validBidRequests, bidderRequest); + const data = JSON.parse(request.data); + + expect(data.user).to.exist; + expect(data.user.eids).to.exist; + expect(data.user.eids).to.be.an('array').that.is.not.empty; + expect(data.user.eids).to.deep.equal(userIdAsEids); + }) + }); + }) describe('interpret response method', function () { it('should return a void array, when the server response are not correct.', function () { const request = { data: JSON.stringify({}) };