Skip to content

Commit

Permalink
Add screen and viewport to ad request
Browse files Browse the repository at this point in the history
  • Loading branch information
antosarho committed Dec 6, 2024
1 parent 6a2c4cd commit b19e154
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 8 additions & 1 deletion modules/adnuntiusBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { registerBidder } from '../src/adapters/bidderFactory.js';
import {BANNER, VIDEO} from '../src/mediaTypes.js';
import {isStr, isEmpty, deepAccess, getUnixTimestampFromNow, convertObjectToArray} from '../src/utils.js';
import {isStr, isEmpty, deepAccess, getUnixTimestampFromNow, convertObjectToArray, getWindowTop} from '../src/utils.js';
import { config } from '../src/config.js';
import { getStorageManager } from '../src/storageManager.js';

Expand Down Expand Up @@ -244,6 +244,13 @@ export const spec = {
queryParamsAndValues.push('consentString=' + consentString);
queryParamsAndValues.push('gdpr=' + flag);
}
const win = getWindowTop() || window;
if (win.screen && win.screen.availHeight) {
queryParamsAndValues.push('screen=' + win.screen.availWidth + 'x' + win.screen.availHeight);
}
if (win.innerWidth) {
queryParamsAndValues.push('viewport=' + win.innerWidth + 'x' + win.innerHeight);
}

const searchParams = new URLSearchParams(window.location.search);
if (searchParams.has('script-override')) {
Expand Down
8 changes: 5 additions & 3 deletions test/spec/modules/adnuntiusBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ describe('adnuntiusBidAdapter', function () {
});

const tzo = new Date().getTimezoneOffset();
const ENDPOINT_URL_BASE = `${URL}${tzo}&format=prebid`;
const screen = window.screen.availWidth + 'x' + window.screen.availHeight;
const viewport = window.innerWidth + 'x' + window.innerHeight;
const ENDPOINT_URL_BASE = `${URL}${tzo}&format=prebid&screen=${screen}&viewport=${viewport}`;
const ENDPOINT_URL = `${ENDPOINT_URL_BASE}&userId=${usi}`;
const ENDPOINT_URL_NOCOOKIE = `${ENDPOINT_URL_BASE}&userId=${usi}&noCookies=true`;
const ENDPOINT_URL_SEGMENTS = `${ENDPOINT_URL_BASE}&segments=segment1,segment2,segment3&userId=${usi}`;
const ENDPOINT_URL_CONSENT = `${EURO_URL}${tzo}&format=prebid&consentString=consentString&gdpr=1&userId=${usi}`;
const ENDPOINT_URL_CONSENT = `${EURO_URL}${tzo}&format=prebid&consentString=consentString&gdpr=1&screen=${screen}&viewport=${viewport}&userId=${usi}`;
const adapter = newBidder(spec);

const bidderRequests = [
Expand Down Expand Up @@ -669,7 +671,7 @@ describe('adnuntiusBidAdapter', function () {
const bid = request[0].bid[0]
expect(bid).to.have.property('bidId');
expect(request[0]).to.have.property('url');
expect(request[0].url).to.equal(ENDPOINT_URL.replace('format=prebid', 'format=prebid&so=overridden-value'));
expect(request[0].url).to.equal(ENDPOINT_URL.replace('&userId', '&so=overridden-value&userId'));
expect(request[0]).to.have.property('data');
expect(request[0].data).to.equal('{"adUnits":[{"auId":"000000000008b6bc","targetId":"123","maxDeals":1,"dimensions":[[640,480],[600,400]]},{"auId":"0000000000000551","targetId":"adn-0000000000000551","dimensions":[[1640,1480],[1600,1400]]}],"context":"https://canonical.com/something-else.html","canonical":"https://canonical.com/page.html"}');
});
Expand Down

0 comments on commit b19e154

Please sign in to comment.