Skip to content

Commit

Permalink
# This is a combination of 26 commits.
Browse files Browse the repository at this point in the history
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

# This is the commit message prebid#23:

Fix multiple bidResponse and bidTimeout calls to getPixelUrl

# This is the commit message prebid#25:

eslint errors fixes(brackets added)

# This is the commit message prebid#26:

Add extra checks for events
  • Loading branch information
pavel committed Jan 30, 2024
1 parent f5c61d9 commit 75178b9
Showing 1 changed file with 46 additions and 35 deletions.
81 changes: 46 additions & 35 deletions modules/setupadBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ import {
getBidIdParameter,
triggerPixel,
logWarn,
} from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { getRefererInfo } from '../src/refererDetection.js';
import { config } from '../src/config.js';
import * as events from '../src/events.js';
import { BANNER } from '../src/mediaTypes.js';
import CONSTANTS from '../src/constants.json';

const BIDDER_CODE = 'setupad';
const ENDPOINT = 'https://prebid.setupad.io/openrtb2/auction';
const SYNC_ENDPOINT = 'https://cookie.stpd.cloud/sync?';
const REPORT_ENDPOINT = 'https://adapter-analytics.setupad.io';
} from "../src/utils.js";
import { registerBidder } from "../src/adapters/bidderFactory.js";
import { getRefererInfo } from "../src/refererDetection.js";
import { config } from "../src/config.js";
import * as events from "../src/events.js";
import { BANNER } from "../src/mediaTypes.js";
import CONSTANTS from "../src/constants.json";

const BIDDER_CODE = "setupad";
const ENDPOINT = "https://prebid.setupad.io/openrtb2/auction";
const SYNC_ENDPOINT = "https://cookie.stpd.cloud/sync?";
const REPORT_ENDPOINT = "https://adapter-analytics.setupad.io";
const GVLID = 1241;
const TIME_TO_LIVE = 360;
const biddersCpms = {};
Expand All @@ -29,7 +29,7 @@ events.on(CONSTANTS.EVENTS.AUCTION_INIT, () => {
});

function getEids(bidRequest) {
if (deepAccess(bidRequest, 'userIdAsEids')) return bidRequest.userIdAsEids;
if (deepAccess(bidRequest, "userIdAsEids")) return bidRequest.userIdAsEids;
}

