-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 TrustX Bid Adapter #3563
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
031fa56
Add trustx adapter and tests for it
PWyrembak 319cadd
update integration example
PWyrembak 0e877f9
Merge remote-tracking branch 'upstream/master'
PWyrembak 0425234
Merge remote-tracking branch 'upstream/master'
PWyrembak 69ab1f4
Update trustx adapter
PWyrembak 817f2fa
Merge remote-tracking branch 'upstream/master'
PWyrembak ef50012
Post-review fixes of Trustx adapter
PWyrembak bd5b75c
Merge remote-tracking branch 'upstream/master'
PWyrembak bff944b
Merge remote-tracking branch 'upstream/master'
PWyrembak 843440d
Code improvement for trustx adapter: changed default price type from …
PWyrembak cd01e9b
Merge remote-tracking branch 'upstream/master'
PWyrembak aa249b5
Update TrustX adapter to support the 1.0 version
PWyrembak 119728b
Merge remote-tracking branch 'upstream/master'
PWyrembak 5f60ac3
Make requested changes for TrustX adapter
PWyrembak 2628673
Updated markdown file for TrustX adapter
PWyrembak b3badf9
Merge remote-tracking branch 'upstream/master'
PWyrembak 292b4dd
Fix TrustX adapter and spec file
PWyrembak b3e1465
Merge remote-tracking branch 'upstream/master'
PWyrembak 09b581a
Update TrustX adapter: r parameter was added to ad request as cache b…
PWyrembak 7b16a1c
Merge remote-tracking branch 'upstream/master'
PWyrembak 73b7249
Add support of gdpr to Trustx Bid Adapter
PWyrembak 08ca36e
Merge remote-tracking branch 'upstream/master'
PWyrembak 4974e55
Add wtimeout to ad request params for TrustX Bid Adapter
PWyrembak 240306f
Merge remote-tracking branch 'upstream/master'
PWyrembak 9175298
TrustX Bid Adapter: remove last ampersand in the ad request
PWyrembak d98be98
Merge remote-tracking branch 'upstream/master'
PWyrembak 83b3aaf
Update TrustX Bid Adapter to support identical uids in parameters
PWyrembak 3e348d2
Merge remote-tracking branch 'upstream/master'
PWyrembak fc2e05a
Merge remote-tracking branch 'upstream/master'
PWyrembak f77c2ee
Update TrustX Bid Adapter to ignore bids that sizes do not match the …
PWyrembak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,8 @@ export const spec = { | |
buildRequests: function(validBidRequests, bidderRequest) { | ||
const auids = []; | ||
const bidsMap = {}; | ||
const slotsMapByUid = {}; | ||
const sizeMap = {}; | ||
const bids = validBidRequests || []; | ||
let priceType = 'net'; | ||
let reqId; | ||
|
@@ -45,18 +47,41 @@ export const spec = { | |
priceType = 'gross'; | ||
} | ||
reqId = bid.bidderRequestId; | ||
if (!bidsMap[bid.params.uid]) { | ||
bidsMap[bid.params.uid] = [bid]; | ||
auids.push(bid.params.uid); | ||
const {params: {uid}, adUnitCode} = bid; | ||
auids.push(uid); | ||
const sizesId = utils.parseSizesInput(bid.sizes); | ||
|
||
if (!slotsMapByUid[uid]) { | ||
slotsMapByUid[uid] = {}; | ||
} | ||
const slotsMap = slotsMapByUid[uid]; | ||
if (!slotsMap[adUnitCode]) { | ||
slotsMap[adUnitCode] = {adUnitCode, bids: [bid], parents: []}; | ||
} else { | ||
bidsMap[bid.params.uid].push(bid); | ||
slotsMap[adUnitCode].bids.push(bid); | ||
} | ||
const slot = slotsMap[adUnitCode]; | ||
|
||
sizesId.forEach((sizeId) => { | ||
sizeMap[sizeId] = true; | ||
if (!bidsMap[uid]) { | ||
bidsMap[uid] = {}; | ||
} | ||
|
||
if (!bidsMap[uid][sizeId]) { | ||
bidsMap[uid][sizeId] = [slot]; | ||
} else { | ||
bidsMap[uid][sizeId].push(slot); | ||
} | ||
slot.parents.push({parent: bidsMap[uid], key: sizeId, uid}); | ||
}); | ||
}); | ||
|
||
const payload = { | ||
u: utils.getTopWindowUrl(), | ||
pt: priceType, | ||
auids: auids.join(','), | ||
sizes: utils.getKeys(sizeMap).join(','), | ||
r: reqId | ||
}; | ||
|
||
|
@@ -138,8 +163,12 @@ function _addBidResponse(serverBid, bidsMap, priceType, bidResponses) { | |
else { | ||
const awaitingBids = bidsMap[serverBid.auid]; | ||
if (awaitingBids) { | ||
awaitingBids.forEach(bid => { | ||
const bidResponse = { | ||
const sizeId = `${serverBid.w}x${serverBid.h}`; | ||
if (awaitingBids[sizeId]) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for this. |
||
const slot = awaitingBids[sizeId][0]; | ||
|
||
const bid = slot.bids.shift(); | ||
bidResponses.push({ | ||
requestId: bid.bidId, // bid.bidderRequestId, | ||
bidderCode: spec.code, | ||
cpm: serverBid.price, | ||
|
@@ -151,9 +180,23 @@ function _addBidResponse(serverBid, bidsMap, priceType, bidResponses) { | |
ttl: TIME_TO_LIVE, | ||
ad: serverBid.adm, | ||
dealId: serverBid.dealid | ||
}; | ||
bidResponses.push(bidResponse); | ||
}); | ||
}); | ||
|
||
if (!slot.bids.length) { | ||
slot.parents.forEach(({parent, key, uid}) => { | ||
const index = parent[key].indexOf(slot); | ||
if (index > -1) { | ||
parent[key].splice(index, 1); | ||
} | ||
if (!parent[key].length) { | ||
delete parent[key]; | ||
if (!utils.getKeys(parent).length) { | ||
delete bidsMap[uid]; | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
} else { | ||
errorMessage = LOG_ERROR_MESS.noPlacementCode + serverBid.auid; | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This creates a circular reference which is not ideal.
But I will not hold up the merge for it.