Skip to content

Commit

Permalink
add adunit geometry parameter to the bid request
Browse files Browse the repository at this point in the history
  • Loading branch information
ybootin committed Oct 20, 2023
1 parent 6f778da commit 6796aa0
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions modules/seedtagBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ function buildBidRequest(validBidRequest) {
return mediaTypesMap[pbjsType];
}
);

const bidRequest = {
id: validBidRequest.bidId,
transactionId: validBidRequest.ortb2Imp?.ext?.tid,
sizes: validBidRequest.sizes,
supplyTypes: mediaTypes,
adUnitId: params.adUnitId,
adUnitCode: validBidRequest.adUnitCode,
geom: geom(validBidRequest.adUnitCode),
placement: params.placement,
requestCount: validBidRequest.bidderRequestsCount || 1, // FIXME : in unit test the parameter bidderRequestsCount is undefined
};
Expand Down Expand Up @@ -198,6 +198,27 @@ function ttfb() {
return ttfb >= 0 && ttfb <= performance.now() ? ttfb : 0;
}

function geom(adunitCode) {
const slot = document.getElementById(adunitCode);
if (slot) {
const scrollY = window.scrollY;
const { top, left, width, height } = slot.getBoundingClientRect();
const viewport = {
width: window.innerWidth,
height: window.innerHeight,
};

return {
scrollY,
top,
left,
width,
height,
viewport,
};
}
}

export function getTimeoutUrl(data) {
let queryParams = '';
if (
Expand Down Expand Up @@ -277,13 +298,13 @@ export const spec = {
if (bidderRequest.gppConsent) {
payload.gppConsent = {
gppString: bidderRequest.gppConsent.gppString,
applicableSections: bidderRequest.gppConsent.applicableSections
}
applicableSections: bidderRequest.gppConsent.applicableSections,
};
} else if (bidderRequest.ortb2?.regs?.gpp) {
payload.gppConsent = {
gppString: bidderRequest.ortb2.regs.gpp,
applicableSections: bidderRequest.ortb2.regs.gpp_sid
}
applicableSections: bidderRequest.ortb2.regs.gpp_sid,
};
}

const payloadString = JSON.stringify(payload);
Expand Down

0 comments on commit 6796aa0

Please sign in to comment.