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

update AJA adapter: support user sync by iframe #3382

Merged
merged 2 commits into from
Dec 18, 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
30 changes: 21 additions & 9 deletions modules/ajaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,28 @@ export const spec = {

getUserSyncs: function(syncOptions, serverResponses) {
const syncs = [];
if (syncOptions.pixelEnabled && serverResponses.length) {
const bidderResponseBody = serverResponses[0].body;
if (bidderResponseBody.syncs) {
bidderResponseBody.syncs.forEach(sync => {
syncs.push({
type: 'image',
url: sync
});
if (!serverResponses.length) {
return syncs;
}

const bidderResponseBody = serverResponses[0].body;

if (syncOptions.pixelEnabled && bidderResponseBody.syncs) {
bidderResponseBody.syncs.forEach(sync => {
syncs.push({
type: 'image',
url: sync
});
}
});
}

if (syncOptions.iframeEnabled && bidderResponseBody.sync_htmls) {
bidderResponseBody.sync_htmls.forEach(sync => {
syncs.push({
type: 'iframe',
url: sync
});
});
}

return syncs;
Expand Down
68 changes: 33 additions & 35 deletions modules/ajaBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,38 @@ Aja bid adapter supports Banner and Outstream Video.
# Test Parameters
```
var adUnits = [
// Banner adUnit
{
code: 'banner-div',
mediaTypes: {
banner: {
sizes: [
[300, 250]
],
}
},
bids: [{
bidder: 'aja',
params: {
asi: 'szs4htFiR'
}
}]
},
// Video outstream adUnit
{
code: 'video-outstream',
mediaTypes: {
video: {
context: 'outstream',
playerSize: [300, 250]
}
},
bids: [
{
bidder: 'aja',
params: {
asi: 'Kp2O2tFig'
}
}
]
}
// Banner adUnit
{
code: 'banner-div',
mediaTypes: {
banner: {
sizes: [
[300, 250]
],
}
},
bids: [{
bidder: 'aja',
params: {
asi: 'szs4htFiR'
}
}]
},
// Video outstream adUnit
{
code: 'video-outstream',
mediaTypes: {
video: {
context: 'outstream',
playerSize: [300, 250]
}
},
bids: [{
bidder: 'aja',
params: {
asi: 'Kp2O2tFig'
}
}]
}
];
```
43 changes: 35 additions & 8 deletions test/spec/modules/ajaBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ describe('AjaAdapter', function () {
'is_ad_return': true,
'ad': { /* ad body */ },
'syncs': [
'https://example.test/1'
'https://example.test/pixel/1'
],
'sync_htmls': [
'https://example.test/iframe/1'
]
}
};
Expand All @@ -158,29 +161,53 @@ describe('AjaAdapter', function () {
'is_ad_return': true,
'ad': { /* ad body */ },
'syncs': [
'https://example.test/2'
'https://example.test/pixel/2'
]
}
};

it('should use a sync url from first response', function () {
const syncs = spec.getUserSyncs({ pixelEnabled: true }, [bidResponse1, bidResponse2]);
it('should use a sync url from first response (pixel and iframe)', function () {
const syncs = spec.getUserSyncs({ pixelEnabled: true, iframeEnabled: true }, [bidResponse1, bidResponse2]);
expect(syncs).to.deep.equal([
{
type: 'image',
url: 'https://example.test/1'
url: 'https://example.test/pixel/1'
},
{
type: 'iframe',
url: 'https://example.test/iframe/1'
}
]);
});

it('handle empty response (e.g. timeout)', function () {
const syncs = spec.getUserSyncs({ pixelEnabled: true }, []);
const syncs = spec.getUserSyncs({ pixelEnabled: true, iframeEnabled: true }, []);
expect(syncs).to.deep.equal([]);
});

it('returns empty syncs when not enabled', function () {
const syncs = spec.getUserSyncs({ pixelEnabled: false }, [bidResponse1]);
it('returns empty syncs when not pixel enabled and not iframe enabled', function () {
const syncs = spec.getUserSyncs({ pixelEnabled: false, iframeEnabled: false }, [bidResponse1]);
expect(syncs).to.deep.equal([]);
});

it('returns pixel syncs when pixel enabled and not iframe enabled', function() {
const syncs = spec.getUserSyncs({ pixelEnabled: true, iframeEnabled: false }, [bidResponse1]);
expect(syncs).to.deep.equal([
{
type: 'image',
url: 'https://example.test/pixel/1'
}
]);
});

it('returns iframe syncs when not pixel enabled and iframe enabled', function() {
const syncs = spec.getUserSyncs({ pixelEnabled: false, iframeEnabled: true }, [bidResponse1]);
expect(syncs).to.deep.equal([
{
type: 'iframe',
url: 'https://example.test/iframe/1'
}
]);
});
});
});