Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNY-3670: listen to ids from user sync #12

Open
wants to merge 56 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
9e072e1
upgrade prebid js
rares-mihai-preda Apr 19, 2022
6f50479
added conversantBidAdapter
rares-mihai-preda May 18, 2022
0f6d62b
added criteoBidAdapter, tripleliftBidAdapter, pulsepointBidAdapter
DarianAvasan May 26, 2022
dd2c7ac
adtelligent bid adapter
alex-calauz-cnx Jun 15, 2022
f29a909
remove oneVideoBidAdapter from modules.json
rares-mihai-preda Jul 8, 2022
dddb048
added yieldmo bid adapter
alex-calauz-cnx Sep 5, 2022
6a5216b
build:connatix script
rares-mihai-preda Sep 14, 2022
ed403f5
Merge tag 'tags/7.16.0' into connatix
DarianAvasan Sep 20, 2022
05e6574
removed flocIdSystem & TrustxBidAdapter from modules.json
DarianAvasan Sep 20, 2022
2aa4bbf
Merge tag 'tags/7.17.0' into connatix
DarianAvasan Sep 28, 2022
8596001
added aniview bid adapter
DarianAvasan Sep 28, 2022
a13f36f
moved line
DarianAvasan Sep 28, 2022
db61e6b
added nextMillennium adapter to modules.json
Alex404Damsa Sep 30, 2022
c732da1
newline at the end of the file
rares-mihai-preda Sep 30, 2022
affb40e
added new adapters
Alex404Damsa Oct 3, 2022
f235695
Merge branch 'connatix' of https://github.com/Connatix/Prebid.js into…
Alex404Damsa Oct 3, 2022
ac53dff
added minutemedia adapter
Alex404Damsa Nov 18, 2022
d87cb0d
added richaudience adapter
DarianAvasan Nov 22, 2022
ec5a7dd
Revert "added richaudience adapter"
DarianAvasan Dec 5, 2022
9ff7b45
Revert "added minutemedia adapter"
Alex404Damsa Dec 12, 2022
e2a6dc8
Added Permutive RTD module
cosminser Jan 6, 2023
a0839a9
comma
cosminser Jan 6, 2023
e3d78dc
[feat] add sharethroughBidAdapter
Dan-Lucian Mar 21, 2023
4deb938
added insticator bid adapter
Alex404Damsa May 15, 2023
962dd2c
Merge tag 'tags/7.54.0' into connatix
cristisilav Jun 27, 2023
f583ade
Add consentManagementGpp module
cristisilav Jun 30, 2023
24f64b3
fix gpp signal (#5)
mariusszabo Jul 3, 2023
ccc92f5
remove gpp module because no need to support it yet
mariusszabo Jul 3, 2023
1236ebd
LiveRamp submodule identityLink
DarianAvasan Jul 20, 2023
f84c4b8
added sonobi bid adapter
alex-calauz-cnx Sep 12, 2023
2accd37
Merge tag 'tags/8.17.0' into connatix
rares-mihai-preda Oct 3, 2023
2d4c628
upgrade to prebid 8.17.0
rares-mihai-preda Oct 3, 2023
5ef2cfa
upgrade to prebid 8.17.0
rares-mihai-preda Oct 3, 2023
e314514
Merge tag 'tags/8.18.0' into connatix
rares-mihai-preda Oct 6, 2023
7fdf0a3
added pgamsspBidAdapter because its alias was removed from adtelligen…
rares-mihai-preda Oct 6, 2023
33d11df
Merge tag 'tags/8.20.0' into connatix
rares-mihai-preda Oct 24, 2023
1cc4ada
added ozone as Connatix bidder partner
rares-mihai-preda Oct 25, 2023
e9e2fdd
added showheroes adapter
OctaviaS20 Nov 23, 2023
0a5525f
added seedtag bid adaptor
Alex404Damsa Nov 28, 2023
b18eccd
added minutemedia
OctaviaS20 Jan 9, 2024
858b330
removed duplicated minute media
rares-mihai-preda Jan 25, 2024
63b996c
Merge tag 'tags/8.37.0' into connatix
OctaviaS20 Feb 16, 2024
8cfda4b
Merge branch 'connatix' of github.com:Connatix/Prebid.js into connatix
OctaviaS20 Feb 16, 2024
2bf6a6d
Merge tag 'tags/8.38.0' into connatix
OctaviaS20 Feb 26, 2024
441bb53
added sovrn bid adapter
OctaviaS20 Mar 12, 2024
9879f30
fix: add consentManagementGpp module
mariuspotorconnatix Mar 14, 2024
4dbb923
added new build and gannet adapters
OctaviaS20 Apr 3, 2024
77cd4fd
renamed build command
OctaviaS20 Apr 3, 2024
67ee6f4
added specific modules for gannett
OctaviaS20 Apr 8, 2024
3da9065
added kueezRtb bid adaptor
Alex404Damsa May 24, 2024
eee0503
add pubProvidedIdSystem module
mariuspotorconnatix May 29, 2024
159d108
CORE: check if the body is available before adding the locator iframe…
olafbuitelaar Jul 8, 2024
d11be4d
Prebid 9.4.1 release
prebidjs-release Jul 9, 2024
ccdd2a9
Merge tag 'tags/9.4.1' into connatix
rares-mihai-preda Jul 10, 2024
daf607a
update to 9.4.1
rares-mihai-preda Jul 11, 2024
b173792
listen to ids from user sync
Sep 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions gannet-modules.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[
"appnexusBidAdapter",
"ixBidAdapter",
"yahoosspBidAdapter",
"openxBidAdapter",
"pubmaticBidAdapter",
"rubiconBidAdapter",
"sonobiBidAdapter",
"tripleliftBidAdapter",
"gridBidAdapter",
"undertoneBidAdapter",
"consentManagementGpp",
"topicsFpdModule",
"gptPreAuction",
"dfpAdServerVideo"
]
63 changes: 63 additions & 0 deletions modules.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
[
"appnexusBidAdapter",
"ixBidAdapter",
"openxBidAdapter",
"pubmaticBidAdapter",
"rhythmoneBidAdapter",
"rubiconBidAdapter",
"telariaBidAdapter",
"medianetBidAdapter",
"admanBidAdapter",
"imdsBidAdapter",
"undertoneBidAdapter",
"amxBidAdapter",
"smaatoBidAdapter",
"smartadserverBidAdapter",
"gridBidAdapter",
"riseBidAdapter",
"yahooAdsBidAdapter",
"unrulyBidAdapter",
"kargoBidAdapter",
"smilewantedBidAdapter",
"krushmediaBidAdapter",
"cadentApertureMXBidAdapter",
"conversantBidAdapter",
"criteoBidAdapter",
"tripleliftBidAdapter",
"pulsepointBidAdapter",
"adtelligentBidAdapter",
"yieldmoBidAdapter",
"aniviewBidAdapter",
"nextMillenniumBidAdapter",
"colossussspBidAdapter",
"resetdigitalBidAdapter",
"mediafuseBidAdapter",
"freewheel-sspBidAdapter",
"adyoulikeBidAdapter",
"minutemediaBidAdapter",
"sharethroughBidAdapter",
"insticatorBidAdapter",
"sonobiBidAdapter",
"pgamsspBidAdapter",
"ozoneBidAdapter",
"showheroes-bsBidAdapter",
"seedtagBidAdapter",
"sovrnBidAdapter",
"kueezRtbBidAdapter",
"adpod",
"consentManagementTcf",
"consentManagementUsp",
"consentManagementGpp",
"tcfControl",
"currency",
"priceFloors",
"schain",
"userId",
"identityLinkIdSystem",
"criteoIdSystem",
"sharedIdSystem",
"uid2IdSystem",
"rtdModule",
"permutiveRtdProvider",
"pubProvidedIdSystem"
]
36 changes: 35 additions & 1 deletion modules/connatixBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
isArray,
formatQS
} from '../src/utils.js';

