-
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
Adlive bid adapter #3109
Merged
Merged
Adlive bid adapter #3109
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
82be81c
send request to endpoint
4b68d66
tests
1b098fa
improve tests
071d0ba
Add description. Small fix
391440a
add maintainer email
c366801
restore origin package.json
1b0a2af
add getUserSyncs function
305d9d5
remove userSyncs
aa2a9b8
change endpoint_url params
0df7202
change test params
82c7d3b
change netRevenue to false
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import * as utils from 'src/utils'; | ||
import { registerBidder } from 'src/adapters/bidderFactory'; | ||
import { BANNER } from 'src/mediaTypes'; | ||
|
||
const BIDDER_CODE = 'adlive'; | ||
const ENDPOINT_URL = 'https://api.publishers.adlive.io/get'; | ||
const CURRENCY = 'USD'; | ||
const TIME_TO_LIVE = 360; | ||
|
||
export const spec = { | ||
code: BIDDER_CODE, | ||
supportedMediaTypes: [BANNER], | ||
|
||
isBidRequestValid: function(bid) { | ||
return !!(bid.params.hashes && utils.isArray(bid.params.hashes)); | ||
}, | ||
|
||
buildRequests: function(validBidRequests) { | ||
let requests = []; | ||
utils._each(validBidRequests, function(bid) { | ||
requests.push({ | ||
method: 'POST', | ||
url: ENDPOINT_URL, | ||
options: { | ||
contentType: 'application/json', | ||
withCredentials: true | ||
}, | ||
data: JSON.stringify({ | ||
transaction_id: bid.bidId, | ||
hashes: utils.getBidIdParameter('hashes', bid.params) | ||
}), | ||
bid | ||
}); | ||
}); | ||
|
||
return requests; | ||
}, | ||
|
||
interpretResponse: function(serverResponse, bidRequest) { | ||
try { | ||
const response = serverResponse.body; | ||
const bidResponses = []; | ||
|
||
utils._each(response, function(bidResponse) { | ||
if (!bidResponse.is_passback) { | ||
bidResponses.push({ | ||
requestId: bidRequest.bidId, | ||
cpm: bidResponse.price, | ||
width: bidResponse.size[0], | ||
height: bidResponse.size[1], | ||
creativeId: bidResponse.hash, | ||
currency: CURRENCY, | ||
netRevenue: true, | ||
ttl: TIME_TO_LIVE, | ||
ad: bidResponse.content | ||
}); | ||
} | ||
}); | ||
|
||
return bidResponses; | ||
} catch (err) { | ||
utils.logError(err); | ||
return []; | ||
} | ||
}, | ||
|
||
getUserSyncs: function (syncOptions, serverResponses, gdprConsent) { | ||
return []; | ||
} | ||
}; | ||
registerBidder(spec); |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Overview | ||
``` | ||
Module Name: Adlive Bid Adapter | ||
Module Type: Bidder Adapter | ||
Maintainer: traffic@adlive.io | ||
``` | ||
|
||
# Description | ||
Module that connects to Adlive's server for bids. | ||
Currently module supports only banner mediaType. | ||
|
||
# Test Parameters | ||
``` | ||
var adUnits = [{ | ||
code: '/test/div', | ||
mediaTypes: { | ||
banner: { | ||
sizes: [[300, 250]] | ||
} | ||
}, | ||
bids: [{ | ||
bidder: 'adlive', | ||
params: { | ||
hashes: ['1e100887dd614b0909bf6c49ba7f69fdd1360437'] | ||
} | ||
}] | ||
}]; | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { expect } from 'chai'; | ||
import { spec } from 'modules/adliveBidAdapter'; | ||
|
||
describe('adliveBidAdapterTests', function() { | ||
let bidRequestData = [ | ||
{ | ||
bidId: 'transaction_1234', | ||
bidder: 'adlive', | ||
params: { | ||
hashes: ['1e100887dd614b0909bf6c49ba7f69fdd1360437'] | ||
}, | ||
sizes: [[300, 250]] | ||
} | ||
]; | ||
let request = []; | ||
|
||
it('validate_pub_params', function() { | ||
expect( | ||
spec.isBidRequestValid({ | ||
bidder: 'adlive', | ||
params: { | ||
hashes: ['1e100887dd614b0909bf6c49ba7f69fdd1360437'] | ||
} | ||
}) | ||
).to.equal(true); | ||
}); | ||
|
||
it('validate_generated_params', function() { | ||
request = spec.buildRequests(bidRequestData); | ||
let req_data = request[0]; | ||
req_data.data = JSON.parse(req_data.data); | ||
|
||
expect(req_data.data.transaction_id).to.equal('transaction_1234'); | ||
}); | ||
|
||
it('validate_response_params', function() { | ||
let serverResponse = { | ||
body: [ | ||
{ | ||
hash: '1e100887dd614b0909bf6c49ba7f69fdd1360437', | ||
content: 'Ad html', | ||
price: 1.12, | ||
size: [300, 250], | ||
is_passback: 0 | ||
} | ||
] | ||
}; | ||
|
||
let bids = spec.interpretResponse(serverResponse, bidRequestData[0]); | ||
expect(bids).to.have.lengthOf(1); | ||
|
||
let bid = bids[0]; | ||
|
||
expect(bid.creativeId).to.equal('1e100887dd614b0909bf6c49ba7f69fdd1360437'); | ||
expect(bid.ad).to.equal('Ad html'); | ||
expect(bid.cpm).to.equal(1.12); | ||
expect(bid.width).to.equal(300); | ||
expect(bid.height).to.equal(250); | ||
expect(bid.currency).to.equal('USD'); | ||
}); | ||
|
||
it('validate_response_params_with passback', function() { | ||
let serverResponse = { | ||
body: [ | ||
{ | ||
hash: '1e100887dd614b0909bf6c49ba7f69fdd1360437', | ||
content: 'Ad html passback', | ||
size: [300, 250], | ||
is_passback: 1 | ||
} | ||
] | ||
}; | ||
let bids = spec.interpretResponse(serverResponse); | ||
|
||
expect(bids).to.have.lengthOf(0); | ||
}); | ||
}); |
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.
If you don't have any userSync pixels you want to fire, you can just remove the entire
getUserSyncs
property from your adapter. It's not required to define it.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.
If I do not define this function, tests do not pass.
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.
Can you clarify what tests do not pass? I disabled that part of your adapter code in the branch copy I checked out and ran
gulp test
. There were no unit test errors from what I saw.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.
@jsnellbaker
I mean circleci tests.
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.
@mifanich I ran the browserstack tests (which is what circleci runs for us automatically) locally with the
getUserSyncs
code disabled and I didn't see any test failures.It's possible there was some other issue that happened in the circleci tests you saw that failed that were unrelated to your adapter's code. Can you try to make the change again and push it in this PR so we can retest it?