Prebid.js icon indicating copy to clipboard operation
Prebid.js copied to clipboard

Getting the floor data from outside of any events

Open bharadhwaj opened this issue 2 years ago • 10 comments

Type of issue

Question

Description

Is there anyway I can get the floor values that is fetched from the endpoint outside the auction events?

I want something like,

Calling pbjs.getFloorData() should have the values which are returned from the custom end point.

(Also if we don't have it already, is there any planning or PR going on to address this?)

Thanks in advance!

bharadhwaj avatar Aug 29 '22 09:08 bharadhwaj

floor data is, currently, an opaque object for which we have not defined a public interface, and is in general not usable outside of an auction / bid request context. Could you provide some details on your use case - what are you looking to do with floor data?

dgirardi avatar Aug 29 '22 15:08 dgirardi

Hi,

Are you a publisher? What is your use case? Why is the information in the BID_REQUESTED event(s) insufficient to you?

Would making the getFloor function return something public solve your use case?

patmmccann avatar Aug 29 '22 15:08 patmmccann

@patmmccann This is Andrew from pubX - @bharadhwaj is a developer with us :)

andrewjmole avatar Aug 29 '22 19:08 andrewjmole

okay i follow, this is a continuation of #8766 ; I guess my recommendation of just adjusting floormin and not the entire floors config didn't work for you.

So basically, the problem is the pub's prebid is hitting your endpoint via the floors module and getting floors.json and you don't know how to refer to the values that are there? If you have js on page, why isnt that js gathering floors.json instead of prebid? Then you can set config with the json, as well as update it in memory based on in session observations, and then do another setconfig ?

patmmccann avatar Aug 29 '22 19:08 patmmccann

cc: @pnhegde

bharadhwaj avatar Aug 30 '22 06:08 bharadhwaj

@patmmccann That was the plan but we can't ensure the auction delay if it's done outside priceFloors. We can implement custom fetch and apply it using setConfig but the initial auction won't be delayed during the custom fetch. We can however apply the dynamic floor config for initial fetch and implement custom fetch for subsequent refreshed auctions. If there is a use case for providing a public interface for accessing floorsData, we're happy to develop a PR for it. If not needed, we will go ahead with the custom fetch method.

Thanks!

pnhegde avatar Aug 30 '22 06:08 pnhegde

True that if the auction needs to do other async operations (rtd / gpdr /etc) you would need to serialize those after retrieving floors. We could accept a promise for floors.data to help with that.

dgirardi avatar Aug 30 '22 16:08 dgirardi

So to restate what we think the request is here: modules or in-page event handlers would like to be able to dynamically mess with floors data, either on the first auction or subsequent auctions. Is that right?

I'm deeply uncomfortable opening up the rather complex floors data profile to modules or in-page code. That will tie our hands for future changes. This needs to be carefully considered -- is there a way we could do something like the adapter-level getFloors function here so that the floors change is limited to a specific scenario rather than the ridiculously complicated world that raw floors data can actually describe?

Yes, I get that PubX can probably handle this, but once code is in PBJS, it's stuck forever in publisher pages. So future enhancements of the raw floors format would become impossible.

bretg avatar Sep 26 '22 15:09 bretg

Would a custom "floor adjustment" function address the use case here? Something like

pbjs.setConfig({
  floors: {
    adjustment: function(bidRequest, floor, floorCur) { /* compute custom new floor and return it */ }
  }
})

to be invoked by the floor module after computing the "normal" floor, in the style of bidCpmAdjustment.

dgirardi avatar Sep 26 '22 16:09 dgirardi

The idea as I understand it is that floors config (in javascript only) supports a function pointer. The floors module will call that function just before it returns the floor value to whomever asked for it

In other words, the bid.getFloor() function would be modified to call the adjustment function just before returning the value. One possible issue is that callers to getFloor() don't currently pass bidRequest. Would we have to modify everyone's getFloor call or is there a way for getFloor to derive that object from context?

Would such a function suffice for your use case @pnhegde and @bharadhwaj ?

bretg avatar Sep 27 '22 19:09 bretg

@bretg We don't have this requirement anymore. We wrote a custom JS to get the floor values outside prebid on the client side itself. So, currently, we don't have this requirement anymore. But in general, it would be better to have a function to get the original endpoint returned floors as they are without any adjustments or currency conversion.

pnhegde avatar Oct 27 '22 10:10 pnhegde

Closing as requirement no longer needed.

ChrisHuie avatar Nov 07 '22 16:11 ChrisHuie