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

Smart: User sync #2310

Merged
merged 4 commits into from
Apr 9, 2018
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
19 changes: 18 additions & 1 deletion modules/smartadserverBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,26 @@ export const spec = {
bidResponses.push(bidResponse);
}
} catch (error) {
console.log('Error while parsing smart server response');
utils.logError('Error while parsing smart server response', error);
}
return bidResponses;
},
/**
* User syncs.
*
* @param {*} syncOptions Publisher prebid configuration.
* @param {*} serverResponses A successful response from the server.
* @return {Syncs[]} An array of syncs that should be executed.
*/
getUserSyncs: function (syncOptions, serverResponses) {
const syncs = []
if (syncOptions.iframeEnabled && serverResponses.length > 0) {
syncs.push({
type: 'iframe',
url: serverResponses[0].body.cSyncUrl
});
}
return syncs;
}
}
registerBidder(spec);
23 changes: 16 additions & 7 deletions test/spec/modules/smartadserverBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import {
import {
spec
} from 'modules/smartadserverBidAdapter';
import {
getTopWindowLocation
} from 'src/utils';
import {
newBidder
} from 'src/adapters/bidderFactory';
Expand All @@ -15,7 +12,7 @@ import {
} from 'src/config';
import * as utils from 'src/utils';

describe('Smart ad server bid adapter tests', () => {
describe('Smart bid adapter tests', () => {
var DEFAULT_PARAMS = [{
adUnitCode: 'sas_42',
bidId: 'abcd1234',
Expand Down Expand Up @@ -63,7 +60,8 @@ describe('Smart ad server bid adapter tests', () => {
isNetCpm: true,
ttl: 300,
adUrl: 'http://awesome.fake.url',
ad: '< --- awesome script --- >'
ad: '< --- awesome script --- >',
cSyncUrl: 'http://awesome.fake.csync.url'
}
};

Expand Down Expand Up @@ -109,6 +107,8 @@ describe('Smart ad server bid adapter tests', () => {
expect(bid.ttl).to.equal(300);
expect(bid.requestId).to.equal(DEFAULT_PARAMS[0].bidId);
expect(bid.referrer).to.equal(utils.getTopWindowUrl());

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

it('Verifies bidder code', () => {
Expand Down Expand Up @@ -151,7 +151,16 @@ describe('Smart ad server bid adapter tests', () => {
})).to.equal(false);
});

it('Verifies sync options', () => {
expect(spec.getUserSyncs).to.be.undefined;
it('Verifies user sync', () => {
var syncs = spec.getUserSyncs({iframeEnabled: true}, [BID_RESPONSE]);
expect(syncs).to.have.lengthOf(1);
expect(syncs[0].type).to.equal('iframe');
expect(syncs[0].url).to.equal('http://awesome.fake.csync.url');

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

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