Skip to content

Commit

Permalink
Add canonical into ad request to Adnuntius ad server (#12255)
Browse files Browse the repository at this point in the history
  • Loading branch information
antosarho authored Sep 19, 2024
1 parent c776805 commit b2831c5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
9 changes: 8 additions & 1 deletion modules/adnuntiusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,14 @@ export const spec = {

networks[network] = networks[network] || {};
networks[network].adUnits = networks[network].adUnits || [];
if (bidderRequest && bidderRequest.refererInfo) networks[network].context = bidderRequest.refererInfo.page;

const refererInfo = bidderRequest && bidderRequest.refererInfo ? bidderRequest.refererInfo : {};
if (refererInfo.page) {
networks[network].context = bidderRequest.refererInfo.page;
}
if (refererInfo.canonicalUrl) {
networks[network].canonical = bidderRequest.refererInfo.canonicalUrl;
}

const payloadRelatedData = storageTool.getPayloadRelatedData(bid.params.network);
if (Object.keys(payloadRelatedData).length > 0) {
Expand Down
9 changes: 7 additions & 2 deletions test/spec/modules/adnuntiusBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,15 +475,20 @@ describe('adnuntiusBidAdapter', function () {
return 'overridden-value';
});

const request = spec.buildRequests(bidderRequests, {});
const request = spec.buildRequests(bidderRequests, {
refererInfo: {
canonicalUrl: 'https://canonical.com/page.html',
page: 'https://canonical.com/something-else.html'
}
});
expect(request.length).to.equal(1);
expect(request[0]).to.have.property('bid');
const bid = request[0].bid[0]
expect(bid).to.have.property('bidId');
expect(request[0]).to.have.property('url');
expect(request[0].url).to.equal(ENDPOINT_URL.replace('format=prebid', 'format=prebid&so=overridden-value'));
expect(request[0]).to.have.property('data');
expect(request[0].data).to.equal('{"adUnits":[{"auId":"000000000008b6bc","targetId":"123","maxDeals":1,"dimensions":[[640,480],[600,400]]},{"auId":"0000000000000551","targetId":"adn-0000000000000551","dimensions":[[1640,1480],[1600,1400]]}]}');
expect(request[0].data).to.equal('{"adUnits":[{"auId":"000000000008b6bc","targetId":"123","maxDeals":1,"dimensions":[[640,480],[600,400]]},{"auId":"0000000000000551","targetId":"adn-0000000000000551","dimensions":[[1640,1480],[1600,1400]]}],"context":"https://canonical.com/something-else.html","canonical":"https://canonical.com/page.html"}');
});

it('Test requests with no local storage', function () {
Expand Down

0 comments on commit b2831c5

Please sign in to comment.