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 : changes in adqueryIdSystem, fix auctionId leak #10128

Merged
merged 31 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
d7b9e7c
added referrer to bid request
adquery May 15, 2023
9c94a25
Merge branch 'orgin/master'
adquery May 16, 2023
2165b5e
added referrer to bid request - tests
adquery May 22, 2023
9fbea74
Merge branch 'orgin/master'
adquery May 26, 2023
1d70d9c
adquery/prebid_qid_work1
adquery May 26, 2023
bafd222
adquery/prebid_qid_work1
adquery Jun 7, 2023
a7b2bf7
adquery/prebid_qid_work1
adquery Jun 12, 2023
6953a10
Merge branch 'orgin/master' into adquery/prebid_qid_work1
adquery Jun 21, 2023
8275876
adquery/prebid_qid_work1
adquery Jun 21, 2023
1834f4a
adquery/prebid_qid_work1
adquery Jun 21, 2023
5718b6d
adquery/prebid_qid_work1
adquery Jun 22, 2023
39f3f6a
adquery/prebid_qid_work1
adquery Jun 22, 2023
fea9b79
adquery/prebid_qid_work1
adquery Jun 26, 2023
7e02932
adquery/prebid_qid_work1
adquery Jun 26, 2023
1c03b22
adquery/prebid_qid_work1
adquery Jun 26, 2023
597d624
adquery/prebid_qid_work1
adquery Jun 26, 2023
6d29198
adquery/prebid_qid_work1
adquery Jun 26, 2023
7250954
adquery/prebid_qid_work1
adquery Jun 26, 2023
69212d0
adquery/prebid_qid_work1
adquery Jun 26, 2023
10ada84
adquery/prebid_qid_work1
adquery Jun 26, 2023
f193d78
adquery/prebid_qid_work1
adquery Jun 26, 2023
37e370b
adquery/prebid_qid_work1
adquery Jun 26, 2023
4ce0552
adquery/prebid_qid_work1
adquery Jun 26, 2023
ea7ad02
adquery/prebid_qid_work1
adquery Jul 20, 2023
c7f04d7
adquery/prebid_qid_work1
adquery Jul 20, 2023
37a8291
adquery/prebid_qid_work1
adquery Jul 20, 2023
dc0007e
Merge branch 'orgin/master' into adquery/prebid_qid_work1
adquery Jul 20, 2023
5cc0f08
adquery/prebid_qid_work1
adquery Jul 20, 2023
a0da0e4
adquery/prebid_qid_work1
adquery Jul 20, 2023
62881c1
Merge branch 'orgin/master' into adquery/prebid_qid_work1
adquery Aug 2, 2023
9756b21
adquery/prebid_qid_work1
adquery Aug 2, 2023
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
42 changes: 21 additions & 21 deletions modules/adqueryBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER} from '../src/mediaTypes.js';
import { logInfo, buildUrl, triggerPixel, parseSizesInput } from '../src/utils.js';
import { getStorageManager } from '../src/storageManager.js';
import {buildUrl, logInfo, parseSizesInput, triggerPixel, getUniqueIdentifierStr} from '../src/utils.js';

const ADQUERY_GVLID = 902;
const ADQUERY_BIDDER_CODE = 'adquery';
Expand All @@ -11,7 +10,6 @@ const ADQUERY_USER_SYNC_DOMAIN = ADQUERY_BIDDER_DOMAIN_PROTOCOL + '://' + ADQUER
const ADQUERY_DEFAULT_CURRENCY = 'PLN';
const ADQUERY_NET_REVENUE = true;
const ADQUERY_TTL = 360;
const storage = getStorageManager({bidderCode: ADQUERY_BIDDER_CODE});

