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 onBidWon method to only execute 1 url #5238

Merged
merged 3 commits into from
May 21, 2020
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
2 changes: 1 addition & 1 deletion integrationExamples/gpt/revcontent_example.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
apiKey: '8a33fa9cf220ae685dcc3544f847cdda858d3b1c',
userId: 673,
domain: 'test.com',
endpoint: 'trends-s0.revcontent.com'
endpoint: 'trends.revcontent.com'
}
}]
}];
Expand Down
20 changes: 1 addition & 19 deletions modules/revcontentBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import {registerBidder} from '../src/adapters/bidderFactory.js';
import * as utils from '../src/utils.js';
import {ajax} from '../src/ajax.js';

const BIDDER_CODE = 'revcontent';
const NATIVE_PARAMS = {
Expand Down Expand Up @@ -223,13 +222,7 @@ export const spec = {
return bidResponses;
},
onBidWon: function (bid) {
var winUrl = bid.nurl;
winUrl = winUrl.replace(/\$\{AUCTION_PRICE\}/, bid.cpm);
var host = extractHostname(winUrl);

ajax(winUrl + '&viewed=1', null, {withCredentials: true});
ajax('https://' + host + '/imp.php', null, 'v=' + encodeURIComponent(encodeURIComponent(getQueryVariable('d', winUrl))) + '&i=' + encodeURIComponent(window.location.href), {method: 'POST', contentType: 'application/x-www-form-urlencoded'});

utils.triggerPixel(bid.nurl);
return true;
}
};
Expand Down Expand Up @@ -280,14 +273,3 @@ function extractHostname(url) {

return hostname;
}

function getQueryVariable(variable, url) {
var query = url;
var vars = query.split('&');
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split('=');
if (decodeURIComponent(pair[0]) == variable) {
return decodeURIComponent(pair[1]);
}
}
}
21 changes: 21 additions & 0 deletions test/spec/modules/revcontentBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {assert, expect} from 'chai';
import {spec} from 'modules/revcontentBidAdapter.js';
import { NATIVE } from 'src/mediaTypes.js';
import { config } from 'src/config.js';
import * as utils from 'src/utils.js';

describe('revcontent adapter', function () {
let serverResponse, bidRequest, bidResponses;
Expand Down Expand Up @@ -327,4 +328,24 @@ describe('revcontent adapter', function () {
assert.ok(result);
});
});

describe('onBidWon', function() {
const bid = {
nurl: 'https://trends-s0.revcontent.com/push/track/?p=${AUCTION_PRICE}&d=nTCdHIfsgKOLFuV7DS1LF%2FnTk5HiFduGU65BgKgB%2BvKyG9YV7ceQWN76HMbBE0C6gwQeXUjravv3Hq5x9TT8CM6r2oUNgkGC9mhgv2yroTH9i3cSoH%2BilxyY19fMXFirtBz%2BF%2FEXKi4bsNh%2BDMPfj0L4elo%2FJEZmx4nslvOneJJjsFjJJtUJc%2F3UPivOisSCa%2B36mAgFQqt%2FSWBriYB%2BVAufz70LaGspF6T6jDzuIyVFJUpLhZVDtLRSJEzh7Lyzzw1FmYarp%2FPg0gZDY48aDdjw5A3Tlj%2Bap0cPHLDprNOyF0dmHDn%2FOVJEDRTWvrQ2JNK1t%2Fg1bGHIih0ec6XBVIBNurqRpLFBuUY6LgXCt0wRZWTByTEZ8AEv8IoYVILJAL%2BXL%2F9IyS4eTcdOUfn5X7gT8QBghCrAFrsCg8ZXKgWddTEXbpN1lU%2FzHdI5eSHkxkJ6WcYxSkY9PyripaIbmKiyb98LQMgTD%2B20RJO5dAmXTQTAcauw6IUPTjgSPEU%2Bd6L5Txd3CM00Hbd%2Bw1bREIQcpKEmlMwrRSwe4bu1BCjlh5A9gvU9Xc2sf7ekS3qPPmtp059r5IfzdNFQJB5aH9HqeDEU%2FxbMHx4ggMgojLBBL1fKrCKLAteEDQxd7PVmFJv7GHU2733vt5TnjKiEhqxHVFyi%2B0MIYMGIziM5HfUqfq3KUf%2F%2FeiCtJKXjg7FS6hOambdimSt7BdGDIZq9QECWdXsXcQqqVLwli27HYDMFVU3TWWRyjkjbhnQID9gQJlcpwIi87jVAODb6qP%2FKGQ%3D%3D',
cpm: '0.1'
};

beforeEach(function() {
sinon.stub(utils, 'triggerPixel');
});

afterEach(function() {
utils.triggerPixel.restore();
});

it('make sure only 1 ajax call is happening', function() {
spec.onBidWon(bid);
expect(utils.triggerPixel.calledOnce).to.equal(true);
});
});
});