From 7cf8fb1a3d05e2ab47c1046e3d56b8b4e310cb06 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Fri, 30 Apr 2021 14:23:05 +0200 Subject: [PATCH 01/13] add required clickurl in every native adrequest --- modules/adyoulikeBidAdapter.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/adyoulikeBidAdapter.js b/modules/adyoulikeBidAdapter.js index 00c7c02dc72..01d5e5e3a5e 100644 --- a/modules/adyoulikeBidAdapter.js +++ b/modules/adyoulikeBidAdapter.js @@ -78,6 +78,10 @@ export const spec = { if (nativeReq.type === 'image') { nativeReq = Object.assign({}, NATIVE_IMAGE, nativeReq); } + // click url is always mandatory even if not specified by publisher + nativeReq.clickUrl = { + required: true + }; accumulator[bidReq.bidId].Native = nativeReq; } if (mediatype === VIDEO) { From cb45b27d550efb2db99943a49adc18280f8f228e Mon Sep 17 00:00:00 2001 From: Guillaume Date: Tue, 25 May 2021 17:13:15 +0200 Subject: [PATCH 02/13] allows the native response to be given as is to prebid if possible --- modules/adyoulikeBidAdapter.js | 97 +++++++++++++++++----------------- 1 file changed, 48 insertions(+), 49 deletions(-) diff --git a/modules/adyoulikeBidAdapter.js b/modules/adyoulikeBidAdapter.js index 01d5e5e3a5e..44d8e2e3016 100644 --- a/modules/adyoulikeBidAdapter.js +++ b/modules/adyoulikeBidAdapter.js @@ -333,6 +333,9 @@ function getVideoAd(response) { } function getNativeAssets(response, nativeConfig) { + if (typeof response.Native === 'object') { + return response.Native; + } const native = {}; var adJson = {}; @@ -366,59 +369,55 @@ function getNativeAssets(response, nativeConfig) { } Object.keys(nativeConfig).map(function(key, index) { - if (typeof response.Native === 'object') { - native[key] = response.Native[key]; - } else { - switch (key) { - case 'title': - native[key] = textsJson.TITLE; - break; - case 'body': - native[key] = textsJson.DESCRIPTION; - break; - case 'cta': - native[key] = textsJson.CALLTOACTION; - break; - case 'sponsoredBy': - native[key] = adJson.Content.Preview.Sponsor.Name; - break; - case 'image': - // main image requested size - const imgSize = nativeConfig.image.sizes || []; - if (!imgSize.length) { - imgSize[0] = response.Width || 300; - imgSize[1] = response.Height || 250; + switch (key) { + case 'title': + native[key] = textsJson.TITLE; + break; + case 'body': + native[key] = textsJson.DESCRIPTION; + break; + case 'cta': + native[key] = textsJson.CALLTOACTION; + break; + case 'sponsoredBy': + native[key] = adJson.Content.Preview.Sponsor.Name; + break; + case 'image': + // main image requested size + const imgSize = nativeConfig.image.sizes || []; + if (!imgSize.length) { + imgSize[0] = response.Width || 300; + imgSize[1] = response.Height || 250; + } + + native[key] = { + url: getImageUrl(adJson, adJson.Content.Preview.Thumbnail.Image, imgSize[0], imgSize[1]), + width: imgSize[0], + height: imgSize[1] + }; + break; + case 'icon': + if (adJson.HasSponsorImage) { + // icon requested size + const iconSize = nativeConfig.icon.sizes || []; + if (!iconSize.length) { + iconSize[0] = 50; + iconSize[1] = 50; } native[key] = { - url: getImageUrl(adJson, adJson.Content.Preview.Thumbnail.Image, imgSize[0], imgSize[1]), - width: imgSize[0], - height: imgSize[1] + url: getImageUrl(adJson, adJson.Content.Preview.Sponsor.Logo.Resource, iconSize[0], iconSize[1]), + width: iconSize[0], + height: iconSize[1] }; - break; - case 'icon': - if (adJson.HasSponsorImage) { - // icon requested size - const iconSize = nativeConfig.icon.sizes || []; - if (!iconSize.length) { - iconSize[0] = 50; - iconSize[1] = 50; - } - - native[key] = { - url: getImageUrl(adJson, adJson.Content.Preview.Sponsor.Logo.Resource, iconSize[0], iconSize[1]), - width: iconSize[0], - height: iconSize[1] - }; - } - break; - case 'privacyIcon': - native[key] = getImageUrl(adJson, adJson.Content.Preview.Credit.Logo.Resource, 25, 25); - break; - case 'privacyLink': - native[key] = adJson.Content.Preview.Credit.Url; - break; - } + } + break; + case 'privacyIcon': + native[key] = getImageUrl(adJson, adJson.Content.Preview.Credit.Logo.Resource, 25, 25); + break; + case 'privacyLink': + native[key] = adJson.Content.Preview.Credit.Url; + break; } }); From c57af68d87ea96b59a0b0c2ea446e3563c5c3325 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Wed, 26 May 2021 10:13:46 +0200 Subject: [PATCH 03/13] add unit tests on new Native case --- test/spec/modules/adyoulikeBidAdapter_spec.js | 113 ++++++++++++------ 1 file changed, 78 insertions(+), 35 deletions(-) diff --git a/test/spec/modules/adyoulikeBidAdapter_spec.js b/test/spec/modules/adyoulikeBidAdapter_spec.js index c432ad1b32d..abf8793865c 100644 --- a/test/spec/modules/adyoulikeBidAdapter_spec.js +++ b/test/spec/modules/adyoulikeBidAdapter_spec.js @@ -300,6 +300,74 @@ describe('Adyoulike Adapter', function () { 'Height': 600, } ]; + + const responseWithSingleNative = [{ + 'BidID': 'bid_id_0', + 'Placement': 'placement_0', + 'Native': { + 'body': 'Considérant l\'extrémité conjoncturelle, il serait bon d\'anticiper toutes les voies de bon sens.', + 'cta': 'Click here to learn more', + 'clickUrl': 'https://tracking.omnitagjs.com/tracking/ar?event_kind=CLICK&attempt=a11a121205932e75e622af275681965d&campaign=f1c80d4bb5643c222ae8de75e9b2f991&url=https%3A%2F%2Fwww.w3.org%2FPeople%2Fmimasa%2Ftest%2Fxhtml%2Fentities%2Fentities-11.xhtml%23lat1', + 'image': { + 'height': 600, + 'url': 'https://blobs.omnitagjs.com/blobs/f1/f1c80d4bb5643c22/fd4362d35bb174d6f1c80d4bb5643c22', + 'width': 300 + }, + 'privacyIcon': 'https://fo-static.omnitagjs.com/fo-static/native/images/info-ayl.png', + 'privacyLink': 'https://blobs.omnitagjs.com/adchoice/', + 'sponsoredBy': 'QA Team', + 'title': 'Adserver Traffic Redirect Internal', + 'impressionTrackers': [ + 'https://testPixelIMP.com/fake', + 'https://tracking.omnitagjs.com/tracking/pixel?event_kind=IMPRESSION&attempt=a11a121205932e75e622af275681965d&campaign=f1c80d4bb5643c222ae8de75e9b2f991', + 'https://tracking.omnitagjs.com/tracking/pixel?event_kind=INSERTION&attempt=a11a121205932e75e622af275681965d&campaign=f1c80d4bb5643c222ae8de75e9b2f991', + ], + 'javascriptTrackers': [ + 'https://testJsIMP.com/fake.js' + ], + 'clickTrackers': [ + 'https://testPixelCLICK.com/fake' + ] + }, + 'Price': 0.5, + 'Height': 600, + }]; + + const nativeResult = [{ + cpm: 0.5, + creativeId: undefined, + currency: 'USD', + netRevenue: true, + requestId: 'bid_id_0', + ttl: 3600, + mediaType: 'native', + native: { + body: 'Considérant l\'extrémité conjoncturelle, il serait bon d\'anticiper toutes les voies de bon sens.', + clickTrackers: [ + 'https://testPixelCLICK.com/fake' + ], + clickUrl: 'https://tracking.omnitagjs.com/tracking/ar?event_kind=CLICK&attempt=a11a121205932e75e622af275681965d&campaign=f1c80d4bb5643c222ae8de75e9b2f991&url=https%3A%2F%2Fwww.w3.org%2FPeople%2Fmimasa%2Ftest%2Fxhtml%2Fentities%2Fentities-11.xhtml%23lat1', + cta: 'Click here to learn more', + image: { + height: 600, + url: 'https://blobs.omnitagjs.com/blobs/f1/f1c80d4bb5643c22/fd4362d35bb174d6f1c80d4bb5643c22', + width: 300, + }, + impressionTrackers: [ + 'https://testPixelIMP.com/fake', + 'https://tracking.omnitagjs.com/tracking/pixel?event_kind=IMPRESSION&attempt=a11a121205932e75e622af275681965d&campaign=f1c80d4bb5643c222ae8de75e9b2f991', + 'https://tracking.omnitagjs.com/tracking/pixel?event_kind=INSERTION&attempt=a11a121205932e75e622af275681965d&campaign=f1c80d4bb5643c222ae8de75e9b2f991' + ], + javascriptTrackers: [ + 'https://testJsIMP.com/fake.js' + ], + privacyIcon: 'https://fo-static.omnitagjs.com/fo-static/native/images/info-ayl.png', + privacyLink: 'https://blobs.omnitagjs.com/adchoice/', + sponsoredBy: 'QA Team', + title: 'Adserver Traffic Redirect Internal', + } + }]; + const responseWithMultiplePlacements = [ { 'BidID': 'bid_id_0', @@ -569,46 +637,21 @@ describe('Adyoulike Adapter', function () { }); it('receive reponse with Native ad', function () { - serverResponse.body = responseWithSinglePlacement; + serverResponse.body = responseWithSingleNative; let result = spec.interpretResponse(serverResponse, {data: '{"Bids":' + JSON.stringify(sentBidNative) + '}'}); expect(result.length).to.equal(1); - expect(result).to.deep.equal([{ - cpm: 0.5, - creativeId: undefined, - currency: 'USD', - netRevenue: true, - requestId: 'bid_id_0', - ttl: 3600, - mediaType: 'native', - native: { - body: 'Considérant l\'extrémité conjoncturelle, il serait bon d\'anticiper toutes les voies de bon sens.', - clickTrackers: [ - 'https://testPixelCLICK.com/fake' - ], - clickUrl: 'https://tracking.omnitagjs.com/tracking/ar?event_kind=CLICK&attempt=a11a121205932e75e622af275681965d&campaign=f1c80d4bb5643c222ae8de75e9b2f991&url=https%3A%2F%2Fwww.w3.org%2FPeople%2Fmimasa%2Ftest%2Fxhtml%2Fentities%2Fentities-11.xhtml%23lat1', - cta: 'Click here to learn more', - image: { - height: 600, - url: 'https://blobs.omnitagjs.com/blobs/f1/f1c80d4bb5643c22/fd4362d35bb174d6f1c80d4bb5643c22', - width: 300, - }, - impressionTrackers: [ - 'https://testPixelIMP.com/fake', - 'https://tracking.omnitagjs.com/tracking/pixel?event_kind=IMPRESSION&attempt=a11a121205932e75e622af275681965d&campaign=f1c80d4bb5643c222ae8de75e9b2f991', - 'https://tracking.omnitagjs.com/tracking/pixel?event_kind=INSERTION&attempt=a11a121205932e75e622af275681965d&campaign=f1c80d4bb5643c222ae8de75e9b2f991' - ], - javascriptTrackers: [ - 'https://testJsIMP.com/fake.js' - ], - privacyIcon: 'https://fo-static.omnitagjs.com/fo-static/native/images/info-ayl.png', - privacyLink: 'https://blobs.omnitagjs.com/adchoice/', - sponsoredBy: 'QA Team', - title: 'Adserver Traffic Redirect Internal', - } + expect(result).to.deep.equal(nativeResult); + }); + + it('receive reponse with Native from ad markup', function () { + serverResponse.body = responseWithSinglePlacement; + let result = spec.interpretResponse(serverResponse, {data: '{"Bids":' + JSON.stringify(sentBidNative) + '}'}); + + expect(result.length).to.equal(1); - }]); + expect(result).to.deep.equal(nativeResult); }); }); }); From 00df091fe2239e0860997eacbf31b65d280284ee Mon Sep 17 00:00:00 2001 From: Guillaume Date: Mon, 31 May 2021 16:28:54 +0200 Subject: [PATCH 04/13] Handle meta object in bid response with default addomains array --- modules/adyoulikeBidAdapter.js | 3 +- test/spec/modules/adyoulikeBidAdapter_spec.js | 33 +++++++++++++++---- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/modules/adyoulikeBidAdapter.js b/modules/adyoulikeBidAdapter.js index 44d8e2e3016..74ce62950f8 100644 --- a/modules/adyoulikeBidAdapter.js +++ b/modules/adyoulikeBidAdapter.js @@ -449,7 +449,8 @@ function createBid(response, bidRequests) { creativeId: response.CreativeID, cpm: response.Price, netRevenue: true, - currency: CURRENCY + currency: CURRENCY, + meta: response.Meta || { advertiserDomains: [] } }; if (request && request.Native) { diff --git a/test/spec/modules/adyoulikeBidAdapter_spec.js b/test/spec/modules/adyoulikeBidAdapter_spec.js index abf8793865c..ad772ee3961 100644 --- a/test/spec/modules/adyoulikeBidAdapter_spec.js +++ b/test/spec/modules/adyoulikeBidAdapter_spec.js @@ -290,6 +290,18 @@ describe('Adyoulike Adapter', function () { 'Placement': 'placement_0' } ]; + + const testMetaObject = { + 'networkId': 123, + 'advertiserId': '3', + 'advertiserName': 'foobar', + 'advertiserDomains': ['foobar.com'], + 'brandId': '345', + 'brandName': 'Foo', + 'primaryCatId': '34', + 'secondaryCatIds': ['IAB-222', 'IAB-333'], + 'mediaType': 'banner' + }; const admSample = "\u003cscript id=\"ayl-prebid-a11a121205932e75e622af275681965d\"\u003e\n(function(){\n\twindow.isPrebid = true\n\tvar prebidResults = /*PREBID*/{\"OnEvents\":{\"CLICK\":[{\"Kind\":\"PIXEL_URL\",\"Url\":\"https://testPixelCLICK.com/fake\"}],\"IMPRESSION\":[{\"Kind\":\"PIXEL_URL\",\"Url\":\"https://testPixelIMP.com/fake\"},{\"Kind\":\"JAVASCRIPT_URL\",\"Url\":\"https://testJsIMP.com/fake.js\"}]},\"Disabled\":false,\"Attempt\":\"a11a121205932e75e622af275681965d\",\"ApiPrefix\":\"https://fo-api.omnitagjs.com/fo-api\",\"TrackingPrefix\":\"https://tracking.omnitagjs.com/tracking\",\"DynamicPrefix\":\"https://tag-dyn.omnitagjs.com/fo-dyn\",\"StaticPrefix\":\"https://fo-static.omnitagjs.com/fo-static\",\"BlobPrefix\":\"https://fo-api.omnitagjs.com/fo-api/blobs\",\"SspPrefix\":\"https://fo-ssp.omnitagjs.com/fo-ssp\",\"VisitorPrefix\":\"https://visitor.omnitagjs.com/visitor\",\"Trusted\":true,\"Placement\":\"e622af275681965d3095808561a1e510\",\"PlacementAccess\":\"ALL\",\"Site\":\"6e2df7a92203c3c7a25561ed63f25a27\",\"Lang\":\"EN\",\"SiteLogo\":null,\"HasSponsorImage\":false,\"ResizeIframe\":true,\"IntegrationConfig\":{\"Kind\":\"WIDGET\",\"Widget\":{\"ExtraStyleSheet\":\"\",\"Placeholders\":{\"Body\":{\"Color\":{\"R\":77,\"G\":21,\"B\":82,\"A\":100},\"BackgroundColor\":{\"R\":255,\"G\":255,\"B\":255,\"A\":100},\"FontFamily\":\"Lato\",\"Width\":\"100%\",\"Align\":\"\",\"BoxShadow\":true},\"CallToAction\":{\"Color\":{\"R\":26,\"G\":157,\"B\":212,\"A\":100}},\"Description\":{\"Length\":130},\"Image\":{\"Width\":600,\"Height\":600,\"Lowres\":false,\"Raw\":false},\"Size\":{\"Height\":\"250px\",\"Width\":\"300px\"},\"Sponsor\":{\"Color\":{\"R\":35,\"G\":35,\"B\":35,\"A\":100},\"Label\":true,\"WithoutLogo\":false},\"Title\":{\"Color\":{\"R\":219,\"G\":181,\"B\":255,\"A\":100}}},\"Selector\":{\"Kind\":\"CSS\",\"Css\":\"#ayl-prebid-a11a121205932e75e622af275681965d\"},\"Insertion\":\"AFTER\",\"ClickFormat\":true,\"Creative20\":true,\"WidgetKind\":\"CREATIVE_TEMPLATE_4\"}},\"Legal\":\"Sponsored\",\"ForcedCampaign\":\"f1c80d4bb5643c222ae8de75e9b2f991\",\"ForcedTrack\":\"\",\"ForcedCreative\":\"\",\"ForcedSource\":\"\",\"DisplayMode\":\"DEFAULT\",\"Campaign\":\"f1c80d4bb5643c222ae8de75e9b2f991\",\"CampaignAccess\":\"ALL\",\"CampaignKind\":\"AD_TRAFFIC\",\"DataSource\":\"LOCAL\",\"DataSourceUrl\":\"\",\"DataSourceOnEventsIsolated\":false,\"DataSourceWithoutCookie\":false,\"Content\":{\"Preview\":{\"Thumbnail\":{\"Image\":{\"Kind\":\"EXTERNAL\",\"Data\":{\"External\":{\"Url\":\"https://tag-dyn.omnitagjs.com/fo-dyn/native/preview/image?key=fd4362d35bb174d6f1c80d4bb5643c22\\u0026kind=INTERNAL\\u0026ztop=0.000000\\u0026zleft=0.000000\\u0026zwidth=0.333333\\u0026zheight=1.000000\\u0026width=[width]\\u0026height=[height]\"}},\"ZoneTop\":0,\"ZoneLeft\":0,\"ZoneWidth\":1,\"ZoneHeight\":1,\"Smart\":false,\"NoTransform\":false,\"Quality\":\"NORMAL\"}},\"Text\":{\"CALLTOACTION\":\"Click here to learn more\",\"DESCRIPTION\":\"Considérant l'extrémité conjoncturelle, il serait bon d'anticiper toutes les voies de bon sens.\",\"SPONSOR\":\"Tested by\",\"TITLE\":\"Adserver Traffic Redirect Internal\"},\"Sponsor\":{\"Name\":\"QA Team\"},\"Credit\":{\"Logo\":{\"Resource\":{\"Kind\":\"EXTERNAL\",\"Data\":{\"External\":{\"Url\":\"https://fo-static.omnitagjs.com/fo-static/native/images/info-ayl.png\"}},\"ZoneTop\":0,\"ZoneLeft\":0,\"ZoneWidth\":1,\"ZoneHeight\":1,\"Smart\":false,\"NoTransform\":false,\"Quality\":\"NORMAL\"}},\"Url\":\"https://blobs.omnitagjs.com/adchoice/\"}},\"Landing\":{\"Url\":\"https://www.w3.org/People/mimasa/test/xhtml/entities/entities-11.xhtml#lat1\",\"LegacyTracking\":false},\"ViewButtons\":{\"Close\":{\"Skip\":6000}},\"InternalContentFields\":{\"AnimatedImage\":false}},\"AdDomain\":\"adyoulike.com\",\"Opener\":\"REDIRECT\",\"PerformUITriggers\":[\"CLICK\"],\"RedirectionTarget\":\"TAB\"}/*PREBID*/;\n\tvar insertAds = function insertAds() {\insertAds();\n\t}\n})();\n\u003c/script\u003e"; const responseWithSinglePlacement = [ { @@ -298,6 +310,7 @@ describe('Adyoulike Adapter', function () { 'Ad': admSample, 'Price': 0.5, 'Height': 600, + 'Meta': testMetaObject } ]; @@ -365,7 +378,8 @@ describe('Adyoulike Adapter', function () { privacyLink: 'https://blobs.omnitagjs.com/adchoice/', sponsoredBy: 'QA Team', title: 'Adserver Traffic Redirect Internal', - } + }, + meta: testMetaObject }]; const responseWithMultiplePlacements = [ @@ -617,6 +631,7 @@ describe('Adyoulike Adapter', function () { expect(result[0].ad).to.equal(admSample); expect(result[0].width).to.equal(300); expect(result[0].height).to.equal(600); + expect(result[0].meta).to.deep.equal(testMetaObject); }); it('receive reponse with multiple placement', function () { @@ -636,8 +651,8 @@ describe('Adyoulike Adapter', function () { expect(result[1].height).to.equal(250); }); - it('receive reponse with Native ad', function () { - serverResponse.body = responseWithSingleNative; + it('receive reponse with Native from ad markup', function () { + serverResponse.body = responseWithSinglePlacement; let result = spec.interpretResponse(serverResponse, {data: '{"Bids":' + JSON.stringify(sentBidNative) + '}'}); expect(result.length).to.equal(1); @@ -645,13 +660,19 @@ describe('Adyoulike Adapter', function () { expect(result).to.deep.equal(nativeResult); }); - it('receive reponse with Native from ad markup', function () { - serverResponse.body = responseWithSinglePlacement; + it('receive reponse with Native ad', function () { + serverResponse.body = responseWithSingleNative; let result = spec.interpretResponse(serverResponse, {data: '{"Bids":' + JSON.stringify(sentBidNative) + '}'}); expect(result.length).to.equal(1); - expect(result).to.deep.equal(nativeResult); + const noMeta = [...nativeResult]; + const metaBackup = noMeta[0].meta; + + // this test should return default meta object + noMeta[0].meta = { advertiserDomains: [] }; + + expect(result).to.deep.equal(noMeta); }); }); }); From 97bd819b785a3100aa3c43a58c9347b3e86c4b90 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Thu, 17 Jun 2021 13:11:24 +0200 Subject: [PATCH 05/13] fix icon retrieval in Native case --- modules/adyoulikeBidAdapter.js | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/modules/adyoulikeBidAdapter.js b/modules/adyoulikeBidAdapter.js index 74ce62950f8..22182caf80f 100644 --- a/modules/adyoulikeBidAdapter.js +++ b/modules/adyoulikeBidAdapter.js @@ -391,32 +391,30 @@ function getNativeAssets(response, nativeConfig) { } native[key] = { - url: getImageUrl(adJson, adJson.Content.Preview.Thumbnail.Image, imgSize[0], imgSize[1]), + url: getImageUrl(adJson, utils.deepAccess(adJson, 'Content.Preview.Thumbnail.Image'), imgSize[0], imgSize[1]), width: imgSize[0], height: imgSize[1] }; break; case 'icon': - if (adJson.HasSponsorImage) { - // icon requested size - const iconSize = nativeConfig.icon.sizes || []; - if (!iconSize.length) { - iconSize[0] = 50; - iconSize[1] = 50; - } - - native[key] = { - url: getImageUrl(adJson, adJson.Content.Preview.Sponsor.Logo.Resource, iconSize[0], iconSize[1]), - width: iconSize[0], - height: iconSize[1] - }; + // icon requested size + const iconSize = nativeConfig.icon.sizes || []; + if (!iconSize.length) { + iconSize[0] = 50; + iconSize[1] = 50; } + + native[key] = { + url: getImageUrl(adJson, utils.deepAccess(adJson, 'Content.Preview.Sponsor.Logo.Resource'), iconSize[0], iconSize[1]), + width: iconSize[0], + height: iconSize[1] + }; break; case 'privacyIcon': - native[key] = getImageUrl(adJson, adJson.Content.Preview.Credit.Logo.Resource, 25, 25); + native[key] = getImageUrl(adJson, utils.deepAccess(adJson, 'Content.Preview.Credit.Logo.Resource'), 25, 25); break; case 'privacyLink': - native[key] = adJson.Content.Preview.Credit.Url; + native[key] = utils.deepAccess(adJson, 'Content.Preview.Credit.Url'); break; } }); From 7897e6acefe9889f77eed5e0feb30b8c3b640d17 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Thu, 17 Jun 2021 13:11:47 +0200 Subject: [PATCH 06/13] Update priorities in case of multiple mediatypes given --- modules/adyoulikeBidAdapter.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/adyoulikeBidAdapter.js b/modules/adyoulikeBidAdapter.js index 22182caf80f..cc851d9db88 100644 --- a/modules/adyoulikeBidAdapter.js +++ b/modules/adyoulikeBidAdapter.js @@ -170,10 +170,10 @@ function getCanonicalUrl() { /* Get mediatype from bidRequest */ function getMediatype(bidRequest) { - var type = BANNER; + var type = NATIVE; - if (utils.deepAccess(bidRequest, 'mediaTypes.native')) { - type = NATIVE; + if (utils.deepAccess(bidRequest, 'mediaTypes.banner')) { + type = BANNER; } else if (utils.deepAccess(bidRequest, 'mediaTypes.video')) { type = VIDEO; } From bbee6cc78ccebf1b0a2c13dfebae9228499be592 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Thu, 17 Jun 2021 15:40:21 +0200 Subject: [PATCH 07/13] improve robustness and fix associated unit test on picture urls --- modules/adyoulikeBidAdapter.js | 75 ++++++++++--------- test/spec/modules/adyoulikeBidAdapter_spec.js | 1 - 2 files changed, 41 insertions(+), 35 deletions(-) diff --git a/modules/adyoulikeBidAdapter.js b/modules/adyoulikeBidAdapter.js index 02856c51c91..5cec76e1571 100644 --- a/modules/adyoulikeBidAdapter.js +++ b/modules/adyoulikeBidAdapter.js @@ -172,11 +172,9 @@ function getCanonicalUrl() { function getMediatype(bidRequest) { if (utils.deepAccess(bidRequest, 'mediaTypes.video')) { return VIDEO; - } - else if (utils.deepAccess(bidRequest, 'mediaTypes.banner')) { + } else if (utils.deepAccess(bidRequest, 'mediaTypes.banner')) { return BANNER; - } - else if (utils.deepAccess(bidRequest, 'mediaTypes.native')) { + } else if (utils.deepAccess(bidRequest, 'mediaTypes.native')) { return NATIVE; } } @@ -282,30 +280,31 @@ function getInternalImgUrl(uid) { function getImageUrl(config, resource, width, height) { let url = ''; + if (resource && resource.Kind) { + switch (resource.Kind) { + case 'INTERNAL': + url = getInternalImgUrl(resource.Data.Internal.BlobReference.Uid); - switch (resource.Kind) { - case 'INTERNAL': - url = getInternalImgUrl(resource.Data.Internal.BlobReference.Uid); - - break; - - case 'EXTERNAL': - const dynPrefix = config.DynamicPrefix; - let extUrl = resource.Data.External.Url; - extUrl = extUrl.replace(/\[height\]/i, '' + height); - extUrl = extUrl.replace(/\[width\]/i, '' + width); + break; - if (extUrl.indexOf(dynPrefix) >= 0) { - const urlmatch = (/.*url=([^&]*)/gm).exec(extUrl); - url = urlmatch ? urlmatch[1] : ''; - if (!url) { - url = getInternalImgUrl((/.*key=([^&]*)/gm).exec(extUrl)[1]); + case 'EXTERNAL': + const dynPrefix = config.DynamicPrefix; + let extUrl = resource.Data.External.Url; + extUrl = extUrl.replace(/\[height\]/i, '' + height); + extUrl = extUrl.replace(/\[width\]/i, '' + width); + + if (extUrl.indexOf(dynPrefix) >= 0) { + const urlmatch = (/.*url=([^&]*)/gm).exec(extUrl); + url = urlmatch ? urlmatch[1] : ''; + if (!url) { + url = getInternalImgUrl((/.*key=([^&]*)/gm).exec(extUrl)[1]); + } + } else { + url = extUrl; } - } else { - url = extUrl; - } - break; + break; + } } return url; @@ -391,11 +390,15 @@ function getNativeAssets(response, nativeConfig) { imgSize[1] = response.Height || 250; } - native[key] = { - url: getImageUrl(adJson, utils.deepAccess(adJson, 'Content.Preview.Thumbnail.Image'), imgSize[0], imgSize[1]), - width: imgSize[0], - height: imgSize[1] - }; + const url = getImageUrl(adJson, utils.deepAccess(adJson, 'Content.Preview.Thumbnail.Image'), imgSize[0], imgSize[1]); + if (url) { + native[key] = { + url, + width: imgSize[0], + height: imgSize[1] + }; + } + break; case 'icon': // icon requested size @@ -405,11 +408,15 @@ function getNativeAssets(response, nativeConfig) { iconSize[1] = 50; } - native[key] = { - url: getImageUrl(adJson, utils.deepAccess(adJson, 'Content.Preview.Sponsor.Logo.Resource'), iconSize[0], iconSize[1]), - width: iconSize[0], - height: iconSize[1] - }; + const icurl = getImageUrl(adJson, utils.deepAccess(adJson, 'Content.Preview.Sponsor.Logo.Resource'), iconSize[0], iconSize[1]); + + if (url) { + native[key] = { + url: icurl, + width: iconSize[0], + height: iconSize[1] + }; + } break; case 'privacyIcon': native[key] = getImageUrl(adJson, utils.deepAccess(adJson, 'Content.Preview.Credit.Logo.Resource'), 25, 25); diff --git a/test/spec/modules/adyoulikeBidAdapter_spec.js b/test/spec/modules/adyoulikeBidAdapter_spec.js index e6e95ea5423..ad772ee3961 100644 --- a/test/spec/modules/adyoulikeBidAdapter_spec.js +++ b/test/spec/modules/adyoulikeBidAdapter_spec.js @@ -302,7 +302,6 @@ describe('Adyoulike Adapter', function () { 'secondaryCatIds': ['IAB-222', 'IAB-333'], 'mediaType': 'banner' }; - const admSample = "\u003cscript id=\"ayl-prebid-a11a121205932e75e622af275681965d\"\u003e\n(function(){\n\twindow.isPrebid = true\n\tvar prebidResults = /*PREBID*/{\"OnEvents\":{\"CLICK\":[{\"Kind\":\"PIXEL_URL\",\"Url\":\"https://testPixelCLICK.com/fake\"}],\"IMPRESSION\":[{\"Kind\":\"PIXEL_URL\",\"Url\":\"https://testPixelIMP.com/fake\"},{\"Kind\":\"JAVASCRIPT_URL\",\"Url\":\"https://testJsIMP.com/fake.js\"}]},\"Disabled\":false,\"Attempt\":\"a11a121205932e75e622af275681965d\",\"ApiPrefix\":\"https://fo-api.omnitagjs.com/fo-api\",\"TrackingPrefix\":\"https://tracking.omnitagjs.com/tracking\",\"DynamicPrefix\":\"https://tag-dyn.omnitagjs.com/fo-dyn\",\"StaticPrefix\":\"https://fo-static.omnitagjs.com/fo-static\",\"BlobPrefix\":\"https://fo-api.omnitagjs.com/fo-api/blobs\",\"SspPrefix\":\"https://fo-ssp.omnitagjs.com/fo-ssp\",\"VisitorPrefix\":\"https://visitor.omnitagjs.com/visitor\",\"Trusted\":true,\"Placement\":\"e622af275681965d3095808561a1e510\",\"PlacementAccess\":\"ALL\",\"Site\":\"6e2df7a92203c3c7a25561ed63f25a27\",\"Lang\":\"EN\",\"SiteLogo\":null,\"HasSponsorImage\":false,\"ResizeIframe\":true,\"IntegrationConfig\":{\"Kind\":\"WIDGET\",\"Widget\":{\"ExtraStyleSheet\":\"\",\"Placeholders\":{\"Body\":{\"Color\":{\"R\":77,\"G\":21,\"B\":82,\"A\":100},\"BackgroundColor\":{\"R\":255,\"G\":255,\"B\":255,\"A\":100},\"FontFamily\":\"Lato\",\"Width\":\"100%\",\"Align\":\"\",\"BoxShadow\":true},\"CallToAction\":{\"Color\":{\"R\":26,\"G\":157,\"B\":212,\"A\":100}},\"Description\":{\"Length\":130},\"Image\":{\"Width\":600,\"Height\":600,\"Lowres\":false,\"Raw\":false},\"Size\":{\"Height\":\"250px\",\"Width\":\"300px\"},\"Sponsor\":{\"Color\":{\"R\":35,\"G\":35,\"B\":35,\"A\":100},\"Label\":true,\"WithoutLogo\":false},\"Title\":{\"Color\":{\"R\":219,\"G\":181,\"B\":255,\"A\":100}}},\"Selector\":{\"Kind\":\"CSS\",\"Css\":\"#ayl-prebid-a11a121205932e75e622af275681965d\"},\"Insertion\":\"AFTER\",\"ClickFormat\":true,\"Creative20\":true,\"WidgetKind\":\"CREATIVE_TEMPLATE_4\"}},\"Legal\":\"Sponsored\",\"ForcedCampaign\":\"f1c80d4bb5643c222ae8de75e9b2f991\",\"ForcedTrack\":\"\",\"ForcedCreative\":\"\",\"ForcedSource\":\"\",\"DisplayMode\":\"DEFAULT\",\"Campaign\":\"f1c80d4bb5643c222ae8de75e9b2f991\",\"CampaignAccess\":\"ALL\",\"CampaignKind\":\"AD_TRAFFIC\",\"DataSource\":\"LOCAL\",\"DataSourceUrl\":\"\",\"DataSourceOnEventsIsolated\":false,\"DataSourceWithoutCookie\":false,\"Content\":{\"Preview\":{\"Thumbnail\":{\"Image\":{\"Kind\":\"EXTERNAL\",\"Data\":{\"External\":{\"Url\":\"https://tag-dyn.omnitagjs.com/fo-dyn/native/preview/image?key=fd4362d35bb174d6f1c80d4bb5643c22\\u0026kind=INTERNAL\\u0026ztop=0.000000\\u0026zleft=0.000000\\u0026zwidth=0.333333\\u0026zheight=1.000000\\u0026width=[width]\\u0026height=[height]\"}},\"ZoneTop\":0,\"ZoneLeft\":0,\"ZoneWidth\":1,\"ZoneHeight\":1,\"Smart\":false,\"NoTransform\":false,\"Quality\":\"NORMAL\"}},\"Text\":{\"CALLTOACTION\":\"Click here to learn more\",\"DESCRIPTION\":\"Considérant l'extrémité conjoncturelle, il serait bon d'anticiper toutes les voies de bon sens.\",\"SPONSOR\":\"Tested by\",\"TITLE\":\"Adserver Traffic Redirect Internal\"},\"Sponsor\":{\"Name\":\"QA Team\"},\"Credit\":{\"Logo\":{\"Resource\":{\"Kind\":\"EXTERNAL\",\"Data\":{\"External\":{\"Url\":\"https://fo-static.omnitagjs.com/fo-static/native/images/info-ayl.png\"}},\"ZoneTop\":0,\"ZoneLeft\":0,\"ZoneWidth\":1,\"ZoneHeight\":1,\"Smart\":false,\"NoTransform\":false,\"Quality\":\"NORMAL\"}},\"Url\":\"https://blobs.omnitagjs.com/adchoice/\"}},\"Landing\":{\"Url\":\"https://www.w3.org/People/mimasa/test/xhtml/entities/entities-11.xhtml#lat1\",\"LegacyTracking\":false},\"ViewButtons\":{\"Close\":{\"Skip\":6000}},\"InternalContentFields\":{\"AnimatedImage\":false}},\"AdDomain\":\"adyoulike.com\",\"Opener\":\"REDIRECT\",\"PerformUITriggers\":[\"CLICK\"],\"RedirectionTarget\":\"TAB\"}/*PREBID*/;\n\tvar insertAds = function insertAds() {\insertAds();\n\t}\n})();\n\u003c/script\u003e"; const responseWithSinglePlacement = [ { From 3e7201c4601564e37f461a6f14c40724b8ac75b5 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Tue, 20 Jul 2021 15:48:11 +0200 Subject: [PATCH 08/13] add support for params.size parameter --- modules/adyoulikeBidAdapter.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/adyoulikeBidAdapter.js b/modules/adyoulikeBidAdapter.js index 5cec76e1571..2a0da7e8b92 100644 --- a/modules/adyoulikeBidAdapter.js +++ b/modules/adyoulikeBidAdapter.js @@ -47,7 +47,7 @@ export const spec = { const sizes = getSize(getSizeArray(bid)); const sizeValid = sizes.width > 0 && sizes.height > 0; - // allows no size fornative only + // allows no size for native only return (bid.params && bid.params.placement && (sizeValid || (bid.mediaTypes && bid.mediaTypes.native))); }, @@ -242,10 +242,19 @@ function createEndpointQS(bidderRequest) { function getSizeArray(bid) { let inputSize = bid.sizes || []; + if (bid.mediaTypes && bid.mediaTypes.banner) { inputSize = bid.mediaTypes.banner.sizes || []; } + // handle size in bid.params in formats: [w, h] and [[w,h]]. + if (Array.isArray(bid.params.size)) { + inputSize = bid.params.size; + if (!Array.isArray(inputSize[0])) { + inputSize = [inputSize] + } + } + return utils.parseSizesInput(inputSize); } From 13da01bfa292200244d723dd5a55383db81d280c Mon Sep 17 00:00:00 2001 From: Guillaume Date: Tue, 20 Jul 2021 16:02:41 +0200 Subject: [PATCH 09/13] add unit test on new size format --- modules/adyoulikeBidAdapter.js | 2 +- test/spec/modules/adyoulikeBidAdapter_spec.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/modules/adyoulikeBidAdapter.js b/modules/adyoulikeBidAdapter.js index 2a0da7e8b92..41fc38df578 100644 --- a/modules/adyoulikeBidAdapter.js +++ b/modules/adyoulikeBidAdapter.js @@ -248,7 +248,7 @@ function getSizeArray(bid) { } // handle size in bid.params in formats: [w, h] and [[w,h]]. - if (Array.isArray(bid.params.size)) { + if (bid.params && Array.isArray(bid.params.size)) { inputSize = bid.params.size; if (!Array.isArray(inputSize[0])) { inputSize = [inputSize] diff --git a/test/spec/modules/adyoulikeBidAdapter_spec.js b/test/spec/modules/adyoulikeBidAdapter_spec.js index ad772ee3961..7e8988b6e24 100644 --- a/test/spec/modules/adyoulikeBidAdapter_spec.js +++ b/test/spec/modules/adyoulikeBidAdapter_spec.js @@ -422,6 +422,17 @@ describe('Adyoulike Adapter', function () { 'transactionId': 'bid_id_1_transaction_id' }; + let bidWSize = { + 'bidId': 'bid_id_1', + 'bidder': 'adyoulike', + 'placementCode': 'adunit/hb-1', + 'params': { + 'placement': 'placement_1', + 'size': [250, 300], + }, + 'transactionId': 'bid_id_1_transaction_id' + }; + let nativeBid = { 'bidId': 'bid_id_1', 'bidder': 'adyoulike', @@ -441,6 +452,10 @@ describe('Adyoulike Adapter', function () { expect(!!spec.isBidRequestValid(bid)).to.equal(true); }); + it('should return true when required params found with size in bid params', function () { + expect(!!spec.isBidRequestValid(bidWSize)).to.equal(true); + }); + it('should return true when required params found for native ad', function () { expect(!!spec.isBidRequestValid(nativeBid)).to.equal(true); }); From dc609d7f8db881c2235eb8923c07c5eb713b6acd Mon Sep 17 00:00:00 2001 From: Guillaume Date: Wed, 28 Jul 2021 10:39:03 +0200 Subject: [PATCH 10/13] Makes sure the playerSize format is consistent --- modules/adyoulikeBidAdapter.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/adyoulikeBidAdapter.js b/modules/adyoulikeBidAdapter.js index 41fc38df578..0c47a90f3bd 100644 --- a/modules/adyoulikeBidAdapter.js +++ b/modules/adyoulikeBidAdapter.js @@ -86,6 +86,11 @@ export const spec = { } if (mediatype === VIDEO) { accumulator[bidReq.bidId].Video = bidReq.mediaTypes.video; + + const size = bidReq.mediaTypes.video.playerSize; + if (Array.isArray(size) && !Array.isArray(size[0])) { + accumulator[bidReq.bidId].Video.playerSize = [size]; + } } return accumulator; }, {}), From 8afe053947d83b5e678a86dcfa1220f2e42dd003 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Wed, 28 Jul 2021 17:26:56 +0200 Subject: [PATCH 11/13] enable Vast response on bidder adapter --- modules/adyoulikeBidAdapter.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/adyoulikeBidAdapter.js b/modules/adyoulikeBidAdapter.js index 0c47a90f3bd..9fe8d41e2be 100644 --- a/modules/adyoulikeBidAdapter.js +++ b/modules/adyoulikeBidAdapter.js @@ -446,7 +446,7 @@ function getNativeAssets(response, nativeConfig) { /* Create bid from response */ function createBid(response, bidRequests) { - if (!response || (!response.Ad && !response.Native)) { + if (!response || (!response.Ad && !response.Native && !response.Vast)) { return } @@ -477,6 +477,7 @@ function createBid(response, bidRequests) { 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'; From d60f235c25e05d76f8f0764bfffd9fe970f6a6df Mon Sep 17 00:00:00 2001 From: Guillaume Date: Wed, 28 Jul 2021 17:38:13 +0200 Subject: [PATCH 12/13] fix lint errors --- modules/adyoulikeBidAdapter.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/adyoulikeBidAdapter.js b/modules/adyoulikeBidAdapter.js index 9fe8d41e2be..38731fdc91c 100644 --- a/modules/adyoulikeBidAdapter.js +++ b/modules/adyoulikeBidAdapter.js @@ -477,7 +477,6 @@ function createBid(response, bidRequests) { 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'; From bd7551f8c3735ca9e70006b6db49c5b56bda984c Mon Sep 17 00:00:00 2001 From: Guillaume Date: Wed, 28 Jul 2021 18:31:51 +0200 Subject: [PATCH 13/13] add test on Vast format case --- test/spec/modules/adyoulikeBidAdapter_spec.js | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/test/spec/modules/adyoulikeBidAdapter_spec.js b/test/spec/modules/adyoulikeBidAdapter_spec.js index 7e8988b6e24..befc95e5f24 100644 --- a/test/spec/modules/adyoulikeBidAdapter_spec.js +++ b/test/spec/modules/adyoulikeBidAdapter_spec.js @@ -158,6 +158,17 @@ describe('Adyoulike Adapter', function () { } }; + const sentBidVideo = { + 'bid_id_0': { + 'PlacementID': 'e622af275681965d3095808561a1e510', + 'TransactionID': 'e8355240-d976-4cd5-a493-640656fe08e8', + 'AvailableSizes': '', + 'Video': { + playerSize: [640, 480] + } + } + }; + const sentNativeImageType = { 'additional': { 'sent': [ @@ -382,6 +393,28 @@ describe('Adyoulike Adapter', function () { meta: testMetaObject }]; + const responseWithSingleVideo = [{ + 'BidID': 'bid_id_0', + 'Placement': 'placement_0', + 'Vast': 'PFZBU1Q+RW1wdHkgc2FtcGxlPC92YXN0Pg==', + 'Price': 0.5, + 'Height': 600, + }]; + + const videoResult = [{ + cpm: 0.5, + creativeId: undefined, + currency: 'USD', + netRevenue: true, + requestId: 'bid_id_0', + ttl: 3600, + mediaType: 'video', + meta: { + advertiserDomains: [] + }, + vastXml: 'Empty sample' + }]; + const responseWithMultiplePlacements = [ { 'BidID': 'bid_id_0', @@ -689,5 +722,13 @@ describe('Adyoulike Adapter', function () { expect(result).to.deep.equal(noMeta); }); + + it('receive Vast reponse with Video ad', function () { + serverResponse.body = responseWithSingleVideo; + let result = spec.interpretResponse(serverResponse, {data: '{"Bids":' + JSON.stringify(sentBidVideo) + '}'}); + + expect(result.length).to.equal(1); + expect(result).to.deep.equal(videoResult); + }); }); });