prebid / prebid-server

Open-source solution for running real-time advertising auctions in the cloud.
https://prebid.org/product-suite/prebid-server/
Apache License 2.0
434 stars 742 forks source link

Prebid Request Correction Module #3941

Open bretg opened 1 month ago

bretg commented 1 month ago

Turns out that client code, both PBJS and PBSDK, is sometimes buggy, and that even once fixed, it's hard to get pubs and/or users to adopt the fixes. So Prebid Server has a role in dealing with the messy real world. Rather than hardcoding such fixes into PBS-core, we propose putting them into a module.

The first two corrections supported by the module are from the Prebid Mobile world.

PBSDK: remove "PrebidMobile/*" from device.ua

As described in https://github.com/prebid/prebid-server/issues/3723, there are versions of the PBSDK that set device.ua to include "PrebidMobile/x.y.z". This can cause some bidders to view the request as invalid traffic.

If the "pbsdkUaCleanup" correction is enabled, the module would:

  1. if app.ext.prebid.source!=“prebid-mobile” exit
  2. if app.ext.prebid.version >= 2.1.6 exit
  3. scan device.ua for the pattern "PrebidMobile/[0-9][^\S]*" (PrebidMobile/, followed by a number, then any number of non-whitespace characters)
  4. If found, remove this pattern from device.ua

this means the module will have to split the major, minor, and patch versions and do all the comparisons. If the version is “2.2”, that should be considered “2.2.0”, which is less than “2.2.3.”

PBSDK: remove errant instl flag

The ‘pbsdkAndroidInstlRemove’, feature removes the instl:1 ORTB flag in the following scenario:

  1. If imp[0].instl is not specified or is 0, exit
  2. if app.ext.prebid.source is not “prebid-mobile”, exit
  3. if app.bundle does not contain the string “android”, exit
  4. if app.ext.prebid.version > 2.2.3, exit
  5. If we're still here, remove the imp[0].instl flag

this means the module will have to split the major, minor, and patch versions and do all the comparisons. If the version is “2.2”, that should be considered “2.2.0”, which is less than “2.2.3.”

Configuration

This is the proposed module configuration:

{
   "hooks": {
      "modules": {
         "pb-request-correction": {
            "enabled": true,
            "pbsdkUaCleanup": true,
            "pbsdkAndroidInstlRemove": true
         }
     }
}

Notes:

bretg commented 3 days ago

released with PBS-Java 3.15