Skip to content

Commit

Permalink
Pass through transactionId and set fd=1 (#1259)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pupis authored and dbemiller committed Jun 12, 2017
1 parent b680317 commit e456fcf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
9 changes: 6 additions & 3 deletions src/adapters/adform.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ function AdformAdapter() {
};

function _callBids(params) {
var bid, _value, _key, i, j, k, l;
var bid, _value, _key, i, j, k, l, reqParams;
var bids = params.bids;
var request = [];
var callbackName = '_adf_' + utils.getUniqueIdentifierStr();
var globalParams = [ [ 'adxDomain', 'adx.adform.net' ], [ 'url', null ], [ 'tid', null ], [ 'callback', '$$PREBID_GLOBAL$$.' + callbackName ] ];
var globalParams = [ [ 'adxDomain', 'adx.adform.net' ], ['fd', 1], [ 'url', null ], [ 'tid', null ], [ 'callback', '$$PREBID_GLOBAL$$.' + callbackName ] ];

for (i = 0, l = bids.length; i < l; i++) {
bid = bids[i];
Expand All @@ -28,7 +28,9 @@ function AdformAdapter() {
}
}

request.push(formRequestUrl(bid.params));
reqParams = bid.params;
reqParams.transactionId = bid.transactionId;
request.push(formRequestUrl(reqParams));
}

request.unshift('//' + globalParams[0][1] + '/adx/?rp=4');
Expand Down Expand Up @@ -76,6 +78,7 @@ function AdformAdapter() {
bidObject.width = adItem.width;
bidObject.height = adItem.height;
bidObject.dealId = adItem.deal_id;
bidObject.transactionId = bid.transactionId;
bidmanager.addBidResponse(bid.placementCode, bidObject);
} else {
bidObject = bidfactory.createBid(STATUSCODES.NO_BID, bid);
Expand Down
18 changes: 12 additions & 6 deletions test/spec/adapters/adform_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@ describe('Adform adapter', () => {
assert.equal(_query.callback.split('.')[1], '_adf_callback');
assert.equal(_query.tid, 145);
assert.equal(_query.rp, 4);
assert.equal(_query.fd, 1);
assert.equal(_query.url, encodeURIComponent('some// there'));
});

it('should correctly form bid items', () => {
const _items = parseUrl(adLoader.loadScript.args[0][0]).items;

assert.deepEqual(_items[0], { mid: '1' });
assert.deepEqual(_items[1], { mid: '2', someVar: 'someValue' });
assert.deepEqual(_items[2], { mid: '3', pdom: 'home' });
assert.deepEqual(_items[0], { mid: '1', transactionId: 'transactionId' });
assert.deepEqual(_items[1], { mid: '2', someVar: 'someValue', transactionId: 'transactionId' });
assert.deepEqual(_items[2], { mid: '3', pdom: 'home', transactionId: 'transactionId' });
});
});

Expand All @@ -60,6 +61,7 @@ describe('Adform adapter', () => {
assert.equal(_bidObject.width, 90);
assert.equal(_bidObject.height, 90);
assert.equal(_bidObject.dealId, 'deal-1');
assert.equal(_bidObject.transactionId, 'transactionId');
});

it('should correctly form empty bid response object', () => {
Expand Down Expand Up @@ -111,6 +113,7 @@ describe('Adform adapter', () => {
});

beforeEach(() => {
var transactionId = 'transactionId';
_adapter = adapter();
utils.getUniqueIdentifierStr = () => 'callback';
sandbox = sinon.sandbox.create();
Expand All @@ -126,7 +129,8 @@ describe('Adform adapter', () => {
url: 'some// there'
},
adxDomain: 'newdomain',
tid: 45
tid: 45,
transactionId: transactionId
},
{
bidId: '123',
Expand All @@ -136,7 +140,8 @@ describe('Adform adapter', () => {
mid: 2,
tid: 145,
someVar: 'someValue'
}
},
transactionId: transactionId
},
{
bidId: 'a1b',
Expand All @@ -145,7 +150,8 @@ describe('Adform adapter', () => {
params: {
mid: 3,
pdom: 'home'
}
},
transactionId: transactionId
}
]});
});
Expand Down

0 comments on commit e456fcf

Please sign in to comment.