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

Adquery Bid Adapter : fix getId and decode method #10312

Merged
merged 5 commits into from
Aug 23, 2023
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
16 changes: 11 additions & 5 deletions modules/adqueryBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export const spec = {
* @return {Bid[]}
*/
interpretResponse: (response, request) => {
logInfo(request);
logInfo(response);

const res = response && response.body && response.body.data;
let bidResponses = [];

Expand Down Expand Up @@ -113,8 +116,12 @@ export const spec = {
*/
onBidWon: (bid) => {
logInfo('onBidWon', bid);

const bidString = JSON.stringify(bid);
const encodedBuf = window.btoa(bidString);
let copyOfBid = JSON.parse(bidString);
delete copyOfBid.ad;
const shortBidString = JSON.stringify(bid);
const encodedBuf = window.btoa(shortBidString);

let params = {
q: encodedBuf,
Expand Down Expand Up @@ -170,7 +177,6 @@ export const spec = {
url: syncUrl
}];
}

};

function buildRequest(validBidRequests, bidderRequest) {
Expand All @@ -188,9 +194,9 @@ function buildRequest(validBidRequests, bidderRequest) {

if (!userId) {
// onetime User ID
const randomValues = Array.from(window.crypto.getRandomValues(new Uint32Array(4)));
userId = randomValues.map(it => it.toString(36)).join().substring(20);

const ramdomValues = Array.from(window.crypto.getRandomValues(new Uint32Array(4)));
userId = ramdomValues.map(val => val.toString(36)).join('').substring(0, 20);
logInfo('generated onetime User ID: ', userId);
window.qid = userId;
}

Expand Down
10 changes: 2 additions & 8 deletions modules/adqueryIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,9 @@ export const adqueryIdSubmodule = {
let qid = window.qid;

if (!qid) {
const ramdomValues = window.crypto.getRandomValues(new Uint32Array(4));
qid = (ramdomValues[0].toString(36) +
ramdomValues[1].toString(36) +
ramdomValues[2].toString(36) +
ramdomValues[3].toString(36))
.substring(0, 20);
const ramdomValues = Array.from(window.crypto.getRandomValues(new Uint32Array(4)));
qid = ramdomValues.map(val => val.toString(36)).join('').substring(0, 20);

const randomValues = Array.from(window.crypto.getRandomValues(new Uint32Array(4)));
qid = randomValues.map(it => it.toString(36)).join().substring(20);
logInfo('adqueryIdSubmodule ID QID GENERTAED:', qid);
}
logInfo('adqueryIdSubmodule ID QID:', qid);
Expand Down
4 changes: 2 additions & 2 deletions test/spec/modules/adqueryIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('AdqueryIdSystem', function () {
describe('getId', function () {
let getDataFromLocalStorageStub;

beforeEach(function() {
beforeEach(function () {
getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage');
});

Expand Down Expand Up @@ -53,7 +53,7 @@ describe('AdqueryIdSystem', function () {
const callback = adqueryIdSubmodule.getId(config).callback;
callback(callbackSpy);
const request = server.requests[0];
expect(request.url).to.contains('https://another_bidder.adquery.io');
expect(request.url).to.contains('https://another_bidder.adquery.io/qid');
request.respond(200, {'Content-Type': 'application/json'}, JSON.stringify({qid: 'testqid'}));
expect(callbackSpy.lastCall.lastArg).to.deep.equal('testqid');
});
Expand Down