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

AdTrue Bid Adapter: getUserSyncs logic update #6338

Merged
merged 30 commits into from
Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
989cd65
add AdTrue bid adapter
haibau Jan 5, 2021
0d624ad
add AdTrue Bid Adapter unit tests
haibau Jan 15, 2021
71decd8
Merge branch 'master' of https://github.com/prebid/Prebid.js
haibau Jan 15, 2021
86e2a37
add AdTrue Bid Adapter unit tests
haibau Jan 15, 2021
46675af
add AdTrue bid adapter
haibau Jan 5, 2021
07bb9d0
add AdTrue Bid Adapter unit tests
haibau Jan 15, 2021
1e7331d
add AdTrue Bid Adapter unit tests
haibau Jan 15, 2021
6e2238b
Merge branch 'master' of https://github.com/haibau/Prebid.js
haibau Jan 16, 2021
e0a14af
add AdTrue bid adapter
haibau Jan 16, 2021
fee25d4
Merge branch 'master' of https://github.com/prebid/Prebid.js
haibau Feb 17, 2021
638887b
adtrue usersync udpate
haibau Feb 18, 2021
5b08b03
adtrue usersync udpate
haibau Feb 18, 2021
4d8d236
#adtrue bidder usersync udpate
haibau Feb 22, 2021
4637ce6
Merge branch 'master' of https://github.com/prebid/Prebid.js
haibau Mar 11, 2021
a52c5b2
#Refactoring code & add unit test
haibau Mar 11, 2021
253a26b
1. Merge branch 'master' of https://github.com/prebid/Prebid.js
haibau Mar 18, 2021
1659856
Update package.json
haibau Mar 18, 2021
c782aa8
Update package-lock.json
haibau Mar 18, 2021
3a0a586
Merge branch 'master' of https://github.com/prebid/Prebid.js
haibau Mar 22, 2021
f159897
1. Merge branch 'master' of https://github.com/prebid/Prebid.js
haibau Mar 22, 2021
01ea8b4
Merge remote-tracking branch 'origin/master'
haibau Mar 22, 2021
45da210
1. Merge branch 'master' of https://github.com/prebid/Prebid.js
haibau Mar 22, 2021
6bc73b0
removing a package-lock.json from PR
haibau Mar 22, 2021
72e3249
Merge branch 'master' of https://github.com/prebid/Prebid.js
haibau Mar 23, 2021
8a3a751
- removing a package-lock.json from PR
haibau Mar 23, 2021
2b62437
Merge remote-tracking branch 'origin/master'
haibau Mar 23, 2021
5a9a059
- removing a package-lock.json from PR
haibau Mar 23, 2021
34be3b2
- removing a package-lock.json from PR
haibau Mar 23, 2021
5850ce5
Merge remote-tracking branch 'origin/master'
haibau Mar 23, 2021
72a1cba
update package-lock.json from upstream
haibau Mar 23, 2021
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
49 changes: 22 additions & 27 deletions modules/adtrueBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ const UNDEFINED = undefined;
const DEFAULT_WIDTH = 0;
const DEFAULT_HEIGHT = 0;
const NET_REVENUE = false;
const USER_SYNC_URL_IFRAME = 'https://hb.adtrue.com/prebid/usersync?t=iframe&p=';
const USER_SYNC_URL_IMAGE = 'https://hb.adtrue.com/prebid/usersync?t=img&p=';
let publisherId = 0;
let zoneId = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

You want them as strings, but default them to zero?

