Documentation ¶
Index ¶
- Constants
- func GetPriceBucketString(cpm float64) map[string]string
- func RoundUp(input float64, places int) (newVal float64)
- type AdUnit
- type BidderDebug
- type Bids
- type ConfigCache
- type HostCookieSettings
- type MediaType
- type PBSAdUnit
- type PBSBid
- type PBSBidSlice
- type PBSBidder
- type PBSCookie
- func (cookie *PBSCookie) AllowSyncs() bool
- func (cookie *PBSCookie) GetUID(familyName string) (string, bool, bool)
- func (cookie *PBSCookie) HasLiveSync(familyName string) bool
- func (cookie *PBSCookie) LiveSyncCount() int
- func (cookie *PBSCookie) MarshalJSON() ([]byte, error)
- func (cookie *PBSCookie) SetCookieOnResponse(w http.ResponseWriter, domain string)
- func (cookie *PBSCookie) SetPreference(allow bool)
- func (cookie *PBSCookie) ToHTTPCookie() *http.Cookie
- func (cookie *PBSCookie) TrySync(familyName string, uid string) error
- func (cookie *PBSCookie) UnmarshalJSON(b []byte) error
- func (cookie *PBSCookie) Unsync(familyName string)
- type PBSRequest
- type PBSResponse
- type PBSVideo
- type SDK
- type UserSyncDeps
- func (deps *UserSyncDeps) GetUIDs(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (deps *UserSyncDeps) OptOut(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (deps *UserSyncDeps) SetUID(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func (deps *UserSyncDeps) VerifyRecaptcha(response string) error
- type UsersyncInfo
Constants ¶
const COOKIE_NAME = "uids"
const DEFAULT_PRECISION = 2
const DEFAULT_TTL = 14 * 24 * time.Hour
DEFAULT_TTL is the default amount of time which a cookie is considered valid.
const MAX_BIDDERS = 8
const RECAPTCHA_URL = "https://www.google.com/recaptcha/api/siteverify"
Recaptcha code from https://github.com/haisum/recaptcha/blob/master/recaptcha.go
Variables ¶
This section is empty.
Functions ¶
func GetPriceBucketString ¶
Types ¶
type BidderDebug ¶
type Bids ¶
type Bids struct { BidderCode string `json:"bidder"` BidID string `json:"bid_id"` Params json.RawMessage `json:"params"` }
type ConfigCache ¶
type HostCookieSettings ¶
type PBSBid ¶
type PBSBid struct { // BidID identifies the Bid Request within the Ad Unit which this Bid targets. It should match one of // the values inside PBSRequest.AdUnits[i].Bids[j].BidID. BidID string `json:"bid_id"` // AdUnitCode identifies the AdUnit which this Bid targets. // It should match one of PBSRequest.AdUnits[i].Code, where "i" matches the AdUnit used in // as BidID. AdUnitCode string `json:"code"` // Creative_id uniquely identifies the creative being served. It is not used by prebid-server, but // it helps publishers and bidders identify and communicate about malicious or inappropriate ads. // This project simply passes it along with the bid. Creative_id string `json:"creative_id,omitempty"` // CreativeMediaType shows whether the creative is a video or banner. CreativeMediaType string `json:"media_type,omitempty"` // BidderCode is the PBSBidder.BidderCode of the PBSBidder who made this bid. BidderCode string `json:"bidder"` // BidHash is the hash of the bidder's unique bid identifier for blockchain. It should not be sent to browser. BidHash string `json:"-"` // Price is the cpm, in US Dollars, which the bidder is willing to pay if this bid is chosen. // TODO: Add support for other currencies someday. Price float64 `json:"price"` // NURL is a URL which returns ad markup, and should be called if the bid wins. // If NURL and Adm are both defined, then Adm takes precedence. NURL string `json:"nurl,omitempty"` // Adm is the ad markup which should be used to deliver the ad, if this bid is chosen. // If NURL and Adm are both defined, then Adm takes precedence. Adm string `json:"adm,omitempty"` // Width is the intended width which Adm should be shown, in pixels. Width uint64 `json:"width,omitempty"` // Height is the intended width which Adm should be shown, in pixels. Height uint64 `json:"height,omitempty"` // DealId is not used by prebid-server, but may be used by buyers and sellers who make special // deals with each other. We simply pass this information along with the bid. DealId string `json:"deal_id,omitempty"` // CacheId is an ID in prebid-cache which can be used to fetch this ad's content. // This supports prebid-mobile, which requires that the content be available from a URL. CacheID string `json:"cache_id,omitempty"` // ResponseTime is the number of milliseconds it took for the adapter to return a bid. ResponseTime int `json:"response_time_ms,omitempty"` AdServerTargeting map[string]string `json:"ad_server_targeting,omitempty"` }
PBSBid is a bid from the auction. These are produced by Adapters, and target a particular Ad Unit.
This JSON format is a contract with both Prebid.js and Prebid-mobile. All changes *must* be backwards compatible, since clients cannot be forced to update their code.
type PBSBidSlice ¶
type PBSBidSlice []*PBSBid
PBSBidSlice attaches the methods of sort.Interface to []PBSBid, ordering them by price. If two prices are equal, then the response time will be used as a tiebreaker. For more information, see https://golang.org/pkg/sort/#Interface
func (PBSBidSlice) Len ¶
func (bids PBSBidSlice) Len() int
func (PBSBidSlice) Less ¶
func (bids PBSBidSlice) Less(i, j int) bool
func (PBSBidSlice) Swap ¶
func (bids PBSBidSlice) Swap(i, j int)
type PBSBidder ¶
type PBSBidder struct { BidderCode string `json:"bidder"` AdUnitCode string `json:"ad_unit,omitempty"` // for index to dedup responses ResponseTime int `json:"response_time_ms,omitempty"` NumBids int `json:"num_bids,omitempty"` Error string `json:"error,omitempty"` NoCookie bool `json:"no_cookie,omitempty"` NoBid bool `json:"no_bid,omitempty"` UsersyncInfo *UsersyncInfo `json:"usersync,omitempty"` Debug []*BidderDebug `json:"debug,omitempty"` AdUnits []PBSAdUnit `json:"-"` }
func (*PBSBidder) LookupAdUnit ¶
func (*PBSBidder) LookupBidID ¶
type PBSCookie ¶
type PBSCookie struct {
// contains filtered or unexported fields
}
PBSCookie is the cookie used in Prebid Server.
To get an instance of this from a request, use ParsePBSCookieFromRequest. To write an instance onto a response, use SetCookieOnResponse.
func ParsePBSCookie ¶
ParsePBSCookie parses the UserSync cookie from a raw HTTP cookie.
func ParsePBSCookieFromRequest ¶
ParsePBSCookieFromRequest parses the UserSyncMap from an HTTP Request.
func (*PBSCookie) AllowSyncs ¶
AllowSyncs is true if the user lets bidders sync cookies, and false otherwise.
func (*PBSCookie) GetUID ¶
GetUID Gets this user's ID for the given family. The first returned value is the user's ID. The second returned value is true if we had a value stored, and false if we didn't. The third returned value is true if that value is "active", and false if it's expired.
If no value was stored, then the "isActive" return value will be false.
func (*PBSCookie) HasLiveSync ¶
HasLiveSync returns true if we have an active UID for the given family, and false otherwise.
func (*PBSCookie) LiveSyncCount ¶
LiveSyncCount returns the number of families which have active UIDs for this user.
func (*PBSCookie) MarshalJSON ¶
func (*PBSCookie) SetCookieOnResponse ¶
func (cookie *PBSCookie) SetCookieOnResponse(w http.ResponseWriter, domain string)
SetCookieOnResponse is a shortcut for "ToHTTPCookie(); cookie.setDomain(domain); setCookie(w, cookie)"
func (*PBSCookie) SetPreference ¶
SetPreference is used to change whether or not we're allowed to sync cookies for this user.
func (*PBSCookie) ToHTTPCookie ¶
Gets an HTTP cookie containing all the data from this UserSyncMap. This is a snapshot--not a live view.
func (*PBSCookie) TrySync ¶
TrySync tries to set the UID for some family name. It returns an error if the set didn't happen.
func (*PBSCookie) UnmarshalJSON ¶
UnmarshalJSON holds some transition code.
"Legacy" cookies had UIDs *without* expiration dates, and recognized "0" as a legitimate UID for audienceNetwork. "Current" cookies always include UIDs with expiration dates, and never allow "0" for audienceNetwork.
This Unmarshal method interprets both data formats, and does some conversions on legacy data to make it current. If you're seeing this message after March 2018, it's safe to assume that all the legacy cookies have been updated and remove the legacy logic.
type PBSRequest ¶
type PBSRequest struct { AccountID string `json:"account_id"` Tid string `json:"tid"` CacheMarkup int8 `json:"cache_markup"` SortBids int8 `json:"sort_bids"` MaxKeyLength int8 `json:"max_key_length"` Secure int8 `json:"secure"` TimeoutMillis int64 `json:"timeout_millis"` AdUnits []AdUnit `json:"ad_units"` IsDebug bool `json:"is_debug"` App *openrtb.App `json:"app"` Device *openrtb.Device `json:"device"` PBSUser json.RawMessage `json:"user"` SDK *SDK `json:"sdk"` // internal Bidders []*PBSBidder `json:"-"` User *openrtb.User `json:"-"` Cookie *PBSCookie `json:"-"` Url string `json:"-"` Domain string `json:"-"` Start time.Time }
func ParsePBSRequest ¶
func ParsePBSRequest(r *http.Request, cache cache.Cache, hostCookieSettings *HostCookieSettings) (*PBSRequest, error)
func (PBSRequest) Elapsed ¶
func (req PBSRequest) Elapsed() int
func (PBSRequest) String ¶
func (p PBSRequest) String() string
type PBSResponse ¶
type PBSResponse struct { TID string `json:"tid,omitempty"` Status string `json:"status,omitempty"` BidderStatus []*PBSBidder `json:"bidder_status,omitempty"` Bids PBSBidSlice `json:"bids,omitempty"` BUrl string `json:"burl,omitempty"` }
type PBSVideo ¶
type PBSVideo struct { //Content MIME types supported. Popular MIME types may include “video/x-ms-wmv” for Windows Media and “video/x-flv” for Flash Video. Mimes []string `json:"mimes,omitempty"` //Minimum video ad duration in seconds. Minduration int64 `json:"minduration,omitempty"` // Maximum video ad duration in seconds. Maxduration int64 `json:"maxduration,omitempty"` //Indicates the start delay in seconds for pre-roll, mid-roll, or post-roll ad placements. Startdelay int64 `json:"startdelay,omitempty"` // Indicates if the player will allow the video to be skipped ( 0 = no, 1 = yes). Skippable int `json:"skippable,omitempty"` // Playback method code Description // 1 - Initiates on Page Load with Sound On // 2 - Initiates on Page Load with Sound Off by Default // 3 - Initiates on Click with Sound On // 4 - Initiates on Mouse-Over with Sound On // 5 - Initiates on Entering Viewport with Sound On // 6 - Initiates on Entering Viewport with Sound Off by Default PlaybackMethod int8 `json:"playback_method,omitempty"` //protocols as specified in ORTB 5.8 // 1 VAST 1.0 // 2 VAST 2.0 // 3 VAST 3.0 // 4 VAST 1.0 Wrapper // 5 VAST 2.0 Wrapper // 6 VAST 3.0 Wrapper // 7 VAST 4.0 // 8 VAST 4.0 Wrapper // 9 DAAST 1.0 // 10 DAAST 1.0 Wrapper Protocols []int8 `json:"protocols,omitempty"` }
Structure for holding video-specific information
type UserSyncDeps ¶
type UserSyncDeps struct { ExternalUrl string RecaptchaSecret string OptOutUrl string OptInUrl string HostCookieSettings *HostCookieSettings Metrics *pbsmetrics.Metrics }
func (*UserSyncDeps) GetUIDs ¶
func (deps *UserSyncDeps) GetUIDs(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*UserSyncDeps) OptOut ¶
func (deps *UserSyncDeps) OptOut(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*UserSyncDeps) SetUID ¶
func (deps *UserSyncDeps) SetUID(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
func (*UserSyncDeps) VerifyRecaptcha ¶
func (deps *UserSyncDeps) VerifyRecaptcha(response string) error