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

ZetaGlobalSspBidAdapter: change logic around mediaType #10074

Merged
merged 48 commits into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
da0b4a5
Merge pull request #1 from prebid/master
asurovenko-zeta Mar 24, 2021
f4ec68e
Merge branch 'master' of git://github.com/prebid/Prebid.js
surovenko Apr 21, 2021
01990a9
Merge remote-tracking branch 'upstream/master'
surovenko May 18, 2021
62f969f
Merge remote-tracking branch 'upstream/master'
surovenko May 18, 2021
ec7c8f0
Merge remote-tracking branch 'upstream/master'
surovenko May 19, 2021
89fe5b1
Merge remote-tracking branch 'upstream/master'
surovenko May 24, 2021
6dc0255
Merge remote-tracking branch 'upstream/master'
surovenko Jun 1, 2021
8dc9ac2
Merge remote-tracking branch 'upstream/master'
surovenko Jun 3, 2021
35353f0
Merge remote-tracking branch 'upstream/master'
surovenko Jun 3, 2021
e6f982a
Merge remote-tracking branch 'upstream/master'
surovenko Jun 4, 2021
70e546c
Merge remote-tracking branch 'upstream/master'
surovenko Jun 7, 2021
cc56875
Merge remote-tracking branch 'upstream/master'
surovenko Jun 15, 2021
f4f2a1e
Merge remote-tracking branch 'upstream/master'
surovenko Jun 16, 2021
3f96c6a
Merge remote-tracking branch 'upstream/master'
surovenko Jul 8, 2021
8e503cd
Merge remote-tracking branch 'upstream/master'
surovenko Aug 3, 2021
1781bfd
Merge remote-tracking branch 'upstream/master'
surovenko Aug 12, 2021
459917b
Merge remote-tracking branch 'upstream/master'
surovenko Aug 17, 2021
9ce50bd
Merge remote-tracking branch 'upstream/master'
surovenko Aug 18, 2021
8f7f147
Merge remote-tracking branch 'upstream/master'
surovenko Aug 19, 2021
a280757
Merge remote-tracking branch 'upstream/master'
surovenko Sep 22, 2021
036d5f1
Merge remote-tracking branch 'upstream/master'
surovenko Nov 19, 2021
33e883f
Merge remote-tracking branch 'upstream/master'
surovenko Nov 26, 2021
e729eb9
Merge remote-tracking branch 'upstream/master'
surovenko Dec 28, 2021
c202e93
Merge remote-tracking branch 'origin/master'
surovenko Feb 17, 2022
95877a7
Merge remote-tracking branch 'upstream/master'
surovenko Feb 22, 2022
bf8f638
Merge remote-tracking branch 'upstream/master'
surovenko Feb 28, 2022
461374f
Merge remote-tracking branch 'upstream/master'
surovenko Mar 5, 2022
b6a2fdc
Merge remote-tracking branch 'upstream/master'
surovenko Mar 9, 2022
92b44e3
Merge remote-tracking branch 'upstream/master'
surovenko May 23, 2022
42381eb
Merge remote-tracking branch 'upstream/master'
surovenko May 25, 2022
f629f34
Merge remote-tracking branch 'upstream/master'
surovenko May 26, 2022
9627d5d
Merge remote-tracking branch 'upstream/master'
surovenko May 27, 2022
3d0c2b2
Merge remote-tracking branch 'upstream/master'
surovenko Aug 10, 2022
0dfdb1c
Merge remote-tracking branch 'upstream/master'
surovenko Nov 14, 2022
9438a2e
Merge remote-tracking branch 'upstream/master'
Feb 1, 2023
4198c51
Merge remote-tracking branch 'upstream/master'
asurovenko-zeta Feb 15, 2023
4064f1f
Merge remote-tracking branch 'upstream/master'
asurovenko-zeta Mar 16, 2023
6b380a1
Merge remote-tracking branch 'upstream/master'
asurovenko-zeta Apr 5, 2023
6cd4e3f
Merge remote-tracking branch 'upstream/master'
asurovenko-zeta Apr 25, 2023
1794ae1
Merge remote-tracking branch 'upstream/master'
asurovenko-zeta Jun 2, 2023
42d2317
Merge remote-tracking branch 'upstream/master'
asurovenko-zeta Jun 8, 2023
d04b912
ZetaGlobalSsp: change logic with mediaType
asurovenko-zeta Jun 8, 2023
c670660
ZetaGlobalSsp: fix build
asurovenko-zeta Jun 8, 2023
3b7e322
ZetaGlobalSsp: fix tests
asurovenko-zeta Jun 8, 2023
30980ee
ZetaGlobalSsp: fix tests (2)
asurovenko-zeta Jun 8, 2023
df38287
ZetaGlobalSsp: fix lint
asurovenko-zeta Jun 8, 2023
ac87818
ZetaGlobalSsp: fix tests (3)
asurovenko-zeta Jun 8, 2023
02895c1
ZetaGlobalSsp: fix tests (4)
asurovenko-zeta Jun 8, 2023
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
27 changes: 9 additions & 18 deletions modules/zeta_global_sspBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ const TIMEOUT_URL = 'https://ssp.disqus.com/timeout/prebid';
const USER_SYNC_URL_IFRAME = 'https://ssp.disqus.com/sync?type=iframe';
const USER_SYNC_URL_IMAGE = 'https://ssp.disqus.com/sync?type=image';
const DEFAULT_CUR = 'USD';
const TTL = 200;
const TTL = 300;
const NET_REV = true;