let NATIVE_ASSET_ID_TO_KEY_MAP = {};
const DATA_TYPES = {
'NUMBER': 'number',
Expand All @@ -25,6 +24,11 @@ const DATA_TYPES = {
'ARRAY': 'array',
'OBJECT': 'object'
};
const SYNC_TYPES = Object.freeze({
1: 'iframe',
2: 'image'
});

const VIDEO_CUSTOM_PARAMS = {
'mimes': DATA_TYPES.ARRAY,
'minduration': DATA_TYPES.NUMBER,
Expand Down Expand Up @@ -478,6 +482,7 @@ export const spec = {
return;
}
publisherId = conf.pubId.trim();
zoneId = conf.zoneId.trim();
haibau marked this conversation as resolved.
Show resolved Hide resolved

payload.site.publisher.id = conf.pubId.trim();
payload.ext.wrapper = {};
Expand Down Expand Up @@ -606,32 +611,22 @@ export const spec = {
return bidResponses;
},
getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent) {
let syncurl = '' + publisherId;

if (gdprConsent) {
syncurl += '&gdpr=' + (gdprConsent.gdprApplies ? 1 : 0);
syncurl += '&gdpr_consent=' + encodeURIComponent(gdprConsent.consentString || '');
}
if (uspConsent) {
syncurl += '&us_privacy=' + encodeURIComponent(uspConsent);
}

// coppa compliance
if (config.getConfig('coppa') === true) {
syncurl += '&coppa=1';
}

if (syncOptions.iframeEnabled) {
return [{
type: 'iframe',
url: USER_SYNC_URL_IFRAME + syncurl
}];
} else {
return [{
type: 'image',
url: USER_SYNC_URL_IMAGE + syncurl
}];
if (!responses || responses.length === 0 || (!syncOptions.iframeEnabled && !syncOptions.pixelEnabled)) {
return [];
}
return responses.filter(rsp => rsp.body && rsp.body.ext && rsp.body.ext.cookie_sync)
.map(rsp => rsp.body.ext.cookie_sync)
.reduce((a, b) => a.concat(b), [])
.map(({url, type}) => ({
type: SYNC_TYPES[type],
url: url +
'&publisherId=' + publisherId +
'&zoneId=' + zoneId +
'&gdpr=' + (gdprConsent ? (gdprConsent.gdprApplies ? 1 : 0) : 0) +
haibau marked this conversation as resolved.
Show resolved Hide resolved
'&gdpr_consent=' + encodeURIComponent((gdprConsent ? gdprConsent.consentString : '')) +
'&us_privacy=' + encodeURIComponent((uspConsent || '')) +
'&coppa=' + (config.getConfig('coppa') === true ? 1 : 0)
}));
haibau marked this conversation as resolved.
Show resolved Hide resolved
}
};
registerBidder(spec);
56 changes: 30 additions & 26 deletions test/spec/modules/adtrueBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,34 +48,42 @@ describe('AdTrueBidAdapter', function () {
}
];
bidResponses = {
'body': {
'id': '1610681506302',
'seatbid': [
body: {
id: '1610681506302',
seatbid: [
{
'bid': [
bid: [
{
'id': '1',
'impid': '201fb513ca24e9',
'price': 2.880000114440918,
'burl': 'https://hb.adtrue.com/prebid/win-notify?impid=1610681506302&wp=${AUCTION_PRICE}',
'adm': '<a href=\'https://adtrue.com?ref=pbjs\' target=\'_blank\'><img src=\'http://cdn.adtrue.com/img/prebid_sample_300x250.jpg?v=1.2\' style=\' width: 300px; \' /></a>',
'adid': '1610681506302',
'adomain': [
id: '1',
impid: '201fb513ca24e9',
price: 2.880000114440918,
burl: 'https://hb.adtrue.com/prebid/win-notify?impid=1610681506302&wp=${AUCTION_PRICE}',
adm: '<a href=\'https://adtrue.com?ref=pbjs\' target=\'_blank\'><img src=\'http://cdn.adtrue.com/img/prebid_sample_300x250.jpg?v=1.2\' style=\' width: 300px; \' /></a>',
adid: '1610681506302',
adomain: [
'adtrue.com'
],
'cid': 'f6l0r6n',
'crid': 'abc77au4',
'attr': [],
'w': 300,
'h': 250
cid: 'f6l0r6n',
crid: 'abc77au4',
attr: [],
w: 300,
h: 250
}
],
'seat': 'adtrue',
'group': 0
seat: 'adtrue',
group: 0
}
],
'bidid': '1610681506302',
'cur': 'USD'
bidid: '1610681506302',
cur: 'USD',
ext: {
cookie_sync: [
{
type: 1,
url: 'https://hb.adtrue.com/prebid/usersync?bidder=adtrue'
}
]
}
}
};
});
Expand Down Expand Up @@ -349,8 +357,7 @@ describe('AdTrueBidAdapter', function () {
});
});
describe('getUserSyncs', function () {
let USER_SYNC_URL_IFRAME = 'https://hb.adtrue.com/prebid/usersync?t=iframe&p=1212';
let USER_SYNC_URL_IMAGE = 'https://hb.adtrue.com/prebid/usersync?t=img&p=1212';
let USER_SYNC_URL_IFRAME = 'https://hb.adtrue.com/prebid/usersync?bidder=adtrue&publisherId=1212&zoneId=21423&gdpr=0&gdpr_consent=&us_privacy=&coppa=0';
let sandbox;
beforeEach(function () {
sandbox = sinon.sandbox.create();
Expand All @@ -359,12 +366,9 @@ describe('AdTrueBidAdapter', function () {
sandbox.restore();
});
it('execute as per config', function () {
expect(spec.getUserSyncs({iframeEnabled: true}, {}, undefined, undefined)).to.deep.equal([{
expect(spec.getUserSyncs({iframeEnabled: true}, [bidResponses], undefined, undefined)).to.deep.equal([{
type: 'iframe', url: USER_SYNC_URL_IFRAME
}]);
expect(spec.getUserSyncs({iframeEnabled: false}, {}, undefined, undefined)).to.deep.equal([{
type: 'image', url: USER_SYNC_URL_IMAGE
}]);
});
});
});