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

Taboola Bid Adapter: fix multiple impressions bug #9104

Merged
merged 128 commits into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
478dc6b
create taboola adapter
mikizi Feb 7, 2022
bb75997
create taboola adapter md
mikizi Feb 7, 2022
a8fe097
taboolaBidAdapter.js - small fixes
mikizi Feb 7, 2022
6314750
taboolaBidAdapter.js - small fixes
mikizi Feb 7, 2022
644ba0f
update the md
mikizi Feb 7, 2022
b09a481
update the Maintainer email
mikizi Feb 8, 2022
0f11f67
* update MD page
mikizi Feb 8, 2022
90b0258
* add privacy to the request builder
mikizi Feb 8, 2022
7b1001c
Merge branch 'master' of https://github.com/prebid/Prebid.js into add…
mikizi Feb 8, 2022
7562ed1
Merge branch 'master' of https://github.com/taboola/Prebid.js into ad…
mikizi Feb 9, 2022
de81396
* code refactoring + add more accurate way to get page url and referer
mikizi Feb 9, 2022
a1dfd88
* code refactoring + gte user id
mikizi Feb 10, 2022
600a9d0
* code refactoring + gte user id
mikizi Feb 13, 2022
7fb1379
* update end point url
mikizi Feb 15, 2022
0cf48ad
small fixes + update epi url
mikizi Feb 21, 2022
2e81b9b
Merge pull request #1 from taboola/add-taboola-bid-adapter
mikizi Apr 24, 2022
7f7a0bc
Merge branch 'master' of https://github.com/prebid/Prebid.js
mikizi May 8, 2022
e6e0235
remove the destruction from the bidResponse property
mikizi May 8, 2022
1dabc41
(update the unit tests) remove the destruction from the bidResponse p…
mikizi May 8, 2022
4e4ff4a
fix tests
mikizi May 9, 2022
9f97222
fix tests - run stubs on each test
mikizi May 9, 2022
40a0cf6
rerun because of another adapter flaky test
mikizi May 9, 2022
07a1508
rerun because of another adapter flaky test
mikizi May 9, 2022
6f73485
fix cors issue, switch between height, width position
mikizi May 10, 2022
c13e0c2
update badv, bcat to be based in the ortb2 to support prebid 7 new pr…
mikizi May 22, 2022
1a81f33
retry run circleci
mikizi May 22, 2022
425281f
retry run circleci
mikizi May 22, 2022
fe9ba64
Merge branch 'master' of https://github.com/prebid/Prebid.js
mikizi May 22, 2022
3196a74
pull from upstream
mikizi May 22, 2022
637c11f
update badv, bcat UT
mikizi May 22, 2022
7ae2995
rerun build
mikizi May 23, 2022
8b56406
rerun build
mikizi May 23, 2022
3ec5b3f
Merge branch 'master' of https://github.com/prebid/Prebid.js
mikizi May 24, 2022
599c827
support storageAllowed restriction on unit tests for prebid 7
mikizi May 26, 2022
37e9f2b
create taboola adapter
mikizi Feb 7, 2022
9e518ba
create taboola adapter md
mikizi Feb 7, 2022
3e2a910
taboolaBidAdapter.js - small fixes
mikizi Feb 7, 2022
2aa70e4
taboolaBidAdapter.js - small fixes
mikizi Feb 7, 2022
0ada596
update the md
mikizi Feb 7, 2022
8603f26
update the Maintainer email
mikizi Feb 8, 2022
e0a2675
* update MD page
mikizi Feb 8, 2022
4ac1cd4
* add privacy to the request builder
mikizi Feb 8, 2022
891fd1e
* code refactoring + add more accurate way to get page url and referer
mikizi Feb 9, 2022
1dd1f4f
* code refactoring + gte user id
mikizi Feb 10, 2022
b99902b
* code refactoring + gte user id
mikizi Feb 13, 2022
dd2c61f
* update end point url
mikizi Feb 15, 2022
4d00a14
small fixes + update epi url
mikizi Feb 21, 2022
8edfa53
remove the destruction from the bidResponse property
mikizi May 8, 2022
306c2f7
(update the unit tests) remove the destruction from the bidResponse p…
mikizi May 8, 2022
22cd757
fix tests
mikizi May 9, 2022
6963eb0
fix tests - run stubs on each test
mikizi May 9, 2022
1757041
rerun because of another adapter flaky test
mikizi May 9, 2022
9229d6b
rerun because of another adapter flaky test
mikizi May 9, 2022
0653add
fix cors issue, switch between height, width position
mikizi May 10, 2022
040b747
update badv, bcat to be based in the ortb2 to support prebid 7 new pr…
mikizi May 22, 2022
c99fbbb
retry run circleci
mikizi May 22, 2022
c39b6cf
retry run circleci
mikizi May 22, 2022
0cdb293
pull from upstream
mikizi May 22, 2022
1c71403
update badv, bcat UT
mikizi May 22, 2022
10acfe7
rerun build
mikizi May 23, 2022
c67302e
rerun build
mikizi May 23, 2022
0784363
support storageAllowed restriction on unit tests for prebid 7
mikizi May 26, 2022
ada62a8
Merge branch 'master' of https://github.com/taboola/Prebid.js
mikizi May 26, 2022
fdc1ca3
support storageAllowed restriction on unit tests for prebid 7
mikizi May 26, 2022
3ea96c1
add it also to the aftereach
mikizi May 26, 2022
c525fc1
add it also to the aftereach
mikizi May 26, 2022
e4f02ce
Merge branch 'master' of https://github.com/prebid/Prebid.js
mikizi May 29, 2022
4c1c508
Merge remote-tracking branch 'origin/master'
mikizi May 29, 2022
27eadc9
Merge branch 'master' of https://github.com/prebid/Prebid.js
mikizi Jun 6, 2022
5baada1
change the api endpoint https protocol
mikizi Jun 6, 2022
78dc863
update Taboola prebid documentation:
jennylt Jun 15, 2022
a995b0a
Merge remote-tracking branch 'origin/master' into Fix_Taboola_Prebid_…
jennylt Jun 20, 2022
041ecb2
Merge branch 'prebid:master' into master
mikizi Jun 20, 2022
e649f52
Merge branch 'master' of https://github.com/prebid/Prebid.js into Fix…
jennylt Jun 26, 2022
6a6a088
Merge remote-tracking branch 'origin/master' into Fix_Taboola_Prebid_…
jennylt Jun 26, 2022
0bf72b6
Merge branch 'master' of https://github.com/prebid/Prebid.js into master
jennylt Jun 27, 2022
5d99fc9
Merge remote-tracking branch 'origin/master' into master
jennylt Jun 27, 2022
3f0ff10
Merge branch 'master' of https://github.com/taboola/Prebid.js into Fi…
jennylt Jun 27, 2022
b649c44
Merge pull request #2 from taboola/Fix_Taboola_Prebid_documentation
mikizi Jun 27, 2022
8ac1d72
Merge branch 'master' of https://github.com/prebid/Prebid.js into master
jennylt Jun 28, 2022
c35b648
Merge branch 'master' of https://github.com/taboola/Prebid.js into Up…
jennylt Jun 28, 2022
40ac5a9
update bid response ttl to 60 seconds.
jennylt Jun 28, 2022
6852a4e
Merge remote-tracking branch 'origin/master' into master
jennylt Jun 28, 2022
e1b1637
Merge branch 'master' of https://github.com/taboola/Prebid.js into Up…
jennylt Jun 28, 2022
207ec18
Merge pull request #3 from taboola/Update_Bid_Response_TTL
jennylt Jun 28, 2022
34a00fa
Merge branch 'master' of https://github.com/prebid/Prebid.js into master
jennylt Jun 28, 2022
2997122
Merge remote-tracking branch 'origin/master' into master
jennylt Jun 28, 2022
0e3919b
update Taboola prebid documentation.
jennylt Jun 28, 2022
bacf5b7
Merge pull request #4 from taboola/Update_documentation
jennylt Jun 28, 2022
d2fb36d
Merge branch 'master' of https://github.com/prebid/Prebid.js into master
jennylt Jun 29, 2022
e8d078e
Merge remote-tracking branch 'origin/master' into master
jennylt Jun 29, 2022
9406ede
update-ttl-passing
ahmadlob Jul 27, 2022
90b646a
Merge pull request #7 from taboola/update-ttl-passing
ahmadlob Jul 27, 2022
b789b21
Update taboolaBidAdapter_spec.js
ahmadlob Jul 27, 2022
63f2384
add fallback default value in case of null
ahmadlob Jul 27, 2022
184484f
add semicolons
ahmadlob Jul 27, 2022
afb6a1f
.
ahmadlob Jul 27, 2022
639b6ca
.
ahmadlob Jul 27, 2022
8662d7f
.
ahmadlob Jul 27, 2022
afd8db6
..
ahmadlob Jul 27, 2022
4ccae81
...
ahmadlob Jul 27, 2022
ef6878b
Merge branch 'prebid:master' into master
ahmadlob Sep 5, 2022
375bbf3
support-dynamic-endpoint-url
ahmadlob Sep 5, 2022
45b09d5
support-dynamic-endpoint-url
ahmadlob Sep 5, 2022
240ba76
support-dynamic-endpoint-url
ahmadlob Sep 5, 2022
362ec97
support-dynamic-endpoint-url
ahmadlob Sep 6, 2022
b93e8b7
support-dynamic-endpoint-url
ahmadlob Sep 6, 2022
5a56c31
Merge branch 'prebid:master' into master
ahmadlob Sep 6, 2022
76d3931
Merge pull request #9 from taboola/support-dynamic-endpoint-url
ahmadlob Sep 6, 2022
8d9202f
support-dynamic-endpoint-url
ahmadlob Sep 6, 2022
d6609c9
Merge pull request #10 from taboola/support-dynamic-endpoint-url
ahmadlob Sep 6, 2022
315566c
Merge branch 'master' of https://github.com/taboola/Prebid.js into ma…
jennylt Sep 14, 2022
c19cea1
Merge remote-tracking branch 'upstream/master' into master
jennylt Sep 14, 2022
b488370
Merge branch 'prebid:master' into master
ahmadlob Sep 20, 2022
8a1e5bc
support-dynamic-endpoint-url
ahmadlob Sep 22, 2022
576218f
Merge branch 'prebid:master' into master
ahmadlob Sep 22, 2022
3f918ee
optional-chaining
ahmadlob Sep 22, 2022
26394f9
Merge pull request #11 from taboola/adding-optional-chaining
ahmadlob Sep 23, 2022
1dc8a3e
Merge branch 'master' of https://github.com/prebid/Prebid.js
jennylt Oct 2, 2022
ed80436
Merge branch 'master' of https://github.com/taboola/Prebid.js
jennylt Oct 2, 2022
4c6d515
set netRevenue to true.
jennylt Oct 2, 2022
51f1faa
Merge pull request #12 from taboola/UpdateResponseNetRevenueField
jennylt Oct 2, 2022
08a8bd2
Merge branch 'master' of https://github.com/prebid/Prebid.js
jennylt Oct 11, 2022
35c800a
Merge remote-tracking branch 'origin/master'
jennylt Oct 11, 2022
cbc2574
fix bid response in case we have multiple impressions
jennylt Oct 11, 2022
f5fa3f7
add test
shakhaltb Oct 12, 2022
a90c2ef
Merge pull request #13 from taboola/Fix_Response
shakhaltb Oct 12, 2022
0e50cfe
fix lint
shakhaltb Oct 12, 2022
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
8 changes: 4 additions & 4 deletions modules/taboolaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export const spec = {
return [];
}

