-
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
Add Sharethrough adapter #865
Conversation
Added Sharethrough Adapter
bidmanager.addBidResponse(bidObj.placementCode, bid); | ||
} | ||
|
||
str.bidWon = function() { |
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.
We currently do not allow bidders to listen to other bids. If a bidder wants to do this, they should add an analytics adapter. This is a publisher opt in only process. https://github.com/prebid/Prebid.js/blob/master/src/adapters/analytics/example2.js
|
||
const str = {}; | ||
str.STR_BTLR_HOST = document.location.protocol + "//btlr.sharethrough.com"; | ||
str.STR_TEST_HOST = document.location.protocol + "//btlr-prebid-test.sharethrough.com"; |
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.
Using a different endpoint for test is not ideal as real issues are discovered in prod. Is there a way to not use a test endpoint here?
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.
We have to use a test endpoint here to guarantee that a creative is always return from our exchange. If we used the real endpoint there's no way to guarantee that a DSP will always bid on the impression request.
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.
Usually other bidders setup a test creative /placement on the live exchange. Is this possible?
const bidRequest = bids[i]; | ||
str.placementCodeSet[bidRequest.placementCode] = bidRequest; | ||
const scriptUrl = _buildSharethroughCall(bidRequest); | ||
str.loadIFrame(scriptUrl); |
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.
Don't load JSONP inside an iframe. Use ajax.js
or adLoader.loadScript()
instead
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.
We need to put the url inside an iframe so we can drop tracking cookies on publisher's page. This method work for iOS Safari since they block 3rd party cookies.
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.
Ok
sfp_js.src = "//native.sharethrough.com/assets/sfp.js"; | ||
sfp_js.type = 'text/javascript'; | ||
sfp_js.charset = 'utf-8'; | ||
window.top.document.getElementsByTagName('body')[0].appendChild(sfp_js); |
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.
window.top
isn't safe to call directly, it should be in a try/catch. Additionally it should be avoided if possible to support SafeFrame in the future.
@@ -0,0 +1,269 @@ | |||
import { expect } from 'chai'; | |||
import Adapter from '../../../src/adapters/sharethrough'; | |||
import adloader from '../../../src/adloader'; |
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 doesn't seem to be used anywhere, is it needed?
|
||
function _receiveMessage(event) { | ||
if(event.origin === str.STR_BTLR_HOST || event.origin === str.STR_TEST_HOST) { | ||
$$PREBID_GLOBAL$$.strcallback(JSON.parse(event.data).response); |
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.
Please wrap JSON.parse
in a try/catch
block
try { | ||
const bid = bidfactory.createBid(1, bidObj); | ||
|
||
bid.bidderCode = 'sharethrough'; |
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.
'sharethrough'
is defined in STR_BIDDER_CODE
, could use that here to avoid duplicating the string
function _callBids(params) { | ||
const bids = params.bids; | ||
|
||
$$PREBID_GLOBAL$$.onEvent('bidWon', str.bidWon); |
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 line can be removed now that you added your analytics adapter.
function _receiveMessage(event) { | ||
if(event.origin === str.STR_BTLR_HOST || event.origin === str.STR_TEST_HOST) { | ||
try { | ||
$$PREBID_GLOBAL$$.strcallback(JSON.parse(event.data).response); |
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 doesn't need to a public function because it's scoped within the adapter itself. Only use a public function if you use JSONP.
import adapter from 'AnalyticsAdapter'; | ||
const utils = require('../../utils'); | ||
|
||
const url = 'https://httpbin.org/post'; |
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.
You probably don't want to be sending data to httpbin.org
@@ -17,7 +17,7 @@ | |||
"prebid" | |||
], | |||
"globalVarName": "pbjs", | |||
"analytics": [], | |||
"analytics": ["sharethrough_analytics"], |
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.
Analytics is explicitly turned on by the publisher so this array should be blank by default
I updated the test pkey parameter |
@matthewlane just need final review for bids back on this one. |
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.
Validated bids come back
* Rz/submit to prebid (#4) Added Sharethrough Adapter * fix warnings * added beacons * made compatible with chrome 37. other minor changes * win beacon fired in analytics adapter * specs for new analytics adapter * add try catch blocks. misc refactor * removed test page * remove debugger * refactor analytics adapter * removed test endpoint * analytics url parameter is empty * removed bidwon listener on adapter * removed analytics from package.json
* refactored the way hb_deal is handled in adserverTargeting * Add Sharethrough adapter (#865) * Rz/submit to prebid (#4) Added Sharethrough Adapter * fix warnings * added beacons * made compatible with chrome 37. other minor changes * win beacon fired in analytics adapter * specs for new analytics adapter * add try catch blocks. misc refactor * removed test page * remove debugger * refactor analytics adapter * removed test endpoint * analytics url parameter is empty * removed bidwon listener on adapter * removed analytics from package.json * refactor hb_deal targeting key as a standard key * rollback errant style fixes * more fixes
* Rz/submit to prebid (prebid#4) Added Sharethrough Adapter * fix warnings * added beacons * made compatible with chrome 37. other minor changes * win beacon fired in analytics adapter * specs for new analytics adapter * add try catch blocks. misc refactor * removed test page * remove debugger * refactor analytics adapter * removed test endpoint * analytics url parameter is empty * removed bidwon listener on adapter * removed analytics from package.json
* refactored the way hb_deal is handled in adserverTargeting * Add Sharethrough adapter (prebid#865) * Rz/submit to prebid (prebid#4) Added Sharethrough Adapter * fix warnings * added beacons * made compatible with chrome 37. other minor changes * win beacon fired in analytics adapter * specs for new analytics adapter * add try catch blocks. misc refactor * removed test page * remove debugger * refactor analytics adapter * removed test endpoint * analytics url parameter is empty * removed bidwon listener on adapter * removed analytics from package.json * refactor hb_deal targeting key as a standard key * rollback errant style fixes * more fixes
…ebid-official-0.18.0 to release/1.13.0 * commit 'e145489bc5dd6d292cf16e7fe80adfdf991562ac': (27 commits) Add changelog entry. Prebid 0.18.0 Release Add Criteo adapter (prebid#928) add an event that fires when requestBids is called (prebid#939) Xaxis adapter submitted by Daniel hoffmann (prebid#938) Add flash detection to TripleLift adapter (prebid#855) OpenX Adapter: Fixed bug regarding cross-domain iframe support (prebid#931) Emit event when setTargetingForGPTAsync is called (prebid#873) Maintenance/refactor hb deal (prebid#935) Reset hb_* keys only for registered aduniits (prebid#934) update code style - smartyads adapter Catch errors in bidsBackHandler. Also fix test cleanup in pbjs api spec. (prebid#905) Smartyads Adapter (prebid#895) Appnexus targeting function (prebid#920) There are 2 changes- (prebid#913) Adding support for all AST parameters (prebid#923) GumGum adapter - include the bid timeout as `tmax` (prebid#908) Add pixel size (prebid#892) enable postMessage listener for cross-domain iframe support (prebid#885) Add Sharethrough adapter (prebid#865) ...
…13.0 to master * commit '7d32ed18c8636d9241ef8b299b6abd885536db69': (27 commits) Add changelog entry. Prebid 0.18.0 Release Add Criteo adapter (prebid#928) add an event that fires when requestBids is called (prebid#939) Xaxis adapter submitted by Daniel hoffmann (prebid#938) Add flash detection to TripleLift adapter (prebid#855) OpenX Adapter: Fixed bug regarding cross-domain iframe support (prebid#931) Emit event when setTargetingForGPTAsync is called (prebid#873) Maintenance/refactor hb deal (prebid#935) Reset hb_* keys only for registered aduniits (prebid#934) update code style - smartyads adapter Catch errors in bidsBackHandler. Also fix test cleanup in pbjs api spec. (prebid#905) Smartyads Adapter (prebid#895) Appnexus targeting function (prebid#920) There are 2 changes- (prebid#913) Adding support for all AST parameters (prebid#923) GumGum adapter - include the bid timeout as `tmax` (prebid#908) Add pixel size (prebid#892) enable postMessage listener for cross-domain iframe support (prebid#885) Add Sharethrough adapter (prebid#865) ...
Type of change
Description of change
Other information
Added Sharethrough Adapter