import {getStorageManager} from '../src/storageManager.js';
import {
BANNER,
} from '../src/mediaTypes.js';
Expand All @@ -18,6 +18,9 @@ const BIDDER_CODE = 'connatix';
const AD_URL = 'https://capi.connatix.com/rtb/hba';
const DEFAULT_MAX_TTL = '3600';
const DEFAULT_CURRENCY = 'USD';
const CNX_IDS = 'cnx_ids';
const CNX_ID_RETENTION_TIME_HOUR = 24 * 30; // 30 days
export const storage = getStorageManager({ bidderCode: BIDDER_CODE });

/*
* Get the bid floor value from the bid object, either using the getFloor function or by accessing the 'params.bidfloor' property.
Expand All @@ -41,6 +44,21 @@ export function getBidFloor(bid) {
}
}

function saveOnAllStorages(name, value, expirationTimeHours) {
const date = new Date();
date.setTime(date.getTime() + (expirationTimeHours * 60 * 60 * 1000));
const expires = `expires=${date.toUTCString()}`;
storage.setCookie(name, value, expires);
storage.setDataInLocalStorage(name, value);
}

function readFromAllStorages(name) {
const fromCookie = storage.getCookie(name);
const fromLocalStorage = storage.getDataFromLocalStorage(name);

return fromCookie || fromLocalStorage || undefined;
}

export const spec = {
code: BIDDER_CODE,
gvlid: 143,
Expand Down Expand Up @@ -94,12 +112,14 @@ export const spec = {
};
});

const cnxIds = readFromAllStorages(CNX_IDS);
const requestPayload = {
ortb2: bidderRequest.ortb2,
gdprConsent: bidderRequest.gdprConsent,
uspConsent: bidderRequest.uspConsent,
gppConsent: bidderRequest.gppConsent,
refererInfo: bidderRequest.refererInfo,
userIds: cnxIds,
bidRequests,
};

Expand Down Expand Up @@ -171,6 +191,20 @@ export const spec = {
params['us_privacy'] = encodeURIComponent(uspConsent);
}

window.addEventListener('message', function handler(event) {
if (!event.data || !event.origin.includes('connatix')) {
return;
}
this.removeEventListener('message', handler);

event.stopImmediatePropagation();

const response = event.data;
if (!response.optout && response.eids) {
saveOnAllStorages(CNX_IDS, response.eids, CNX_ID_RETENTION_TIME_HOUR);
}
}, true)

const syncUrl = serverResponses[0].body.UserSyncEndpoint;
const queryParams = Object.keys(params).length > 0 ? formatQS(params) : '';

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prebid.js",
"version": "9.4.0",
"version": "9.4.1",
"description": "Header Bidding Management Library",
"main": "src/prebid.public.js",
"exports": {
Expand All @@ -15,7 +15,9 @@
"scripts": {
"serve": "gulp serve",
"test": "gulp test",
"lint": "gulp lint"
"lint": "gulp lint",
"build:connatix": "gulp build-bundle-prod --disable NATIVE --modules=modules.json",
"build:connatix:gannett": "gulp build-bundle-prod --disable NATIVE --modules=gannet-modules.json"
},
"repository": {
"type": "git",
Expand Down
10 changes: 7 additions & 3 deletions src/adRendering.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,12 @@ export function renderAdDirect(doc, adId, options) {
*/
export function insertLocatorFrame() {
if (!window.frames[PB_LOCATOR]) {
const frame = createInvisibleIframe();
frame.name = PB_LOCATOR;
document.body.appendChild(frame);
if (!document.body) {
window.requestAnimationFrame(insertLocatorFrame);
} else {
const frame = createInvisibleIframe();
frame.name = PB_LOCATOR;
document.body.appendChild(frame);
}
}
}
97 changes: 97 additions & 0 deletions test/pages/banner_sync.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<!-- This is a Test Page for a Banner End-to-End test -->
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<title>Prebid.js Banner Example</title>

