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

SmartAdServer Bid Adapter: image sync and noAd #6236

Merged
merged 3 commits into from
Feb 9, 2021
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
12 changes: 10 additions & 2 deletions modules/smartadserverBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const spec = {
const bidResponses = [];
let response = serverResponse.body;
try {
if (response) {
if (response && !response.isNoAd) {
const bidRequest = JSON.parse(bidRequestString.data);

let bidResponse = {
Expand All @@ -144,7 +144,8 @@ export const spec = {
dealId: response.dealId,
currency: response.currency,
netRevenue: response.isNetCpm,
ttl: response.ttl
ttl: response.ttl,
dspPixels: response.dspPixels
};

if (bidRequest.mediaType === VIDEO) {
Expand Down Expand Up @@ -179,6 +180,13 @@ export const spec = {
type: 'iframe',
url: serverResponses[0].body.cSyncUrl
});
} else if (syncOptions.pixelEnabled && serverResponses.length > 0 && serverResponses[0].body.dspPixels !== undefined) {
serverResponses[0].body.dspPixels.forEach(function(pixel) {
syncs.push({
type: 'image',
url: pixel
});
});
}
return syncs;
}
Expand Down
69 changes: 68 additions & 1 deletion test/spec/modules/smartadserverBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,41 @@ describe('Smart bid adapter tests', function () {
ttl: 300,
adUrl: 'http://awesome.fake.url',
ad: '< --- awesome script --- >',
cSyncUrl: 'http://awesome.fake.csync.url'
cSyncUrl: 'http://awesome.fake.csync.url',
isNoAd: false
}
};

var BID_RESPONSE_IS_NO_AD = {
body: {
cpm: 12,
width: 300,
height: 250,
creativeId: 'zioeufg',
currency: 'GBP',
isNetCpm: true,
ttl: 300,
adUrl: 'http://awesome.fake.url',
ad: '< --- awesome script --- >',
cSyncUrl: 'http://awesome.fake.csync.url',
isNoAd: true
}
};

var BID_RESPONSE_IMAGE_SYNC = {
body: {
cpm: 12,
width: 300,
height: 250,
creativeId: 'zioeufg',
currency: 'GBP',
isNetCpm: true,
ttl: 300,
adUrl: 'http://awesome.fake.url',
ad: '< --- awesome script --- >',
cSyncUrl: 'http://awesome.fake.csync.url',
isNoAd: false,
dspPixels: ['pixelOne', 'pixelTwo', 'pixelThree']
}
};

Expand Down Expand Up @@ -149,6 +183,18 @@ describe('Smart bid adapter tests', function () {
expect(requestContent).to.have.property('ckid').and.to.equal(42);
});

it('Verify parse response with no ad', function () {
const request = spec.buildRequests(DEFAULT_PARAMS);
const bids = spec.interpretResponse(BID_RESPONSE_IS_NO_AD, request[0]);
expect(bids).to.have.lengthOf(0);

expect(function () {
spec.interpretResponse(BID_RESPONSE_IS_NO_AD, {
data: 'invalid Json'
})
}).to.not.throw();
});

it('Verify parse response', function () {
const request = spec.buildRequests(DEFAULT_PARAMS);
const bids = spec.interpretResponse(BID_RESPONSE, request[0]);
Expand Down Expand Up @@ -258,6 +304,27 @@ describe('Smart bid adapter tests', function () {
expect(syncs).to.have.lengthOf(0);
});

it('Verifies user sync using dspPixels', function () {
var syncs = spec.getUserSyncs({
iframeEnabled: false,
pixelEnabled: true
}, [BID_RESPONSE_IMAGE_SYNC]);
expect(syncs).to.have.lengthOf(3);
expect(syncs[0].type).to.equal('image');

syncs = spec.getUserSyncs({
iframeEnabled: false,
pixelEnabled: false
}, [BID_RESPONSE_IMAGE_SYNC]);
expect(syncs).to.have.lengthOf(0);

syncs = spec.getUserSyncs({
iframeEnabled: false,
pixelEnabled: true
}, []);
expect(syncs).to.have.lengthOf(0);
});

describe('gdpr tests', function () {
afterEach(function () {
config.resetConfig();
Expand Down