Skip to content

Commit f5c61d9

Browse files
author
pavel
committed
# This is a combination of 22 commits.tree 8abae7e
parent cecfce3 author pavel <[email protected]> 1706627437 +0200 committer pavel <[email protected]> 1706627437 +0200 gpgsig -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEqGYI3KX/FkbObQG8FABtd4pCs/AFAmW5EW0ACgkQFABtd4pC s/CK3w//WWJSFUlycnnNKTV2XfdcBjooOeZZvjpXVthwr09CCC4uO//kw4bPluhn f5fcVFdXzrY1AZ6ch8Wo3msX/Pkso014jIGd5aIWcHpNYFtffACwH/40Y8AcJNZd bsOZxVK0awPTz/RihC5eY+0J3cP+iFWP/FlYJoHEQIBXq/Eg6mWoAhxwpL/JvxbY QbLFWsRn2ckQ6ftOZgm3/jh8VLaG1zWbWImlWEs5Zel+CorJBTniTj58VbApelYD TFMgbSR2I4NGVaqNIrHePnSMsDATxalQ2nZPwY6raKCHWIbvoUPIn/OpDMMbKgC7 nCwounNmObxFVoj3xusAZppzHpKPasY8xKWb2Kr7zfhZArsOMC6B7fYqQNK0cWG3 8RR/10oheJD9M2kRlfLiqnRv7ExY08SQ/ZMo9LA8BeRUGBXhh6++8FKhKIHvX1gL k1R5W6c+NNWP+PDFsmrFpMn+LpYdl84I7yfYK5dHuw80od7f1wuAVYpswi6Cziy9 /KY6/rfENvUrGTmWSh5GdDBel89ACCfFkasIKB92xhzKTfjzF/DXkc8XQZOMbt1j CsILgWMNfLPMo4Dlgdx/tYCSLLBNEtZ1/hhUcFQ3+0TzLf0GtMkvMnlBnDinqe1n 1P30fQ2I5W5NJKDPrCOnRymI6QOAPFXtMF11R81mbB9H8asft/E= =oJtZ -----END PGP SIGNATURE----- bugfixes # This is the commit message prebid#22: Remove test parameter
1 parent cecfce3 commit f5c61d9

File tree

3 files changed

+37
-43
lines changed

3 files changed

+37
-43
lines changed

modules/setupadBidAdapter.js

+31-38
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ import CONSTANTS from '../src/constants.json';
1717
const BIDDER_CODE = 'setupad';
1818
const ENDPOINT = 'https://prebid.setupad.io/openrtb2/auction';
1919
const SYNC_ENDPOINT = 'https://cookie.stpd.cloud/sync?';
20-
const REPORT_ENDPOINT = 'https://adapter-analytics.azurewebsites.net/api/adapter-analytics';
20+
const REPORT_ENDPOINT = 'https://adapter-analytics.setupad.io';
2121
const GVLID = 1241;
2222
const TIME_TO_LIVE = 360;
23-
const allBidders = {};
23+
const biddersCpms = {};
24+
const biddersCreativeIds = {};
2425

