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

Mediago Bid Adapter : add cookieSync and gdpr #10724

Merged
merged 57 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
d34c542
Mediago Bid Adapter:new adapter
Aug 17, 2022
dfea766
remove console
Aug 18, 2022
ba97c8a
change spec file to fix CircleCI
Aug 18, 2022
d96c1fc
change spec file to fix CircleCI
Aug 18, 2022
66bf6a0
change spec file
Aug 18, 2022
461cf79
Update mediagoBidAdapter.js
BaronJHYu Aug 24, 2022
618809e
Update mediagoBidAdapter.js
Aug 24, 2022
d4e14f7
rerun CurcleCi
BaronJHYu Aug 24, 2022
da74779
update mediagoBidAdapter
Sep 16, 2022
801884b
Merge branch 'master' of github.com:BaronJHYu/Prebid.js
Sep 16, 2022
63b7cc5
Merge branch 'master' of github.com:prebid/Prebid.js into prebid-master
Sep 16, 2022
8e4199c
Merge branch 'prebid-master'
Sep 16, 2022
20353cb
Merge branch 'prebid:master' into master
BaronJHYu Nov 16, 2022
b52fd79
update discoveryBidAdapter
Nov 16, 2022
541cfed
Merge branch 'prebid:master' into master
BaronJHYu Nov 30, 2022
9a55054
Discovery Bid Adapter : parameter updates
Nov 30, 2022
355d2b1
Mediago Bid Adapter : parameter updates
Nov 30, 2022
6fb0a02
Mediago Bid Adapter : code style format
Nov 30, 2022
68dcbd8
rerun circleci
Nov 30, 2022
bb2777c
rerun circleci
Dec 1, 2022
0ed9493
rerun circleci
Dec 1, 2022
d09cf94
rerun circleci
Dec 1, 2022
9e42186
Merge branch 'prebid:master' into master
BaronJHYu Feb 14, 2023
28b5d2b
Update mediagoBidAdapter & discoveryBidAdapter:report eids to server
Feb 14, 2023
809dc71
Merge branch 'master' of github.com:BaronJHYu/Prebid.js
Feb 14, 2023
5c24963
Update mediagoBidAdapter & discoveryBidAdapter:report eids to server
Feb 14, 2023
e103260
update Mediago & Discovery BidAdapter:remove size filter
Feb 24, 2023
f7e7b2a
update Mediago & Discovery BidAdapter:code format
Feb 24, 2023
2b1d8c0
update Mediago & Discovery BidAdapter:code format
Feb 24, 2023
d3c8806
update Mediago & Discovery BidAdapter:add param in banner format
Feb 24, 2023
8451b08
Merge branch 'prebid:master' into master
BaronJHYu Mar 3, 2023
32492f1
update mediago & discovery:first party data
Mar 3, 2023
455b843
Merge branch 'master' of github.com:BaronJHYu/Prebid.js
Mar 3, 2023
5d92500
update mediago & discovery:first party data
Mar 3, 2023
e897e9a
update mediago & discovery:first party data
Mar 3, 2023
409b599
Merge branch 'prebid:master' into master
BaronJHYu Jun 27, 2023
5658450
fix(mediago & discovery): update param tagid
Jun 27, 2023
c6ad1c1
fix(mediago & discovery): update param tagid
Jun 27, 2023
041876b
Merge branch 'prebid:master' into master
BaronJHYu Aug 30, 2023
5cfd1fd
Merge branch 'prebid:master' into master
BaronJHYu Nov 3, 2023
d5cb0fb
feat:add imp params for analysis
Nov 3, 2023
96eb09a
fix:add imp params for analysis
Nov 3, 2023
3833b90
code format
Nov 3, 2023
e2c81fb
test:add test data & test
Nov 6, 2023
98db061
format code
Nov 6, 2023
3c6de5b
rerun circleci
Nov 6, 2023
2d05d00
Merge branch 'prebid:master' into master
BaronJHYu Nov 10, 2023
2d8cfc3
Merge branch 'prebid:master' into master
BaronJHYu Nov 14, 2023
cc1895d
feat: 1. add cookieSync 2. add gdpr
Nov 14, 2023
5d81f7e
code format
Nov 14, 2023
fca52d6
rerun circleci
Nov 14, 2023
ace0549
add gvlid
Nov 16, 2023
1847dcf
feat:add param 1.ppuid 2.content 3.cat 4.reqtime
Dec 1, 2023
e89124f
Merge branch 'prebid:master' into master
BaronJHYu Dec 1, 2023
10f546a
fix: getUserSyncs param fixed
Dec 1, 2023
4377fc2
fix: getUserSyncs param fixed
Dec 1, 2023
486e88e
feat: add param 1. adUnitCode 2. referrer
Dec 4, 2023
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
63 changes: 48 additions & 15 deletions modules/mediagoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ const BIDDER_CODE = 'mediago';
const ENDPOINT_URL =
// ((PROTOCOL === 'https:') ? 'https' : 'http') +
'https://rtb-us.mediago.io/api/bid?tn=';
const COOKY_SYNC_URL = 'https://trace.mediago.io/ju/cs/eplist';
const TIME_TO_LIVE = 500;
const GVLID = 1020;
// const ENDPOINT_URL = '/api/bid?tn=';
const storage = getStorageManager({bidderCode: BIDDER_CODE});
const storage = getStorageManager({ bidderCode: BIDDER_CODE });
let globals = {};
let itemMaps = {};

