-
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
33Across Adapter: Removed the usage of utils library #1917
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1dac29c
Removed the usage of utils library to get bidder requests during user…
curlyblueeagle 3d32bfd
Fixed extra space which cause lint to fail
curlyblueeagle 2dc4397
Implemented user sync per code review feedback in https://github.com/…
curlyblueeagle b8f2ab5
Minor feedback changes
curlyblueeagle 5d96533
Re-instated lint check for all files which was accidentally commited …
curlyblueeagle 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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
const { registerBidder } = require('../src/adapters/bidderFactory'); | ||
const utils = require('../src/utils'); | ||
const { userSync } = require('../src/userSync'); | ||
const { config } = require('../src/config'); | ||
|
||
const BIDDER_CODE = '33across'; | ||
const END_POINT = 'https://ssc.33across.com/api/v1/hb'; | ||
|
@@ -38,9 +39,7 @@ function _createServerRequest(bidRequest) { | |
} | ||
} | ||
|
||
// Allowing site to be a test configuration object or just the id (former required for testing, | ||
// latter when used by publishers) | ||
ttxRequest.site = params.site || { id: params.siteId }; | ||
ttxRequest.site = { id: params.siteId }; | ||
|
||
// Go ahead send the bidId in request to 33exchange so it's kept track of in the bid response and | ||
// therefore in ad targetting process | ||
|
@@ -51,28 +50,18 @@ function _createServerRequest(bidRequest) { | |
withCredentials: false | ||
}; | ||
|
||
if (bidRequest.params.customHeaders) { | ||
options.customHeaders = bidRequest.params.customHeaders; | ||
} | ||
// Allow the ability to configure the HB endpoint for testing purposes. | ||
const ttxSettings = config.getConfig('ttxSettings'); | ||
const url = (ttxSettings && ttxSettings.url) || END_POINT; | ||
|
||
return { | ||
'method': 'POST', | ||
'url': bidRequest.params.url || END_POINT, | ||
'url': url, | ||
'data': JSON.stringify(ttxRequest), | ||
'options': options | ||
} | ||
} | ||
|
||
// Sync object will always be of type iframe for ttx | ||
function _createSync(bid) { | ||
const syncUrl = bid.params.syncUrl || SYNC_ENDPOINT; | ||
|
||
return { | ||
type: 'iframe', | ||
url: `${syncUrl}&id=${bid.params.siteId || bid.params.site.id}` | ||
} | ||
} | ||
|
||
function _getFormatSize(sizeArr) { | ||
return { | ||
w: sizeArr[0], | ||
|
@@ -81,6 +70,18 @@ function _getFormatSize(sizeArr) { | |
} | ||
} | ||
|
||
// Register one sync per bid since each ad unit may potenitally be linked to a uniqe guid | ||
// Sync type will always be 'iframe' for 33Across | ||
function _registerUserSyncs(requestData) { | ||
const ttxRequest = JSON.parse(requestData); | ||
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. wrap JSON.parse in |
||
const ttxSettings = config.getConfig('ttxSettings'); | ||
|
||
let syncUrl = (ttxSettings && ttxSettings.syncUrl) || SYNC_ENDPOINT; | ||
|
||
syncUrl = `${syncUrl}&id=${ttxRequest.site.id}`; | ||
userSync.registerSync('iframe', BIDDER_CODE, syncUrl); | ||
} | ||
|
||
function isBidRequestValid(bid) { | ||
if (bid.bidder !== BIDDER_CODE || typeof bid.params === 'undefined') { | ||
return false; | ||
|
@@ -104,7 +105,12 @@ function buildRequests(bidRequests) { | |
} | ||
|
||
// NOTE: At this point, the response from 33exchange will only ever contain one bid i.e. the highest bid | ||
function interpretResponse(serverResponse) { | ||
function interpretResponse(serverResponse, bidRequest) { | ||
// Register user sync first | ||
if (bidRequest && bidRequest.data) { | ||
_registerUserSyncs(bidRequest.data); | ||
} | ||
|
||
const bidResponses = []; | ||
|
||
// If there are bids, look at the first bid of the first seatbid (see NOTE above for assumption about ttx) | ||
|
@@ -115,24 +121,11 @@ function interpretResponse(serverResponse) { | |
return bidResponses; | ||
} | ||
|
||
// Register one sync per bid since each ad unit may potenitally be linked to a uniqe guid | ||
function getUserSyncs(syncOptions) { | ||
let syncs = []; | ||
const ttxBidRequests = utils.getBidderRequestAllAdUnits(BIDDER_CODE).bids; | ||
|
||
if (syncOptions.iframeEnabled) { | ||
syncs = ttxBidRequests.map(_createSync); | ||
} | ||
|
||
return syncs; | ||
} | ||
|
||
const spec = { | ||
code: BIDDER_CODE, | ||
isBidRequestValid, | ||
buildRequests, | ||
interpretResponse, | ||
getUserSyncs | ||
interpretResponse | ||
} | ||
|
||
registerBidder(spec); | ||
|
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.
Do import over here.
import { userSync } from 'src/userSync';
This will make sure it imports same object https://github.com/prebid/Prebid.js/blob/master/src/userSync.js#L189