Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 13 additions & 1 deletion modules/impactifyBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,18 @@ export const spec = {
.filter((bid) => bid.price > 0)
.map((bid) => {
const isPlayer = impMap[bid.impid]?.ext?.impactify?.format === 'player';
const isVideo = !!impMap[bid.impid]?.video;
let mediaType;
if (bid?.mtype === 2) {
mediaType = 'video';
} else if (bid?.mtype === 1) {
mediaType = 'banner';
} else if (isPlayer || isVideo) {
mediaType = 'video';
} else {
mediaType = 'banner';
}

return {
id: bid.id,
requestId: bid.impid,
Expand All @@ -413,14 +425,14 @@ export const spec = {
height: bid.h || 0,
ttl: 300,
creativeId: bid.crid || 0,
mediaType: mediaType,
meta: {
advertiserDomains:
bid.adomain && bid.adomain.length ? bid.adomain : [],
},

...(isPlayer
? {
mediaType: "video",
vastUrl: bid.ext?.vast_url,
vastXml: bid.adm,
}
Expand Down
57 changes: 53 additions & 4 deletions test/spec/modules/impactifyBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,17 +336,18 @@ describe('ImpactifyAdapter', function () {
id: '65820304700829014',
impid: '462c08f20d428',
price: 3.40,
mtype: 2,
adm: '<script type="text/javascript" src="https://ad.impactify.io/static/ad/tag.js"></script>',
adid: '97517771',
iurl: 'https://fra1-ib.adnxs.com/cr?id=97517771',
cid: '9325',
crid: '97517771',
w: 1,
h: 1,
meta: { 'advertiserDomains': ['testdomain.com'] },
adomain: ['testdomain.com'],
ext: {
prebid: {
'type': 'video'
type: 'video'
},
bidder: {
prebid: {
Expand Down Expand Up @@ -406,7 +407,8 @@ describe('ImpactifyAdapter', function () {
}
},
]
}
};

const expectedResponse = [
{
id: '65820304700829014',
Expand All @@ -417,7 +419,8 @@ describe('ImpactifyAdapter', function () {
ad: '<script type="text/javascript" src="https://ad.impactify.io/static/ad/tag.js"></script>',
width: 1,
height: 1,
meta: { 'advertiserDomains': ['testdomain.com'] },
mediaType: 'video',
meta: { advertiserDomains: ['testdomain.com'] },
ttl: 300,
creativeId: '97517771'
}
Expand Down Expand Up @@ -448,6 +451,7 @@ describe('ImpactifyAdapter', function () {
id: 'bid-1',
impid: 'imp-1',
price: 2.5,
mtype: 2,
ext: {
vast_url: 'https://example.com/vast.xml'
},
Expand All @@ -467,6 +471,51 @@ describe('ImpactifyAdapter', function () {
expect(result[0].vastXml).to.equal('<VAST>fallback</VAST>');
expect(result[0]).to.not.have.property('ad');
});

it('should map banner responses to banner bids', function () {
const bidRequest = {
data: JSON.stringify({
imp: [{
id: 'imp-banner-1',
ext: {
impactify: {
format: 'display'
}
}
}]
})
};

const serverResponse = {
body: {
cur: 'USD',
seatbid: [{
bid: [{
id: 'bid-banner-1',
impid: 'imp-banner-1',
price: 1.75,
mtype: 1,
adm: '<div>banner creative</div>',
crid: 'creative-banner-1',
w: 300,
h: 250,
adomain: ['advertiser.com']
}]
}]
}
};

const result = spec.interpretResponse(serverResponse, bidRequest);

expect(result).to.have.length(1);
expect(result[0].mediaType).to.equal('banner');
expect(result[0].ad).to.equal('<div>banner creative</div>');
expect(result[0]).to.not.have.property('vastUrl');
expect(result[0]).to.not.have.property('vastXml');
expect(result[0].meta).to.deep.equal({
advertiserDomains: ['advertiser.com']
});
});
});
describe('getUserSyncs', function () {
const videoBidRequests = [
Expand Down
Loading