Skip to content

Commit

Permalink
Merge branch 'master' into prebid-7
Browse files Browse the repository at this point in the history
  • Loading branch information
dgirardi committed May 16, 2022
2 parents 863b2ee + 873d314 commit 6259946
Show file tree
Hide file tree
Showing 69 changed files with 5,247 additions and 1,561 deletions.
11 changes: 9 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,19 @@ module.exports = {
'no-throw-literal': 'off',
'no-undef': 2,
'no-useless-escape': 'off',
'no-console': 'error'
'no-console': 'error',
},
overrides: Object.keys(allowedModules).map((key) => ({
files: key + '/**/*.js',
rules: {
'prebid/validate-imports': ['error', allowedModules[key]]
'prebid/validate-imports': ['error', allowedModules[key]],
'no-restricted-globals': [
'error',
{
name: 'require',
message: 'use import instead'
}
]
}
})).concat([{
// code in other packages (such as plugins/eslint) is not "seen" by babel and its parser will complain.
Expand Down
76 changes: 65 additions & 11 deletions integrationExamples/gpt/weboramaRtdProvider_example.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>weborama rtd submodule example</title>
</head>

<body>
Expand All @@ -26,31 +27,39 @@
params: {
setPrebidTargeting: true, // optional
sendToBidders: true, // optional
onData: function (data, site) { // optional
var kind = (site) ? 'site' : 'user';
console.log('onData', kind, data);
onData: function (data, meta) { // optional
console.log('onData', data, meta);
},
weboCtxConf: {
token: "to-be-defined", // mandatory
targetURL: "https://prebid.org", // default is document.URL
setPrebidTargeting: true, // override param.setPrebidTargeting or default true
sendToBidders: true, // override param.sendToBidders or default true
defaultProfile: { // optional
webo_ctx: ['moon'],
webo_ctx: ["Rugby_Renault_c11495", "Sport_c11893"],
webo_ds: ['bar']
},
//, onData: function (data, ...) { ...}
// enabled: false,
//, onData: function (data,...) { ...}
},
weboUserDataConf: {
accountId: 12345, // optional
accountId: 12345, // recommended
setPrebidTargeting: true, // override param.setPrebidTargeting or default true
sendToBidders: true, // override param.sendToBidders or default true
sendToBidders: ['smartadserver'], // specify the bidder to share data
defaultProfile: { // optional
webo_cs: ['Red'],
webo_cs: ['red'],
webo_audiences: ['bam']
},
localStorageProfileKey: 'webo_wam2gam_entry', // default
// enabled: false,
//, onData: function (data,...) { ...}
},
sfbxLiteDataConf: {
enabled: true,
defaultProfile: { // optional
lite_occupation: ['gérant', 'bénévole'],
lite_hobbies: ['sport', 'cinéma'],
},
}
}
}]
Expand All @@ -62,6 +71,9 @@
var div_1_sizes = [
[300, 300]
];
var div_2_sizes = [
[600, 100]
];

var PREBID_TIMEOUT = 3000;
var FAILSAFE_TIMEOUT = 5000;
Expand Down Expand Up @@ -106,6 +118,46 @@
networkId: 456456,
},
}]
},
{
code: '/1056029/webo-wam-prebid',
mediaTypes: {
banner: {
sizes: div_2_sizes
}
},
bids: [{
bidder: 'smartadserver',
params: {
siteId: 1234,
pageId: 1234,
formatId: 1234,
}
}, {
bidder: 'pubmatic',
params: {
publisherId: '32572',
}
}, {
bidder: 'appnexus',
params: {
placementId: 234234,
}
}, {
bidder: 'rubicon',
params: {
accountId: '14062',
siteId: '70608',
zoneId: '335918',
userId: '12346',
}
}, {
bidder: 'criteo',
params: {
zoneId: 234234,
networkId: 456456,
},
}]
}
];

Expand Down Expand Up @@ -138,14 +190,14 @@
});
}


// in case PBJS doesn't load
setTimeout(function () {
initAdserver();
}, FAILSAFE_TIMEOUT);

googletag.cmd.push(function () {
googletag.defineSlot('/1056029/webo-ctx-prebid', div_1_sizes, 'div-gpt-ad-1620653642627-0').addService(googletag.pubads());
googletag.defineSlot('/1056029/webo-wam-prebid', div_2_sizes, 'div-gpt-ad-1645023761875-0').addService(googletag.pubads());
googletag.pubads().disableInitialLoad();
googletag.enableServices();
});
Expand All @@ -154,18 +206,20 @@

<article>
<p>
test webo ctx using prebid.js
test webo rtd submodule with prebid.js
</p>
</article>
<h2>Basic Prebid.js Example</h2>
<h5>Div-1</h5>
<!-- /1056029/webo-ctx-prebid -->
<div id='div-gpt-ad-1620653642627-0' style='width: 300px; height: 300px;'>
<script type='text/javascript'>
googletag.cmd.push(function () {
googletag.display('div-gpt-ad-1620653642627-0');
});
</script>
</div>

