From c71462b5ea841fbe1c0bbbeedf42c88620a33420 Mon Sep 17 00:00:00 2001 From: PavloMalashnyak <99171840+PavloMalashnyak@users.noreply.github.com> Date: Tue, 17 Oct 2023 14:59:50 +0300 Subject: [PATCH 01/17] PE-87: Implement Prebid Adapter (#1) * PE-87: implement BT Bid Adapter * PE-87: rework adapter to use ortbConverter lib, make requested changes * PE-87: update imports --- modules/BTBidAdapter.js | 133 ++++++++++++++++++++++ modules/BTBidAdapter.md | 44 ++++++++ test/spec/modules/BTBidAdapte_spec.js | 154 ++++++++++++++++++++++++++ 3 files changed, 331 insertions(+) create mode 100644 modules/BTBidAdapter.js create mode 100644 modules/BTBidAdapter.md create mode 100644 test/spec/modules/BTBidAdapte_spec.js diff --git a/modules/BTBidAdapter.js b/modules/BTBidAdapter.js new file mode 100644 index 00000000000..84ccb37655b --- /dev/null +++ b/modules/BTBidAdapter.js @@ -0,0 +1,133 @@ +import { config } from '../src/config.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { deepSetValue, isBoolean, isStr, logWarn } from '../src/utils.js'; +import { BANNER } from '../src/mediaTypes.js'; +import { ortbConverter } from '../libraries/ortbConverter/converter.js'; + +const BIDDER_CODE = 'blockthrough'; +const GVLID = 815; +const ENDPOINT_URL = 'https://pbs.btloader.com/openrtb2/auction'; + +const CONVERTER = ortbConverter({ + context: { + netRevenue: true, + ttl: 30, + }, + imp, + request, +}); + +/** + * Builds an impression object for the ORTB 2.5 request. + * + * @param {function} buildImp - The function for building an imp object. + * @param {Object} bidRequest - The bid request object. + * @param {Object} context - The context object. + * @returns {Object} The ORTB 2.5 imp object. + */ +function imp(buildImp, bidRequest, context) { + const imp = buildImp(bidRequest, context); + const { params, ortb2Imp } = bidRequest; + + if (params) { + const { siteId, ab, ...btBidParams } = params; + Object.assign(imp, { ext: btBidParams, siteId, ab }); + } + if (ortb2Imp?.ext.gpid) { + deepSetValue(imp, 'gpid', ortb2Imp.ext.gpid); + } + + return imp; +} + +/** + * Builds a request object for the ORTB 2.5 request. + * + * @param {function} buildRequest - The function for building a request object. + * @param {Array} imps - An array of ORTB 2.5 impression objects. + * @param {Object} bidderRequest - The bidder request object. + * @param {Object} context - The context object. + * @returns {Object} The ORTB 2.5 request object. + */ +function request(buildRequest, imps, bidderRequest, context) { + const request = buildRequest(imps, bidderRequest, context); + if (config.getConfig('debug')) { + request.test = 1; + } + + return request; +} + +/** + * Checks if a bid request is valid. + * + * @param {Object} bid - The bid request object. + * @returns {boolean} True if the bid request is valid, false otherwise. + */ +function isBidRequestValid(bid) { + const { ab, siteId } = bid.params; + + if (!siteId || !isStr(siteId)) { + logWarn('BT Bid Adapter: siteId must be string type.'); + return false; + } + + if (!ab || !isBoolean(ab)) { + logWarn('BT Bid Adapter: ab must be boolean type.'); + return false; + } + + return true; +} + +/** + * Builds the bid requests for the BT Service. + * + * @param {Array} validBidRequests - An array of valid bid request objects. + * @param {Object} bidderRequest - The bidder request object. + * @returns {Array} An array of BT Service bid requests. + */ +function buildRequests(validBidRequests, bidderRequest) { + const data = CONVERTER.toORTB({ + bidRequests: validBidRequests, + bidderRequest, + }); + + return [ + { + method: 'POST', + url: ENDPOINT_URL, + data, + bids: validBidRequests, + }, + ]; +} + +/** + * Interprets the server response and maps it to bids. + * + * @param {Object} serverResponse - The server response object. + * @param {Object} request - The request object. + * @returns {Array} An array of bid objects. + */ +function interpretResponse(serverResponse, request) { + if (!serverResponse || !request) { + return []; + } + + return CONVERTER.fromORTB({ + response: serverResponse.body, + request: request.data, + }).bids; +} + +export const spec = { + code: BIDDER_CODE, + gvlid: GVLID, + supportedMediaTypes: [BANNER], + isBidRequestValid, + buildRequests, + interpretResponse, +}; + +registerBidder(spec); diff --git a/modules/BTBidAdapter.md b/modules/BTBidAdapter.md new file mode 100644 index 00000000000..f8e9e19a3b8 --- /dev/null +++ b/modules/BTBidAdapter.md @@ -0,0 +1,44 @@ +# Overview + +**Module Name**: BT Bidder Adapter +**Module Type**: Bidder Adapter +**Maintainer**: engsupport@blockthrough.com + +# Description + +The BT Bidder Adapter provides an interface to the BT Service. The BT Bidder Adapter sends one request to the BT Service per ad unit. Behind the scenes, the BT Service further disperses requests to various configured exchanges. This operational model closely resembles that of Prebid Server, where a single request is made from the client side, and responses are gathered from multiple exchanges. + +# Bid Params + +| Key | Scope | Type | Description | +| ------ | -------- | ------- | -------------------------------------------------------------- | +| ab | Required | Boolean | Whether AdBlock is enabled. | +| siteId | Required | String | Unique site ID. | +| bidder | Required | Object | Bidder configuration. Could configure several bidders this way | + +## AdUnits configuration example + +``` + var adUnits = [{ + code: 'banner-div-1', + mediaTypes: { + banner: { + sizes: [[728, 90]] + } + }, + bids: [{ + bidder: 'blockthrough', + params: { + ab: true, + siteId: '12345', + bidderA: { + publisherId: 55555, + }, + bidderB: { + zoneId: 12, + } + } + }] + }]; + +``` diff --git a/test/spec/modules/BTBidAdapte_spec.js b/test/spec/modules/BTBidAdapte_spec.js new file mode 100644 index 00000000000..59230a45dbd --- /dev/null +++ b/test/spec/modules/BTBidAdapte_spec.js @@ -0,0 +1,154 @@ +import { expect } from 'chai'; +import { spec } from 'modules/BTBidAdapter.js'; +import { BANNER } from '../../../src/mediaTypes.js'; +// load modules that register ORTB processors +import 'src/prebid.js'; +import 'modules/currency.js'; +import 'modules/userId/index.js'; +import 'modules/multibid/index.js'; +import 'modules/priceFloors.js'; +import 'modules/consentManagement.js'; +import 'modules/consentManagementUsp.js'; +import 'modules/consentManagementGpp.js'; +import 'modules/enrichmentFpdModule.js'; +import 'modules/gdprEnforcement.js'; +import 'modules/gppControl_usnat.js'; +import 'modules/schain.js'; + +describe('BT Bid Adapter', () => { + const ENDPOINT_URL = 'https://pbs.btloader.com/openrtb2/auction'; + const validBidRequests = [ + { + bidId: '2e9f38ea93bb9e', + bidder: 'blockthrough', + adUnitCode: 'adunit-code', + mediaTypes: { [BANNER]: { sizes: [[300, 250]] } }, + params: { + ab: true, + siteId: '55555', + bidderA: { + pubId: '11111', + }, + }, + bidderRequestId: 'test-bidder-request-id', + auctionId: 'test-auction-id', + }, + ]; + const bidderRequest = { + auctionId: 'test-auction-id', + bidderCode: 'blockthrough', + bidderRequestId: 'test-bidder-request-id', + bids: validBidRequests, + }; + + describe('isBidRequestValid', function () { + it('should validate bid request with valid params', () => { + const validBid = { + params: { + ab: true, + siteId: 'exampleSiteId', + pubmatic: { + publisherId: 55555, + }, + }, + sizes: [[300, 250]], + bidId: '123', + adUnitCode: 'leaderboard', + }; + + const isValid = spec.isBidRequestValid(validBid); + + expect(isValid).to.be.true; + }); + + it('should not validate bid request with invalid params', () => { + const invalidBid = { + params: {}, + sizes: [[300, 250]], + bidId: '123', + adUnitCode: 'leaderboard', + }; + + const isValid = spec.isBidRequestValid(invalidBid); + + expect(isValid).to.be.false; + }); + }); + + describe('buildRequests', () => { + it('should build post request when ortb2 fields are present', () => { + const bidderParams = { + bidderA: { + pubId: '11111', + }, + }; + + const requests = spec.buildRequests(validBidRequests, bidderRequest); + + expect(requests[0].method).to.equal('POST'); + expect(requests[0].url).to.equal(ENDPOINT_URL); + expect(requests[0].data).to.exist; + expect(requests[0].data.imp[0].ext).to.deep.equal(bidderParams); + expect(requests[0].data.imp[0].ab).to.be.true; + expect(requests[0].data.imp[0].siteId).to.equal('55555'); + }); + }); + + describe('interpretResponse', () => { + it('should return empty array if serverResponse is not defined', () => { + const bidRequest = spec.buildRequests(validBidRequests, bidderRequest); + const bids = spec.interpretResponse(undefined, bidRequest); + + expect(bids.length).to.equal(0); + }); + + it('should return bids array when serverResponse is defined and seatbid array is not empty', () => { + const bidResponse = { + body: { + id: 'bid-response', + cur: 'USD', + seatbid: [ + { + bid: [ + { + impid: '2e9f38ea93bb9e', + crid: 'creative-id', + cur: 'USD', + price: 9, + price: 2, + w: 300, + h: 250, + mtype: 1, + adomain: ['test.com'], + }, + ], + }, + ], + }, + }; + + const expectedBids = [ + { + cpm: 2, + creativeId: 'creative-id', + creative_id: 'creative-id', + currency: 'USD', + height: 250, + mediaType: 'banner', + meta: { + advertiserDomains: ['test.com'], + }, + netRevenue: true, + requestId: '2e9f38ea93bb9e', + ttl: 30, + width: 300, + }, + ]; + + const request = spec.buildRequests(validBidRequests, bidderRequest)[0]; + const bids = spec.interpretResponse(bidResponse, request); + + expect(bids).to.deep.equal(expectedBids); + }); + }); +}); From 9ded78cce57db83d9d30eaef64a6fd7f16af4419 Mon Sep 17 00:00:00 2001 From: PavloMalashnyak <99171840+PavloMalashnyak@users.noreply.github.com> Date: Thu, 26 Oct 2023 16:12:47 +0300 Subject: [PATCH 02/17] PE-110: Add user sync logic to the Prebid Adapter (#3) * PE-110: add user sync logic * PE-110: update userSync url * PE-110: check if iframe is enabled before setting params --- modules/BTBidAdapter.js | 41 ++++++++++++++++++++++++ test/spec/modules/BTBidAdapte_spec.js | 45 +++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) diff --git a/modules/BTBidAdapter.js b/modules/BTBidAdapter.js index 84ccb37655b..c9680322f07 100644 --- a/modules/BTBidAdapter.js +++ b/modules/BTBidAdapter.js @@ -7,6 +7,7 @@ import { ortbConverter } from '../libraries/ortbConverter/converter.js'; const BIDDER_CODE = 'blockthrough'; const GVLID = 815; const ENDPOINT_URL = 'https://pbs.btloader.com/openrtb2/auction'; +const SYNC_URL = 'https://cdn.btloader.com/user_sync.html'; const CONVERTER = ortbConverter({ context: { @@ -121,6 +122,45 @@ function interpretResponse(serverResponse, request) { }).bids; } +/** + * Generates user synchronization data based on provided options and consents. + * + * @param {Object} syncOptions - Synchronization options. + * @param {Object[]} serverResponses - An array of server responses. + * @param {Object} gdprConsent - GDPR consent information. + * @param {string} uspConsent - US Privacy consent string. + * @param {Object} gppConsent - Google Publisher Policies (GPP) consent information. + * @returns {Object[]} An array of user synchronization objects. + */ +function getUserSyncs( + syncOptions, + serverResponses, + gdprConsent, + uspConsent, + gppConsent +) { + let syncs = []; + const syncUrl = new URL(SYNC_URL); + + if (syncOptions.iframeEnabled) { + if (gdprConsent) { + syncUrl.searchParams.set('gdpr', Number(gdprConsent.gdprApplies)); + syncUrl.searchParams.set('gdpr_consent', gdprConsent.consentString); + } + if (gppConsent) { + syncUrl.searchParams.set('gpp', gppConsent.gppString); + syncUrl.searchParams.set('gpp_sid', gppConsent.applicableSections); + } + if (uspConsent) { + syncUrl.searchParams.set('us_privacy', uspConsent); + } + + syncs.push({ type: 'iframe', url: syncUrl.href }); + } + + return syncs; +} + export const spec = { code: BIDDER_CODE, gvlid: GVLID, @@ -128,6 +168,7 @@ export const spec = { isBidRequestValid, buildRequests, interpretResponse, + getUserSyncs, }; registerBidder(spec); diff --git a/test/spec/modules/BTBidAdapte_spec.js b/test/spec/modules/BTBidAdapte_spec.js index 59230a45dbd..10a282f5d53 100644 --- a/test/spec/modules/BTBidAdapte_spec.js +++ b/test/spec/modules/BTBidAdapte_spec.js @@ -151,4 +151,49 @@ describe('BT Bid Adapter', () => { expect(bids).to.deep.equal(expectedBids); }); }); + + describe('getUserSyncs', () => { + const SYNC_URL = 'https://cdn.btloader.com/user_sync.html'; + + it('should return an empty array if no sync options are provided', () => { + const syncs = spec.getUserSyncs({}, [], null, null, null); + + expect(syncs).to.deep.equal([]); + }); + + it('should include consent parameters in sync URL if they are provided', () => { + const gdprConsent = { + gdprApplies: true, + consentString: 'GDPRConsentString123', + }; + const gppConsent = { + gppString: 'GPPString123', + applicableSections: ['sectionA'], + }; + const us_privacy = '1YNY'; + const expectedSyncUrl = `${SYNC_URL}?gdpr=1&gdpr_consent=${gdprConsent.consentString}&gpp=${gppConsent.gppString}&gpp_sid=sectionA&us_privacy=${us_privacy}`; + + const syncs = spec.getUserSyncs( + { iframeEnabled: true }, + [], + gdprConsent, + us_privacy, + gppConsent + ); + + expect(syncs).to.deep.equal([{ type: 'iframe', url: expectedSyncUrl }]); + }); + + it('should not include any consent parameters if no consents are provided', () => { + const syncs = spec.getUserSyncs( + { iframeEnabled: true }, + [], + null, + null, + null + ); + + expect(syncs).to.deep.equal([{ type: 'iframe', url: SYNC_URL }]); + }); + }); }); From f8de65a0940e3ee792e381305c375947505e2228 Mon Sep 17 00:00:00 2001 From: PavloMalashnyak <99171840+PavloMalashnyak@users.noreply.github.com> Date: Wed, 8 Nov 2023 16:42:59 +0200 Subject: [PATCH 03/17] PE-111: BT Prebid Adapter can request AA ads or regular ads (#2) --- modules/BTBidAdapter.js | 8 +++++++- test/spec/modules/BTBidAdapte_spec.js | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/BTBidAdapter.js b/modules/BTBidAdapter.js index c9680322f07..62b820e7e94 100644 --- a/modules/BTBidAdapter.js +++ b/modules/BTBidAdapter.js @@ -32,7 +32,7 @@ function imp(buildImp, bidRequest, context) { if (params) { const { siteId, ab, ...btBidParams } = params; - Object.assign(imp, { ext: btBidParams, siteId, ab }); + Object.assign(imp, { ext: btBidParams }); } if (ortb2Imp?.ext.gpid) { deepSetValue(imp, 'gpid', ortb2Imp.ext.gpid); @@ -52,6 +52,12 @@ function imp(buildImp, bidRequest, context) { */ function request(buildRequest, imps, bidderRequest, context) { const request = buildRequest(imps, bidderRequest, context); + const { params } = bidderRequest.bids?.[0] || {}; + + if (params) { + const { ab, siteId } = params; + deepSetValue(request, 'site.ext.blockthrough', { ab, siteId }); + } if (config.getConfig('debug')) { request.test = 1; } diff --git a/test/spec/modules/BTBidAdapte_spec.js b/test/spec/modules/BTBidAdapte_spec.js index 10a282f5d53..107bbaa7bf1 100644 --- a/test/spec/modules/BTBidAdapte_spec.js +++ b/test/spec/modules/BTBidAdapte_spec.js @@ -89,8 +89,8 @@ describe('BT Bid Adapter', () => { expect(requests[0].url).to.equal(ENDPOINT_URL); expect(requests[0].data).to.exist; expect(requests[0].data.imp[0].ext).to.deep.equal(bidderParams); - expect(requests[0].data.imp[0].ab).to.be.true; - expect(requests[0].data.imp[0].siteId).to.equal('55555'); + expect(requests[0].data.site.ext.blockthrough.ab).to.be.true; + expect(requests[0].data.site.ext.blockthrough.siteId).to.equal('55555'); }); }); From 8d9d4998ca60a1d8a398d50648ccd4d4de941282 Mon Sep 17 00:00:00 2001 From: PavloMalashnyak <99171840+PavloMalashnyak@users.noreply.github.com> Date: Tue, 14 Nov 2023 17:50:49 +0200 Subject: [PATCH 04/17] PE-120: Send Prebid Bidder info to BT Server (#4) * PE-120: add btBidderCode to the bid object * PE-120: use single quotes for logs string --- modules/BTBidAdapter.js | 23 ++++++++++++++++++++--- test/spec/modules/BTBidAdapte_spec.js | 3 ++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/modules/BTBidAdapter.js b/modules/BTBidAdapter.js index 62b820e7e94..50aa5028b75 100644 --- a/modules/BTBidAdapter.js +++ b/modules/BTBidAdapter.js @@ -16,6 +16,7 @@ const CONVERTER = ortbConverter({ }, imp, request, + bidResponse, }); /** @@ -65,6 +66,22 @@ function request(buildRequest, imps, bidderRequest, context) { return request; } +/** + * Processes a bid response using the provided build function, bid, and context. + * + * @param {Function} buildBidResponse - The function to build the bid response. + * @param {Object} bid - The bid object to include in the bid response. + * @param {Object} context - The context object containing additional information. + * @returns {Object} - The processed bid response. + */ +function bidResponse(buildBidResponse, bid, context) { + const bidResponse = buildBidResponse(bid, context); + const { seat } = context.seatbid || {}; + bidResponse.btBidderCode = seat; + + return bidResponse; +} + /** * Checks if a bid request is valid. * @@ -75,12 +92,12 @@ function isBidRequestValid(bid) { const { ab, siteId } = bid.params; if (!siteId || !isStr(siteId)) { - logWarn('BT Bid Adapter: siteId must be string type.'); + logWarn('BT Bid Adapter: a string type "siteId" must be provided.'); return false; } - if (!ab || !isBoolean(ab)) { - logWarn('BT Bid Adapter: ab must be boolean type.'); + if (!isBoolean(ab)) { + logWarn('BT Bid Adapter: a boolean type "ab" must be provided.'); return false; } diff --git a/test/spec/modules/BTBidAdapte_spec.js b/test/spec/modules/BTBidAdapte_spec.js index 107bbaa7bf1..6312ea4f4f1 100644 --- a/test/spec/modules/BTBidAdapte_spec.js +++ b/test/spec/modules/BTBidAdapte_spec.js @@ -114,7 +114,6 @@ describe('BT Bid Adapter', () => { impid: '2e9f38ea93bb9e', crid: 'creative-id', cur: 'USD', - price: 9, price: 2, w: 300, h: 250, @@ -122,6 +121,7 @@ describe('BT Bid Adapter', () => { adomain: ['test.com'], }, ], + seat: 'test-seat', }, ], }, @@ -129,6 +129,7 @@ describe('BT Bid Adapter', () => { const expectedBids = [ { + btBidderCode: 'test-seat', cpm: 2, creativeId: 'creative-id', creative_id: 'creative-id', From fbd21effe3c9c8015805dc962dcd79fb6c6e3e7f Mon Sep 17 00:00:00 2001 From: PavloMalashnyak <99171840+PavloMalashnyak@users.noreply.github.com> Date: Tue, 28 Nov 2023 16:45:28 +0200 Subject: [PATCH 05/17] PE-123: Add More Metadata in site.ext.blockthrough (#5) * PE-123: send additional meta data * PE-123: send auctionID under imp.ext.prebid.blockthrough * PE-123: use ortb2 config to set site.ext params * PE-123: sent auctionId in ext.prebid.blockthrough.auctionID * PE-123: update logs for bidderConfig setup --- modules/BTBidAdapter.js | 31 +++++------ modules/BTBidAdapter.md | 76 ++++++++++++++++++--------- test/spec/modules/BTBidAdapte_spec.js | 18 +++---- 3 files changed, 72 insertions(+), 53 deletions(-) diff --git a/modules/BTBidAdapter.js b/modules/BTBidAdapter.js index 50aa5028b75..63a75c132f8 100644 --- a/modules/BTBidAdapter.js +++ b/modules/BTBidAdapter.js @@ -1,6 +1,6 @@ import { config } from '../src/config.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { deepSetValue, isBoolean, isStr, logWarn } from '../src/utils.js'; +import { deepSetValue, isPlainObject, logWarn } from '../src/utils.js'; import { BANNER } from '../src/mediaTypes.js'; import { ortbConverter } from '../libraries/ortbConverter/converter.js'; @@ -32,8 +32,16 @@ function imp(buildImp, bidRequest, context) { const { params, ortb2Imp } = bidRequest; if (params) { - const { siteId, ab, ...btBidParams } = params; - Object.assign(imp, { ext: btBidParams }); + const { blockthrough, ...btBidderParams } = params; + + deepSetValue(imp, 'ext', btBidderParams); + if (blockthrough.auctionID) { + deepSetValue( + imp, + 'ext.prebid.blockthrough.auctionID', + blockthrough.auctionID + ); + } } if (ortb2Imp?.ext.gpid) { deepSetValue(imp, 'gpid', ortb2Imp.ext.gpid); @@ -53,12 +61,6 @@ function imp(buildImp, bidRequest, context) { */ function request(buildRequest, imps, bidderRequest, context) { const request = buildRequest(imps, bidderRequest, context); - const { params } = bidderRequest.bids?.[0] || {}; - - if (params) { - const { ab, siteId } = params; - deepSetValue(request, 'site.ext.blockthrough', { ab, siteId }); - } if (config.getConfig('debug')) { request.test = 1; } @@ -89,15 +91,8 @@ function bidResponse(buildBidResponse, bid, context) { * @returns {boolean} True if the bid request is valid, false otherwise. */ function isBidRequestValid(bid) { - const { ab, siteId } = bid.params; - - if (!siteId || !isStr(siteId)) { - logWarn('BT Bid Adapter: a string type "siteId" must be provided.'); - return false; - } - - if (!isBoolean(ab)) { - logWarn('BT Bid Adapter: a boolean type "ab" must be provided.'); + if (!isPlainObject(bid.params) || !Object.keys(bid.params).length) { + logWarn('BT Bid Adapter: bid params must be provided.'); return false; } diff --git a/modules/BTBidAdapter.md b/modules/BTBidAdapter.md index f8e9e19a3b8..7897cee1a2a 100644 --- a/modules/BTBidAdapter.md +++ b/modules/BTBidAdapter.md @@ -8,37 +8,63 @@ The BT Bidder Adapter provides an interface to the BT Service. The BT Bidder Adapter sends one request to the BT Service per ad unit. Behind the scenes, the BT Service further disperses requests to various configured exchanges. This operational model closely resembles that of Prebid Server, where a single request is made from the client side, and responses are gathered from multiple exchanges. +The BT adapter requires setup and approval from the Blockthrough team. Please reach out to marketing@blockthrough.com for more information. + # Bid Params -| Key | Scope | Type | Description | -| ------ | -------- | ------- | -------------------------------------------------------------- | -| ab | Required | Boolean | Whether AdBlock is enabled. | -| siteId | Required | String | Unique site ID. | -| bidder | Required | Object | Bidder configuration. Could configure several bidders this way | +| Key | Scope | Type | Description | +| ------ | -------- | ------ | -------------------------------------------------------------- | +| bidder | Required | Object | Bidder configuration. Could configure several bidders this way | -## AdUnits configuration example +# Bidder Config + +Make sure to set ab, orgID, websiteID values received after approval using `pbjs.setBidderConfig`. +## Example + +```javascript +pbjs.setBidderConfig({ + bidders: ['blockthrough'], + config: { + ortb2: { + site: { + ext: { + blockthrough: { + ab: false, + orgID: 'orgID', + websiteID: 'websiteID', + }, + }, + }, + }, + }, +}); ``` - var adUnits = [{ - code: 'banner-div-1', - mediaTypes: { - banner: { - sizes: [[728, 90]] - } + +## AdUnits configuration example + +```javascript +var adUnits = [ + { + code: 'banner-div-1', + mediaTypes: { + banner: { + sizes: [[728, 90]], }, - bids: [{ + }, + bids: [ + { bidder: 'blockthrough', params: { - ab: true, - siteId: '12345', - bidderA: { - publisherId: 55555, - }, - bidderB: { - zoneId: 12, - } - } - }] - }]; - + bidderA: { + publisherId: 55555, + }, + bidderB: { + zoneId: 12, + }, + }, + }, + ], + }, +]; ``` diff --git a/test/spec/modules/BTBidAdapte_spec.js b/test/spec/modules/BTBidAdapte_spec.js index 6312ea4f4f1..c2671970268 100644 --- a/test/spec/modules/BTBidAdapte_spec.js +++ b/test/spec/modules/BTBidAdapte_spec.js @@ -24,18 +24,17 @@ describe('BT Bid Adapter', () => { adUnitCode: 'adunit-code', mediaTypes: { [BANNER]: { sizes: [[300, 250]] } }, params: { - ab: true, - siteId: '55555', + blockthrough: { + auctionID: 'auctionID', + }, bidderA: { pubId: '11111', }, }, bidderRequestId: 'test-bidder-request-id', - auctionId: 'test-auction-id', }, ]; const bidderRequest = { - auctionId: 'test-auction-id', bidderCode: 'blockthrough', bidderRequestId: 'test-bidder-request-id', bids: validBidRequests, @@ -45,8 +44,6 @@ describe('BT Bid Adapter', () => { it('should validate bid request with valid params', () => { const validBid = { params: { - ab: true, - siteId: 'exampleSiteId', pubmatic: { publisherId: 55555, }, @@ -77,10 +74,13 @@ describe('BT Bid Adapter', () => { describe('buildRequests', () => { it('should build post request when ortb2 fields are present', () => { - const bidderParams = { + const impExtParams = { bidderA: { pubId: '11111', }, + prebid: { + blockthrough: { auctionID: 'auctionID' }, + }, }; const requests = spec.buildRequests(validBidRequests, bidderRequest); @@ -88,9 +88,7 @@ describe('BT Bid Adapter', () => { expect(requests[0].method).to.equal('POST'); expect(requests[0].url).to.equal(ENDPOINT_URL); expect(requests[0].data).to.exist; - expect(requests[0].data.imp[0].ext).to.deep.equal(bidderParams); - expect(requests[0].data.site.ext.blockthrough.ab).to.be.true; - expect(requests[0].data.site.ext.blockthrough.siteId).to.equal('55555'); + expect(requests[0].data.imp[0].ext).to.deep.equal(impExtParams); }); }); From 7b0341c9e0c18c53ea991674693b1a7b2c92af4f Mon Sep 17 00:00:00 2001 From: PavloMalashnyak <99171840+PavloMalashnyak@users.noreply.github.com> Date: Tue, 28 Nov 2023 18:42:04 +0200 Subject: [PATCH 06/17] PE-000: check if blockthrough is defined (#6) --- modules/BTBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/BTBidAdapter.js b/modules/BTBidAdapter.js index 63a75c132f8..657491adb17 100644 --- a/modules/BTBidAdapter.js +++ b/modules/BTBidAdapter.js @@ -35,7 +35,7 @@ function imp(buildImp, bidRequest, context) { const { blockthrough, ...btBidderParams } = params; deepSetValue(imp, 'ext', btBidderParams); - if (blockthrough.auctionID) { + if (blockthrough?.auctionID) { deepSetValue( imp, 'ext.prebid.blockthrough.auctionID', From a13434f6e271817d743db5d938b745128f1b9a77 Mon Sep 17 00:00:00 2001 From: PavloMalashnyak <99171840+PavloMalashnyak@users.noreply.github.com> Date: Fri, 22 Dec 2023 16:21:45 +0200 Subject: [PATCH 07/17] PE-87: remove BT specific logic (#7) --- modules/BTBidAdapter.js | 16 ++++------------ modules/BTBidAdapter.md | 2 +- test/spec/modules/BTBidAdapte_spec.js | 10 ++-------- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/modules/BTBidAdapter.js b/modules/BTBidAdapter.js index 657491adb17..e789ec996da 100644 --- a/modules/BTBidAdapter.js +++ b/modules/BTBidAdapter.js @@ -6,8 +6,9 @@ import { ortbConverter } from '../libraries/ortbConverter/converter.js'; const BIDDER_CODE = 'blockthrough'; const GVLID = 815; -const ENDPOINT_URL = 'https://pbs.btloader.com/openrtb2/auction'; -const SYNC_URL = 'https://cdn.btloader.com/user_sync.html'; +// reach out for approval to marketing@blockthrough.com +const ENDPOINT_URL = 'https://pbs.sample.com'; +const SYNC_URL = 'https://cdn.sample.com'; const CONVERTER = ortbConverter({ context: { @@ -32,16 +33,7 @@ function imp(buildImp, bidRequest, context) { const { params, ortb2Imp } = bidRequest; if (params) { - const { blockthrough, ...btBidderParams } = params; - - deepSetValue(imp, 'ext', btBidderParams); - if (blockthrough?.auctionID) { - deepSetValue( - imp, - 'ext.prebid.blockthrough.auctionID', - blockthrough.auctionID - ); - } + deepSetValue(imp, 'ext', params); } if (ortb2Imp?.ext.gpid) { deepSetValue(imp, 'gpid', ortb2Imp.ext.gpid); diff --git a/modules/BTBidAdapter.md b/modules/BTBidAdapter.md index 7897cee1a2a..1d89fec5197 100644 --- a/modules/BTBidAdapter.md +++ b/modules/BTBidAdapter.md @@ -18,7 +18,7 @@ The BT adapter requires setup and approval from the Blockthrough team. Please re # Bidder Config -Make sure to set ab, orgID, websiteID values received after approval using `pbjs.setBidderConfig`. +Make sure to set required ab, orgID, websiteID values received after approval using `pbjs.setBidderConfig`. ## Example diff --git a/test/spec/modules/BTBidAdapte_spec.js b/test/spec/modules/BTBidAdapte_spec.js index c2671970268..f756b3ef7aa 100644 --- a/test/spec/modules/BTBidAdapte_spec.js +++ b/test/spec/modules/BTBidAdapte_spec.js @@ -16,7 +16,7 @@ import 'modules/gppControl_usnat.js'; import 'modules/schain.js'; describe('BT Bid Adapter', () => { - const ENDPOINT_URL = 'https://pbs.btloader.com/openrtb2/auction'; + const ENDPOINT_URL = 'https://pbs.sample.com'; const validBidRequests = [ { bidId: '2e9f38ea93bb9e', @@ -24,9 +24,6 @@ describe('BT Bid Adapter', () => { adUnitCode: 'adunit-code', mediaTypes: { [BANNER]: { sizes: [[300, 250]] } }, params: { - blockthrough: { - auctionID: 'auctionID', - }, bidderA: { pubId: '11111', }, @@ -78,9 +75,6 @@ describe('BT Bid Adapter', () => { bidderA: { pubId: '11111', }, - prebid: { - blockthrough: { auctionID: 'auctionID' }, - }, }; const requests = spec.buildRequests(validBidRequests, bidderRequest); @@ -152,7 +146,7 @@ describe('BT Bid Adapter', () => { }); describe('getUserSyncs', () => { - const SYNC_URL = 'https://cdn.btloader.com/user_sync.html'; + const SYNC_URL = 'https://cdn.sample.com/'; it('should return an empty array if no sync options are provided', () => { const syncs = spec.getUserSyncs({}, [], null, null, null); From 3a19f733dc110672bd377069729fdd05c076456f Mon Sep 17 00:00:00 2001 From: PavloMalashnyak <99171840+PavloMalashnyak@users.noreply.github.com> Date: Tue, 9 Jan 2024 18:20:54 +0200 Subject: [PATCH 08/17] PE-87: Implement Prebid Adapter - misc fixes (#9) * PE-87: rename test file, add bidder config * PE-87: increase ttl --- modules/BTBidAdapter.js | 2 +- modules/BTBidAdapter.md | 4 ++-- .../modules/{BTBidAdapte_spec.js => BTBidAdapter_spec.js} | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename test/spec/modules/{BTBidAdapte_spec.js => BTBidAdapter_spec.js} (100%) diff --git a/modules/BTBidAdapter.js b/modules/BTBidAdapter.js index e789ec996da..a0e9638b990 100644 --- a/modules/BTBidAdapter.js +++ b/modules/BTBidAdapter.js @@ -13,7 +13,7 @@ const SYNC_URL = 'https://cdn.sample.com'; const CONVERTER = ortbConverter({ context: { netRevenue: true, - ttl: 30, + ttl: 60, }, imp, request, diff --git a/modules/BTBidAdapter.md b/modules/BTBidAdapter.md index 1d89fec5197..e29bc688b0c 100644 --- a/modules/BTBidAdapter.md +++ b/modules/BTBidAdapter.md @@ -31,8 +31,8 @@ pbjs.setBidderConfig({ ext: { blockthrough: { ab: false, - orgID: 'orgID', - websiteID: 'websiteID', + orgID: '4829301576428910', + websiteID: '5654012389765432', }, }, }, diff --git a/test/spec/modules/BTBidAdapte_spec.js b/test/spec/modules/BTBidAdapter_spec.js similarity index 100% rename from test/spec/modules/BTBidAdapte_spec.js rename to test/spec/modules/BTBidAdapter_spec.js From cce6ffb48ede6a4a5c6b71ef8ce47caf11b988a1 Mon Sep 17 00:00:00 2001 From: PavloMalashnyak Date: Tue, 9 Jan 2024 18:39:05 +0200 Subject: [PATCH 09/17] PE-000: fix test --- test/spec/modules/BTBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/BTBidAdapter_spec.js b/test/spec/modules/BTBidAdapter_spec.js index f756b3ef7aa..d7db027c274 100644 --- a/test/spec/modules/BTBidAdapter_spec.js +++ b/test/spec/modules/BTBidAdapter_spec.js @@ -133,7 +133,7 @@ describe('BT Bid Adapter', () => { }, netRevenue: true, requestId: '2e9f38ea93bb9e', - ttl: 30, + ttl: 60, width: 300, }, ]; From e6156dec107626a3d06dbdc7a1b70e6bc457b44f Mon Sep 17 00:00:00 2001 From: PavloMalashnyak <99171840+PavloMalashnyak@users.noreply.github.com> Date: Wed, 17 Jan 2024 17:35:19 +0200 Subject: [PATCH 10/17] BP-74: Change the way we enable debug (#10) --- modules/BTBidAdapter.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/BTBidAdapter.js b/modules/BTBidAdapter.js index a0e9638b990..45eae9c5630 100644 --- a/modules/BTBidAdapter.js +++ b/modules/BTBidAdapter.js @@ -1,4 +1,3 @@ -import { config } from '../src/config.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { deepSetValue, isPlainObject, logWarn } from '../src/utils.js'; import { BANNER } from '../src/mediaTypes.js'; @@ -53,7 +52,7 @@ function imp(buildImp, bidRequest, context) { */ function request(buildRequest, imps, bidderRequest, context) { const request = buildRequest(imps, bidderRequest, context); - if (config.getConfig('debug')) { + if (window.location.href.includes('btServerTest=true')) { request.test = 1; } From 8758e2a16b822ef83453471b85408cf525d86374 Mon Sep 17 00:00:00 2001 From: PavloMalashnyak <99171840+PavloMalashnyak@users.noreply.github.com> Date: Thu, 25 Jan 2024 18:28:28 +0200 Subject: [PATCH 11/17] BP-79: Send GPID as a part of `imp[].ext` (#11) * BP-79: send gpid in imp.ext * BP-79: add optional operator --- modules/BTBidAdapter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/BTBidAdapter.js b/modules/BTBidAdapter.js index 45eae9c5630..76b243e1b7f 100644 --- a/modules/BTBidAdapter.js +++ b/modules/BTBidAdapter.js @@ -34,8 +34,8 @@ function imp(buildImp, bidRequest, context) { if (params) { deepSetValue(imp, 'ext', params); } - if (ortb2Imp?.ext.gpid) { - deepSetValue(imp, 'gpid', ortb2Imp.ext.gpid); + if (ortb2Imp?.ext?.gpid) { + deepSetValue(imp, 'ext.gpid', ortb2Imp.ext.gpid); } return imp; From fa802e24a6f43858d5f6b28cdaef04d69fcc450f Mon Sep 17 00:00:00 2001 From: PavloMalashnyak <99171840+PavloMalashnyak@users.noreply.github.com> Date: Tue, 6 Feb 2024 13:17:44 +0200 Subject: [PATCH 12/17] BP-90: Update Cookie Sync Logic (#12) * BP-90: pass bidder to cookie sync * BP-90: update sync logic, fix typo * BP-90: use const for syncs variable --- modules/BTBidAdapter.js | 45 ++++++++++++++++-------- test/spec/modules/BTBidAdapter_spec.js | 47 ++++++++++++++++---------- 2 files changed, 61 insertions(+), 31 deletions(-) diff --git a/modules/BTBidAdapter.js b/modules/BTBidAdapter.js index 76b243e1b7f..4f0f32502a9 100644 --- a/modules/BTBidAdapter.js +++ b/modules/BTBidAdapter.js @@ -148,24 +148,41 @@ function getUserSyncs( uspConsent, gppConsent ) { - let syncs = []; - const syncUrl = new URL(SYNC_URL); + if (!syncOptions.iframeEnabled || !serverResponses?.length) { + return []; + } - if (syncOptions.iframeEnabled) { - if (gdprConsent) { - syncUrl.searchParams.set('gdpr', Number(gdprConsent.gdprApplies)); - syncUrl.searchParams.set('gdpr_consent', gdprConsent.consentString); - } - if (gppConsent) { - syncUrl.searchParams.set('gpp', gppConsent.gppString); - syncUrl.searchParams.set('gpp_sid', gppConsent.applicableSections); - } - if (uspConsent) { - syncUrl.searchParams.set('us_privacy', uspConsent); + const bidderCodes = new Set(); + serverResponses.forEach((serverResponse) => { + if (serverResponse?.body?.ext?.responsetimemillis) { + Object.keys(serverResponse.body.ext.responsetimemillis).forEach( + bidderCodes.add, + bidderCodes + ); } + }); + + if (!bidderCodes.size) { + return []; + } + + const syncs = []; + const syncUrl = new URL(SYNC_URL); + syncUrl.searchParams.set('bidders', [...bidderCodes].join(',')); - syncs.push({ type: 'iframe', url: syncUrl.href }); + if (gdprConsent) { + syncUrl.searchParams.set('gdpr', Number(gdprConsent.gdprApplies)); + syncUrl.searchParams.set('gdpr_consent', gdprConsent.consentString); } + if (gppConsent) { + syncUrl.searchParams.set('gpp', gppConsent.gppString); + syncUrl.searchParams.set('gpp_sid', gppConsent.applicableSections); + } + if (uspConsent) { + syncUrl.searchParams.set('us_privacy', uspConsent); + } + + syncs.push({ type: 'iframe', url: syncUrl.href }); return syncs; } diff --git a/test/spec/modules/BTBidAdapter_spec.js b/test/spec/modules/BTBidAdapter_spec.js index d7db027c274..49db8bdc781 100644 --- a/test/spec/modules/BTBidAdapter_spec.js +++ b/test/spec/modules/BTBidAdapter_spec.js @@ -154,7 +154,19 @@ describe('BT Bid Adapter', () => { expect(syncs).to.deep.equal([]); }); - it('should include consent parameters in sync URL if they are provided', () => { + it('should return an empty array if no server responses are provided', () => { + const syncs = spec.getUserSyncs( + { iframeEnabled: true }, + [], + null, + null, + null + ); + + expect(syncs).to.deep.equal([]); + }); + + it('should pass consent parameters and bidder codes in sync URL if they are provided', () => { const gdprConsent = { gdprApplies: true, consentString: 'GDPRConsentString123', @@ -164,29 +176,30 @@ describe('BT Bid Adapter', () => { applicableSections: ['sectionA'], }; const us_privacy = '1YNY'; - const expectedSyncUrl = `${SYNC_URL}?gdpr=1&gdpr_consent=${gdprConsent.consentString}&gpp=${gppConsent.gppString}&gpp_sid=sectionA&us_privacy=${us_privacy}`; - + const expectedSyncUrl = new URL(SYNC_URL); + expectedSyncUrl.searchParams.set('bidders', 'pubmatic,ix'); + expectedSyncUrl.searchParams.set('gdpr', 1); + expectedSyncUrl.searchParams.set( + 'gdpr_consent', + gdprConsent.consentString + ); + expectedSyncUrl.searchParams.set('gpp', gppConsent.gppString); + expectedSyncUrl.searchParams.set('gpp_sid', 'sectionA'); + expectedSyncUrl.searchParams.set('us_privacy', us_privacy); const syncs = spec.getUserSyncs( { iframeEnabled: true }, - [], + [ + { body: { ext: { responsetimemillis: { pubmatic: 123 } } } }, + { body: { ext: { responsetimemillis: { pubmatic: 123, ix: 123 } } } }, + ], gdprConsent, us_privacy, gppConsent ); - expect(syncs).to.deep.equal([{ type: 'iframe', url: expectedSyncUrl }]); - }); - - it('should not include any consent parameters if no consents are provided', () => { - const syncs = spec.getUserSyncs( - { iframeEnabled: true }, - [], - null, - null, - null - ); - - expect(syncs).to.deep.equal([{ type: 'iframe', url: SYNC_URL }]); + expect(syncs).to.deep.equal([ + { type: 'iframe', url: expectedSyncUrl.href }, + ]); }); }); }); From 0e26a080e328a7d8b22303a6f6019acdaa63ae57 Mon Sep 17 00:00:00 2001 From: PavloMalashnyak <99171840+PavloMalashnyak@users.noreply.github.com> Date: Tue, 6 Feb 2024 13:18:18 +0200 Subject: [PATCH 13/17] BP-55: Re-add endpoint URLs (#13) --- modules/BTBidAdapter.js | 5 ++--- test/spec/modules/BTBidAdapter_spec.js | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/BTBidAdapter.js b/modules/BTBidAdapter.js index 4f0f32502a9..bc6f96e3604 100644 --- a/modules/BTBidAdapter.js +++ b/modules/BTBidAdapter.js @@ -5,9 +5,8 @@ import { ortbConverter } from '../libraries/ortbConverter/converter.js'; const BIDDER_CODE = 'blockthrough'; const GVLID = 815; -// reach out for approval to marketing@blockthrough.com -const ENDPOINT_URL = 'https://pbs.sample.com'; -const SYNC_URL = 'https://cdn.sample.com'; +const ENDPOINT_URL = 'https://pbs.btloader.com/openrtb2/auction'; +const SYNC_URL = 'https://cdn.btloader.com/user_sync.html'; const CONVERTER = ortbConverter({ context: { diff --git a/test/spec/modules/BTBidAdapter_spec.js b/test/spec/modules/BTBidAdapter_spec.js index 49db8bdc781..c199ecfa400 100644 --- a/test/spec/modules/BTBidAdapter_spec.js +++ b/test/spec/modules/BTBidAdapter_spec.js @@ -16,7 +16,7 @@ import 'modules/gppControl_usnat.js'; import 'modules/schain.js'; describe('BT Bid Adapter', () => { - const ENDPOINT_URL = 'https://pbs.sample.com'; + const ENDPOINT_URL = 'https://pbs.btloader.com/openrtb2/auction'; const validBidRequests = [ { bidId: '2e9f38ea93bb9e', @@ -146,7 +146,7 @@ describe('BT Bid Adapter', () => { }); describe('getUserSyncs', () => { - const SYNC_URL = 'https://cdn.sample.com/'; + const SYNC_URL = 'https://cdn.btloader.com/user_sync.html'; it('should return an empty array if no sync options are provided', () => { const syncs = spec.getUserSyncs({}, [], null, null, null); From fee388104e11045e365aceeda77a8be3e39dead1 Mon Sep 17 00:00:00 2001 From: PavloMalashnyak <99171840+PavloMalashnyak@users.noreply.github.com> Date: Thu, 8 Feb 2024 18:03:46 +0200 Subject: [PATCH 14/17] BP-91: Add prebid JS version to auction request (#14) --- modules/BTBidAdapter.js | 5 +++++ test/spec/modules/BTBidAdapter_spec.js | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/modules/BTBidAdapter.js b/modules/BTBidAdapter.js index bc6f96e3604..7b50b90124b 100644 --- a/modules/BTBidAdapter.js +++ b/modules/BTBidAdapter.js @@ -51,6 +51,11 @@ function imp(buildImp, bidRequest, context) { */ function request(buildRequest, imps, bidderRequest, context) { const request = buildRequest(imps, bidderRequest, context); + deepSetValue(request, 'ext.prebid.channel', { + name: 'pbjs', + version: '$prebid.version$', + }); + if (window.location.href.includes('btServerTest=true')) { request.test = 1; } diff --git a/test/spec/modules/BTBidAdapter_spec.js b/test/spec/modules/BTBidAdapter_spec.js index c199ecfa400..e0306abb7f0 100644 --- a/test/spec/modules/BTBidAdapter_spec.js +++ b/test/spec/modules/BTBidAdapter_spec.js @@ -82,6 +82,10 @@ describe('BT Bid Adapter', () => { expect(requests[0].method).to.equal('POST'); expect(requests[0].url).to.equal(ENDPOINT_URL); expect(requests[0].data).to.exist; + expect(requests[0].data.ext.prebid.channel).to.deep.equal({ + name: 'pbjs', + version: '$prebid.version$', + }); expect(requests[0].data.imp[0].ext).to.deep.equal(impExtParams); }); }); From df12fac78732dc8e962a12b157d12e2e4566aa18 Mon Sep 17 00:00:00 2001 From: PavloMalashnyak <99171840+PavloMalashnyak@users.noreply.github.com> Date: Mon, 4 Mar 2024 16:03:26 +0200 Subject: [PATCH 15/17] BP-139: Send Blockthrough Metadata in query params (#16) * BP-139: send metadata in query params * BP-139: update tests --- modules/BTBidAdapter.js | 15 ++++++++++++++- test/spec/modules/BTBidAdapter_spec.js | 19 ++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/modules/BTBidAdapter.js b/modules/BTBidAdapter.js index 7b50b90124b..833ada7a138 100644 --- a/modules/BTBidAdapter.js +++ b/modules/BTBidAdapter.js @@ -55,6 +55,11 @@ function request(buildRequest, imps, bidderRequest, context) { name: 'pbjs', version: '$prebid.version$', }); + deepSetValue( + request, + 'site.ext.blockthrough.ab', + !!bidderRequest.ortb2.site.ext.blockthrough.ab + ); if (window.location.href.includes('btServerTest=true')) { request.test = 1; @@ -107,10 +112,18 @@ function buildRequests(validBidRequests, bidderRequest) { bidderRequest, }); + const endpointUrl = new URL(ENDPOINT_URL); + const { ab, orgID, websiteID } = data.site.ext.blockthrough; + + endpointUrl.searchParams.set('ab', ab); + endpointUrl.searchParams.set('orgID', orgID); + endpointUrl.searchParams.set('websiteID', websiteID); + endpointUrl.searchParams.set('pbjsVersion', '$prebid.version$'); + return [ { method: 'POST', - url: ENDPOINT_URL, + url: endpointUrl.href, data, bids: validBidRequests, }, diff --git a/test/spec/modules/BTBidAdapter_spec.js b/test/spec/modules/BTBidAdapter_spec.js index e0306abb7f0..5ed6a879f35 100644 --- a/test/spec/modules/BTBidAdapter_spec.js +++ b/test/spec/modules/BTBidAdapter_spec.js @@ -17,6 +17,8 @@ import 'modules/schain.js'; describe('BT Bid Adapter', () => { const ENDPOINT_URL = 'https://pbs.btloader.com/openrtb2/auction'; + const orgID = '4829301576428910'; + const websiteID = '5654012389765432'; const validBidRequests = [ { bidId: '2e9f38ea93bb9e', @@ -35,6 +37,16 @@ describe('BT Bid Adapter', () => { bidderCode: 'blockthrough', bidderRequestId: 'test-bidder-request-id', bids: validBidRequests, + ortb2: { + site: { + ext: { + blockthrough: { + orgID, + websiteID, + }, + }, + }, + }, }; describe('isBidRequestValid', function () { @@ -76,11 +88,16 @@ describe('BT Bid Adapter', () => { pubId: '11111', }, }; + const expectedEndpointUrl = new URL(ENDPOINT_URL); + expectedEndpointUrl.searchParams.set('ab', 'false'); + expectedEndpointUrl.searchParams.set('orgID', orgID); + expectedEndpointUrl.searchParams.set('websiteID', websiteID); + expectedEndpointUrl.searchParams.set('pbjsVersion', '$prebid.version$'); const requests = spec.buildRequests(validBidRequests, bidderRequest); expect(requests[0].method).to.equal('POST'); - expect(requests[0].url).to.equal(ENDPOINT_URL); + expect(requests[0].url).to.equal(expectedEndpointUrl.href); expect(requests[0].data).to.exist; expect(requests[0].data.ext.prebid.channel).to.deep.equal({ name: 'pbjs', From 67de2540aab7b441d09587afec09049986b1de87 Mon Sep 17 00:00:00 2001 From: PavloMalashnyak <99171840+PavloMalashnyak@users.noreply.github.com> Date: Mon, 4 Mar 2024 16:03:53 +0200 Subject: [PATCH 16/17] BP-55: Implement Prebid Adapter - clarify bidderConfig params (#15) * BP-55: add clarification for config variables * BP-55: remove ab value from doc --- modules/BTBidAdapter.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/BTBidAdapter.md b/modules/BTBidAdapter.md index e29bc688b0c..31feec430fb 100644 --- a/modules/BTBidAdapter.md +++ b/modules/BTBidAdapter.md @@ -18,7 +18,12 @@ The BT adapter requires setup and approval from the Blockthrough team. Please re # Bidder Config -Make sure to set required ab, orgID, websiteID values received after approval using `pbjs.setBidderConfig`. +Make sure to set required orgID, websiteID values received after approval using `pbjs.setBidderConfig`. + +| Name | Scope | Description | Example | Type | +| ----------- | -------- | -------------------------------------------------------------------- | ------------------ | -------- | +| `orgID` | required | A unique ID for your organization provided by the Blockthrough team. | `4829301576428910` | `string` | +| `websiteID` | required | A unique ID for your site provided by the Blockthrough team. | `5654012389765432` | `string` | ## Example @@ -30,7 +35,6 @@ pbjs.setBidderConfig({ site: { ext: { blockthrough: { - ab: false, orgID: '4829301576428910', websiteID: '5654012389765432', }, From 88cbe4a15bee3f1233e3d9a2354a5add3f70f9f7 Mon Sep 17 00:00:00 2001 From: hzhyltsova Date: Fri, 24 Apr 2026 14:46:44 +0200 Subject: [PATCH 17/17] chore: fix BTBidAdapter test imports for upstream compatibility consentManagement.js was renamed to consentManagementTcf.js, enrichmentFpdModule.js and gdprEnforcement.js were removed in upstream. --- test/spec/modules/BTBidAdapter_spec.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/spec/modules/BTBidAdapter_spec.js b/test/spec/modules/BTBidAdapter_spec.js index 5ed6a879f35..57d0849af91 100644 --- a/test/spec/modules/BTBidAdapter_spec.js +++ b/test/spec/modules/BTBidAdapter_spec.js @@ -7,11 +7,9 @@ import 'modules/currency.js'; import 'modules/userId/index.js'; import 'modules/multibid/index.js'; import 'modules/priceFloors.js'; -import 'modules/consentManagement.js'; +import 'modules/consentManagementTcf.js'; import 'modules/consentManagementUsp.js'; import 'modules/consentManagementGpp.js'; -import 'modules/enrichmentFpdModule.js'; -import 'modules/gdprEnforcement.js'; import 'modules/gppControl_usnat.js'; import 'modules/schain.js';