Skip to content

Commit

Permalink
Craft Bid Adapter : update for imuIdSystem (#9757)
Browse files Browse the repository at this point in the history
* update craftBidAdapter for imuIdSystem

* update craftBidAdapter for develop
  • Loading branch information
crumbjp authored Apr 4, 2023
1 parent c0eadc0 commit 8c8a2d7
Showing 1 changed file with 29 additions and 24 deletions.
53 changes: 29 additions & 24 deletions modules/craftBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ export const spec = {
buildRequests: function(bidRequests, bidderRequest) {
// convert Native ORTB definition to old-style prebid native definition
bidRequests = convertOrtbRequestToProprietaryNative(bidRequests);

const bidRequest = bidRequests[0];
const tags = bidRequests.map(bidToTag);
const schain = bidRequests[0].schain;
const schain = bidRequest.schain;
const payload = {
tags: [...tags],
ua: navigator.userAgent,
Expand All @@ -44,26 +44,31 @@ export const spec = {
},
schain: schain
};
if (bidderRequest && bidderRequest.gdprConsent) {
payload.gdpr_consent = {
consent_string: bidderRequest.gdprConsent.consentString,
consent_required: bidderRequest.gdprConsent.gdprApplies
};
}
if (bidderRequest && bidderRequest.uspConsent) {
payload.us_privacy = bidderRequest.uspConsent;
}
if (bidderRequest && bidderRequest.refererInfo) {
let refererinfo = {
// TODO: this collects everything it finds, except for the canonical URL
rd_ref: bidderRequest.refererInfo.topmostLocation,
rd_top: bidderRequest.refererInfo.reachedTop,
rd_ifs: bidderRequest.refererInfo.numIframes,
};
if (bidderRequest.refererInfo.stack) {
refererinfo.rd_stk = bidderRequest.refererInfo.stack.join(',');
if (bidderRequest) {
if (bidderRequest.gdprConsent) {
payload.gdpr_consent = {
consent_string: bidderRequest.gdprConsent.consentString,
consent_required: bidderRequest.gdprConsent.gdprApplies
};
}
if (bidderRequest.uspConsent) {
payload.us_privacy = bidderRequest.uspConsent;
}
if (bidderRequest.refererInfo) {
let refererinfo = {
// TODO: this collects everything it finds, except for the canonical URL
rd_ref: bidderRequest.refererInfo.topmostLocation,
rd_top: bidderRequest.refererInfo.reachedTop,
rd_ifs: bidderRequest.refererInfo.numIframes,
};
if (bidderRequest.refererInfo.stack) {
refererinfo.rd_stk = bidderRequest.refererInfo.stack.join(',');
}
payload.referrer_detection = refererinfo;
}
if (bidRequest.userId) {
payload.userId = bidRequest.userId
}
payload.referrer_detection = refererinfo;
}
const request = formatRequest(payload, bidderRequest);
return request;
Expand Down Expand Up @@ -106,7 +111,7 @@ export const spec = {
params = convertTypes({
'sitekey': 'string',
'placementId': 'string',
'keywords': transformBidderParamKeywords
'keywords': transformBidderParamKeywords,
}, params);
if (isOpenRtb) {
if (isPopulatedArray(params.keywords)) {
Expand Down Expand Up @@ -148,11 +153,11 @@ function formatRequest(payload, bidderRequest) {
withCredentials: false
};
}

const baseUrl = payload.tags[0].url || URL_BASE;
const payloadString = JSON.stringify(payload);
return {
method: 'POST',
url: `${URL_BASE}/${payload.tags[0].sitekey}`,
url: `${baseUrl}/${payload.tags[0].sitekey}`,
data: payloadString,
bidderRequest,
options
Expand Down

0 comments on commit 8c8a2d7

Please sign in to comment.