const VIDEO_REGEX = new RegExp(/VAST\s+version/);

const DATA_TYPES = {
'NUMBER': 'number',
'STRING': 'string',
Expand Down Expand Up @@ -201,7 +199,10 @@ export const spec = {
advertiserDomains: zetaBid.adomain
};
}
provideMediaType(zetaBid, bid);
provideMediaType(zetaBid, bid, bidRequest.data);
if (bid.mediaType === VIDEO) {
bid.vastXml = bid.ad;
}
bidResponses.push(bid);
})
})
Expand Down Expand Up @@ -333,21 +334,11 @@ function provideEids(request, payload) {
}
}

function provideMediaType(zetaBid, bid) {
if (zetaBid.ext && zetaBid.ext.bidtype) {
if (zetaBid.ext.bidtype === VIDEO) {
bid.mediaType = VIDEO;
bid.vastXml = bid.ad;
} else {
bid.mediaType = BANNER;
}
function provideMediaType(zetaBid, bid, bidRequest) {
if (zetaBid.ext && zetaBid.ext.prebid && zetaBid.ext.prebid.type) {
bid.mediaType = zetaBid.ext.prebid.type === VIDEO ? VIDEO : BANNER;
} else {
if (VIDEO_REGEX.test(bid.ad)) {
bid.mediaType = VIDEO;
bid.vastXml = bid.ad;
} else {
bid.mediaType = BANNER;
}
bid.mediaType = bidRequest.imp[0].video ? VIDEO : BANNER;
}
}

Expand Down
139 changes: 136 additions & 3 deletions test/spec/modules/zeta_global_sspBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,87 @@ describe('Zeta Ssp Bid Adapter', function () {
params: params
}];

const zetaResponse = {
body: {
id: '12345',
seatbid: [
{
bid: [
{
id: 'auctionId',
impid: 'impId',
price: 0.0,
adm: 'adMarkup',
crid: 'creativeId',
adomain: [
'https://example.com'
],
h: 250,
w: 300
}
]
}
],
cur: 'USD'
}
}

const responseBannerPayload = {
data: {
id: '123',
site: {
id: 'SITE_ID',
page: 'page.com',
domain: 'domain.com'
},
user: {
id: '45asdf9tydhrty789adfad4678rew656789',
buyeruid: '1234567890'
},
cur: [
'USD'
],
imp: [
{
id: '1',
banner: {
h: 600,
w: 160
}
}
],
at: 1
}
};

const responseVideoPayload = {
data: {
id: '123',
site: {
id: 'SITE_ID',
page: 'page.com',
domain: 'domain.com'
},
user: {
id: '45asdf9tydhrty789adfad4678rew656789',
buyeruid: '1234567890'
},
cur: [
'USD'
],
imp: [
{
id: '1',
video: {
h: 600,
w: 160
}
}
],
at: 1
}
};

it('Test the bid validation function', function () {
const validBid = spec.isBidRequestValid(bannerRequest[0]);
const invalidBid = spec.isBidRequestValid(null);
Expand Down Expand Up @@ -224,7 +305,10 @@ describe('Zeta Ssp Bid Adapter', function () {
'https://example.com'
],
h: 250,
w: 300
w: 300,
ext: {
bidtype: 'banner'
}
},
{
id: 'auctionId2',
Expand All @@ -251,7 +335,10 @@ describe('Zeta Ssp Bid Adapter', function () {
'https://example3.com'
],
h: 400,
w: 300
w: 300,
ext: {
bidtype: 'video'
}
}
]
}
Expand All @@ -260,7 +347,7 @@ describe('Zeta Ssp Bid Adapter', function () {
}
};

const bidResponse = spec.interpretResponse(response, null);
const bidResponse = spec.interpretResponse(response, responseBannerPayload);
expect(bidResponse).to.not.be.empty;

const bid1 = bidResponse[0];
Expand Down Expand Up @@ -465,4 +552,50 @@ describe('Zeta Ssp Bid Adapter', function () {
expect(payload.imp[0].banner.format[2].w).to.eql(100);
expect(payload.imp[0].banner.format[2].h).to.eql(150);
});

it('Test the response default mediaType:banner', function () {
const bidResponse = spec.interpretResponse(zetaResponse, responseBannerPayload);
expect(bidResponse).to.not.be.empty;
expect(bidResponse.length).to.eql(1);
expect(bidResponse[0].mediaType).to.eql(BANNER);
expect(bidResponse[0].ad).to.eql(zetaResponse.body.seatbid[0].bid[0].adm);
expect(bidResponse[0].vastXml).to.be.undefined;
});

it('Test the response default mediaType:video', function () {
const bidResponse = spec.interpretResponse(zetaResponse, responseVideoPayload);
expect(bidResponse).to.not.be.empty;
expect(bidResponse.length).to.eql(1);
expect(bidResponse[0].mediaType).to.eql(VIDEO);
expect(bidResponse[0].ad).to.eql(zetaResponse.body.seatbid[0].bid[0].adm);
expect(bidResponse[0].vastXml).to.eql(zetaResponse.body.seatbid[0].bid[0].adm);
});

it('Test the response mediaType:video from ext param', function () {
zetaResponse.body.seatbid[0].bid[0].ext = {
prebid: {
type: 'video'
}
}
const bidResponse = spec.interpretResponse(zetaResponse, responseBannerPayload);
expect(bidResponse).to.not.be.empty;
expect(bidResponse.length).to.eql(1);
expect(bidResponse[0].mediaType).to.eql(VIDEO);
expect(bidResponse[0].ad).to.eql(zetaResponse.body.seatbid[0].bid[0].adm);
expect(bidResponse[0].vastXml).to.eql(zetaResponse.body.seatbid[0].bid[0].adm);
});

it('Test the response mediaType:banner from ext param', function () {
zetaResponse.body.seatbid[0].bid[0].ext = {
prebid: {
type: 'banner'
}
}
const bidResponse = spec.interpretResponse(zetaResponse, responseVideoPayload);
expect(bidResponse).to.not.be.empty;
expect(bidResponse.length).to.eql(1);
expect(bidResponse[0].mediaType).to.eql(BANNER);
expect(bidResponse[0].ad).to.eql(zetaResponse.body.seatbid[0].bid[0].adm);
expect(bidResponse[0].vastXml).to.be.undefined;
});
});