From bd1bf503b1238f5a7a096dfaec72f328c265ff6c Mon Sep 17 00:00:00 2001 From: ASUS Date: Wed, 18 Dec 2024 19:20:15 -0300 Subject: [PATCH 01/13] wip --- integrationExamples/gpt/bms_sample.html | 123 ++++++++++++++ .../gpt/x-domain/creative.html | 2 +- modules/bmsBidAdapter.js | 158 ++++++++++++++++++ modules/bmsBidAdapter.md | 31 ++++ 4 files changed, 313 insertions(+), 1 deletion(-) create mode 100755 integrationExamples/gpt/bms_sample.html create mode 100644 modules/bmsBidAdapter.js create mode 100644 modules/bmsBidAdapter.md diff --git a/integrationExamples/gpt/bms_sample.html b/integrationExamples/gpt/bms_sample.html new file mode 100755 index 00000000000..ed9a126e4ef --- /dev/null +++ b/integrationExamples/gpt/bms_sample.html @@ -0,0 +1,123 @@ + + + + + + + + + + + + +

Prebid.js Test - Geolocation

+
Div-1
+
+ +
+ +
+

Geolocation Debug Information

+

Check browser console for geolocation details

+
+ + diff --git a/integrationExamples/gpt/x-domain/creative.html b/integrationExamples/gpt/x-domain/creative.html index 63842b00882..b7ba6b36a79 100644 --- a/integrationExamples/gpt/x-domain/creative.html +++ b/integrationExamples/gpt/x-domain/creative.html @@ -2,7 +2,7 @@ // creative will be rendered, e.g. GAM delivering a SafeFrame // this code is autogenerated, also available in 'build/creative/creative.js' - + - +// this script can be returned by an ad server delivering a cross domain iframe, +into which the // creative will be rendered, e.g. GAM delivering a SafeFrame // +this code is autogenerated, also available in 'build/creative/creative.js' From 5aef4738f6795a789b52cf8e013f180ab8027594 Mon Sep 17 00:00:00 2001 From: ASUS Date: Wed, 8 Jan 2025 11:38:58 -0300 Subject: [PATCH 07/13] wip --- .../gpt/x-domain/creative.html | 99 +++---------------- 1 file changed, 11 insertions(+), 88 deletions(-) diff --git a/integrationExamples/gpt/x-domain/creative.html b/integrationExamples/gpt/x-domain/creative.html index 569881f5aba..63842b00882 100644 --- a/integrationExamples/gpt/x-domain/creative.html +++ b/integrationExamples/gpt/x-domain/creative.html @@ -1,90 +1,13 @@ -// this script can be returned by an ad server delivering a cross domain iframe, -into which the // creative will be rendered, e.g. GAM delivering a SafeFrame // -this code is autogenerated, also available in 'build/creative/creative.js' +// this script can be returned by an ad server delivering a cross domain iframe, into which the +// creative will be rendered, e.g. GAM delivering a SafeFrame + +// this code is autogenerated, also available in 'build/creative/creative.js' + + From d3ed698e2f87ef90a3b896ec0c2a64e9906550cd Mon Sep 17 00:00:00 2001 From: ASUS Date: Mon, 13 Jan 2025 10:15:17 -0300 Subject: [PATCH 08/13] Refactor geolocation implementationn --- integrationExamples/gpt/bms_sample.html | 260 +++++++++++++++--------- modules/bmsBidAdapter.js | 19 -- 2 files changed, 161 insertions(+), 118 deletions(-) diff --git a/integrationExamples/gpt/bms_sample.html b/integrationExamples/gpt/bms_sample.html index ed9a126e4ef..624b13ab358 100755 --- a/integrationExamples/gpt/bms_sample.html +++ b/integrationExamples/gpt/bms_sample.html @@ -1,123 +1,185 @@ - + - + - - - -

Prebid.js Test - Geolocation

-
Div-1
-
- -
+ -
-

Geolocation Debug Information

-

Check browser console for geolocation details

