Skip to content

Commit

Permalink
Smaato: Add DOOH support (prebid#11801)
Browse files Browse the repository at this point in the history
  • Loading branch information
Enigo authored and DecayConstant committed Jul 18, 2024
1 parent 18ff524 commit 50f5f28
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
23 changes: 17 additions & 6 deletions modules/smaatoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,19 @@ const converter = ortbConverter({
return bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies;
}

function setPublisherId(node) {
deepSetValue(node, 'publisher.id', bidRequest.params.publisherId);
}

const request = buildRequest(imps, bidderRequest, context);
const bidRequest = context.bidRequests[0];
let siteContent;
let content;
const mediaType = context.mediaType;
if (mediaType === VIDEO) {
const videoParams = bidRequest.mediaTypes[VIDEO];
if (videoParams.context === ADPOD) {
request.imp = createAdPodImp(request.imp[0], videoParams);
siteContent = addOptionalAdpodParameters(videoParams);
content = addOptionalAdpodParameters(videoParams);
}
}

Expand All @@ -242,19 +246,26 @@ const converter = ortbConverter({

if (request.site) {
request.site.id = window.location.hostname
if (siteContent) {
request.site.content = siteContent;
if (content) {
request.site.content = content;
}
setPublisherId(request.site);
} else if (request.dooh) {
request.dooh.id = window.location.hostname
if (content) {
request.dooh.content = content;
}
setPublisherId(request.dooh);
} else {
request.site = {
id: window.location.hostname,
domain: bidderRequest.refererInfo.domain || window.location.hostname,
page: bidderRequest.refererInfo.page || window.location.href,
ref: bidderRequest.refererInfo.ref,
content: siteContent || null
content: content || null
}
setPublisherId(request.site);
}
deepSetValue(request.site, 'publisher.id', bidRequest.params.publisherId);

if (request.regs) {
if (isGdprApplicable()) {
Expand Down
27 changes: 27 additions & 0 deletions test/spec/modules/smaatoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,33 @@ describe('smaatoBidAdapterTest', () => {
expect(req.site.page).to.equal(page);
expect(req.site.ref).to.equal(ref);
expect(req.site.publisher.id).to.equal('publisherId');
expect(req.dooh).to.be.undefined;
})

it('sends correct dooh from ortb2', () => {
const name = 'name';
const domain = 'domain';
const keywords = 'keyword1,keyword2';
const venuetypetax = 1;
const ortb2 = {
dooh: {
name: name,
domain: domain,
keywords: keywords,
venuetypetax: venuetypetax
},
};

const reqs = spec.buildRequests([singleBannerBidRequest], {...defaultBidderRequest, ortb2});

const req = extractPayloadOfFirstAndOnlyRequest(reqs);
expect(req.dooh.id).to.exist.and.to.be.a('string');
expect(req.dooh.name).to.equal(name);
expect(req.dooh.domain).to.equal(domain);
expect(req.dooh.keywords).to.equal(keywords);
expect(req.dooh.venuetypetax).to.equal(venuetypetax);
expect(req.dooh.publisher.id).to.equal('publisherId');
expect(req.site).to.be.undefined;
})

it('sends correct device from ortb2', () => {
Expand Down

0 comments on commit 50f5f28

Please sign in to comment.