-
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 Criteo bid adapter to Prebid 1.x #2370
Conversation
modules/criteoBidAdapter.js
Outdated
'amp': 1, | ||
}; | ||
const PROFILE_ID = 207; | ||
const PUBLISHER_TAG_URL = '//static.criteo.net/js/ld/publishertag.prebid.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.
Can you put a comment here pointing to https://github.com/Prebid-org/prebid-js-external-js-criteo/blob/master/dist/prod.js as source?
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.
Done.
@Spark-NF |
request:
Response
|
try { | ||
const fastBid = localStorage.getItem('criteo_fast_bid'); | ||
if (fastBid !== null) { | ||
eval(fastBid); // eslint-disable-line no-eval |
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.
is there an alternative to using eval here? What's being done?
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.
Our adapter relies on an external script (publishertag.js). Once loaded for the first time we put it into the local storage and eval it during the next calls to not reload it from the network and have a better performances.
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.
very interesting. Going to discuss with the prebid team
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.
Thinking about this some more, I don't think this is safe since you are blindly reading in content from localStorage, which can be overwritten by any script on page. Please remove.
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.
As discussed by mail the is the only way we can store our library in the local storage and then reuse 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.
@ahubertcriteo
Do you have any stats that show this is faster than a modern browser caching of the parsed code? It doesn't really make sense to eval (parse) it twice.
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.
Yes, we made a lot of testing with our publishers, and results are very positive.
The time between the call to buildRequests
/callBids
and the call to the PublisherTag entry point (in this adapter new Criteo.PubTag.Adapters.Prebid
) was reduced by 80 to 95%, going from a few hundreds milliseconds (sometimes more than 1s depending on the publisher) to a few milliseconds (usually around 10ms).
The number of timeouts as detected by Prebid was also halved.
Even if the file was cached by the browser, the fact that we're simply adding a <script>
causes it to have a pretty low priority in the loading chain. Plus, it's asynchronous as opposed to the localStorage that is synchronous (and fast).
If you'd rather have the localStorage.setItem
more explicit, we can update the adapter to do so. However, we'd need an API to do a GET and return the file's contents (the ajax
one seems like it could do the job).
window.criteo_prebid_native_slots[id] = { callback, payload }; | ||
|
||
// The creative is in an iframe so we have to get the callback and payload | ||
// from the parent window (doesn't work with safeframes) |
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 you have a postMessage solution that would work in safeFrames?
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.
Maybe, we will study this possibility and push it in a second iteration if feasable.
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.
that's fine
modules/criteoBidAdapter.js
Outdated
|
||
// Reload the PublisherTag after the timeout to ensure FastBid is up-to-date and tracking done properly | ||
setTimeout(() => { | ||
loadScript(PUBLISHER_TAG_URL); |
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 are going to update this function signature to include module/bidder code so we can track who is loading external JS. Will reply shortly with the changes.
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
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.
@ahubertcriteo @Spark-NF
Please use loadExternalScript
method instead.
This will enforce a whitelist of which adapters are allowed to load external JS:
https://github.com/prebid/Prebid.js/blob/master/src/adloader.js#L9
modules/criteoBidAdapter.js
Outdated
import { parse } from 'src/url'; | ||
import * as utils from 'src/utils'; | ||
|
||
var events = require('src/events'); |
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.
prefer const.
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.
Will be remove if we remove the event listenening below.
modules/criteoBidAdapter.js
Outdated
|
||
registeredEvents = true; | ||
|
||
events.on(EVENTS.BID_WON, (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.
we currently have a policy that bidder adapters cannot consume internal prebid.js events. You'll need to remove these event listeners.
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 I ask what is the rational of this policy?
- On our side we wanted to track those events to help publishers with their integrations when they encounter a lot of timeouts
(some of them have inconsistencies in their timeouts configuration between the one passed in requestBids call and the one in the global setTimeout) - As documented here (http://prebid.org/dev-docs/publisher-api-reference.html#module_pbjs.onEvent), can we replace the call to "events.on" by onEvent ?
- If not what would be the right alternative way to collect those informations ?
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.
Reason is that we don't want vendors inspecting other vendor bids. I realize that you are not doing that but we want to make this preventable in the code.
The correct way is not fully implemented yet, but you could start with spec.onTimeout
function.
http://prebid.org/dev-docs/bidder-adaptor.html#registering-on-timeout
Other events can be added to the spec in a separate PR if desired. Thanks
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 will remove this and use the onTimeout instead for the timeout event.
However we wanted to catch those events to spot publishers with timeout issues (inconsistencies between the timeout given in requestBids and the global one triggering dfp). Have you solutions on your side which will allow the bidders to known which timeout will be triggered first ?
@Spark-NF @ahubertcriteo |
In some cases, the buildCdbRequest function might return a falsy value, in case of error in creating the request or if we know in advance that this request will return a no-bid. In this case, the buildRequests() method should not return a request, causing a no-bid.
@Spark-NF and @ahubertcriteo - any further progress on this PR? |
Would be nice to get this merged in... |
How did this get committed with |
How about the convention "No loading of external libraries: All code must be present in the adapter, not loaded at runtime."? |
@mkendall07 Are you going to enforce rules on this adapter or is Criteo going to get a free pass? |
Dear @benjaminclot , @piwanczak , Thank you for your interest in Criteo Direct Bidder. On the question above (usage of external library), Criteo follows the policies put in place by Prebid.org. Our adapter indeed makes use of our external library, so as to ensure that you can smoothly benefit from some of our latest updates. In doing so, we are following a review process from Prebid.org and comply with the the instructions and policy described by Prebid’s external JS repository mechanism (see link). Would you have any question, feel free to reach out your Criteo representative. On Fastbid/eval: the function is being used to ensure correct working of our adapter in Prebid 1.0 and doesn’t represent a risk per se. In parallel, we are working on alternative versions, which will soon be submitted to our Prebid repo. In the meantime, would you have any concern, please contact your Criteo representative so as to address it. Kind regards, |
@mkendall07 Could you please state the official approach by Prebid team?
As I strongly believe in "open" in opensource I feel it would be great for everyone to know the very same thing and be able to use the same tools. @mafaigna Thank you for your input. Unfortunately this does not answer my question. I'm glad to hear that you work on alternatives, though. |
* Convert Criteo adapter to bidderFactory * Add documentation for Prebid 1.0 Criteo adapter * Add support for zone-matching bids on Prebid 1.0 Criteo adapter * Add unit tests to the Prebid 1.0 Criteo adapter * Explicit the fact that Criteo bids are net revenue * Pass currency in Criteo 1.0 adapter * Update Criteo adapter to use PublisherTag if present * Implement fastbid in prebid 1.0 criteo adapter * Pass the bid requests to the Criteo interpret method * Add missing ttl and creativeId fields to Criteo bids * Add 'native' support to the Criteo adapter * Check that the Criteo adapter returned by PublisherTag is not empty * Update criteo prebid adapter to reload publisher tag once auction is finished * Fix 'assign to const' IE errors in Criteo native adapter * Disable the PublisherTag event queue * Fix Criteo adapter on older Prebid versions not using response.body * Fix TypeError if FastBid is outdated * Remove the success variable in tryGetCriteoFastBid * Fix events being overwritten with FastBid * Update PublisherTag loading comment * Use adUnitCode as impid * Add events handlers in Criteo adapter to fix timeouts not treated as such * Add handler for setTargeting event * Move the registeredEvents set higher up to reduce the chances of race conditions * Fix UTests following recent Criteo adapter changes * Add comment linking to the PublisherTag unminified source * Do not return a request in buildRequests on error In some cases, the buildCdbRequest function might return a falsy value, in case of error in creating the request or if we know in advance that this request will return a no-bid. In this case, the buildRequests() method should not return a request, causing a no-bid. * Use loadExternalScript instead of loadScript * Use spec.onTimeout instead of registering an event handler * GDPR support in Criteo adapter (#4) GDPR support in Criteo adapter * Remove BID_WON and SET_TARGETING events from Criteo adapter * Update adapter version * Add support for multi-size in Criteo adapter * Fix support for multi size in Criteo adapter * Update adapterVersion to 7
* Convert Criteo adapter to bidderFactory * Add documentation for Prebid 1.0 Criteo adapter * Add support for zone-matching bids on Prebid 1.0 Criteo adapter * Add unit tests to the Prebid 1.0 Criteo adapter * Explicit the fact that Criteo bids are net revenue * Pass currency in Criteo 1.0 adapter * Update Criteo adapter to use PublisherTag if present * Implement fastbid in prebid 1.0 criteo adapter * Pass the bid requests to the Criteo interpret method * Add missing ttl and creativeId fields to Criteo bids * Add 'native' support to the Criteo adapter * Check that the Criteo adapter returned by PublisherTag is not empty * Update criteo prebid adapter to reload publisher tag once auction is finished * Fix 'assign to const' IE errors in Criteo native adapter * Disable the PublisherTag event queue * Fix Criteo adapter on older Prebid versions not using response.body * Fix TypeError if FastBid is outdated * Remove the success variable in tryGetCriteoFastBid * Fix events being overwritten with FastBid * Update PublisherTag loading comment * Use adUnitCode as impid * Add events handlers in Criteo adapter to fix timeouts not treated as such * Add handler for setTargeting event * Move the registeredEvents set higher up to reduce the chances of race conditions * Fix UTests following recent Criteo adapter changes * Add comment linking to the PublisherTag unminified source * Do not return a request in buildRequests on error In some cases, the buildCdbRequest function might return a falsy value, in case of error in creating the request or if we know in advance that this request will return a no-bid. In this case, the buildRequests() method should not return a request, causing a no-bid. * Use loadExternalScript instead of loadScript * Use spec.onTimeout instead of registering an event handler * GDPR support in Criteo adapter (prebid#4) GDPR support in Criteo adapter * Remove BID_WON and SET_TARGETING events from Criteo adapter * Update adapter version * Add support for multi-size in Criteo adapter * Fix support for multi size in Criteo adapter * Update adapterVersion to 7
Type of change
Description of change
Other information