Skip to content

Commit

Permalink
TheMediaGrid Bid Adapter: use referrer from refererInfo (prebid#3968)
Browse files Browse the repository at this point in the history
* Added Grid Bid Adapter

* remove priceType from TheMediaGrid Bid Adapter

* Add video support in Grid Bid Adapter

* Added test parameter for video slot

* update Grid Bid Adapter to set size in response bid

* Update Grid Bid Adapter to support identical uids in parameters

* Fix typo in test file for Grid Bid Adapter

* Update The Grid Media Bidder Adapter to send refererInfo.referer as 'u' parameter in ad request
  • Loading branch information
TheMediaGrid authored and jaiminpanchal27 committed Jul 9, 2019
1 parent 3709e47 commit 242d19f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 3 additions & 1 deletion modules/gridBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,15 @@ export const spec = {
});

const payload = {
u: utils.getTopWindowUrl(),
auids: auids.join(','),
sizes: utils.getKeys(sizeMap).join(','),
r: reqId
};

if (bidderRequest) {
if (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) {
payload.u = encodeURIComponent(bidderRequest.refererInfo.referer);
}
if (bidderRequest.timeout) {
payload.wtimeout = bidderRequest.timeout;
}
Expand Down
13 changes: 8 additions & 5 deletions test/spec/modules/gridBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ describe('TheMediaGrid Adapter', function () {
});
return res;
}
const bidderRequest = {refererInfo: {referer: 'http://example.com'}};
const encodedReferer = encodeURIComponent(bidderRequest.refererInfo.referer);
let bidRequests = [
{
'bidder': 'grid',
Expand Down Expand Up @@ -84,29 +86,30 @@ describe('TheMediaGrid Adapter', function () {
];

it('should attach valid params to the tag', function () {
const request = spec.buildRequests([bidRequests[0]]);
const request = spec.buildRequests([bidRequests[0]], bidderRequest);
expect(request.data).to.be.an('string');
const payload = parseRequest(request.data);
expect(payload).to.have.property('u').that.is.a('string');
expect(payload).to.have.property('u', encodedReferer);
expect(payload).to.have.property('auids', '1');
expect(payload).to.have.property('sizes', '300x250,300x600');
expect(payload).to.have.property('r', '22edbae2733bf6');
});

it('auids must not be duplicated', function () {
const request = spec.buildRequests(bidRequests);
const request = spec.buildRequests(bidRequests, bidderRequest);
expect(request.data).to.be.an('string');
const payload = parseRequest(request.data);
expect(payload).to.have.property('u').that.is.a('string');
expect(payload).to.have.property('u', encodedReferer);
expect(payload).to.have.property('auids', '1,1,2');
expect(payload).to.have.property('sizes', '300x250,300x600,728x90');
expect(payload).to.have.property('r', '22edbae2733bf6');
});

it('if gdprConsent is present payload must have gdpr params', function () {
const request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'AAA', gdprApplies: true}});
const request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'AAA', gdprApplies: true}, refererInfo: bidderRequest.refererInfo});
expect(request.data).to.be.an('string');
const payload = parseRequest(request.data);
expect(payload).to.have.property('u', encodedReferer);
expect(payload).to.have.property('gdpr_consent', 'AAA');
expect(payload).to.have.property('gdpr_applies', '1');
});
Expand Down

0 comments on commit 242d19f

Please sign in to comment.