<!-- Prebid.js -->
<script src="http://localhost:4444/bundle?modules=appnexusBidAdapter"></script>

<!-- Google Publisher Tag -->
<script async src="https://www.googletagservices.com/tag/js/gpt.js"></script>

<script>
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

// Prebid Banner Ad Unit
const adUnits = [{
code: 'div-gpt-ad-1460505748561-0',
mediaTypes: {
banner: {
sizes: [[300, 250], [300, 600]],
}
},
bids: [{
bidder: 'appnexus',
params: {
placementId: 13144370
}
}]
}
,{
code: 'div-gpt-ad-1460505748561-1',
mediaTypes: {
banner: {
sizes: [[300, 250], [300, 600]],
}
},
bids: [{
bidder: "appnexus",
params: {
placementId: 13144370
}
}]
}
];
</script>

<script>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];

googletag.cmd.push(function() {
googletag.pubads().disableInitialLoad();
});

pbjs.que.push(function () {
pbjs.setConfig({enableTIDs: true});
pbjs.addAdUnits(adUnits);
pbjs.requestBids({ bidsBackHandler: sendAdServerRequest });
});

function sendAdServerRequest() {
googletag.cmd.push(function () {
pbjs.que.push(function () {
pbjs.setTargetingForGPTAsync('div-gpt-ad-1460505748561-0');
googletag.pubads().refresh();
});
});
}
</script>