/** @type {BidderSpec} */
export const spec = {
Expand Down Expand Up @@ -55,10 +53,6 @@ export const spec = {
* @return {Bid[]}
*/
interpretResponse: (response, request) => {
logInfo(request);
logInfo(response);

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

Expand Down Expand Up @@ -87,17 +81,6 @@ export const spec = {
bidResponses.push(bidResponse);
logInfo('bidResponses', bidResponses);

if (res && res.qid) {
if (storage.getDataFromLocalStorage('qid')) {
qid = storage.getDataFromLocalStorage('qid');
if (qid && qid.includes('%7B%22')) {
storage.setDataInLocalStorage('qid', res.qid);
}
} else {
storage.setDataInLocalStorage('qid', res.qid);
}
}

return bidResponses;
},

Expand Down Expand Up @@ -189,8 +172,26 @@ export const spec = {
}

};

function buildRequest(validBidRequests, bidderRequest) {
let bid = validBidRequests;
logInfo('buildRequest: ', bid);

let userId = null;
if (window.qid) {
userId = window.qid;
}

if (bid.userId && bid.userId.qid) {
userId = bid.userId.qid
}

if (!userId) {
// onetime User ID
userId = (getUniqueIdentifierStr() + getUniqueIdentifierStr()).substring(0, 22);
Fixed Show fixed Hide fixed
window.qid = userId;
}

let pageUrl = '';
if (bidderRequest && bidderRequest.refererInfo) {
pageUrl = bidderRequest.refererInfo.page || '';
Expand All @@ -199,11 +200,10 @@ function buildRequest(validBidRequests, bidderRequest) {
return {
v: '$prebid.version$',
placementCode: bid.params.placementId,
// TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781
auctionId: bid.auctionId,
auctionId: null,
type: bid.params.type,
adUnitCode: bid.adUnitCode,
bidQid: storage.getDataFromLocalStorage('qid') || null,
bidQid: userId,
bidId: bid.bidId,
bidder: bid.bidder,
bidPageUrl: pageUrl,
Expand Down
67 changes: 37 additions & 30 deletions modules/adqueryIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import {ajax} from '../src/ajax.js';
import {getStorageManager} from '../src/storageManager.js';
import {submodule} from '../src/hook.js';
import { isFn, isStr, isPlainObject, logError } from '../src/utils.js';
import {isFn, isPlainObject, isStr, logError, logInfo, getUniqueIdentifierStr} from '../src/utils.js';
import {MODULE_TYPE_UID} from '../src/activities/modules.js';

const MODULE_NAME = 'qid';
Expand Down Expand Up @@ -51,11 +51,7 @@ export const adqueryIdSubmodule = {
* @returns {{qid:Object}}
*/
decode(value) {
let qid = storage.getDataFromLocalStorage('qid');
if (isStr(qid)) {
return {qid: qid};
}
return (value && typeof value['qid'] === 'string') ? { 'qid': value['qid'] } : undefined;
return {qid: value}
},
/**
* performs action to obtain id and return a value in the callback's response argument
Expand All @@ -64,38 +60,49 @@ export const adqueryIdSubmodule = {
* @returns {IdResponse|undefined}
*/
getId(config) {
logInfo('adqueryIdSubmodule getId');
if (!isPlainObject(config.params)) {
config.params = {};
}
const url = paramOrDefault(config.params.url,

const url = paramOrDefault(
config.params.url,
`https://bidder.adquery.io/prebid/qid`,
config.params.urlArg);
config.params.urlArg
);

const resp = function (callback) {
let qid = storage.getDataFromLocalStorage('qid');
if (isStr(qid)) {
const responseObj = {qid: qid};
callback(responseObj);
} else {
const callbacks = {
success: response => {
let responseObj;
if (response) {
try {
responseObj = JSON.parse(response);
} catch (error) {
logError(error);
}
let qid = window.qid;

if (!qid) {
qid = (getUniqueIdentifierStr() + getUniqueIdentifierStr()).substring(0, 22);
logInfo('adqueryIdSubmodule ID QID GENERTAED:', qid);
}
logInfo('adqueryIdSubmodule ID QID:', qid);

const callbacks = {
success: response => {
let responseObj;
if (response) {
try {
responseObj = JSON.parse(response);
} catch (error) {
logError(error);
}
callback(responseObj);
},
error: error => {
logError(`${MODULE_NAME}: ID fetch encountered an error`, error);
callback();
}
};
ajax(url, callbacks, undefined, {method: 'GET'});
}
if (responseObj.qid) {
let myQid = responseObj.qid;
storage.setDataInLocalStorage('qid', myQid);
return callback(myQid);
}
callback();
},
error: error => {
logError(`${MODULE_NAME}: ID fetch encountered an error`, error);
callback();
}
};
ajax(url + '?qid=' + qid, callbacks, undefined, {method: 'GET'});
};
return {callback: resp};
}
Expand Down