<button onclick="googletag.cmd.push(function() { googletag.pubads().refresh(); });">
Show/Refresh Ad
</button>
Expand Down
1 change: 1 addition & 0 deletions modules/.submodules.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"dfpAdServerVideo"
],
"rtdModule": [
"airgridRtdProvider",
"browsiRtdProvider",
"dgkeywordRtdProvider",
"geoedgeRtdProvider",
Expand Down
28 changes: 5 additions & 23 deletions modules/adagioBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,32 +269,14 @@ function getDevice() {
};

function getSite(bidderRequest) {
let domain = '';
let page = '';
let referrer = '';

const { refererInfo } = bidderRequest;

if (canAccessTopWindow()) {
const wt = getWindowTop();
domain = wt.location.hostname;
page = wt.location.href;
referrer = wt.document.referrer || '';
} else if (refererInfo.reachedTop) {
const url = parseUrl(refererInfo.referer);
domain = url.hostname;
page = refererInfo.referer;
} else if (refererInfo.stack && refererInfo.stack.length && refererInfo.stack[0]) {
// important note check if refererInfo.stack[0] is 'thruly' because a `null` value
// will be considered as "localhost" by the parseUrl function.
const url = parseUrl(refererInfo.stack[0]);
domain = url.hostname;
}
const url = parseUrl(refererInfo.referer);

return {
domain,
page,
referrer
domain: url.hostname || '',
page: refererInfo.referer || '',
referrer: canAccessTopWindow() ? getWindowTop().document.referrer || '' : getWindowSelf().document.referrer || '',
top: refererInfo.reachedTop
};
};

Expand Down
51 changes: 37 additions & 14 deletions modules/airgridRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,40 @@
* @module modules/airgridRtdProvider
* @requires module:modules/realTimeData
*/
import {submodule} from '../src/hook.js';
import {deepAccess, deepSetValue, mergeDeep} from '../src/utils.js';
import {getGlobal} from '../src/prebidGlobal.js';
import {getStorageManager} from '../src/storageManager.js';
import { config } from '../src/config.js';
import { submodule } from '../src/hook.js';
import {
mergeDeep,
isPlainObject,
deepSetValue,
deepAccess,
} from '../src/utils.js';
import { getGlobal } from '../src/prebidGlobal.js';
import { getStorageManager } from '../src/storageManager.js';

const MODULE_NAME = 'realTimeData';
const SUBMODULE_NAME = 'airgrid';
const AG_TCF_ID = 782;
export const AG_AUDIENCE_IDS_KEY = 'edkt_matched_audience_ids'
export const AG_AUDIENCE_IDS_KEY = 'edkt_matched_audience_ids';

export const storage = getStorageManager({gvlid: AG_TCF_ID, moduleName: SUBMODULE_NAME});
export const storage = getStorageManager({
gvlid: AG_TCF_ID,
moduleName: SUBMODULE_NAME,
});

/**
* Attach script tag to DOM
* @param {Object} rtdConfig
* @return {void}
*/
export function attachScriptTagToDOM(rtdConfig) {
var edktInitializor = window.edktInitializor = window.edktInitializor || {};
var edktInitializor = (window.edktInitializor = window.edktInitializor || {});
if (!edktInitializor.invoked) {
edktInitializor.invoked = true;
edktInitializor.accountId = rtdConfig.params.accountId;
edktInitializor.publisherId = rtdConfig.params.publisherId;
edktInitializor.apiKey = rtdConfig.params.apiKey;
edktInitializor.load = function(e) {
edktInitializor.load = function (e) {
var p = e || 'sdk';
var n = document.createElement('script');
n.type = 'module';
Expand All @@ -47,7 +56,7 @@ export function attachScriptTagToDOM(rtdConfig) {
*/
export function getMatchedAudiencesFromStorage() {
const audiences = storage.getDataFromLocalStorage(AG_AUDIENCE_IDS_KEY);
if (!audiences) return []
if (!audiences) return [];
try {
return JSON.parse(audiences);
} catch (e) {
Expand All @@ -67,8 +76,8 @@ function setAudiencesToAppNexusAdUnits(adUnits, audiences) {
if (bid.bidder && bid.bidder === 'appnexus') {
deepSetValue(bid, 'params.keywords.perid', audiences || []);
}
})
})
});
});
}

/**
Expand All @@ -86,6 +95,14 @@ export function getAudiencesAsBidderOrtb2(rtdConfig, audiences) {
return Object.fromEntries(bidders.map(bidder => [bidder, agOrtb2]));
}

export function setAudiencesUsingAppNexusAuctionKeywords(audiences) {
config.setConfig({
appnexusAuctionKeywords: {
perid: audiences,
},
});
}

/**
* Module init
* @param {Object} rtdConfig
Expand All @@ -105,23 +122,29 @@ function init(rtdConfig, userConsent) {
* @param {Object} userConsent
* @return {void}
*/
export function passAudiencesToBidders(bidConfig, onDone, rtdConfig, userConsent) {
export function passAudiencesToBidders(
bidConfig,
onDone,
rtdConfig,
userConsent
) {
const adUnits = bidConfig.adUnits || getGlobal().adUnits;
const audiences = getMatchedAudiencesFromStorage();
if (audiences.length > 0) {
setAudiencesUsingAppNexusAuctionKeywords(audiences);
mergeDeep(bidConfig?.ortb2Fragments?.bidder, getAudiencesAsBidderOrtb2(rtdConfig, audiences));
if (adUnits) {
setAudiencesToAppNexusAdUnits(adUnits, audiences);
}
}
onDone();
};
}

/** @type {RtdSubmodule} */
export const airgridSubmodule = {
name: SUBMODULE_NAME,
init: init,
getBidRequestData: passAudiencesToBidders
getBidRequestData: passAudiencesToBidders,
};

submodule(MODULE_NAME, airgridSubmodule);
Loading

0 comments on commit 6259946

Please sign in to comment.