From c831decfebca28d8b7e6d45d55d2df0053cdcdf6 Mon Sep 17 00:00:00 2001 From: bbjjki4 Date: Wed, 15 Sep 2021 11:12:04 +0900 Subject: [PATCH 01/16] make buildRequests --- modules/loglyliftBidAdapter.js | 80 ++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 modules/loglyliftBidAdapter.js diff --git a/modules/loglyliftBidAdapter.js b/modules/loglyliftBidAdapter.js new file mode 100644 index 00000000000..c9b894eb463 --- /dev/null +++ b/modules/loglyliftBidAdapter.js @@ -0,0 +1,80 @@ +import { config } from '../src/config.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { NATIVE } from '../src/mediaTypes.js'; + +const BIDDER_CODE = 'loglylift'; +const ENDPOINT_URL = 'https://bid.logly.co.jp/prebid'; + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [NATIVE], + isBidRequestValid: function (bid) { + return !!(bid.params && bid.params.adspotId); + }, + buildRequests: function (bidRequests, bidderRequest) { + const requests = []; + for (let i = 0, len = bidRequests.length; i < len; i++) { + const request = { + method: 'POST', + url: ENDPOINT_URL + '?adspot_id=' + bidRequests[i].params.adspotId, + data: JSON.stringify(newBidRequest(bidRequests[i], bidderRequest)), + options: {}, + bidderRequest + }; + requests.push(request); + } + return requests; + }, + interpretResponse: function (serverResponse, {bidderRequest}) { + serverResponse = serverResponse.body; + const bids = []; + // eslint-disable-next-line no-console + console.dir(bidderRequest); + // eslint-disable-next-line no-console + console.dir(serverResponse); + if (!serverResponse || serverResponse.error) { + return bids; + } + serverResponse.seatbid.forEach(function (bid) { + // const native = {}; + // native.title = 'title'; + // native.url = 'https://cdn.logly.co.jp/images/000/194/300/normal.jpg'; + // bid.native = native; + // bid.dealId = undefined; + bids.push(bid); + }) + // eslint-disable-next-line no-console + console.dir(bids); + return bids; + }, + onBidWon: function (bid) { + // eslint-disable-next-line no-console + console.log('onBidWon'); + // eslint-disable-next-line no-console + console.dir(bid); + }, +}; + +function newBidRequest(bid, bidderRequest) { + const currencyObj = config.getConfig('currency'); + const currency = (currencyObj && currencyObj.adServerCurrency) || 'USD'; + + return { + auctionId: bid.auctionId, + bidderRequestId: bid.bidderRequestId, + transactionId: bid.transactionId, + adUnitCode: bid.adUnitCode, + bidId: bid.bidId, + mediaTypes: bid.mediaTypes, + params: bid.params, + prebidJsVersion: '$prebid.version$', + url: window.location.href, + domain: config.getConfig('publisherDomain'), + referrer: bidderRequest.refererInfo.referer, + auctionStartTime: bidderRequest.auctionStart, + currency: currency, + timeout: config.getConfig('bidderTimeout') + }; +} + +registerBidder(spec); From eb7a1984073dad6fc28ddfc216d86c8904078699 Mon Sep 17 00:00:00 2001 From: bbjjki4 Date: Wed, 22 Sep 2021 15:54:20 +0900 Subject: [PATCH 02/16] remove useless code --- modules/loglyliftBidAdapter.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/modules/loglyliftBidAdapter.js b/modules/loglyliftBidAdapter.js index c9b894eb463..bfb35d88785 100644 --- a/modules/loglyliftBidAdapter.js +++ b/modules/loglyliftBidAdapter.js @@ -29,9 +29,7 @@ export const spec = { serverResponse = serverResponse.body; const bids = []; // eslint-disable-next-line no-console - console.dir(bidderRequest); - // eslint-disable-next-line no-console - console.dir(serverResponse); + console.log(bidderRequest); if (!serverResponse || serverResponse.error) { return bids; } @@ -46,13 +44,7 @@ export const spec = { // eslint-disable-next-line no-console console.dir(bids); return bids; - }, - onBidWon: function (bid) { - // eslint-disable-next-line no-console - console.log('onBidWon'); - // eslint-disable-next-line no-console - console.dir(bid); - }, + } }; function newBidRequest(bid, bidderRequest) { @@ -70,7 +62,7 @@ function newBidRequest(bid, bidderRequest) { prebidJsVersion: '$prebid.version$', url: window.location.href, domain: config.getConfig('publisherDomain'), - referrer: bidderRequest.refererInfo.referer, + referer: bidderRequest.refererInfo.referer, auctionStartTime: bidderRequest.auctionStart, currency: currency, timeout: config.getConfig('bidderTimeout') From 46dd7d3a9dd2c81902cc84bf400c97a6b2853470 Mon Sep 17 00:00:00 2001 From: bbjjki4 Date: Wed, 22 Sep 2021 15:54:30 +0900 Subject: [PATCH 03/16] change ENDPOINTN_URL --- modules/loglyliftBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/loglyliftBidAdapter.js b/modules/loglyliftBidAdapter.js index bfb35d88785..8971a1ccfba 100644 --- a/modules/loglyliftBidAdapter.js +++ b/modules/loglyliftBidAdapter.js @@ -3,7 +3,7 @@ import { registerBidder } from '../src/adapters/bidderFactory.js'; import { NATIVE } from '../src/mediaTypes.js'; const BIDDER_CODE = 'loglylift'; -const ENDPOINT_URL = 'https://bid.logly.co.jp/prebid'; +const ENDPOINT_URL = 'https://bid.logly.co.jp/prebid/client/v1'; export const spec = { code: BIDDER_CODE, From f9e97368d0dba4bf60b2d39cd9ac49ad2b364464 Mon Sep 17 00:00:00 2001 From: bbjjki4 Date: Wed, 22 Sep 2021 15:55:05 +0900 Subject: [PATCH 04/16] add spec test --- test/spec/modules/loglyliftBidAdapter_spec.js | 166 ++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 test/spec/modules/loglyliftBidAdapter_spec.js diff --git a/test/spec/modules/loglyliftBidAdapter_spec.js b/test/spec/modules/loglyliftBidAdapter_spec.js new file mode 100644 index 00000000000..30f64f3a3d9 --- /dev/null +++ b/test/spec/modules/loglyliftBidAdapter_spec.js @@ -0,0 +1,166 @@ +import { expect } from 'chai'; +import { spec } from '../../../modules/loglyliftBidAdapter'; +import * as utils from 'src/utils.js'; + +describe('loglyliftBidAdapter', function () { + const nativeBidRequests = [{ + bidder: 'loglylift', + bidId: '254304ac29e265', + params: { + adspotId: '16' + }, + adUnitCode: '/19968336/prebid_native_example_1', + transactionId: '10aee457-617c-4572-ab5b-99df1d73ccb4', + sizes: [ + [] + ], + bidderRequestId: '15da3afd9632d7', + auctionId: 'f890b7d9-e787-4237-ac21-6d8554abac9f', + mediaTypes: { + native: { + body: { + required: true + }, + icon: { + required: false + }, + title: { + required: true + }, + image: { + required: true + }, + sponsoredBy: { + required: true + } + } + } + }]; + const bidderRequest = { + refererInfo: { + referer: 'fakeReferer', + reachedTop: true, + numIframes: 1, + stack: [] + }, + auctionStart: 1632194172781, + bidderCode: 'loglylift', + bidderRequestId: '15da3afd9632d7', + auctionId: 'f890b7d9-e787-4237-ac21-6d8554abac9f', + timeout: 3000 + }; + + const nativeServerResponse = { + body: { + bids: [{ + bid: { + requestId: '254304ac29e265', + cpm: 10.123, + width: 360, + height: 360, + creativeId: '123456789', + currency: 'JPY', + netRevenue: true, + ttl: 30, + native: { + clickUrl: 'https://dsp.logly.co.jp/click?ad=EXAMPECLICKURL', + image: { + url: 'https://cdn.logly.co.jp/images/000/194/300/normal.jpg', + width: '360', + height: '360' + }, + impressionTrackers: [ + 'https://b.logly.co.jp/sorry.html' + ], + sponsoredBy: 'logly', + title: 'Native Title', + } + } + }], + } + }; + + describe('isBidRequestValid', function () { + it('should return true if the adspotId parameter is present', function () { + expect(spec.isBidRequestValid(nativeBidRequests[0])).to.be.true; + }); + + it('should return false if the adspotId parameter is not present', function () { + let bidRequest = utils.deepClone(nativeBidRequests[0]); + delete bidRequest.params.adspotId; + expect(spec.isBidRequestValid(bidRequest)).to.be.false; + }); + }); + + describe('buildRequests', function () { + it('should generate a valid single POST request for multiple bid requests', function () { + const request = spec.buildRequests(nativeBidRequests, bidderRequest)[0]; + expect(request.method).to.equal('POST'); + expect(request.url).to.equal('https://bid.logly.co.jp/prebid/client/v1?adspot_id=16'); + expect(request.data).to.exist; + + const data = JSON.parse(request.data); + expect(data.auctionId).to.equal(nativeBidRequests[0].auctionId); + expect(data.bidderRequestId).to.equal(nativeBidRequests[0].bidderRequestId); + expect(data.transactionId).to.equal(nativeBidRequests[0].transactionId); + expect(data.adUnitCode).to.equal(nativeBidRequests[0].adUnitCode); + expect(data.bidId).to.equal(nativeBidRequests[0].bidId); + expect(data.mediaTypes).to.deep.equal(nativeBidRequests[0].mediaTypes); + expect(data.params).to.deep.equal(nativeBidRequests[0].params); + expect(data.prebidJsVersion).to.equal('5.14.0-pre'); + expect(data.url).to.exist; + expect(data.domain).to.exist; + expect(data.referer).to.equal(bidderRequest.refererInfo.referer); + expect(data.auctionStartTime).to.equal(bidderRequest.auctionStart); + expect(data.currency).to.exist; + expect(data.timeout).to.equal(bidderRequest.timeout); + }); + }); + + // describe('interpretResponse', function () { + // it('should return an empty array if an invalid response is passed', function () { + // const interpretedResponse = spec.interpretResponse({}, {}); + // expect(interpretedResponse).to.be.an('array').that.is.empty; + // }); + + // it('should return valid response when passed valid server response', function () { + // const request = spec.buildRequests(bidRequests, bidderRequest)[0]; + // const interpretedResponse = spec.interpretResponse(serverResponse, request); + + // expect(interpretedResponse).to.have.lengthOf(1); + + // expect(interpretedResponse[0].requestId).to.equal(serverResponse.body.seatbid[0].bid.requestId); + // expect(interpretedResponse[0].cpm).to.equal(serverResponse.body.seatbid[0].bid.cpm); + // expect(interpretedResponse[0].width).to.equal(serverResponse.body.seatbid[0].bid.width); + // expect(interpretedResponse[0].height).to.equal(serverResponse.body.seatbid[0].bid.height); + // expect(interpretedResponse[0].creativeId).to.equal(serverResponse.body.seatbid[0].bid.creativeId); + // expect(interpretedResponse[0].currency).to.equal(serverResponse.body.seatbid[0].bid.currency); + // expect(interpretedResponse[0].netRevenue).to.equal(serverResponse.body.seatbid[0].bid.netRevenue); + // expect(interpretedResponse[0].ad).to.equal(serverResponse.body.seatbid[0].bid.ad); + // expect(interpretedResponse[0].ttl).to.equal(serverResponse.body.seatbid[0].bid.ttl); + // expect(interpretedResponse[0].meta.advertiserDomains).to.equal(serverResponse.body.seatbid[0].bid.meta.advertiserDomains); + + // // native + // const nativeRequest = spec.buildRequests(nativeBidRequests, bidderRequest)[0]; + // const interpretedResponseForNative = spec.interpretResponse(nativeServerResponse, nativeRequest); + + // expect(interpretedResponseForNative).to.have.lengthOf(1); + + // expect(interpretedResponseForNative[0].requestId).to.equal(nativeServerResponse.body.seatbid[0].bid.requestId); + // expect(interpretedResponseForNative[0].cpm).to.equal(nativeServerResponse.body.seatbid[0].bid.cpm); + // expect(interpretedResponseForNative[0].width).to.equal(nativeServerResponse.body.seatbid[0].bid.width); + // expect(interpretedResponseForNative[0].height).to.equal(nativeServerResponse.body.seatbid[0].bid.height); + // expect(interpretedResponseForNative[0].creativeId).to.equal(nativeServerResponse.body.seatbid[0].bid.creativeId); + // expect(interpretedResponseForNative[0].currency).to.equal(nativeServerResponse.body.seatbid[0].bid.currency); + // expect(interpretedResponseForNative[0].netRevenue).to.equal(nativeServerResponse.body.seatbid[0].bid.netRevenue); + // expect(interpretedResponseForNative[0].ttl).to.equal(nativeServerResponse.body.seatbid[0].bid.ttl); + // expect(interpretedResponseForNative[0].native.clickUrl).to.equal(nativeServerResponse.body.seatbid[0].bid.native.clickUrl); + // expect(interpretedResponseForNative[0].native.image.url).to.equal(nativeServerResponse.body.seatbid[0].bid.native.image.url); + // expect(interpretedResponseForNative[0].native.image.width).to.equal(nativeServerResponse.body.seatbid[0].bid.native.image.width); + // expect(interpretedResponseForNative[0].native.impressionTrackers).to.equal(nativeServerResponse.body.seatbid[0].bid.native.impressionTrackers); + // expect(interpretedResponseForNative[0].native.sponsoredBy).to.equal(nativeServerResponse.body.seatbid[0].bid.native.sponsoredBy); + // expect(interpretedResponseForNative[0].native.title).to.equal(nativeServerResponse.body.seatbid[0].bid.native.title); + // expect(interpretedResponseForNative[0].meta.advertiserDomains[0]).to.equal(serverResponse.body.seatbid[0].bid.meta.advertiserDomains[0]); + // }); + // }); +}); From 14dcdc2715a08b97e92f6549bfc5feb274f29a38 Mon Sep 17 00:00:00 2001 From: bbjjki4 Date: Wed, 22 Sep 2021 16:43:17 +0900 Subject: [PATCH 05/16] format code --- modules/loglyliftBidAdapter.js | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/modules/loglyliftBidAdapter.js b/modules/loglyliftBidAdapter.js index 8971a1ccfba..923e03c41e7 100644 --- a/modules/loglyliftBidAdapter.js +++ b/modules/loglyliftBidAdapter.js @@ -25,25 +25,16 @@ export const spec = { } return requests; }, - interpretResponse: function (serverResponse, {bidderRequest}) { + interpretResponse: function (serverResponse, { bidderRequest }) { serverResponse = serverResponse.body; - const bids = []; - // eslint-disable-next-line no-console - console.log(bidderRequest); + const bidResponses = []; if (!serverResponse || serverResponse.error) { - return bids; + return bidResponses; } - serverResponse.seatbid.forEach(function (bid) { - // const native = {}; - // native.title = 'title'; - // native.url = 'https://cdn.logly.co.jp/images/000/194/300/normal.jpg'; - // bid.native = native; - // bid.dealId = undefined; - bids.push(bid); + serverResponse.bids.forEach(function (bid) { + bidResponses.push(bid); }) - // eslint-disable-next-line no-console - console.dir(bids); - return bids; + return bidResponses; } }; From aed2af06339e8e08e76dcfe20a22cd8d2edccf3f Mon Sep 17 00:00:00 2001 From: bbjjki4 Date: Wed, 22 Sep 2021 18:03:46 +0900 Subject: [PATCH 06/16] fix serverResponse --- modules/loglyliftBidAdapter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/loglyliftBidAdapter.js b/modules/loglyliftBidAdapter.js index 923e03c41e7..4016d683abe 100644 --- a/modules/loglyliftBidAdapter.js +++ b/modules/loglyliftBidAdapter.js @@ -31,8 +31,8 @@ export const spec = { if (!serverResponse || serverResponse.error) { return bidResponses; } - serverResponse.bids.forEach(function (bid) { - bidResponses.push(bid); + serverResponse.bids.forEach(function (bids) { + bidResponses.push(bids.bid); }) return bidResponses; } From 4807a3adcc1196632727898bf151678a86ea0dde Mon Sep 17 00:00:00 2001 From: bbjjki4 Date: Wed, 22 Sep 2021 18:03:51 +0900 Subject: [PATCH 07/16] add test --- test/spec/modules/loglyliftBidAdapter_spec.js | 64 ++++++------------- 1 file changed, 20 insertions(+), 44 deletions(-) diff --git a/test/spec/modules/loglyliftBidAdapter_spec.js b/test/spec/modules/loglyliftBidAdapter_spec.js index 30f64f3a3d9..1ea9ac4b545 100644 --- a/test/spec/modules/loglyliftBidAdapter_spec.js +++ b/test/spec/modules/loglyliftBidAdapter_spec.js @@ -36,6 +36,7 @@ describe('loglyliftBidAdapter', function () { } } }]; + const bidderRequest = { refererInfo: { referer: 'fakeReferer', @@ -117,50 +118,25 @@ describe('loglyliftBidAdapter', function () { }); }); - // describe('interpretResponse', function () { - // it('should return an empty array if an invalid response is passed', function () { - // const interpretedResponse = spec.interpretResponse({}, {}); - // expect(interpretedResponse).to.be.an('array').that.is.empty; - // }); - - // it('should return valid response when passed valid server response', function () { - // const request = spec.buildRequests(bidRequests, bidderRequest)[0]; - // const interpretedResponse = spec.interpretResponse(serverResponse, request); - - // expect(interpretedResponse).to.have.lengthOf(1); - - // expect(interpretedResponse[0].requestId).to.equal(serverResponse.body.seatbid[0].bid.requestId); - // expect(interpretedResponse[0].cpm).to.equal(serverResponse.body.seatbid[0].bid.cpm); - // expect(interpretedResponse[0].width).to.equal(serverResponse.body.seatbid[0].bid.width); - // expect(interpretedResponse[0].height).to.equal(serverResponse.body.seatbid[0].bid.height); - // expect(interpretedResponse[0].creativeId).to.equal(serverResponse.body.seatbid[0].bid.creativeId); - // expect(interpretedResponse[0].currency).to.equal(serverResponse.body.seatbid[0].bid.currency); - // expect(interpretedResponse[0].netRevenue).to.equal(serverResponse.body.seatbid[0].bid.netRevenue); - // expect(interpretedResponse[0].ad).to.equal(serverResponse.body.seatbid[0].bid.ad); - // expect(interpretedResponse[0].ttl).to.equal(serverResponse.body.seatbid[0].bid.ttl); - // expect(interpretedResponse[0].meta.advertiserDomains).to.equal(serverResponse.body.seatbid[0].bid.meta.advertiserDomains); - - // // native - // const nativeRequest = spec.buildRequests(nativeBidRequests, bidderRequest)[0]; - // const interpretedResponseForNative = spec.interpretResponse(nativeServerResponse, nativeRequest); + describe('interpretResponse', function () { + it('should return an empty array if an invalid response is passed', function () { + const interpretedResponse = spec.interpretResponse({}, {}); + expect(interpretedResponse).to.be.an('array').that.is.empty; + }); - // expect(interpretedResponseForNative).to.have.lengthOf(1); + it('should return valid response when passed valid server response', function () { + const request = spec.buildRequests(nativeBidRequests, bidderRequest)[0]; + const interpretedResponse = spec.interpretResponse(nativeServerResponse, request); - // expect(interpretedResponseForNative[0].requestId).to.equal(nativeServerResponse.body.seatbid[0].bid.requestId); - // expect(interpretedResponseForNative[0].cpm).to.equal(nativeServerResponse.body.seatbid[0].bid.cpm); - // expect(interpretedResponseForNative[0].width).to.equal(nativeServerResponse.body.seatbid[0].bid.width); - // expect(interpretedResponseForNative[0].height).to.equal(nativeServerResponse.body.seatbid[0].bid.height); - // expect(interpretedResponseForNative[0].creativeId).to.equal(nativeServerResponse.body.seatbid[0].bid.creativeId); - // expect(interpretedResponseForNative[0].currency).to.equal(nativeServerResponse.body.seatbid[0].bid.currency); - // expect(interpretedResponseForNative[0].netRevenue).to.equal(nativeServerResponse.body.seatbid[0].bid.netRevenue); - // expect(interpretedResponseForNative[0].ttl).to.equal(nativeServerResponse.body.seatbid[0].bid.ttl); - // expect(interpretedResponseForNative[0].native.clickUrl).to.equal(nativeServerResponse.body.seatbid[0].bid.native.clickUrl); - // expect(interpretedResponseForNative[0].native.image.url).to.equal(nativeServerResponse.body.seatbid[0].bid.native.image.url); - // expect(interpretedResponseForNative[0].native.image.width).to.equal(nativeServerResponse.body.seatbid[0].bid.native.image.width); - // expect(interpretedResponseForNative[0].native.impressionTrackers).to.equal(nativeServerResponse.body.seatbid[0].bid.native.impressionTrackers); - // expect(interpretedResponseForNative[0].native.sponsoredBy).to.equal(nativeServerResponse.body.seatbid[0].bid.native.sponsoredBy); - // expect(interpretedResponseForNative[0].native.title).to.equal(nativeServerResponse.body.seatbid[0].bid.native.title); - // expect(interpretedResponseForNative[0].meta.advertiserDomains[0]).to.equal(serverResponse.body.seatbid[0].bid.meta.advertiserDomains[0]); - // }); - // }); + expect(interpretedResponse).to.have.lengthOf(1); + expect(interpretedResponse[0].cpm).to.equal(nativeServerResponse.body.bids[0].bid.cpm); + expect(interpretedResponse[0].width).to.equal(nativeServerResponse.body.bids[0].bid.width); + expect(interpretedResponse[0].height).to.equal(nativeServerResponse.body.bids[0].bid.height); + expect(interpretedResponse[0].creativeId).to.equal(nativeServerResponse.body.bids[0].bid.creativeId); + expect(interpretedResponse[0].currency).to.equal(nativeServerResponse.body.bids[0].bid.currency); + expect(interpretedResponse[0].netRevenue).to.equal(nativeServerResponse.body.bids[0].bid.netRevenue); + expect(interpretedResponse[0].ttl).to.equal(nativeServerResponse.body.bids[0].bid.ttl); + expect(interpretedResponse[0].native).to.deep.equal(nativeServerResponse.body.bids[0].bid.native); + }); + }); }); From 12b6ca0c32ce16aba7d6515d1f47b40f4e2679f1 Mon Sep 17 00:00:00 2001 From: bbjjki4 Date: Fri, 24 Sep 2021 10:39:14 +0900 Subject: [PATCH 08/16] add overview --- modules/loglyliftBidAdapter.md | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 modules/loglyliftBidAdapter.md diff --git a/modules/loglyliftBidAdapter.md b/modules/loglyliftBidAdapter.md new file mode 100644 index 00000000000..6bcc73e9fec --- /dev/null +++ b/modules/loglyliftBidAdapter.md @@ -0,0 +1,40 @@ +# Overview +``` +Module Name: LOGLY lift for Publisher +Module Type: Bidder Adapter +Maintainer: dev@logly.co.jp +``` + +# Description +Module that connects to Logly's demand sources. +Currently module supports only native mediaType. + +# Test Parameters +``` +var adUnits = [ + // Native adUnit + { + code: 'test-native-code', + sizes: [[1, 1]], + mediaTypes: { + native: { + title: { + required: true + }, + image: { + required: true + }, + sponsoredBy: { + required: true + } + } + }, + bids: [{ + bidder: 'loglylift', + params: { + adspotId: 16 + } + }] + } +]; +``` From d62c328b70b9a17762ce43d459a40bfe0a36512e Mon Sep 17 00:00:00 2001 From: bbjjki4 Date: Fri, 1 Oct 2021 13:47:50 +0900 Subject: [PATCH 09/16] fix the bid adpter to adapt the actual response --- modules/loglyliftBidAdapter.js | 4 +- test/spec/modules/loglyliftBidAdapter_spec.js | 60 +++++++++---------- 2 files changed, 31 insertions(+), 33 deletions(-) diff --git a/modules/loglyliftBidAdapter.js b/modules/loglyliftBidAdapter.js index 4016d683abe..923e03c41e7 100644 --- a/modules/loglyliftBidAdapter.js +++ b/modules/loglyliftBidAdapter.js @@ -31,8 +31,8 @@ export const spec = { if (!serverResponse || serverResponse.error) { return bidResponses; } - serverResponse.bids.forEach(function (bids) { - bidResponses.push(bids.bid); + serverResponse.bids.forEach(function (bid) { + bidResponses.push(bid); }) return bidResponses; } diff --git a/test/spec/modules/loglyliftBidAdapter_spec.js b/test/spec/modules/loglyliftBidAdapter_spec.js index 1ea9ac4b545..982956e58e7 100644 --- a/test/spec/modules/loglyliftBidAdapter_spec.js +++ b/test/spec/modules/loglyliftBidAdapter_spec.js @@ -54,28 +54,26 @@ describe('loglyliftBidAdapter', function () { const nativeServerResponse = { body: { bids: [{ - bid: { - requestId: '254304ac29e265', - cpm: 10.123, - width: 360, - height: 360, - creativeId: '123456789', - currency: 'JPY', - netRevenue: true, - ttl: 30, - native: { - clickUrl: 'https://dsp.logly.co.jp/click?ad=EXAMPECLICKURL', - image: { - url: 'https://cdn.logly.co.jp/images/000/194/300/normal.jpg', - width: '360', - height: '360' - }, - impressionTrackers: [ - 'https://b.logly.co.jp/sorry.html' - ], - sponsoredBy: 'logly', - title: 'Native Title', - } + requestId: '254304ac29e265', + cpm: 10.123, + width: 360, + height: 360, + creativeId: '123456789', + currency: 'JPY', + netRevenue: true, + ttl: 30, + native: { + clickUrl: 'https://dsp.logly.co.jp/click?ad=EXAMPECLICKURL', + image: { + url: 'https://cdn.logly.co.jp/images/000/194/300/normal.jpg', + width: '360', + height: '360' + }, + impressionTrackers: [ + 'https://b.logly.co.jp/sorry.html' + ], + sponsoredBy: 'logly', + title: 'Native Title', } }], } @@ -108,7 +106,7 @@ describe('loglyliftBidAdapter', function () { expect(data.bidId).to.equal(nativeBidRequests[0].bidId); expect(data.mediaTypes).to.deep.equal(nativeBidRequests[0].mediaTypes); expect(data.params).to.deep.equal(nativeBidRequests[0].params); - expect(data.prebidJsVersion).to.equal('5.14.0-pre'); + expect(data.prebidJsVersion).to.equal('5.16.0-pre'); expect(data.url).to.exist; expect(data.domain).to.exist; expect(data.referer).to.equal(bidderRequest.refererInfo.referer); @@ -129,14 +127,14 @@ describe('loglyliftBidAdapter', function () { const interpretedResponse = spec.interpretResponse(nativeServerResponse, request); expect(interpretedResponse).to.have.lengthOf(1); - expect(interpretedResponse[0].cpm).to.equal(nativeServerResponse.body.bids[0].bid.cpm); - expect(interpretedResponse[0].width).to.equal(nativeServerResponse.body.bids[0].bid.width); - expect(interpretedResponse[0].height).to.equal(nativeServerResponse.body.bids[0].bid.height); - expect(interpretedResponse[0].creativeId).to.equal(nativeServerResponse.body.bids[0].bid.creativeId); - expect(interpretedResponse[0].currency).to.equal(nativeServerResponse.body.bids[0].bid.currency); - expect(interpretedResponse[0].netRevenue).to.equal(nativeServerResponse.body.bids[0].bid.netRevenue); - expect(interpretedResponse[0].ttl).to.equal(nativeServerResponse.body.bids[0].bid.ttl); - expect(interpretedResponse[0].native).to.deep.equal(nativeServerResponse.body.bids[0].bid.native); + expect(interpretedResponse[0].cpm).to.equal(nativeServerResponse.body.bids[0].cpm); + expect(interpretedResponse[0].width).to.equal(nativeServerResponse.body.bids[0].width); + expect(interpretedResponse[0].height).to.equal(nativeServerResponse.body.bids[0].height); + expect(interpretedResponse[0].creativeId).to.equal(nativeServerResponse.body.bids[0].creativeId); + expect(interpretedResponse[0].currency).to.equal(nativeServerResponse.body.bids[0].currency); + expect(interpretedResponse[0].netRevenue).to.equal(nativeServerResponse.body.bids[0].netRevenue); + expect(interpretedResponse[0].ttl).to.equal(nativeServerResponse.body.bids[0].ttl); + expect(interpretedResponse[0].native).to.deep.equal(nativeServerResponse.body.bids[0].native); }); }); }); From 116144b5920cd422e3c2b863752894c4134d7138 Mon Sep 17 00:00:00 2001 From: bbjjki4 Date: Mon, 15 Nov 2021 17:33:17 +0900 Subject: [PATCH 10/16] treat adspotId as integer --- test/spec/modules/loglyliftBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/loglyliftBidAdapter_spec.js b/test/spec/modules/loglyliftBidAdapter_spec.js index 982956e58e7..5459d6788eb 100644 --- a/test/spec/modules/loglyliftBidAdapter_spec.js +++ b/test/spec/modules/loglyliftBidAdapter_spec.js @@ -7,7 +7,7 @@ describe('loglyliftBidAdapter', function () { bidder: 'loglylift', bidId: '254304ac29e265', params: { - adspotId: '16' + adspotId: 16 }, adUnitCode: '/19968336/prebid_native_example_1', transactionId: '10aee457-617c-4572-ab5b-99df1d73ccb4', From 8f3e239de84ab9e96865b188892d28ae4848c24f Mon Sep 17 00:00:00 2001 From: bbjjki4 Date: Wed, 17 Nov 2021 16:56:54 +0900 Subject: [PATCH 11/16] add getUserSyncs --- modules/loglyliftBidAdapter.js | 16 +++++++++++++++ modules/loglyliftBidAdapter.md | 15 ++++++++++++++ test/spec/modules/loglyliftBidAdapter_spec.js | 20 +++++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/modules/loglyliftBidAdapter.js b/modules/loglyliftBidAdapter.js index 923e03c41e7..e5b80cd6cf1 100644 --- a/modules/loglyliftBidAdapter.js +++ b/modules/loglyliftBidAdapter.js @@ -8,9 +8,11 @@ const ENDPOINT_URL = 'https://bid.logly.co.jp/prebid/client/v1'; export const spec = { code: BIDDER_CODE, supportedMediaTypes: [NATIVE], + isBidRequestValid: function (bid) { return !!(bid.params && bid.params.adspotId); }, + buildRequests: function (bidRequests, bidderRequest) { const requests = []; for (let i = 0, len = bidRequests.length; i < len; i++) { @@ -25,6 +27,7 @@ export const spec = { } return requests; }, + interpretResponse: function (serverResponse, { bidderRequest }) { serverResponse = serverResponse.body; const bidResponses = []; @@ -35,7 +38,20 @@ export const spec = { bidResponses.push(bid); }) return bidResponses; + }, + + getUserSyncs: function (syncOptions, serverResponses) { + const syncs = []; + + if (syncOptions.iframeEnabled) { + syncs.push({ + type: 'iframe', + url: 'https://sync.logly.co.jp/sync/sync.html' + }); + } + return syncs; } + }; function newBidRequest(bid, bidderRequest) { diff --git a/modules/loglyliftBidAdapter.md b/modules/loglyliftBidAdapter.md index 6bcc73e9fec..5645903f20f 100644 --- a/modules/loglyliftBidAdapter.md +++ b/modules/loglyliftBidAdapter.md @@ -38,3 +38,18 @@ var adUnits = [ } ]; ``` + +# UserSync example + +``` +pbjs.setConfig({ + userSync: { + filterSettings: { + iframe: { + bidders: '*', // '*' represents all bidders + filter: 'include' + } + } + } +}); +``` diff --git a/test/spec/modules/loglyliftBidAdapter_spec.js b/test/spec/modules/loglyliftBidAdapter_spec.js index 5459d6788eb..8ba24d412e5 100644 --- a/test/spec/modules/loglyliftBidAdapter_spec.js +++ b/test/spec/modules/loglyliftBidAdapter_spec.js @@ -137,4 +137,24 @@ describe('loglyliftBidAdapter', function () { expect(interpretedResponse[0].native).to.deep.equal(nativeServerResponse.body.bids[0].native); }); }); + + describe('getUserSync tests', function () { + it('UserSync test : check type = iframe, check usermatch URL', function () { + const syncOptions = { + 'iframeEnabled': true + } + let userSync = spec.getUserSyncs(syncOptions); + expect(userSync[0].type).to.equal('iframe'); + const USER_SYNC_URL = 'https://sync.logly.co.jp/sync/sync.html'; + expect(userSync[0].url).to.equal(USER_SYNC_URL); + }); + + it('When iframeEnabled is false, no userSync should be returned', function () { + const syncOptions = { + 'iframeEnabled': false + } + let userSync = spec.getUserSyncs(syncOptions); + expect(userSync).to.be.an('array').that.is.empty; + }); + }); }); From abb0dbd15056423bb790e9890e936e22bd021e9b Mon Sep 17 00:00:00 2001 From: bbjjki4 Date: Thu, 18 Nov 2021 12:12:00 +0900 Subject: [PATCH 12/16] add serverResponses.length > 0 on 'if' condition --- modules/loglyliftBidAdapter.js | 2 +- test/spec/modules/loglyliftBidAdapter_spec.js | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/loglyliftBidAdapter.js b/modules/loglyliftBidAdapter.js index e5b80cd6cf1..e1319d08766 100644 --- a/modules/loglyliftBidAdapter.js +++ b/modules/loglyliftBidAdapter.js @@ -43,7 +43,7 @@ export const spec = { getUserSyncs: function (syncOptions, serverResponses) { const syncs = []; - if (syncOptions.iframeEnabled) { + if (syncOptions.iframeEnabled && serverResponses.length > 0) { syncs.push({ type: 'iframe', url: 'https://sync.logly.co.jp/sync/sync.html' diff --git a/test/spec/modules/loglyliftBidAdapter_spec.js b/test/spec/modules/loglyliftBidAdapter_spec.js index 8ba24d412e5..21077910b52 100644 --- a/test/spec/modules/loglyliftBidAdapter_spec.js +++ b/test/spec/modules/loglyliftBidAdapter_spec.js @@ -143,7 +143,7 @@ describe('loglyliftBidAdapter', function () { const syncOptions = { 'iframeEnabled': true } - let userSync = spec.getUserSyncs(syncOptions); + let userSync = spec.getUserSyncs(syncOptions, [nativeServerResponse]); expect(userSync[0].type).to.equal('iframe'); const USER_SYNC_URL = 'https://sync.logly.co.jp/sync/sync.html'; expect(userSync[0].url).to.equal(USER_SYNC_URL); @@ -153,7 +153,15 @@ describe('loglyliftBidAdapter', function () { const syncOptions = { 'iframeEnabled': false } - let userSync = spec.getUserSyncs(syncOptions); + let userSync = spec.getUserSyncs(syncOptions, [nativeServerResponse]); + expect(userSync).to.be.an('array').that.is.empty; + }); + + it('When nativeSrrverResponses empty, no userSync should be returned', function () { + const syncOptions = { + 'iframeEnabled': false + } + let userSync = spec.getUserSyncs(syncOptions, []); expect(userSync).to.be.an('array').that.is.empty; }); }); From fcdd6d4ce6988b66b655dafb19b459271a394a04 Mon Sep 17 00:00:00 2001 From: bbjjki4 Date: Mon, 22 Nov 2021 10:43:53 +0900 Subject: [PATCH 13/16] fix typo --- test/spec/modules/loglyliftBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/loglyliftBidAdapter_spec.js b/test/spec/modules/loglyliftBidAdapter_spec.js index 21077910b52..62c56d4a3be 100644 --- a/test/spec/modules/loglyliftBidAdapter_spec.js +++ b/test/spec/modules/loglyliftBidAdapter_spec.js @@ -157,7 +157,7 @@ describe('loglyliftBidAdapter', function () { expect(userSync).to.be.an('array').that.is.empty; }); - it('When nativeSrrverResponses empty, no userSync should be returned', function () { + it('When nativeServerResponses empty, no userSync should be returned', function () { const syncOptions = { 'iframeEnabled': false } From 0ac2abf17c0303d154ccdf6eac2e22d59d5c91b8 Mon Sep 17 00:00:00 2001 From: bbjjki4 Date: Mon, 22 Nov 2021 10:45:13 +0900 Subject: [PATCH 14/16] use test adspotId which has a test ad --- modules/loglyliftBidAdapter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/loglyliftBidAdapter.md b/modules/loglyliftBidAdapter.md index 5645903f20f..9bca238b03e 100644 --- a/modules/loglyliftBidAdapter.md +++ b/modules/loglyliftBidAdapter.md @@ -32,7 +32,7 @@ var adUnits = [ bids: [{ bidder: 'loglylift', params: { - adspotId: 16 + adspotId: 4302078 } }] } From 0921048ef02c7fb3b0ae4baaf1525dc51ec5eab2 Mon Sep 17 00:00:00 2001 From: bbjjki4 Date: Fri, 26 Nov 2021 13:50:23 +0900 Subject: [PATCH 15/16] fix prebidJsVersion test --- test/spec/modules/loglyliftBidAdapter_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/loglyliftBidAdapter_spec.js b/test/spec/modules/loglyliftBidAdapter_spec.js index 62c56d4a3be..9eb4eade510 100644 --- a/test/spec/modules/loglyliftBidAdapter_spec.js +++ b/test/spec/modules/loglyliftBidAdapter_spec.js @@ -106,7 +106,7 @@ describe('loglyliftBidAdapter', function () { expect(data.bidId).to.equal(nativeBidRequests[0].bidId); expect(data.mediaTypes).to.deep.equal(nativeBidRequests[0].mediaTypes); expect(data.params).to.deep.equal(nativeBidRequests[0].params); - expect(data.prebidJsVersion).to.equal('5.16.0-pre'); + expect(data.prebidJsVersion).to.equal('6.3.0-pre'); expect(data.url).to.exist; expect(data.domain).to.exist; expect(data.referer).to.equal(bidderRequest.refererInfo.referer); From 064d3c35bd859f3f6a2edc0f29cb3082a87a6960 Mon Sep 17 00:00:00 2001 From: bbjjki4 Date: Fri, 10 Dec 2021 13:53:15 +0900 Subject: [PATCH 16/16] adapt advertiserDomains --- test/spec/modules/loglyliftBidAdapter_spec.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/spec/modules/loglyliftBidAdapter_spec.js b/test/spec/modules/loglyliftBidAdapter_spec.js index 9eb4eade510..6d5fe0c1e57 100644 --- a/test/spec/modules/loglyliftBidAdapter_spec.js +++ b/test/spec/modules/loglyliftBidAdapter_spec.js @@ -62,6 +62,9 @@ describe('loglyliftBidAdapter', function () { currency: 'JPY', netRevenue: true, ttl: 30, + meta: { + advertiserDomains: ['advertiserexample.com'] + }, native: { clickUrl: 'https://dsp.logly.co.jp/click?ad=EXAMPECLICKURL', image: { @@ -106,7 +109,7 @@ describe('loglyliftBidAdapter', function () { expect(data.bidId).to.equal(nativeBidRequests[0].bidId); expect(data.mediaTypes).to.deep.equal(nativeBidRequests[0].mediaTypes); expect(data.params).to.deep.equal(nativeBidRequests[0].params); - expect(data.prebidJsVersion).to.equal('6.3.0-pre'); + expect(data.prebidJsVersion).to.equal('6.5.0-pre'); expect(data.url).to.exist; expect(data.domain).to.exist; expect(data.referer).to.equal(bidderRequest.refererInfo.referer); @@ -135,6 +138,7 @@ describe('loglyliftBidAdapter', function () { expect(interpretedResponse[0].netRevenue).to.equal(nativeServerResponse.body.bids[0].netRevenue); expect(interpretedResponse[0].ttl).to.equal(nativeServerResponse.body.bids[0].ttl); expect(interpretedResponse[0].native).to.deep.equal(nativeServerResponse.body.bids[0].native); + expect(interpretedResponse[0].meta.advertiserDomains[0]).to.equal(nativeServerResponse.body.bids[0].meta.advertiserDomains[0]); }); });