pbs

package
v0.0.0-...-498b6f3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2021 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	USERSYNC_OPT_OUT     = "usersync.opt_outs"
	USERSYNC_BAD_REQUEST = "usersync.bad_requests"
	USERSYNC_SUCCESS     = "usersync.%s.sets"
)
View Source
const MAX_BIDDERS = 8
View Source
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

This section is empty.

Types

type AdUnit

type AdUnit struct {
	Code       string           `json:"code"`
	TopFrame   int8             `json:"is_top_frame"`
	Sizes      []openrtb.Format `json:"sizes"`
	Bids       []Bids           `json:"bids"`
	ConfigID   string           `json:"config_id"`
	MediaTypes []string         `json:"media_types"`
	Instl      int8             `json:"instl"`
	Video      PBSVideo         `json:"video"`
}

type BidderDebug

type BidderDebug struct {
	RequestURI   string `json:"request_uri,omitempty"`
	RequestBody  string `json:"request_body,omitempty"`
	ResponseBody string `json:"response_body,omitempty"`
	StatusCode   int    `json:"status_code,omitempty"`
}

type Bids

type Bids struct {
	BidderCode string          `json:"bidder"`
	BidID      string          `json:"bid_id"`
	Params     json.RawMessage `json:"params"`
}

func ConfigGet

func ConfigGet(cache cache.Cache, id string) ([]Bids, error)

type ConfigCache

type ConfigCache interface {
	LoadConfig(string) ([]Bids, error)
}

type MediaType

type MediaType byte
const (
	MEDIA_TYPE_BANNER MediaType = iota
	MEDIA_TYPE_VIDEO
)

func ParseMediaType

func ParseMediaType(s string) (MediaType, error)

func ParseMediaTypes

func ParseMediaTypes(types []string) []MediaType

type PBSAdUnit

type PBSAdUnit struct {
	Sizes      []openrtb.Format
	TopFrame   int8
	Code       string
	BidID      string
	Params     json.RawMessage
	Video      PBSVideo
	MediaTypes []MediaType
	Instl      int8
}

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"`
	// Complete cache url returned from the prebid-cache.
	// more flexible than a design that assumes the UUID is always appended to the end of the URL.
	CacheURL string `json:"cache_url,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 *usersync.UsersyncInfo `json:"usersync,omitempty"`
	Debug        []*BidderDebug         `json:"debug,omitempty"`

	AdUnits []PBSAdUnit `json:"-"`
}

func (*PBSBidder) LookupAdUnit

func (bidder *PBSBidder) LookupAdUnit(Code string) (unit *PBSAdUnit)

func (*PBSBidder) LookupBidID

func (bidder *PBSBidder) LookupBidID(Code string) string

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  *usersync.PBSCookie `json:"-"`
	Url     string              `json:"-"`
	Domain  string              `json:"-"`
	Regs    *openrtb.Regs       `json:"-"`
	Start   time.Time
}

func ParsePBSRequest

func ParsePBSRequest(r *http.Request, cfg *config.AuctionTimeouts, cache cache.Cache, hostCookieConfig *config.HostCookie) (*PBSRequest, error)

func (PBSRequest) Elapsed

func (req PBSRequest) Elapsed() int

func (*PBSRequest) ParseConsent

func (req *PBSRequest) ParseConsent() string

parses the "User.ext.consent" from the request, if it exists. Otherwise returns an empty string.

func (*PBSRequest) ParseGDPR

func (req *PBSRequest) ParseGDPR() string

parses the "Regs.ext.gdpr" from the request, if it exists. Otherwise returns an empty string.

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 SDK

type SDK struct {
	Version  string `json:"version"`
	Source   string `json:"source"`
	Platform string `json:"platform"`
}

type UserSyncDeps

type UserSyncDeps struct {
	ExternalUrl      string
	RecaptchaSecret  string
	HostCookieConfig *config.HostCookie
	MetricsEngine    metrics.MetricsEngine
	PBSAnalytics     analytics.PBSAnalyticsModule
}

func (*UserSyncDeps) OptOut

func (deps *UserSyncDeps) OptOut(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

func (*UserSyncDeps) VerifyRecaptcha

func (deps *UserSyncDeps) VerifyRecaptcha(response string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL