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

Adyoulike bidder: improve robustness to multiple mediatypes #7863

Merged
merged 34 commits into from
Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5fb2f8f
Merge remote-tracking branch 'origin/master'
guiann Apr 14, 2021
f07f989
Merge remote-tracking branch 'origin/master'
guiann Apr 30, 2021
7cf8fb1
add required clickurl in every native adrequest
guiann Apr 30, 2021
cb45b27
allows the native response to be given as is to prebid if possible
guiann May 25, 2021
c57af68
add unit tests on new Native case
guiann May 26, 2021
bfb6101
Merge branch 'forceClickUrl'
guiann May 26, 2021
df7e7bc
Merge remote-tracking branch 'origin/master'
guiann May 27, 2021
979dbb5
Merge remote-tracking branch 'origin/master'
guiann May 31, 2021
77000a4
Merge remote-tracking branch 'Adyoulike/master'
guiann May 31, 2021
00df091
Handle meta object in bid response with default addomains array
guiann May 31, 2021
9ed3845
Merge remote-tracking branch 'Adyoulike/master'
guiann Jun 1, 2021
97bd819
fix icon retrieval in Native case
guiann Jun 17, 2021
7897e6a
Update priorities in case of multiple mediatypes given
guiann Jun 17, 2021
9e8968b
merge master branch
guiann Jun 17, 2021
bbee6cc
improve robustness and fix associated unit test on picture urls
guiann Jun 17, 2021
0f3aa09
Merge remote-tracking branch 'origin/master'
guiann Jul 20, 2021
3e7201c
add support for params.size parameter
guiann Jul 20, 2021
89c5d24
Merge remote-tracking branch 'Adyoulike/master'
guiann Jul 20, 2021
13da01b
add unit test on new size format
guiann Jul 20, 2021
e87b7a9
Merge remote-tracking branch 'origin/master'
guiann Jul 26, 2021
dc609d7
Makes sure the playerSize format is consistent
guiann Jul 28, 2021
41198fc
Merge remote-tracking branch 'Adyoulike/master'
guiann Jul 28, 2021
8afe053
enable Vast response on bidder adapter
guiann Jul 28, 2021
d60f235
fix lint errors
guiann Jul 28, 2021
3315a72
Merge remote-tracking branch 'origin/master'
guiann Jul 28, 2021
bd7551f
add test on Vast format case
guiann Jul 28, 2021
055fe9f
Merge remote-tracking branch 'origin/master'
guiann Oct 27, 2021
55bae6b
Merge remote-tracking branch 'origin/master'
guiann Nov 2, 2021
95137ab
add userId to bidrequest
guiann Nov 3, 2021
ec8c460
Merge remote-tracking branch 'origin/master'
guiann Nov 3, 2021
cb9abdf
revert package-lock.json changes
guiann Nov 5, 2021
c0f845c
Merge remote-tracking branch 'origin/master'
guiann Nov 18, 2021
4c33eeb
Merge remote-tracking branch 'origin/master'
guiann Dec 15, 2021
ac0fafe
improve multiple mediatype handling
guiann Dec 16, 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
22 changes: 13 additions & 9 deletions modules/adyoulikeBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,13 @@ function getCanonicalUrl() {

/* Get mediatype from bidRequest */
function getMediatype(bidRequest) {
if (deepAccess(bidRequest, 'mediaTypes.banner')) {
return BANNER;
}
if (deepAccess(bidRequest, 'mediaTypes.video')) {
return VIDEO;
} else if (deepAccess(bidRequest, 'mediaTypes.banner')) {
return BANNER;
} else if (deepAccess(bidRequest, 'mediaTypes.native')) {
}
if (deepAccess(bidRequest, 'mediaTypes.native')) {
return NATIVE;
}
}
Expand Down Expand Up @@ -345,7 +347,7 @@ function getTrackers(eventsArray, jsTrackers) {

function getVideoAd(response) {
var adJson = {};
if (typeof response.Ad === 'string') {
if (typeof response.Ad === 'string' && response.Ad.indexOf('\/\*PREBID\*\/') > 0) {
adJson = JSON.parse(response.Ad.match(/\/\*PREBID\*\/(.*)\/\*PREBID\*\//)[1]);
return deepAccess(adJson, 'Content.MainVideo.Vast');
}
Expand Down Expand Up @@ -478,13 +480,15 @@ function createBid(response, bidRequests) {
meta: response.Meta || { advertiserDomains: [] }
};

if (request && request.Native) {
// retreive video response if present
const vast64 = response.Vast || getVideoAd(response);
if (vast64) {
bid.vastXml = window.atob(vast64);
bid.mediaType = 'video';
} else if (request.Native) {
// format Native response if Native was requested
bid.native = getNativeAssets(response, request.Native);
bid.mediaType = 'native';
} else if (request && request.Video) {
const vast64 = response.Vast || getVideoAd(response);
bid.vastXml = vast64 ? window.atob(vast64) : '';
bid.mediaType = 'video';
} else {
bid.width = response.Width;
bid.height = response.Height;
Expand Down
49 changes: 49 additions & 0 deletions test/spec/modules/adyoulikeBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,40 @@ describe('Adyoulike Adapter', function () {
}
];

const bidRequestWithMultipleMediatype = [
{
'bidId': 'bid_id_0',
'bidder': 'adyoulike',
'placementCode': 'adunit/hb-0',
'params': {
'placement': 'placement_0'
},
'sizes': '300x250',
'mediaTypes': {
'banner': {
'sizes': ['640x480']
},
'video': {
'playerSize': [640, 480],
'context': 'outstream'
},
'native': {
'image': {
'required': true,
},
'title': {
'required': true,
'len': 80
},
'cta': {
'required': false
},
}
},
'transactionId': 'bid_id_0_transaction_id'
}
];

const bidRequestWithNativeImageType = [
{
'bidId': 'bid_id_0',
Expand Down Expand Up @@ -647,6 +681,21 @@ describe('Adyoulike Adapter', function () {
expect(payload.Bids['bid_id_0'].TransactionID).to.be.equal('bid_id_0_transaction_id');
});

it('sends bid request to endpoint with single placement multiple mediatype', function () {
canonicalQuery.restore();
const request = spec.buildRequests(bidRequestWithMultipleMediatype, bidderRequest);
const payload = JSON.parse(request.data);

expect(request.url).to.contain(getEndpoint());
expect(request.method).to.equal('POST');

expect(request.url).to.not.contains('CanonicalUrl=' + encodeURIComponent(canonicalUrl));
expect(payload.Version).to.equal('1.0');
expect(payload.Bids['bid_id_0'].PlacementID).to.be.equal('placement_0');
expect(payload.PageRefreshed).to.equal(false);
expect(payload.Bids['bid_id_0'].TransactionID).to.be.equal('bid_id_0_transaction_id');
});

it('sends bid request to endpoint with multiple placements', function () {
const request = spec.buildRequests(bidRequestMultiPlacements, bidderRequest);
const payload = JSON.parse(request.data);
Expand Down