Skip to content

Commit

Permalink
Merge branch 'prebid:master' into autoplay-fix-fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
github-matthieu-wipliez authored Jun 20, 2024
2 parents 9f041df + 0ee1ba7 commit cf8fea2
Show file tree
Hide file tree
Showing 41 changed files with 2,724 additions and 627 deletions.
1 change: 1 addition & 0 deletions integrationExamples/gpt/raynRtdProvider_example.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"3": ["264", "267", "261"],
"4": ["438"]
},
"103015": ['agdv23', 'avscg3'],
"903555595": {
"7": {
"2": ["51", "246"]
Expand Down
35 changes: 35 additions & 0 deletions libraries/adagioUtils/adagioUtils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {
canAccessWindowTop,
generateUUID,
getWindowSelf,
getWindowTop,
isSafeFrameWindow
} from '../../src/utils.js';

/**
* Returns the best Window object to use with ADAGIO.
* @returns {Window} window.top or window.self object
*/
export function getBestWindowForAdagio() {
return (canAccessWindowTop()) ? getWindowTop() : getWindowSelf();
}

/**
* Returns the window.ADAGIO global object used to store Adagio data.
* This object is created in window.top if possible, otherwise in window.self.
*/
export const _ADAGIO = (function() {
const w = getBestWindowForAdagio();

w.ADAGIO = w.ADAGIO || {};
w.ADAGIO.pageviewId = w.ADAGIO.pageviewId || generateUUID();
w.ADAGIO.adUnits = w.ADAGIO.adUnits || {};
w.ADAGIO.pbjsAdUnits = w.ADAGIO.pbjsAdUnits || [];
w.ADAGIO.queue = w.ADAGIO.queue || [];
w.ADAGIO.versions = w.ADAGIO.versions || {};
w.ADAGIO.versions.pbjs = '$prebid.version$';
w.ADAGIO.windows = w.ADAGIO.windows || [];
w.ADAGIO.isSafeFrameWindow = isSafeFrameWindow();

return w.ADAGIO;
})();
1 change: 1 addition & 0 deletions modules/.submodules.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"1plusXRtdProvider",
"a1MediaRtdProvider",
"aaxBlockmeterRtdProvider",
"adagioRtdProvider",
"adlooxRtdProvider",
"adnuntiusRtdProvider",
"airgridRtdProvider",
Expand Down
18 changes: 1 addition & 17 deletions modules/adagioBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ import {
generateUUID,
getDNT,
getWindowSelf,
getWindowTop,
isArray,
isArrayOfNums,
isFn,
isInteger,
isNumber,
isSafeFrameWindow,
isStr,
logError,
logInfo,
Expand All @@ -26,6 +24,7 @@ import { config } from '../src/config.js';
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';
import { find } from '../src/polyfill.js';
import { getGptSlotInfoForAdUnitCode } from '../libraries/gptUtils/gptUtils.js';
import { _ADAGIO } from '../libraries/adagioUtils/adagioUtils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { userSync } from '../src/userSync.js';

Expand Down Expand Up @@ -78,21 +77,6 @@ export const ORTB_VIDEO_PARAMS = {
* Returns the window.ADAGIO global object used to store Adagio data.
* This object is created in window.top if possible, otherwise in window.self.
*/
const _ADAGIO = (function() {
const w = (canAccessWindowTop()) ? getWindowTop() : getWindowSelf();

w.ADAGIO = w.ADAGIO || {};
w.ADAGIO.pageviewId = w.ADAGIO.pageviewId || generateUUID();
w.ADAGIO.adUnits = w.ADAGIO.adUnits || {};
w.ADAGIO.pbjsAdUnits = w.ADAGIO.pbjsAdUnits || [];
w.ADAGIO.queue = w.ADAGIO.queue || [];
w.ADAGIO.versions = w.ADAGIO.versions || {};
w.ADAGIO.versions.pbjs = '$prebid.version$';
w.ADAGIO.isSafeFrameWindow = isSafeFrameWindow();

return w.ADAGIO;
})();

function getDevice() {
const language = navigator.language ? 'language' : 'userLanguage';
return {
Expand Down
61 changes: 15 additions & 46 deletions modules/adagioRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
deepAccess,
deepSetValue,
generateUUID,
getDomLoadingDuration,
getSafeframeGeometry,
getUniqueIdentifierStr,
getWindowSelf,
getWindowTop,
Expand All @@ -24,6 +26,7 @@ import {
isStr,
prefixLog
} from '../src/utils.js';
import { _ADAGIO, getBestWindowForAdagio } from '../libraries/adagioUtils/adagioUtils.js';
import { getGptSlotInfoForAdUnitCode } from '../libraries/gptUtils/gptUtils.js';

/**
Expand All @@ -42,23 +45,6 @@ const { logError, logWarn } = prefixLog('AdagioRtdProvider:');
// Guard to avoid storing the same bid data several times.
const guard = new Set();

/**
* Returns the window.ADAGIO global object used to store Adagio data.
* This object is created in window.top if possible, otherwise in window.self.
*/
const _ADAGIO = (function() {
const w = (canAccessWindowTop()) ? getWindowTop() : getWindowSelf();

w.ADAGIO = w.ADAGIO || {};
w.ADAGIO.pageviewId = w.ADAGIO.pageviewId || generateUUID();
w.ADAGIO.adUnits = w.ADAGIO.adUnits || {};
w.ADAGIO.pbjsAdUnits = w.ADAGIO.pbjsAdUnits || [];
w.ADAGIO.queue = w.ADAGIO.queue || [];
w.ADAGIO.windows = w.ADAGIO.windows || [];

return w.ADAGIO;
})();

/**
* Store the sampling data.
* This data is used to determine if beacons should be sent to adagio.
Expand Down Expand Up @@ -131,12 +117,14 @@ const _FEATURES = (function() {
features.data = {};
},
get: function() {
const w = getBestWindowForAdagio();

if (!features.initialized) {
features.data = {
page_dimensions: getPageDimensions().toString(),
viewport_dimensions: getViewPortDimensions().toString(),
user_timestamp: getTimestampUTC().toString(),
dom_loading: getDomLoadingDuration().toString(),
dom_loading: getDomLoadingDuration(w).toString(),
};
features.initialized = true;
}
Expand Down Expand Up @@ -275,6 +263,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 @@ -428,16 +417,14 @@ function getSlotPosition(adUnit) {
const position = { x: 0, y: 0 };

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

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

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 @@ -513,16 +500,14 @@ function getViewPortDimensions() {
const viewportDims = { w: 0, h: 0 };

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

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

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 All @@ -538,22 +523,6 @@ function getTimestampUTC() {
return Math.floor(new Date().getTime() / 1000) - new Date().getTimezoneOffset() * 60;
}

function getDomLoadingDuration() {
const w = (canAccessWindowTop()) ? getWindowTop() : getWindowSelf();
const performance = w.performance;

let domLoadingDuration = -1;

if (performance && performance.timing && performance.timing.navigationStart > 0) {
const val = performance.timing.domLoading - performance.timing.navigationStart;
if (val > 0) {
domLoadingDuration = val;
}
}

return domLoadingDuration;
}

/**
* registerEventsForAdServers bind adagio listeners to ad-server events.
* Theses events are used to track the viewability and attention.
Expand Down
34 changes: 3 additions & 31 deletions modules/bliinkBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { registerBidder } from '../src/adapters/bidderFactory.js'
import { config } from '../src/config.js'
import { _each, deepAccess, deepSetValue, getWindowSelf, getWindowTop } from '../src/utils.js'
import { _each, canAccessWindowTop, deepAccess, deepSetValue, getDomLoadingDuration, getWindowSelf, getWindowTop } from '../src/utils.js'
export const BIDDER_CODE = 'bliink'
export const GVL_ID = 658
export const BLIINK_ENDPOINT_ENGINE = 'https://engine.bliink.io/prebid'
Expand Down Expand Up @@ -121,35 +121,6 @@ export function getKeywords() {
return [];
}

function canAccessTopWindow() {
try {
if (getWindowTop().location.href) {
return true;
}
} catch (error) {
return false;
}
}

/**
* domLoading feature is computed on window.top if reachable.
*/
export function getDomLoadingDuration() {
let domLoadingDuration = -1;
let performance;

performance = (canAccessTopWindow()) ? getWindowTop().performance : getWindowSelf().performance;

if (performance && performance.timing && performance.timing.navigationStart > 0) {
const val = performance.timing.domLoading - performance.timing.navigationStart;
if (val > 0) {
domLoadingDuration = val;
}
}

return domLoadingDuration;
}

/**
* @param bidResponse
* @return {({cpm, netRevenue: boolean, requestId, width: number, currency, ttl: number, creativeId, height: number}&{mediaType: string, vastXml})|null}
Expand Down Expand Up @@ -208,7 +179,8 @@ export const isBidRequestValid = (bid) => {
*/
export const buildRequests = (validBidRequests, bidderRequest) => {
if (!validBidRequests || !bidderRequest || !bidderRequest.bids) return null
const domLoadingDuration = getDomLoadingDuration().toString();
const w = (canAccessWindowTop()) ? getWindowTop() : getWindowSelf();
const domLoadingDuration = getDomLoadingDuration(w).toString();
const tags = bidderRequest.bids.map((bid) => {
let bidFloor;
const sizes = bid.sizes.map((size) => ({ w: size[0], h: size[1] }));
Expand Down
2 changes: 1 addition & 1 deletion modules/ceeIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const ceeIdSubmodule = {
* performs action to obtain id and return a value
* @function
* @returns {(IdResponse|undefined)}
*/
*/
getId(config) {
const { params = {} } = config;
const { tokenName, value } = params
Expand Down
33 changes: 31 additions & 2 deletions modules/id5IdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const LOCAL_STORAGE = 'html5';
const LOG_PREFIX = 'User ID - ID5 submodule: ';
const ID5_API_CONFIG_URL = 'https://id5-sync.com/api/config/prebid';
const ID5_DOMAIN = 'id5-sync.com';
const TRUE_LINK_SOURCE = 'true-link-id5-sync.com';

// order the legacy cookie names in reverse priority order so the last
// cookie in the array is the most preferred to use
Expand Down Expand Up @@ -134,12 +135,13 @@ export const id5IdSubmodule = {
* @returns {(Object|undefined)}
*/
decode(value, config) {
let universalUid;
let universalUid, publisherTrueLinkId;
let ext = {};

if (value && typeof value.universal_uid === 'string') {
universalUid = value.universal_uid;
ext = value.ext || ext;
publisherTrueLinkId = value.publisherTrueLinkId;
} else {
return undefined;
}
Expand All @@ -159,6 +161,12 @@ export const id5IdSubmodule = {
};
}

if (publisherTrueLinkId) {
responseObj.trueLinkId = {
uid: publisherTrueLinkId,
};
}

const abTestingResult = deepAccess(value, 'ab_testing.result');
switch (abTestingResult) {
case 'control':
Expand Down Expand Up @@ -263,7 +271,22 @@ export const id5IdSubmodule = {
return data.ext;
}
}
},
'trueLinkId': {
getValue: function (data) {
return data.uid;
},
getSource: function (data) {
return TRUE_LINK_SOURCE;
},
atype: 1,
getUidExt: function (data) {
if (data.ext) {
return data.ext;
}
}
}

}
};

Expand Down Expand Up @@ -380,6 +403,8 @@ export class IdFetchFlow {
const referer = getRefererInfo();
const signature = (this.cacheIdObj && this.cacheIdObj.signature) ? this.cacheIdObj.signature : getLegacyCookieSignature();
const nbPage = incrementAndResetNb(params.partner);
const trueLinkInfo = window.id5Bootstrap ? window.id5Bootstrap.getTrueLinkInfo() : {booted: false};

const data = {
'partner': params.partner,
'gdpr': hasGdpr,
Expand All @@ -392,7 +417,8 @@ export class IdFetchFlow {
'u': referer.stack[0] || window.location.href,
'v': '$prebid.version$',
'storage': this.submoduleConfig.storage,
'localStorage': storage.localStorageIsEnabled() ? 1 : 0
'localStorage': storage.localStorageIsEnabled() ? 1 : 0,
'true_link': trueLinkInfo
};

// pass in optional data, but only if populated
Expand Down Expand Up @@ -431,6 +457,9 @@ export class IdFetchFlow {
try {
if (fetchCallResponse.privacy) {
storeInLocalStorage(ID5_PRIVACY_STORAGE_NAME, JSON.stringify(fetchCallResponse.privacy), NB_EXP_DAYS);
if (window.id5Bootstrap && window.id5Bootstrap.setPrivacy) {
window.id5Bootstrap.setPrivacy(fetchCallResponse.privacy);
}
}
} catch (error) {
logError(LOG_PREFIX + 'Error while writing privacy info into local storage.', error);
Expand Down
Loading

0 comments on commit cf8fea2

Please sign in to comment.