Skip to content

Commit 3b51731

Browse files
patmmccanndgirardi
andauthored
Vidazoo utils: fix screen resolution detection (prebid#14122)
* Fix Vidazoo utils screen resolution detection * remove duplication --------- Co-authored-by: Demetrio Girardi <dgirardi@prebid.org>
1 parent 99c6ec3 commit 3b51731

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

libraries/vidazooUtils/bidderUtils.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import {
66
parseSizesInput,
77
parseUrl,
88
triggerPixel,
9-
uniques
9+
uniques,
10+
getWinDimensions
1011
} from '../../src/utils.js';
1112
import {chunk} from '../chunk/chunk.js';
1213
import {CURRENCY, DEAL_ID_EXPIRY, SESSION_ID_KEY, TTL_SECONDS, UNIQUE_DEAL_ID_EXPIRY} from './constants.js';
@@ -280,7 +281,7 @@ export function buildRequestData(bid, topWindowUrl, sizes, bidderRequest, bidder
280281
uniqueDealId: uniqueDealId,
281282
bidderVersion: bidderVersion,
282283
prebidVersion: '$prebid.version$',
283-
res: `${screen.width}x${screen.height}`,
284+
res: getScreenResolution(),
284285
schain: schain,
285286
mediaTypes: mediaTypes,
286287
isStorageAllowed: isStorageAllowed,
@@ -374,6 +375,15 @@ export function buildRequestData(bid, topWindowUrl, sizes, bidderRequest, bidder
374375
return data;
375376
}
376377

378+
function getScreenResolution() {
379+
const dimensions = getWinDimensions();
380+
const width = dimensions?.screen?.width;
381+
const height = dimensions?.screen?.height;
382+
if (width != null && height != null) {
383+
return `${width}x${height}`
384+
}
385+
}
386+
377387
export function createInterpretResponseFn(bidderCode, allowSingleRequest) {
378388
return function interpretResponse(serverResponse, request) {
379389
if (!serverResponse || !serverResponse.body) {

test/spec/modules/shinezRtbBidAdapter_spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
tryParseJSON,
1515
getUniqueDealId,
1616
} from '../../../libraries/vidazooUtils/bidderUtils.js';
17-
import {parseUrl, deepClone} from 'src/utils.js';
17+
import {parseUrl, deepClone, getWinDimensions} from 'src/utils.js';
1818
import {version} from 'package.json';
1919
import {useFakeTimers} from 'sinon';
2020
import {BANNER, VIDEO} from '../../../src/mediaTypes.js';
@@ -428,7 +428,7 @@ describe('ShinezRtbBidAdapter', function () {
428428
bidderVersion: adapter.version,
429429
prebidVersion: version,
430430
schain: BID.schain,
431-
res: `${window.top.screen.width}x${window.top.screen.height}`,
431+
res: `${getWinDimensions().screen.width}x${getWinDimensions().screen.height}`,
432432
mediaTypes: [BANNER],
433433
gpid: '0123456789',
434434
uqs: getTopWindowQueryParams(),

0 commit comments

Comments
 (0)