Skip to content

Index Exchange: Schain module support (legacy) #4771

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

Merged
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: 11 additions & 1 deletion modules/ixBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as utils from '../src/utils';
import { BANNER, VIDEO } from '../src/mediaTypes';
import find from 'core-js/library/fn/array/find';
import { config } from '../src/config';
import find from 'core-js/library/fn/array/find';
import isInteger from 'core-js/library/fn/number/is-integer';
import { registerBidder } from '../src/adapters/bidderFactory';

Expand Down Expand Up @@ -234,6 +234,16 @@ function buildRequest(validBidRequests, bidderRequest, impressions, version) {
r.site = {};
r.ext = {};
r.ext.source = 'prebid';

// if an schain is provided, send it along
if (validBidRequests[0].schain) {
r.source = {
ext: {
schain: validBidRequests[0].schain
}
};
}

if (userEids.length > 0) {
r.user = {};
r.user.eids = userEids;
Expand Down
17 changes: 15 additions & 2 deletions modules/ixBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ var adUnits = [{
}];
```

##### 1. Add IX to the appropriate ad units
### 1. Add IX to the appropriate ad units

For each size in an ad unit that IX will be bidding on, add one of the following
bid objects under `adUnits[].bids`:
Expand Down Expand Up @@ -259,7 +259,20 @@ var adUnits = [{
}];
```

##### 2. Include `ixBidAdapter` in your build process
#### Video Caching

Note that the IX adapter expects a client-side Prebid Cache to be enabled for video bidding.

```
pbjs.setConfig({
usePrebidCache: true,
cache: {
url: 'https://prebid.adnxs.com/pbc/v1/cache'
}
});
```

### 2. Include `ixBidAdapter` in your build process

When running the build command, include `ixBidAdapter` as a module, as well as `dfpAdServerVideo` if you require video support.

Expand Down
36 changes: 33 additions & 3 deletions test/spec/modules/ixBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,24 @@ describe('IndexexchangeAdapter', function () {
const VIDEO_ENDPOINT_VERSION = 8.1;
const BANNER_ENDPOINT_VERSION = 7.2;

const SAMPLE_SCHAIN = {
'ver': '1.0',
'complete': 1,
'nodes': [
{
'asi': 'indirectseller.com',
'sid': '00001',
'hp': 1
},

{
'asi': 'indirectseller-2.com',
'sid': '00002',
'hp': 2
}
]
};

const DEFAULT_BANNER_VALID_BID = [
{
bidder: 'ix',
Expand All @@ -26,7 +44,8 @@ describe('IndexexchangeAdapter', function () {
transactionId: '173f49a8-7549-4218-a23c-e7ba59b47229',
bidId: '1a2b3c4d',
bidderRequestId: '11a22b33c44d',
auctionId: '1aa2bb3cc4dd'
auctionId: '1aa2bb3cc4dd',
schain: SAMPLE_SCHAIN
}
];

Expand Down Expand Up @@ -56,7 +75,8 @@ describe('IndexexchangeAdapter', function () {
transactionId: '173f49a8-7549-4218-a23c-e7ba59b47230',
bidId: '1a2b3c4e',
bidderRequestId: '11a22b33c44e',
auctionId: '1aa2bb3cc4de'
auctionId: '1aa2bb3cc4de',
schain: SAMPLE_SCHAIN
}
];

Expand Down Expand Up @@ -483,6 +503,11 @@ describe('IndexexchangeAdapter', function () {
const requestMethod = request.method;
const query = request.data;

const bidWithoutSchain = utils.deepClone(DEFAULT_BANNER_VALID_BID);
delete bidWithoutSchain[0].schain;
const requestWithoutSchain = spec.buildRequests(bidWithoutSchain, DEFAULT_OPTION)[0];
const queryWithoutSchain = requestWithoutSchain.data;

const bidWithoutMediaType = utils.deepClone(DEFAULT_BANNER_VALID_BID);
delete bidWithoutMediaType[0].mediaTypes;
bidWithoutMediaType[0].sizes = [[300, 250], [300, 600]];
Expand All @@ -505,18 +530,23 @@ describe('IndexexchangeAdapter', function () {

it('payload should have correct format and value', function () {
const payload = JSON.parse(query.r);

expect(payload.id).to.equal(DEFAULT_BANNER_VALID_BID[0].bidderRequestId);
expect(payload.site).to.exist;
expect(payload.site.page).to.equal(DEFAULT_OPTION.refererInfo.referer);
expect(payload.site.ref).to.equal(document.referrer);
expect(payload.ext).to.exist;
expect(payload.ext.source).to.equal('prebid');
expect(payload.source.ext.schain).to.deep.equal(SAMPLE_SCHAIN);
expect(payload.imp).to.exist;
expect(payload.imp).to.be.an('array');
expect(payload.imp).to.have.lengthOf(1);
});

it('payload should not include schain when not provided', function () {
const payload = JSON.parse(queryWithoutSchain.r);
expect(payload.source).to.not.exist; // source object currently only written for schain
});

it('impression should have correct format and value', function () {
const impression = JSON.parse(query.r).imp[0];
const sidValue = `${DEFAULT_BANNER_VALID_BID[0].params.size[0].toString()}x${DEFAULT_BANNER_VALID_BID[0].params.size[1].toString()}`;
Expand Down