+ +
+
test-div
+
+
test-div2
+
- + diff --git a/modules/bmsBidAdapter.js b/modules/bmsBidAdapter.js index dfbd66ac1c4..5c8b61b57e6 100644 --- a/modules/bmsBidAdapter.js +++ b/modules/bmsBidAdapter.js @@ -3,7 +3,6 @@ import { registerBidder } from "../src/adapters/bidderFactory.js"; import { BANNER } from "../src/mediaTypes.js"; import { getStorageManager } from "../src/storageManager.js"; import * as utils from "../src/utils.js"; - const BIDDER_CODE = "bms"; const ENDPOINT_URL = "https://api.prebid.int.us-east-2.bluemsdev.team/v1/bid?exchangeId=prebid"; @@ -45,12 +44,6 @@ function request(buildRequest, imps, bidderRequest, context) { // Adiciona ID do publisher utils.deepSetValue(request, "site.publisher.id", context.publisherId); - - // Adiciona geolocalização se disponível - if (context.geo) { - utils.deepSetValue(request, "device.geo", context.geo); - } - return request; } @@ -79,14 +72,10 @@ export const spec = { // Construir requisições OpenRTB usando `ortbConverter` buildRequests: function (validBidRequests, bidderRequest) { - // Extrair geolocalização - const geo = extractGeoLocation(bidderRequest); - const context = { publisherId: validBidRequests.find( (bidRequest) => bidRequest.params?.publisherId )?.params.publisherId, - geo: geo, // Adiciona informações de geolocalização ao contexto }; const ortbRequest = converter.toORTB({ @@ -137,12 +126,4 @@ export const spec = { }, }; -// Função auxiliar para extrair geolocalização -function extractGeoLocation(bidderRequest) { - if (bidderRequest?.ortb2?.device?.geo) { - return bidderRequest.ortb2.device.geo; - } - return null; -} - registerBidder(spec); From d6d004a0bcd9084e8d168db1f12a904b74df54e2 Mon Sep 17 00:00:00 2001 From: ASUS Date: Mon, 13 Jan 2025 11:22:55 -0300 Subject: [PATCH 09/13] chore: minor adjustments --- integrationExamples/gpt/bms_sample.html | 6 ++-- modules/bmsBidAdapter.js | 28 +++++++-------- test/spec/modules/bmsBidAdapter_spec.js | 48 ++++++++++++------------- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/integrationExamples/gpt/bms_sample.html b/integrationExamples/gpt/bms_sample.html index 624b13ab358..c9ff3d4c133 100755 --- a/integrationExamples/gpt/bms_sample.html +++ b/integrationExamples/gpt/bms_sample.html @@ -70,8 +70,8 @@ geo: { lat: -23.5505, lon: -46.6333, - type: 1, // GPS/Location Services - accuracy: 100, // Precisão em metros + type: 1, + accuracy: 100, }, }, }; @@ -100,7 +100,7 @@ }, ], }, - floors: {}, // Ativa o módulo + floors: {}, ortb2: ortb2, }); pbjs.bidderSettings = { diff --git a/modules/bmsBidAdapter.js b/modules/bmsBidAdapter.js index 5c8b61b57e6..648b88731e3 100644 --- a/modules/bmsBidAdapter.js +++ b/modules/bmsBidAdapter.js @@ -5,8 +5,8 @@ import { getStorageManager } from "../src/storageManager.js"; import * as utils from "../src/utils.js"; const BIDDER_CODE = "bms"; const ENDPOINT_URL = - "https://api.prebid.int.us-east-2.bluemsdev.team/v1/bid?exchangeId=prebid"; -const GVLID = 620; + "https://api.prebid.int.us-east-1.bluems.com/v1/bid?exchangeId=prebid"; +const GVLID = 1105; const COOKIE_NAME = "bmsCookieId"; const DEFAULT_CURRENCY = "USD"; @@ -32,8 +32,8 @@ function getBidFloor(bid) { const converter = ortbConverter({ context: { - netRevenue: true, // Configuração padrão de receita líquida - ttl: 100, // Tempo de vida padrão para respostas de lances + netRevenue: true, // Default net revenue configuration + ttl: 100, // Default time-to-live for bid responses }, imp, request, @@ -42,7 +42,7 @@ const converter = ortbConverter({ function request(buildRequest, imps, bidderRequest, context) { let request = buildRequest(imps, bidderRequest, context); - // Adiciona ID do publisher + // Add publisher ID utils.deepSetValue(request, "site.publisher.id", context.publisherId); return request; } @@ -63,14 +63,14 @@ function imp(buildImp, bidRequest, context) { export const spec = { code: BIDDER_CODE, gvlid: GVLID, - supportedMediaTypes: [BANNER], // Tipos de mídia suportados + supportedMediaTypes: [BANNER], // Supported media types - // Validar requisição de lance + // Validate bid request isBidRequestValid: function (bid) { return !!bid.params.placementId && !!bid.params.publisherId; }, - // Construir requisições OpenRTB usando `ortbConverter` + // Build OpenRTB requests using `ortbConverter` buildRequests: function (validBidRequests, bidderRequest) { const context = { publisherId: validBidRequests.find( @@ -84,12 +84,12 @@ export const spec = { context, }); - // Adicionar extensões à requisição + // Add extensions to the request ortbRequest.ext = ortbRequest.ext || {}; utils.deepSetValue(ortbRequest, "ext.gvlid", GVLID); if (storage.localStorageIsEnabled()) { - // Incluir ID do cookie do usuário, se disponível + // Include user cookie ID if available const ckid = storage.getDataFromLocalStorage(COOKIE_NAME) || null; if (ckid) { utils.deepSetValue(ortbRequest, "user.ext.buyerid", ckid); @@ -101,22 +101,22 @@ export const spec = { url: ENDPOINT_URL, data: ortbRequest, options: { - contentType: "application/json", + contentType: "text/plain", }, }; }, - // Interpretar respostas OpenRTB usando `ortbConverter` + // Interpret OpenRTB responses using `ortbConverter` interpretResponse: function (serverResponse, request) { const ortbResponse = serverResponse.body; - // Analisar resposta OpenRTB em respostas Prebid + // Parse OpenRTB response into Prebid responses const prebidResponses = converter.fromORTB({ response: ortbResponse, request: request.data, }).bids; - // Adicionar metadados aos lances + // Add metadata to bids prebidResponses.forEach((bid) => { bid.meta = bid.meta || {}; bid.meta.adapterVersion = "1.0.0"; diff --git a/test/spec/modules/bmsBidAdapter_spec.js b/test/spec/modules/bmsBidAdapter_spec.js index 52670e9f674..b8526bc2757 100755 --- a/test/spec/modules/bmsBidAdapter_spec.js +++ b/test/spec/modules/bmsBidAdapter_spec.js @@ -1,15 +1,15 @@ -import { expect } from "chai"; -import sinon from "sinon"; -import { spec, storage } from "modules/bmsBidAdapter.js"; +import { expect } from 'chai'; +import sinon from 'sinon'; +import { spec, storage } from 'modules/bmsBidAdapter.js'; -const BIDDER_CODE = "bms"; +const BIDDER_CODE = 'bms'; const ENDPOINT_URL = - "https://api.prebid.int.us-east-2.bluemsdev.team/v1/bid?exchangeId=prebid"; + 'https://api.prebid.int.us-east-2.bluemsdev.team/v1/bid?exchangeId=prebid'; const GVLID = 620; -const COOKIE_NAME = "bmsCookieId"; -const CURRENCY = "USD"; +const COOKIE_NAME = 'bmsCookieId'; +const CURRENCY = 'USD'; -describe("bmsBidAdapter:", function () { +describe('bmsBidAdapter:', function () { let sandbox; beforeEach(function () { @@ -20,38 +20,38 @@ describe("bmsBidAdapter:", function () { sandbox.restore(); }); - describe("isBidRequestValid:", function () { - it("should return true for valid bid requests", function () { + describe('isBidRequestValid:', function () { + it('should return true for valid bid requests', function () { const validBid = { params: { - placementId: "12345", - publisherId: "67890", + placementId: '12345', + publisherId: '67890', }, }; expect(spec.isBidRequestValid(validBid)).to.be.true; }); - it("should return false for invalid bid requests", function () { + it('should return false for invalid bid requests', function () { const invalidBid = { params: { - placementId: "12345", + placementId: '12345', }, }; expect(spec.isBidRequestValid(invalidBid)).to.be.false; }); }); - describe("buildRequests:", function () { + describe('buildRequests:', function () { let validBidRequests; let bidderRequest; beforeEach(function () { validBidRequests = [ { - bidId: "bid1", + bidId: 'bid1', params: { - placementId: "12345", - publisherId: "67890", + placementId: '12345', + publisherId: '67890', }, getFloor: () => ({ currency: CURRENCY, floor: 1.5 }), }, @@ -59,19 +59,19 @@ describe("bmsBidAdapter:", function () { bidderRequest = { refererInfo: { - page: "https://example.com", + page: 'https://example.com', }, }; - sandbox.stub(storage, "getDataFromLocalStorage").returns("testBuyerId"); + sandbox.stub(storage, 'getDataFromLocalStorage').returns('testBuyerId'); }); - it("should build a valid OpenRTB request", function () { + it('should build a valid OpenRTB request', function () { const request = spec.buildRequests(validBidRequests, bidderRequest); - expect(request.method).to.equal("POST"); + expect(request.method).to.equal('POST'); expect(request.url).to.equal(ENDPOINT_URL); - expect(request.options.contentType).to.equal("application/json"); + expect(request.options.contentType).to.equal('application/json'); const ortbRequest = request.data; expect(ortbRequest.ext.gvlid).to.equal(GVLID); @@ -79,7 +79,7 @@ describe("bmsBidAdapter:", function () { expect(ortbRequest.imp[0].bidfloorcur).to.equal(CURRENCY); }); - it("should omit bidfloor if getFloor is not implemented", function () { + it('should omit bidfloor if getFloor is not implemented', function () { validBidRequests[0].getFloor = undefined; const request = spec.buildRequests(validBidRequests, bidderRequest); From e5dbdfd2118fbc7352182485e3cc02c3a4a00d79 Mon Sep 17 00:00:00 2001 From: ASUS Date: Wed, 15 Jan 2025 18:59:25 -0300 Subject: [PATCH 10/13] feat: add bidWon --- .../gpt/x-domain/creative.html | 2 +- modules/bmsBidAdapter.js | 45 +++++++++++++------ 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/integrationExamples/gpt/x-domain/creative.html b/integrationExamples/gpt/x-domain/creative.html index 63842b00882..b7ba6b36a79 100644 --- a/integrationExamples/gpt/x-domain/creative.html +++ b/integrationExamples/gpt/x-domain/creative.html @@ -2,7 +2,7 @@ // creative will be rendered, e.g. GAM delivering a SafeFrame // this code is autogenerated, also available in 'build/creative/creative.js' - +