<script>
googletag.cmd.push(function () {
googletag
.defineSlot('/19968336/header-bid-tag-0', [[300, 250], [300, 600]], 'div-gpt-ad-1460505748561-0')
.addService(googletag.pubads());

googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
</head>

<body>
<h2>Prebid.js Banner Ad Unit Test</h2>
<div id='div-gpt-ad-1460505748561-0'>
<script>
googletag.cmd.push(function () { googletag.display('div-gpt-ad-1460505748561-0'); });
</script>
</div>
<div id="targeting-keys"></div>
</body>

</html>
34 changes: 20 additions & 14 deletions test/spec/e2e/banner/basic_banner_ad.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const expect = require('chai').expect;
const {setupTest, testPageURL} = require('../../../helpers/testing-utils');

const TEST_PAGE_URL = testPageURL('banner.html?pbjs_debug=true');
const SYNC_PAGE_URL = testPageURL('banner_sync.html?pbjs_debug=true');
const CREATIVE_IFRAME_ID = 'google_ads_iframe_/19968336/header-bid-tag-0_0';
const CREATIVE_IFRAME_CSS_SELECTOR = 'iframe[id="' + CREATIVE_IFRAME_ID + '"]';

Expand All @@ -14,20 +15,25 @@ const EXPECTED_TARGETING_KEYS = {
'hb_bidder_appnexus': 'appnexus'
};

setupTest({
url: TEST_PAGE_URL,
waitFor: CREATIVE_IFRAME_CSS_SELECTOR,
expectGAMCreative: true
}, 'Prebid.js Banner Ad Unit Test', function () {
it('should load the targeting keys with correct values', async function () {
const result = await browser.execute(function () {
return window.pbjs.getAdserverTargeting('div-gpt-ad-1460505748561-1');
});
const targetingKeys = result['div-gpt-ad-1460505748561-1'];
Object.entries({
'synchronously': SYNC_PAGE_URL,
'asynchronously': TEST_PAGE_URL,
}).forEach(([t, testPage]) => {
setupTest({
url: testPage,
waitFor: CREATIVE_IFRAME_CSS_SELECTOR,
expectGAMCreative: true
}, `Prebid.js Banner Ad Unit Test (loading ${t})`, function () {
it('should load the targeting keys with correct values', async function () {
const result = await browser.execute(function () {
return window.pbjs.getAdserverTargeting('div-gpt-ad-1460505748561-1');
});
const targetingKeys = result['div-gpt-ad-1460505748561-1'];

expect(targetingKeys).to.include(EXPECTED_TARGETING_KEYS);
expect(targetingKeys.hb_adid).to.be.a('string');
expect(targetingKeys.hb_adid_appnexus).to.be.a('string');
expect(targetingKeys.hb_size).to.satisfy((size) => size === '300x250' || '300x600');
expect(targetingKeys).to.include(EXPECTED_TARGETING_KEYS);
expect(targetingKeys.hb_adid).to.be.a('string');
expect(targetingKeys.hb_adid_appnexus).to.be.a('string');
expect(targetingKeys.hb_size).to.satisfy((size) => size === '300x250' || '300x600');
});
});
});
Loading