Skip to content

Commit

Permalink
Adagio Rtd Provider: add missing signal at ortb2.site.ext.data.adg_rt…
Browse files Browse the repository at this point in the history
…d level (#11772)

* AdagioRtdProvider: add missing signal at ortb2 level

* AdagioRtdProvider: move safeFrame related code inside Core utils.js
  • Loading branch information
osazos committed Jun 19, 2024
1 parent eacd24e commit 0668544
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
22 changes: 10 additions & 12 deletions modules/adagioRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
deepSetValue,
generateUUID,
getDomLoadingDuration,
getSafeframeGeometry,
getUniqueIdentifierStr,
getWindowSelf,
getWindowTop,
Expand Down Expand Up @@ -278,6 +279,7 @@ function onGetBidRequestData(bidReqConfig, callback, config) {
const features = _internal.getFeatures().get();
const ext = {
uid: generateUUID(),
pageviewId: _ADAGIO.pageviewId,
features: { ...features },
session: { ..._SESSION.get() }
};
Expand Down Expand Up @@ -431,16 +433,14 @@ function getSlotPosition(adUnit) {
const position = { x: 0, y: 0 };

if (isSafeFrameWindow()) {
const ws = getWindowSelf();
const { self } = getSafeframeGeometry() || {};

const sfGeom = (typeof ws.$sf.ext.geom === 'function') ? ws.$sf.ext.geom() : null;

if (!sfGeom || !sfGeom.self) {
if (!self) {
return '';
}

position.x = Math.round(sfGeom.self.t);
position.y = Math.round(sfGeom.self.l);
position.x = Math.round(self.t);
position.y = Math.round(self.l);
} else {
try {
// window.top based computing
Expand Down Expand Up @@ -516,16 +516,14 @@ function getViewPortDimensions() {
const viewportDims = { w: 0, h: 0 };

if (isSafeFrameWindow()) {
const ws = getWindowSelf();

const sfGeom = (typeof ws.$sf.ext.geom === 'function') ? ws.$sf.ext.geom() : null;
const { win } = getSafeframeGeometry() || {};

if (!sfGeom || !sfGeom.win) {
if (!win) {
return '';
}

viewportDims.w = Math.round(sfGeom.win.w);
viewportDims.h = Math.round(sfGeom.win.h);
viewportDims.w = Math.round(win.w);
viewportDims.h = Math.round(win.h);
} else {
// window.top based computing
const wt = getWindowTop();
Expand Down
15 changes: 15 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,21 @@ export function isSafeFrameWindow() {
return !!(ws.$sf && ws.$sf.ext);
}

/**
* Returns the result of calling the function $sf.ext.geom() if it exists
* @see https://iabtechlab.com/wp-content/uploads/2016/03/SafeFrames_v1.1_final.pdf — 5.4 Function $sf.ext.geom
* @returns {Object | undefined} geometric information about the container
*/
export function getSafeframeGeometry() {
try {
const ws = getWindowSelf();
return (typeof ws.$sf.ext.geom === 'function') ? ws.$sf.ext.geom() : undefined;
} catch (e) {
logError('Error getting SafeFrame geometry', e);
return undefined;
}
}

export function isSafariBrowser() {
return /^((?!chrome|android|crios|fxios).)*safari/i.test(navigator.userAgent);
}
Expand Down

0 comments on commit 0668544

Please sign in to comment.