Skip to content

Commit

Permalink
Adquery Bid Adapter : fix getId and decode method (#10312)
Browse files Browse the repository at this point in the history
* adquery/prebid_qid_work2

* adquery/prebid_qid_work2

* adquery/prebid_qid_work2

* adquery/prebid_qid_work2
  • Loading branch information
adquery committed Aug 23, 2023
1 parent 59338f3 commit a094e35
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
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

0 comments on commit a094e35

Please sign in to comment.