Skip to content

Commit 4d9c15a

Browse files
Connatix Bid Adapter: support viewability (#12122)
* implement viewability support openxBidAdapter remove PAF, bugfix ortbConverter response (#12105) Appnexus Bid Adapter: fix parse of the encoded string to check for ast_override_div argument (#12106) Richaudience Bid Adapter : add compability with DSA (#12099) * Update richaudienceBidAdapter.md Update maintainer e-mail to [email protected] * Add richaudienceBidAdapter.js file * Add richaudienceBidAdapter_spec.js * Update richaudienceBidAdapter.js * RichaudienceBidAdapter add compability with DSA * RichaudienceBidAdapter add compability with DSA * RichaudienceBidAdapter add compability with DSA --------- Co-authored-by: Patrick McCann <[email protected]> Co-authored-by: sergigimenez <[email protected]> finish unit testing added container identifier for viewability on bid params Add new TGM adapter (#12100) Co-authored-by: apykhteyev <[email protected]> Prebid 9.9.0 release Increment version to 9.10.0-pre deprecate old copper6 alias (#12112) LimelightDigital Adapter: Add support of ortb2 and ortb2Imp objects (#12078) * Add support of ortb2 and ortb2Imp objects * Fix tests * Fix tests --------- Co-authored-by: apykhteyev <[email protected]> update configuration example (#12109) FPD Enrichment: Replace device values `w` and `h` with screen size; add `ext.vpw` and `ext.vph` (#12108) Core: fix broken native resizing (#12096) * Core: fix broken native resizing * fix test Weborama RTD Module: BUGFIX on user-centric profile validation (#12095) * update unit tests * fix code and doc * improve integration example * add extra test * improve logging * fix lint issues hotfix - after this I will fix all tests fix fix width and height fix iframe detection change detected viewability between 0 and 1 to be consistent with declared viewability improve the case case where the publisher doesn't send us a container id to check viewability fully covered by tests fix test that works local re-use percentInView method fix unit tests removed test Revert "removed test" This reverts commit 15dcab7. Anyclip Bid Adapter : refactor bid adapter (#12030) * update anyclip adapter * remove coppa * fix jsdoc warnings * create bidderUtils * delete duplicate code * refactor --------- Co-authored-by: Chucky-choo <[email protected]> Digital Matter Bid Adapter: initial release (#12114) * update anyclip adapter * remove coppa * fix jsdoc warnings * create bidderUtils * delete duplicate code * refactor * add digitalMatter Bid Adapter --------- Co-authored-by: Chucky-choo <[email protected]> IX Bid Adapter: Remove client FT pbjs_allow_all_eids (#12117) Co-authored-by: Sajid Mahmood <[email protected]> SeedingAlliance Adapter: rework to properly use openRTB standard internally (#12101) * rework adapter to only use openRTB data internally * added comments * fix lint errors saambaaBidAdapter.js: make alias of advangelist (#11992) * saambaaBidAdapter.js: reuse repeated code block * Update saambaaBidAdapter.js * Update advangelistsBidAdapter.js * Update saambaaBidAdapter.js * Update advangelistsBidAdapter.js * Update saambaaBidAdapter.js * Update advangelistsBidAdapter.js * Create index.js * Update saambaaBidAdapter.js * Update advangelistsBidAdapter.js * Update index.js * Update advangelistsBidAdapter.js * Update saambaaBidAdapter.js * Update index.js * Update advangelistsBidAdapter.js * Update saambaaBidAdapter.js * Update index.js * Update advangelistsBidAdapter.js * Update saambaaBidAdapter.js * Update advangelistsBidAdapter.js * Delete modules/saambaaBidAdapter.js * Update advangelistsBidAdapter.js * Update beachfrontBidAdapter.js * Update beachfrontBidAdapter.js * Update beachfrontBidAdapter.js * Update nextrollBidAdapter.js * Update beachfrontBidAdapter.js * Update index.js * Update advangelistsBidAdapter.js * Update beachfrontBidAdapter.js * Create saambaaBidAdapter.js * fix file name --------- Co-authored-by: Chris Huie <[email protected]> Prebid 9.10.0 release Increment version to 9.11.0-pre Core: make sure adUnitCodes are unique in auction events (#12127) Mobian RTD provider: update API endpoint (#12121) * update API endpoint for mobian RTD provider * lint mobian RTD provider Initial Commit for Symitri Analytics Adapter (#12132) Co-authored-by: Manan <[email protected]> Djax Bid Adapter : initial release (#12120) * Djax bid adapter files added * fix linting issue * Linting issue fixed * Update djaxBidAdapter.js * Update djaxBidAdapter_spec.js * Update djaxBidAdapter_spec.js --------- Co-authored-by: Chris Huie <[email protected]> Co-authored-by: Patrick McCann <[email protected]> Preciso : Added new library to remove code duplication in bid adapter (#11868) * Preciso : Added new library to remove code duplication in bid adapter * modified bidfloor mapping logic * error fix * error fix * import bidUtils.js in IdxBidadapter to reduce the code duplicataion * import bidUtils.js in IdxBidadapter to reduce the code duplicataion * Error fix * Imported bidUtils library into redtram bid adapter * import common library in mediabramaBidAdapter * import common library in loganBidAdapter to remove code duplication * removed storageManaser from library * renderer.js changes reverted 33across - allow aliasing (#12138) Updating isBidRequestValid logic to account for aliasing of bidder names (#12136) Digitalmatter Bid Adapter : add dichange alias (#12133) * add alias * fix alias --------- Co-authored-by: Chucky-choo <[email protected]> add media consortium adapter (#11892) Co-authored-by: Maxime Lequain <[email protected]> UserID: merge EIDs with first party data (#12110) * ortbConverter: do not override EIDS provided as first party data * update tests * Allow bidder-specific FPD enrichments * Refactor eid generation, add primaryIds * EIDs as FPD * Fix tests * PBS tests, fix multiple hook registration * Fix more test cleanup * remove eidPermissions * refactor oderByPriority * refactor initializedSubmodules * fix lint * update id5 primaryIds * simplify eid source filtering * clean up PBS userId logic * Revert "Allow bidder-specific FPD enrichments" This reverts commit 2fb7452. * undo bidder-specific enrichments * use startAuction instead of requestBids * add test on userIdAsEids * Fix lint Bump ws, @wdio/browserstack-service, @wdio/cli and @wdio/local-runner (#12148) Bumps [ws](https://github.com/websockets/ws) to 8.17.1 and updates ancestor dependencies [ws](https://github.com/websockets/ws), [@wdio/browserstack-service](https://github.com/webdriverio/webdriverio/tree/HEAD/packages/wdio-browserstack-service), [@wdio/cli](https://github.com/webdriverio/webdriverio/tree/HEAD/packages/wdio-cli) and [@wdio/local-runner](https://github.com/webdriverio/webdriverio/tree/HEAD/packages/wdio-local-runner). These dependencies need to be updated together. Updates `ws` from 8.13.0 to 8.17.1 - [Release notes](https://github.com/websockets/ws/releases) - [Commits](websockets/ws@8.13.0...8.17.1) Updates `@wdio/browserstack-service` from 8.39.0 to 9.0.5 - [Release notes](https://github.com/webdriverio/webdriverio/releases) - [Changelog](https://github.com/webdriverio/webdriverio/blob/main/CHANGELOG.md) - [Commits](https://github.com/webdriverio/webdriverio/commits/v9.0.5/packages/wdio-browserstack-service) Updates `@wdio/cli` from 8.39.0 to 9.0.5 - [Release notes](https://github.com/webdriverio/webdriverio/releases) - [Changelog](https://github.com/webdriverio/webdriverio/blob/main/CHANGELOG.md) - [Commits](https://github.com/webdriverio/webdriverio/commits/v9.0.5/packages/wdio-cli) Updates `@wdio/local-runner` from 8.39.0 to 9.0.5 - [Release notes](https://github.com/webdriverio/webdriverio/releases) - [Changelog](https://github.com/webdriverio/webdriverio/blob/main/CHANGELOG.md) - [Commits](https://github.com/webdriverio/webdriverio/commits/v9.0.5/packages/wdio-local-runner) --- updated-dependencies: - dependency-name: ws dependency-type: indirect - dependency-name: "@wdio/browserstack-service" dependency-type: direct:development - dependency-name: "@wdio/cli" dependency-type: direct:development - dependency-name: "@wdio/local-runner" dependency-type: direct:development ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Smartadserver Bid Adapter : add DSA support (#12141) * add support of dsa * restore topics * DSA fix for UT Change consent default param name (#12154) Co-authored-by: Danijel Ristic <[email protected]> Freedom Ad Network Bid Adapter: initial release (#12153) * Create fanAdapter.md * Create fanAdapter.js * Create fanAdapter_spec.js * Update fanAdapter_spec.js * Update fanAdapter.js * Update fanAdapter.js * Update fanAdapter_spec.js * Update fanAdapter.js * Update fanAdapter_spec.js * Update fanAdapter.js * Update fanAdapter_spec.js * Update fanAdapter.js * Update fanAdapter_spec.js * Update fanAdapter.js * Update fanAdapter.js deleted bidder name check (#12157) Co-authored-by: Octavia Suceava <[email protected]> Connatix Bid Adapter : support eids (#12142) * add eids on request * change naming --------- Co-authored-by: Darian Avasan <[email protected]> Co-authored-by: Octavia Suceava <[email protected]> PrebidServer Bid Adapter : update to use gloablly defined alias or s2sConfig defined alias (#12159) * update to use gloablly defined alias or s2sConfig defined alias * Add test case --------- Co-authored-by: Demetrio Girardi <[email protected]> * fix build * test if can fix * Revert "test if can fix" This reverts commit 221f612. * remove test * refactoring --------- Co-authored-by: Demetrio Girardi <[email protected]>
1 parent 08c1cc0 commit 4d9c15a

File tree

2 files changed

+369
-2
lines changed

2 files changed

+369
-2
lines changed

modules/connatixBidAdapter.js

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@ import {
22
registerBidder
33
} from '../src/adapters/bidderFactory.js';
44

5+
import { percentInView } from '../libraries/percentInView/percentInView.js';
6+
57
import {
68
deepAccess,
79
isFn,
810
logError,
911
isArray,
1012
formatQS,
13+
getWindowTop,
14+
isNumber,
15+
isStr,
1116
deepSetValue
1217
} from '../src/utils.js';
1318

@@ -62,6 +67,76 @@ export function validateVideo(mediaTypes) {
6267
return video.context !== ADPOD;
6368
}
6469

70+
export function _getMinSize(sizes) {
71+
if (!sizes || sizes.length === 0) return undefined;
72+
return sizes.reduce((minSize, currentSize) => {
73+
const minArea = minSize.w * minSize.h;
74+
const currentArea = currentSize.w * currentSize.h;
75+
return currentArea < minArea ? currentSize : minSize;
76+
});
77+
}
78+
79+
export function _canSelectViewabilityContainer() {
80+
try {
81+
window.top.document.querySelector('#viewability-container');
82+
return true;
83+
} catch (e) {
84+
return false;
85+
}
86+
}
87+
88+
export function _isViewabilityMeasurable(element) {
89+
if (!element) return false;
90+
return _canSelectViewabilityContainer(element);
91+
}
92+
93+
export function _getViewability(element, topWin, { w, h } = {}) {
94+
return topWin.document.visibilityState === 'visible'
95+
? percentInView(element, topWin, { w, h })
96+
: 0;
97+
}
98+
99+
export function detectViewability(bid) {
100+
const { params, adUnitCode } = bid;
101+
102+
const viewabilityContainerIdentifier = params.viewabilityContainerIdentifier;
103+
104+
let element = null;
105+
let bidParamSizes = null;
106+
let minSize = [];
107+
108+
if (isStr(viewabilityContainerIdentifier)) {
109+
try {
110+
element = document.querySelector(viewabilityContainerIdentifier) || window.top.document.querySelector(viewabilityContainerIdentifier);
111+
if (element) {
112+
bidParamSizes = [element.offsetWidth, element.offsetHeight];
113+
minSize = _getMinSize(bidParamSizes)
114+
}
115+
} catch (e) {
116+
logError(`Error while trying to find viewability container element: ${viewabilityContainerIdentifier}`);
117+
}
118+
}
119+
120+
if (!element) {
121+
// Get the sizes from the mediaTypes object if it exists, otherwise use the sizes array from the bid object
122+
bidParamSizes = bid.mediaTypes && bid.mediaTypes.banner && bid.mediaTypes.banner.sizes ? bid.mediaTypes.banner.sizes : bid.sizes;
123+
bidParamSizes = typeof bidParamSizes === 'undefined' && bid.mediaType && bid.mediaType.video && bid.mediaType.video.playerSize ? bid.mediaType.video.playerSize : bidParamSizes;
124+
bidParamSizes = typeof bidParamSizes === 'undefined' && bid.mediaType && bid.mediaType.video && isNumber(bid.mediaType.video.w) && isNumber(bid.mediaType.h) ? [bid.mediaType.video.w, bid.mediaType.video.h] : bidParamSizes;
125+
minSize = _getMinSize(bidParamSizes ?? [])
126+
element = document.getElementById(adUnitCode);
127+
}
128+
129+
if (_isViewabilityMeasurable(element)) {
130+
const minSizeObj = {
131+
w: minSize[0],
132+
h: minSize[1]
133+
}
134+
return Math.round(_getViewability(element, getWindowTop(), minSizeObj))
135+
}
136+
137+
return null;
138+
}
139+
65140
/**
66141
* Get ids from Prebid User ID Modules and add them to the payload
67142
*/
@@ -91,9 +166,10 @@ export const spec = {
91166
const hasMediaTypes = Boolean(mediaTypes) && (Boolean(mediaTypes[BANNER]) || Boolean(mediaTypes[VIDEO]));
92167
const isValidBanner = validateBanner(mediaTypes);
93168
const isValidVideo = validateVideo(mediaTypes);
169+
const isValidViewability = typeof params.viewabilityPercentage === 'undefined' || (isNumber(params.viewabilityPercentage) && params.viewabilityPercentage >= 0 && params.viewabilityPercentage <= 1);
94170
const hasRequiredBidParams = Boolean(params.placementId);
95171

96-
const isValid = hasBidId && hasMediaTypes && isValidBanner && isValidVideo && hasRequiredBidParams;
172+
const isValid = hasBidId && hasMediaTypes && isValidBanner && isValidVideo && hasRequiredBidParams && isValidViewability;
97173
if (!isValid) {
98174
logError(
99175
`Invalid bid request:
@@ -120,10 +196,18 @@ export const spec = {
120196
params,
121197
sizes,
122198
} = bid;
199+
200+
let detectedViewabilityPercentage = detectViewability(bid);
201+
if (isNumber(detectedViewabilityPercentage)) {
202+
detectedViewabilityPercentage = detectedViewabilityPercentage / 100;
203+
}
204+
123205
return {
124206
bidId,
125207
mediaTypes,
126208
sizes,
209+
detectedViewabilityPercentage,
210+
declaredViewabilityPercentage: bid.params.viewabilityPercentage ?? null,
127211
placementId: params.placementId,
128212
floor: getBidFloor(bid),
129213
};

0 commit comments

Comments
 (0)