2526
const sendingDataStatistic = initSendingDataStatistic();
2627
events.on(CONSTANTS.EVENTS.AUCTION_INIT, () => {
@@ -75,7 +76,6 @@ export const spec = {
7576
device,
7677
site,
7778
imp: [],
78-
test: 1,
7979
};
8080

8181
const imp = {
@@ -171,10 +171,8 @@ export const spec = {
171171
};
172172

173173
// Set all bidders obj for later use in getPixelUrl()
174-
allBidders[res.seat] = {};
175-
allBidders[res.seat].cpm = bidResponse.cpm;
176-
allBidders[res.seat].currency = bidResponse.currency;
177-
allBidders[res.seat].creativeId = bidResponse.creativeId;
174+
biddersCpms[res.seat] = bidResponse.cpm;
175+
biddersCreativeIds[res.seat] = bidResponse.creativeId;
178176

179177
bidResponse.ad = ad;
180178
bidResponse.adUrl = adUrl;
@@ -215,7 +213,7 @@ export const spec = {
215213
getPixelUrl: function (eventName, bid, timestamp) {
216214
let bidder = bid.bidder || bid.bidderCode;
217215
const auctionId = bid.auctionId;
218-
if (bidder != BIDDER_CODE) return;
216+
if (bidder !== BIDDER_CODE) return;
219217

220218
let params;
221219
if (bid.params) {
@@ -239,31 +237,28 @@ export const spec = {
239237
if (!placementIds) return;
240238

241239
let extraBidParams = '';
242-
// additional params on bidWon
243-
if (eventName === 'bidWon') {
244-
extraBidParams = `&cpm=${bid.originalCpm}&currency=${bid.originalCurrency}`;
240+
241+
if (eventName === CONSTANTS.EVENTS.BID_RESPONSE) {
242+
bidder = JSON.stringify(biddersCpms);
243+
244+
// Add extra parameters
245+
extraBidParams = `&currency=${bid.originalCurrency}`;
245246
}
246247

247-
if (eventName === 'bidResponse') {
248-
// Exclude not needed creativeId key for bidResponse bidders
249-
const filteredBidders = Object.fromEntries(
250-
Object.entries(allBidders).map(([bidderKey, bidderObj]) => [
251-
bidderKey,
252-
Object.fromEntries(Object.entries(bidderObj).filter(([key]) => key !== 'creativeId')),
253-
])
254-
);
255-
bidder = JSON.stringify(filteredBidders);
256-
} else if (eventName === 'bidWon') {
248+
if (eventName === CONSTANTS.EVENTS.BID_WON) {
257249
// Iterate through all bidders to find the winning bidder by using creativeId as identification
258-
for (const bidderName in allBidders) {
250+
for (const bidderName in biddersCreativeIds) {
259251
if (
260-
allBidders.hasOwnProperty(bidderName) &&
261-
allBidders[bidderName].creativeId === bid.creativeId
252+
biddersCreativeIds.hasOwnProperty(bidderName) &&
253+
biddersCreativeIds[bidderName] === bid.creativeId
262254
) {
263255
bidder = bidderName;
264-
break; // Exit the loop once a match is found
256+
break; // Exit the loop if a match is found
265257
}
266258
}
259+
260+
// Add extra parameters
261+
extraBidParams = `&cpm=${bid.originalCpm}&currency=${bid.originalCurrency}`;
267262
}
268263

269264
const url = `${REPORT_ENDPOINT}?event=${eventName}&bidder=${bidder}&placementIds=${placementIds}&auctionId=${auctionId}${extraBidParams}&timestamp=${timestamp}`;
@@ -357,6 +352,7 @@ function initSendingDataStatistic() {
357352

358353
disabledSending = false;
359354
enabledSending = false;
355+
auctionIds = {};
360356
eventHendlers = {};
361357

362358
initEvents() {
@@ -393,24 +389,21 @@ function initSendingDataStatistic() {
393389
}
394390

395391
eventHandler(eventName) {
396-
const eventHandlerFunc = this.getEventHandler(eventName);
397-
if (eventName == CONSTANTS.EVENTS.BID_TIMEOUT) {
398-
return (bids) => {
399-
if (this.disabledSending || !Array.isArray(bids)) return;
400-
401-
for (let bid of bids) {
402-
eventHandlerFunc(bid);
403-
}
404-
};
405-
}
406-
407-
return eventHandlerFunc;
392+
return this.getEventHandler(eventName);
408393
}
409394

410395
getEventHandler(eventName) {
411396
return (bid) => {
412397
if (this.disabledSending) return;
413-
398+
if (
399+
this.auctionIds[bid.auctionId] === bid.bidder &&
400+
eventName === CONSTANTS.EVENTS.BID_RESPONSE
401+
) {
402+
return;
403+
}
404+
if (eventName === CONSTANTS.EVENTS.BID_RESPONSE) {
405+
this.auctionIds[bid.auctionId] = bid.bidder;
406+
}
414407
const url = spec.getPixelUrl(eventName, bid, Date.now());
415408
if (!url) return;
416409
triggerPixel(url);

modules/setupadBidAdapter.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Overview
22

3-
```
3+
```text
44
Module Name: Setupad Bid Adapter
55
Module Type: Bidder Adapter
66
Maintainer: [email protected]

test/spec/modules/setupadBidAdapter_spec.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ describe('SetupadAdapter', function () {
6060
h: 250,
6161
},
6262
],
63+
seat: 'testBidder',
6364
},
6465
],
6566
cur: 'USD',
@@ -242,7 +243,7 @@ describe('SetupadAdapter', function () {
242243
});
243244

244245
describe('getPixelUrl', function () {
245-
const REPORT_ENDPOINT = 'https://adapter-analytics.azurewebsites.net/api/adapter-analytics';
246+
const REPORT_ENDPOINT = 'https://adapter-analytics.setupad.io';
246247
const mockData = [
247248
{
248249
timestamp: 123456789,
@@ -324,12 +325,11 @@ describe('SetupadAdapter', function () {
324325
bid: {
325326
auctionId: 'test-auction-id',
326327
bidderCode: 'setupad',
327-
originalCpm: 0.8,
328328
originalCurrency: 'USD',
329329
params: { placement_id: '123' },
330330
},
331331

332-
expected: `${REPORT_ENDPOINT}?event=bidResponse&bidder=setupad&placementIds=123&auctionId=test-auction-id&cpm=0.8&currency=USD&timestamp=123456789`,
332+
expected: `${REPORT_ENDPOINT}?event=bidResponse&bidder={"testBidder":0.8}&placementIds=123&auctionId=test-auction-id&currency=USD&timestamp=123456789`,
333333
},
334334

335335
{
@@ -385,11 +385,12 @@ describe('SetupadAdapter', function () {
385385
auctionId: 'test-auction-id',
386386
bidder: 'setupad',
387387
originalCpm: 0.8,
388+
creativeId: 'test-bid-id',
388389
originalCurrency: 'USD',
389390
params: { placement_id: '123', account_id: 'test' },
390391
},
391392

392-
expected: `${REPORT_ENDPOINT}?event=bidWon&bidder=setupad&placementIds=123&auctionId=test-auction-id&cpm=0.8&currency=USD&timestamp=123456789`,
393+
expected: `${REPORT_ENDPOINT}?event=bidWon&bidder=testBidder&placementIds=123&auctionId=test-auction-id&cpm=0.8&currency=USD&timestamp=123456789`,
393394
},
394395
];
395396

0 commit comments

Comments
 (0)