export const spec = {
Expand All @@ -45,9 +45,10 @@ export const spec = {
const requests = [];
window.nmmRefreshCounts = window.nmmRefreshCounts || {};
_each(validBidRequests, function (bid) {
window.nmmRefreshCounts[bid.adUnitCode] = window.nmmRefreshCounts[bid.adUnitCode] || 0;
const id = getBidIdParameter('placement_id', bid.params);
const accountId = getBidIdParameter('account_id', bid.params);
window.nmmRefreshCounts[bid.adUnitCode] =
window.nmmRefreshCounts[bid.adUnitCode] || 0;
const id = getBidIdParameter("placement_id", bid.params);
const accountId = getBidIdParameter("account_id", bid.params);
const auctionId = bid.auctionId;
const bidId = bid.bidId;
const eids = getEids(bid) || [];
Expand All @@ -62,7 +63,7 @@ export const spec = {
ext: {
prebid: {
storedrequest: {
id: accountId || 'default',
id: accountId || "default",
},
},

Expand All @@ -87,7 +88,7 @@ export const spec = {
},
};

if (deepAccess(bid, 'mediaTypes.banner')) {
if (deepAccess(bid, "mediaTypes.banner")) {
imp.banner = {
format: (sizes || []).map((s) => {
return { w: s[0], h: s[1] };
Expand All @@ -106,23 +107,23 @@ export const spec = {
if (uspConsent) payload.regs.ext.us_privacy = uspConsent;

if (gdprConsent) {
if (typeof gdprConsent.gdprApplies !== 'undefined') {
if (typeof gdprConsent.gdprApplies !== "undefined") {
payload.regs.ext.gdpr = gdprConsent.gdprApplies ? 1 : 0;
}

if (typeof gdprConsent.consentString !== 'undefined') {
if (typeof gdprConsent.consentString !== "undefined") {
payload.user.ext.consent = gdprConsent.consentString;
}
}
}
const params = bid.params;

requests.push({
method: 'POST',
method: "POST",
url: ENDPOINT,
data: JSON.stringify(payload),
options: {
contentType: 'text/plain',
contentType: "text/plain",
withCredentials: true,
},

Expand All @@ -139,10 +140,10 @@ export const spec = {
if (
!serverResponse ||
!serverResponse.body ||
typeof serverResponse.body != 'object' ||
typeof serverResponse.body != "object" ||
Object.keys(serverResponse.body).length === 0
) {
logWarn('no response or body is malformed');
logWarn("no response or body is malformed");
return [];
}

Expand Down Expand Up @@ -193,15 +194,15 @@ export const spec = {
const queryParams = [];

queryParams.push(`bidders=${bidders}`);
queryParams.push('gdpr=' + +gdprConsent.gdprApplies);
queryParams.push('gdpr_consent=' + gdprConsent.consentString);
queryParams.push('usp_consent=' + (uspConsent || ''));
queryParams.push("gdpr=" + +gdprConsent.gdprApplies);
queryParams.push("gdpr_consent=" + gdprConsent.consentString);
queryParams.push("usp_consent=" + (uspConsent || ""));

const strQueryParams = queryParams.join('&');
const strQueryParams = queryParams.join("&");

syncs.push({
type: 'iframe',
url: SYNC_ENDPOINT + strQueryParams + '&type=iframe',
type: "iframe",
url: SYNC_ENDPOINT + strQueryParams + "&type=iframe",
});

return syncs;
Expand Down Expand Up @@ -232,11 +233,12 @@ export const spec = {
placementIdsArray.push(param.placement_id);
});

const placementIds = (placementIdsArray.length && placementIdsArray.join(';')) || '';
const placementIds =
(placementIdsArray.length && placementIdsArray.join(";")) || "";

if (!placementIds) return;

let extraBidParams = '';
let extraBidParams = "";

if (eventName === CONSTANTS.EVENTS.BID_RESPONSE) {
bidder = JSON.stringify(biddersCpms);
Expand All @@ -261,6 +263,14 @@ export const spec = {
extraBidParams = `&cpm=${bid.originalCpm}&currency=${bid.originalCurrency}`;
}

if (
eventName === CONSTANTS.EVENTS.BID_REQUESTED ||
eventName === CONSTANTS.EVENTS.BID_TIMEOUT ||
eventName === CONSTANTS.EVENTS.NO_BID
) {
bidder = BIDDER_CODE;
}

const url = `${REPORT_ENDPOINT}?event=${eventName}&bidder=${bidder}&placementIds=${placementIds}&auctionId=${auctionId}${extraBidParams}&timestamp=${timestamp}`;

return url;
Expand Down Expand Up @@ -288,7 +298,7 @@ function getAdEl(bid) {
.find((slot) => slot.getAdUnitPath() === bid.adUnitCode);
const slotElementId = slot && slot.getSlotElementId();
if (!slotElementId) return null;
return document.querySelector('#' + slotElementId);
return document.querySelector("#" + slotElementId);
}

function getBoundingClient(bid) {
Expand All @@ -300,7 +310,7 @@ function getBoundingClient(bid) {
function getAd(bid) {
let ad, adUrl, vastXml, vastUrl;

switch (deepAccess(bid, 'ext.prebid.type')) {
switch (deepAccess(bid, "ext.prebid.type")) {
default:
if (bid.adm && bid.nurl) {
ad = bid.adm;
Expand Down Expand Up @@ -356,7 +366,8 @@ function initSendingDataStatistic() {
eventHendlers = {};

initEvents() {
this.disabledSending = !!config.getBidderConfig()?.setupad?.disabledSendingStatisticData;
this.disabledSending =
!!config.getBidderConfig()?.setupad?.disabledSendingStatisticData;
if (this.disabledSending) {
this.removeEvents();
} else {
Expand Down

0 comments on commit 75178b9

Please sign in to comment.