-
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
Conceptx Bid Adapter : initial release #9835
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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,70 @@ | ||
import { registerBidder } from '../src/adapters/bidderFactory.js'; | ||
import { BANNER } from '../src/mediaTypes.js'; | ||
// import { logError, logInfo, logWarn, parseUrl } from '../src/utils.js'; | ||
|
||
const BIDDER_CODE = 'conceptx'; | ||
let ENDPOINT_URL = 'https://conceptx.cncpt-central.com/openrtb'; | ||
// const LOG_PREFIX = 'ConceptX: '; | ||
|
||
export const spec = { | ||
code: BIDDER_CODE, | ||
supportedMediaTypes: [BANNER], | ||
isBidRequestValid: function (bid) { | ||
return !!(bid.bidId); | ||
}, | ||
|
||
buildRequests: function (validBidRequests, bidderRequest) { | ||
// logWarn(LOG_PREFIX + 'all native assets containing URL should be sent as placeholders with sendId(icon, image, clickUrl, displayUrl, privacyLink, privacyIcon)'); | ||
const requests = []; | ||
|
||
if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) { | ||
ENDPOINT_URL += '?gdpr_applies=' + bidderRequest.gdprConsent.gdprApplies; | ||
ENDPOINT_URL += '&consentString=' + bidderRequest.gdprConsent.consentString; | ||
} | ||
for (var i = 0; i < validBidRequests.length; i++) { | ||
const requestParent = { adUnits: [], meta: {} }; | ||
const bid = validBidRequests[i] | ||
const { adUnitCode, auctionId, bidId, bidder, bidderRequestId, ortb2 } = bid | ||
requestParent.meta = { adUnitCode, auctionId, bidId, bidder, bidderRequestId, ortb2 } | ||
|
||
const { site, adunit } = bid.params | ||
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. Same syntax suggestion as above |
||
const adUnit = { site, adunit, targetId: bid.bidId } | ||
if (bid.mediaTypes && bid.mediaTypes.banner && bid.mediaTypes.banner.sizes) adUnit.dimensions = bid.mediaTypes.banner.sizes | ||
requestParent.adUnits.push(adUnit); | ||
requests.push({ | ||
method: 'POST', | ||
url: ENDPOINT_URL, | ||
options: { | ||
withCredentials: false, | ||
}, | ||
data: JSON.stringify(requestParent), | ||
}); | ||
} | ||
|
||
return requests; | ||
}, | ||
|
||
interpretResponse: function (serverResponse, bidRequest) { | ||
const bidResponsesFromServer = serverResponse.body.bidResponses; | ||
const firstDummy = bidResponsesFromServer[0] | ||
const firstSeat = firstDummy.ads[0] | ||
const bidResponses = []; | ||
const bidResponse = { | ||
requestId: firstSeat.requestId, | ||
cpm: firstSeat.cpm, | ||
width: firstSeat.width, | ||
height: firstSeat.height, | ||
creativeId: firstSeat.creativeId, | ||
dealId: firstSeat.dealId, | ||
currency: firstSeat.currency, | ||
netRevenue: true, | ||
ttl: firstSeat.ttl, | ||
referrer: firstSeat.referrer, | ||
ad: firstSeat.html | ||
}; | ||
bidResponses.push(bidResponse); | ||
return bidResponses; | ||
}, | ||
|
||
} | ||
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,36 @@ | ||
# Overview | ||
|
||
``` | ||
Module Name: ConceptX Bidder Adapter | ||
Module Type: Bidder Adapter | ||
Maintainer: info@concept.dk | ||
``` | ||
|
||
# Description | ||
|
||
ConceptX Bidder Adapter for Prebid.js. | ||
Only Banner format is supported. | ||
|
||
# Test Parameters | ||
``` | ||
var adUnits = [ | ||
{ | ||
code: "test-div", | ||
mediaTypes: { | ||
banner: { | ||
sizes: [[980, 180]] | ||
} | ||
}, | ||
bids: [ | ||
{ | ||
bidder: "conceptx", | ||
params: { | ||
site: "example", | ||
adunit: "some-id-3", | ||
} | ||
}, | ||
] | ||
}, | ||
|
||
]; | ||
``` |
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,136 @@ | ||
// import or require modules necessary for the test, e.g.: | ||
import { expect } from 'chai'; // may prefer 'assert' in place of 'expect' | ||
import { spec } from 'modules/conceptxBidAdapter.js'; | ||
import { newBidder } from 'src/adapters/bidderFactory.js'; | ||
// import { config } from 'src/config.js'; | ||
|
||
describe('conceptxBidAdapter', function () { | ||
const URL = 'https://conceptx.cncpt-central.com/openrtb'; | ||
|
||
// before(() => { | ||
|
||
// }); | ||
|
||
// after(() => { | ||
// // $$PREBID_GLOBAL$$.bidderSettings = {}; | ||
// }); | ||
|
||
// afterEach(function () { | ||
// config.resetConfig(); | ||
// }); | ||
|
||
const ENDPOINT_URL = `${URL}`; | ||
const ENDPOINT_URL_CONSENT = `${URL}?gdpr_applies=true&consentString=ihaveconsented`; | ||
const adapter = newBidder(spec); | ||
|
||
const bidderRequests = [ | ||
{ | ||
bidId: '123', | ||
bidder: 'conceptx', | ||
params: { | ||
site: 'example', | ||
adunit: 'some-id-3' | ||
}, | ||
mediaTypes: { | ||
banner: { | ||
sizes: [[930, 180]], | ||
} | ||
}, | ||
} | ||
] | ||
|
||
const singleBidRequest = { | ||
bid: [ | ||
{ | ||
bidId: '123', | ||
} | ||
] | ||
} | ||
|
||
const serverResponse = { | ||
body: { | ||
'bidResponses': [ | ||
{ | ||
'ads': [ | ||
{ | ||
'referrer': 'http://localhost/prebidpage_concept_bidder.html', | ||
'ttl': 360, | ||
'html': '<h1>DUMMY</h1>', | ||
'requestId': '214dfadd1f8826', | ||
'cpm': 46, | ||
'currency': 'DKK', | ||
'width': 930, | ||
'height': 180, | ||
'creativeId': 'FAKE-ID', | ||
'meta': { | ||
'mediaType': 'banner' | ||
}, | ||
'netRevenue': true, | ||
'destinationUrls': { | ||
'destination': 'https://concept.dk' | ||
} | ||
} | ||
], | ||
'matchedAdCount': 1, | ||
'targetId': '214dfadd1f8826' | ||
} | ||
] | ||
} | ||
} | ||
|
||
describe('inherited functions', function () { | ||
it('exists and is a function', function () { | ||
expect(adapter.callBids).to.exist.and.to.be.a('function'); | ||
}); | ||
}); | ||
|
||
describe('isBidRequestValid', function () { | ||
it('should return true when required params found', function () { | ||
expect(spec.isBidRequestValid(bidderRequests[0])).to.equal(true); | ||
}); | ||
}); | ||
|
||
describe('buildRequests', function () { | ||
it('Test requests', function () { | ||
const request = spec.buildRequests(bidderRequests, {}); | ||
expect(request.length).to.equal(1); | ||
expect(request[0]).to.have.property('data'); | ||
const bid = JSON.parse(request[0].data).adUnits[0] | ||
expect(bid.site).to.equal('example'); | ||
expect(bid.adunit).to.equal('some-id-3'); | ||
expect(JSON.stringify(bid.dimensions)).to.equal(JSON.stringify([ | ||
[930, 180]])); | ||
}); | ||
}); | ||
|
||
describe('user privacy', function () { | ||
it('should NOT send GDPR Consent data if gdprApplies equals undefined', function () { | ||
let request = spec.buildRequests(bidderRequests, { gdprConsent: { gdprApplies: undefined, consentString: 'iDoNotConsent' } }); | ||
expect(request.length).to.equal(1); | ||
expect(request[0]).to.have.property('url') | ||
expect(request[0].url).to.equal(ENDPOINT_URL); | ||
}); | ||
it('should send GDPR Consent data if gdprApplies', function () { | ||
let request = spec.buildRequests(bidderRequests, { gdprConsent: { gdprApplies: true, consentString: 'ihaveconsented' } }); | ||
expect(request.length).to.equal(1); | ||
expect(request[0]).to.have.property('url') | ||
expect(request[0].url).to.equal(ENDPOINT_URL_CONSENT); | ||
}); | ||
}); | ||
|
||
describe('interpretResponse', function () { | ||
it('should return valid response when passed valid server response', function () { | ||
const interpretedResponse = spec.interpretResponse(serverResponse, singleBidRequest); | ||
const ad = serverResponse.body.bidResponses[0].ads[0] | ||
expect(interpretedResponse).to.have.lengthOf(1); | ||
expect(interpretedResponse[0].cpm).to.equal(ad.cpm); | ||
expect(interpretedResponse[0].width).to.equal(Number(ad.width)); | ||
expect(interpretedResponse[0].height).to.equal(Number(ad.height)); | ||
expect(interpretedResponse[0].creativeId).to.equal(ad.creativeId); | ||
expect(interpretedResponse[0].currency).to.equal(ad.currency); | ||
expect(interpretedResponse[0].netRevenue).to.equal(true); | ||
expect(interpretedResponse[0].ad).to.equal(ad.html); | ||
expect(interpretedResponse[0].ttl).to.equal(360); | ||
}); | ||
}); | ||
}); |
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 is code style, not a request for changes, but instead what about
requestParent.meta = { adUnitCode, auctionId, bidId, bidder, bidderRequestId, ortb2 } = bid;
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.
@cpcpn-emil auctionid might be null in Prebid 8