return bids.map((bid, id) => getBid(bid.bidId, currency, bidResponses[id])).filter(Boolean);
return bidResponses.map((bidResponse) => getBid(bids, currency, bidResponse)).filter(Boolean);
},
};

Expand Down Expand Up @@ -204,7 +204,7 @@ function getBidResponses({body}) {

const {seatbid, cur} = body;

if (!seatbid.length || !seatbid[0].bid) {
if (!seatbid.length || !seatbid[0].bid || !seatbid[0].bid.length) {
return [];
}

Expand All @@ -214,14 +214,14 @@ function getBidResponses({body}) {
};
}

function getBid(requestId, currency, bidResponse) {
function getBid(bids, currency, bidResponse) {
if (!bidResponse) {
return;
}
const {
price: cpm, crid: creativeId, adm: ad, w: width, h: height, exp: ttl, adomain: advertiserDomains, meta = {}
} = bidResponse;

let requestId = bids[bidResponse.impid - 1].bidId;
if (advertiserDomains && advertiserDomains.length > 0) {
meta.advertiserDomains = advertiserDomains
}
Expand Down
121 changes: 110 additions & 11 deletions test/spec/modules/taboolaBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import {config} from '../../../src/config'
import * as utils from '../../../src/utils'

describe('Taboola Adapter', function () {
let hasLocalStorage, cookiesAreEnabled, getDataFromLocalStorage, localStorageIsEnabled, getCookie;
let hasLocalStorage, cookiesAreEnabled, getDataFromLocalStorage, localStorageIsEnabled, getCookie, commonBidRequest;

beforeEach(() => {
hasLocalStorage = sinon.stub(userData.storageManager, 'hasLocalStorage');
cookiesAreEnabled = sinon.stub(userData.storageManager, 'cookiesAreEnabled');
getCookie = sinon.stub(userData.storageManager, 'getCookie');
getDataFromLocalStorage = sinon.stub(userData.storageManager, 'getDataFromLocalStorage');
localStorageIsEnabled = sinon.stub(userData.storageManager, 'localStorageIsEnabled');

commonBidRequest = createBidRequest();
$$PREBID_GLOBAL$$.bidderSettings = {
taboola: {
storageAllowed: true
Expand All @@ -30,19 +30,19 @@ describe('Taboola Adapter', function () {
$$PREBID_GLOBAL$$.bidderSettings = {};
})

const commonBidRequest = {
const displayBidRequestParams = {
sizes: [[300, 250], [300, 600]]
}

const createBidRequest = () => ({
bidder: 'taboola',
params: {
publisherId: 'publisherId',
tagId: 'placement name'
},
bidId: 'aa43860a-4644-442a-b5e0-93f268cs4d19',
auctionId: '65746dca-26f3-4186-be13-dfa63469b1b7',
}

const displayBidRequestParams = {
sizes: [[300, 250], [300, 600]]
}
bidId: utils.generateUUID(),
auctionId: utils.generateUUID(),
});

describe('isBidRequestValid', function () {
it('should fail when bid is invalid - tagId isn`t defined', function () {
Expand Down Expand Up @@ -132,7 +132,7 @@ describe('Taboola Adapter', function () {

describe('buildRequests', function () {
const defaultBidRequest = {
...commonBidRequest,
...createBidRequest(),
...displayBidRequestParams,
}

Expand Down Expand Up @@ -441,6 +441,105 @@ describe('Taboola Adapter', function () {
overriddenServerResponse.body.seatbid[0].bid = bid;
});

it('should interpret multi impression request', function () {
const multiRequest = {
bids: [
{
...createBidRequest(),
...displayBidRequestParams
},
{
...createBidRequest(),
...displayBidRequestParams
}
]
}

const multiServerResponse = {
body: {
'id': '49ffg4d58ef9a163a69fhgfghd4fad03621b9e036f24f7_15',
'seatbid': [
{
'bid': [
{
'id': '0b3dd94348-134b-435f-8db5-6bf5afgfc39e86c',
'impid': '2',
'price': 0.342068,
'adid': '2785119545551083381',
'adm': 'ADM2',
'adomain': [
'example.xyz'
],
'cid': '15744349',
'crid': '278195503434041083381',
'w': 300,
'h': 250,
'exp': 60,
'lurl': 'http://us-trc.taboola.com/sample'
},
{
'id': '0b3dd94348-134b-435f-8db5-6bf5afgfc39e86c',
'impid': '1',
'price': 0.342068,
'adid': '2785119545551083381',
'adm': 'ADM1',
'adomain': [
'example.xyz'
],
'cid': '15744349',
'crid': '278195503434041083381',
'w': 300,
'h': 250,
'exp': 60,
'lurl': 'http://us-trc.taboola.com/sample'
}
],
'seat': '14204545260'
}
],
'bidid': 'da43860a-4644-442a-b5e0-93f268cf8d19',
'cur': 'USD'
}
};

const [bid] = multiServerResponse.body.seatbid[0].bid;
const expectedRes = [
{
requestId: multiRequest.bids[1].bidId,
cpm: bid.price,
creativeId: bid.crid,
ttl: 60,
netRevenue: true,
currency: multiServerResponse.body.cur,
mediaType: 'banner',
ad: multiServerResponse.body.seatbid[0].bid[0].adm,
width: bid.w,
height: bid.h,
meta: {
'advertiserDomains': bid.adomain
},
},
{
requestId: multiRequest.bids[0].bidId,
cpm: bid.price,
creativeId: bid.crid,
ttl: 60,
netRevenue: true,
currency: multiServerResponse.body.cur,
mediaType: 'banner',
ad: multiServerResponse.body.seatbid[0].bid[1].adm,
width: bid.w,
height: bid.h,
meta: {
'advertiserDomains': bid.adomain
},
}
]

const res = spec.interpretResponse(multiServerResponse, multiRequest)
expect(res).to.deep.equal(expectedRes)
});

it('should interpret display response', function () {
const [bid] = serverResponse.body.seatbid[0].bid;
const expectedRes = [
Expand Down