Expand Down Expand Up @@ -156,11 +158,7 @@ function transformSizes(requestSizes) {
let sizes = [];
let sizeObj = {};

if (
utils.isArray(requestSizes) &&
requestSizes.length === 2 &&
!utils.isArray(requestSizes[0])
) {
if (utils.isArray(requestSizes) && requestSizes.length === 2 && !utils.isArray(requestSizes[0])) {
sizeObj.width = parseInt(requestSizes[0], 10);
sizeObj.height = parseInt(requestSizes[1], 10);
sizes.push(sizeObj);
Expand Down Expand Up @@ -207,17 +205,13 @@ function getItems(validBidRequests, bidderRequest) {

// 确认尺寸是否符合我们要求
for (let size of sizes) {
matchSize = mediagoAdSize.find(
(item) => size.width === item.w && size.height === item.h
);
matchSize = mediagoAdSize.find(item => size.width === item.w && size.height === item.h);
if (matchSize) {
break;
}
}
if (!matchSize) {
matchSize = sizes[0]
? { h: sizes[0].height || 0, w: sizes[0].width || 0 }
: { h: 0, w: 0 };
matchSize = sizes[0] ? { h: sizes[0].height || 0, w: sizes[0].width || 0 } : { h: 0, w: 0 };
}

const bidFloor = getBidFloor(req);
Expand All @@ -226,6 +220,18 @@ function getItems(validBidRequests, bidderRequest) {
utils.deepAccess(req, 'ortb2Imp.ext.data.pbadslot') ||
utils.deepAccess(req, 'params.placementId', 0);

const gdprConsent = {};
if (bidderRequest && bidderRequest.gdprConsent) {
gdprConsent.consent = bidderRequest.gdprConsent.consentString;
gdprConsent.gdpr = bidderRequest.gdprConsent.gdprApplies ? 1 : 0;
// if (bidderRequest.gdprConsent.addtlConsent && bidderRequest.gdprConsent.addtlConsent.indexOf('~') !== -1) {
// let ac = bidderRequest.gdprConsent.addtlConsent;
// // pull only the ids from the string (after the ~) and convert them to an array of ints
// let acStr = ac.substring(ac.indexOf('~') + 1);
// gdpr_consent.addtl_consent = acStr.split('.').map(id => parseInt(id, 10));
// }
}

// if (mediaTypes.native) {}
// banner广告类型
if (mediaTypes.banner) {
Expand All @@ -242,6 +248,8 @@ function getItems(validBidRequests, bidderRequest) {
ext: {
ortb2Imp: utils.deepAccess(req, 'ortb2Imp'), // 传入完整对象,分析日志数据
gpid: gpid, // 加入后无法返回广告
adslot: utils.deepAccess(req, 'ortb2Imp.ext.data.adserver.adslot', '', ''),
...gdprConsent, // gdpr
},
tagid: req.params && req.params.tagid,
};
Expand All @@ -268,16 +276,18 @@ function getParam(validBidRequests, bidderRequest) {
const sharedid =
utils.deepAccess(validBidRequests[0], 'userId.sharedid.id') ||
utils.deepAccess(validBidRequests[0], 'userId.pubcid');
const eids = validBidRequests[0].userIdAsEids || validBidRequests[0].userId;

const bidsUserIdAsEids = validBidRequests[0].userIdAsEids;
const bidsUserid = validBidRequests[0].userId;
const eids = bidsUserIdAsEids || bidsUserid;

let isMobile = isMobileAndTablet() ? 1 : 0;
// input test status by Publisher. more frequently for test true req
let isTest = validBidRequests[0].params.test || 0;
let auctionId = getProperty(bidderRequest, 'auctionId');
let items = getItems(validBidRequests, bidderRequest);

const domain =
utils.deepAccess(bidderRequest, 'refererInfo.domain') || document.domain;
const domain = utils.deepAccess(bidderRequest, 'refererInfo.domain') || document.domain;
const location = utils.deepAccess(bidderRequest, 'refererInfo.location');
const page = utils.deepAccess(bidderRequest, 'refererInfo.page');
const referer = utils.deepAccess(bidderRequest, 'refererInfo.ref');
Expand Down Expand Up @@ -305,6 +315,8 @@ function getParam(validBidRequests, bidderRequest) {
},
ext: {
eids,
bidsUserIdAsEids,
bidsUserid,
firstPartyData,
},
user: {
Expand Down Expand Up @@ -336,6 +348,7 @@ function getParam(validBidRequests, bidderRequest) {

export const spec = {
code: BIDDER_CODE,
gvlid: GVLID,
// aliases: ['ex'], // short code
/**
* Determines whether or not the given bid request is valid.
Expand Down Expand Up @@ -415,6 +428,26 @@ export const spec = {
return bidResponses;
},

getUserSyncs: function (syncOptions, serverResponse, gdprConsent, uspConsent, gppConsent) {
const origin = encodeURIComponent(location.origin || `https://${location.host}`);
const url = `${COOKY_SYNC_URL}?dm=${origin}&gdpr_consent=${gdprConsent.consentString}`;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When running this in simple testing, I'm getting this error.

mediagoBidAdapter.js:433 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'consentString')
at Object.getUserSyncs (mediagoBidAdapter.js:433:76)
at bidderFactory.js:512:22
at registerSyncs (bidderFactory.js:347:5)
at bidderFactory.js:265:11
at Object.runWithBidder (config.js:508:14)
at afterAllResponses (bidderFactory.js:263:9)
at perfMetrics.js:288:17
at utils.js:661:12
at bidderFactory.js:448:7
at runWithBidder (config.js:508:14)

I'm not setting up any of the gdpr things for this test, just a simple test in hello_world.html. I would assume you want this to function to work in this situation as well. I think you should be checking if these variables are set in this function. You can see the various ways people are checking for this in other adapters.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for reminding, i have fixed error.

if (syncOptions.iframeEnabled) {
return [
{
type: 'iframe',
url: `https://cdn.mediago.io/js/cookieSync.html?gdpr_consent=${gdprConsent.consentString}`,
},
];
} else {
return [
{
type: 'image',
url: url,
},
];
}
},

/**
* Register bidder specific code, which will execute if bidder timed out after an auction
* @param {data} Containing timeout specific data
Expand Down
Loading