Documentation
¶
Index ¶
- type AdFormats
- type BidRequest
- func (r *BidRequest) AccessPoint() adtype.AccessPoint
- func (r *BidRequest) Age() uint
- func (r *BidRequest) AppID() uint64
- func (r *BidRequest) AppInfo() *udetect.App
- func (r *BidRequest) AuctionID() string
- func (r *BidRequest) AuctionType() types.AuctionType
- func (r *BidRequest) BrowserInfo() *udetect.Browser
- func (r *BidRequest) CarrierInfo() *udetect.Carrier
- func (r *BidRequest) Categories() []uint64
- func (r *BidRequest) Clone() *BidRequest
- func (r *BidRequest) Context() context.Context
- func (r *BidRequest) CurrentGeoTime() time.Time
- func (r *BidRequest) DeviceInfo() *udetect.Device
- func (r *BidRequest) Domain() []string
- func (r *BidRequest) DomainName() string
- func (r *BidRequest) Done() <-chan struct{}
- func (r *BidRequest) ExtTargetIDs() []string
- func (r *BidRequest) ExternalAuctionID() string
- func (r *BidRequest) ExternalID() string
- func (r *BidRequest) Formats() types.BidFormater
- func (r *BidRequest) GeoID() uint64
- func (r *BidRequest) GeoInfo() *udetect.Geo
- func (r *BidRequest) Get(key string) any
- func (r *BidRequest) HTTPRequest() *fasthttp.RequestCtx
- func (r *BidRequest) ID() string
- func (r *BidRequest) ImpressionByID(id string) *adtype.Impression
- func (r *BidRequest) ImpressionUpdate(fn func(imp *adtype.Impression) bool)
- func (r *BidRequest) Impressions() []*adtype.Impression
- func (r *BidRequest) IsAdBlock() bool
- func (r *BidRequest) IsDebug() bool
- func (r *BidRequest) IsIPv6() bool
- func (r *BidRequest) IsPrivateBrowsing() bool
- func (r *BidRequest) IsProxy() bool
- func (r *BidRequest) IsRobot() bool
- func (r *BidRequest) IsSecure() bool
- func (r *BidRequest) Keywords() []string
- func (r *BidRequest) LanguageID() uint64
- func (r *BidRequest) MinECPM() (minBid billing.Money)
- func (r *BidRequest) OSInfo() *udetect.OS
- func (r *BidRequest) PrepareWithFormats(formats types.FormatsAccessor) adtype.BidRequester
- func (r *BidRequest) ProjectID() uint64
- func (r *BidRequest) Release()
- func (r *BidRequest) ServiceDomain() string
- func (r *BidRequest) Set(key string, val any)
- func (r *BidRequest) SetContext(ctx context.Context)
- func (r *BidRequest) SetSourceFilter(ids ...uint64)
- func (r *BidRequest) Sex() uint
- func (r *BidRequest) SiteInfo() *udetect.Site
- func (r *BidRequest) Size() (w, h int)
- func (r *BidRequest) SourceFilterCheck(id uint64) bool
- func (r *BidRequest) String() (res string)
- func (r *BidRequest) Tags() []string
- func (r *BidRequest) TargetID() uint64
- func (r *BidRequest) TargetIDs() []uint64
- func (r *BidRequest) Time() time.Time
- func (r *BidRequest) TrafficSourceID() uint64
- func (r *BidRequest) Unset(keys ...string)
- func (r *BidRequest) UserInfo() *adtype.User
- func (r *BidRequest) Validate() error
- func (r *BidRequest) WithFormats(formats types.FormatsAccessor) adtype.BidRequester
- type BidRequestFlags
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdFormats ¶
type AdFormats struct {
// contains filtered or unexported fields
}
func (*AdFormats) Bitset ¶
func (a *AdFormats) Bitset() *searchtypes.NumberBitset[uint]
func (*AdFormats) TypeMask ¶
func (a *AdFormats) TypeMask() types.FormatTypeBitset
type BidRequest ¶
type BidRequest struct {
IDVal string `json:"id,omitempty"` // Auction ID
ExtID string `json:"bidid,omitempty"` // External Auction ID
Timemark time.Time `json:"timemark,omitempty"` // Timestamp of the request
Ctx context.Context `json:"-"` // Context for request handling
Debug bool `json:"debug,omitempty"` // Debug mode flag
// Source of the request
AccessPointLnk adtype.AccessPoint `json:"-"` // Access point information
AucType types.AuctionType `json:"auction_type,omitempty"` // Type of auction
RequestCtx *fasthttp.RequestCtx `json:"-"` // HTTP request context
Request any `json:"-"` // Original request from RTB or another protocol
Person personification.Person `json:"-"` // Personification data
Imps []*adtype.Impression `json:"imps,omitempty"` // List of impressions
AppTarget *admodels.Application `json:"app_target,omitempty"` // Target application
Device *udetect.Device `json:"device,omitempty"` // Device information
App *udetect.App `json:"app,omitempty"` // App information
Site *udetect.Site `json:"site,omitempty"` // Site information
User *adtype.User `json:"user,omitempty"` // User information
StateFlags BidRequestFlags `json:"flags"` // State flags for the request
Ext map[string]any `json:"ext,omitempty"` // Additional extensions
Tracer any `json:"-"` // Tracing information
// contains filtered or unexported fields
}
BidRequest represents a bid request in the ad system. It contains all necessary information for processing an ad bid.
func (*BidRequest) AccessPoint ¶
func (r *BidRequest) AccessPoint() adtype.AccessPoint
AccessPoint returns the access point associated with the BidRequest.
func (*BidRequest) AppID ¶
func (r *BidRequest) AppID() uint64
AppID returns the ID of the target application. Returns 0 if the app target is unavailable.
func (*BidRequest) AppInfo ¶
func (r *BidRequest) AppInfo() *udetect.App
AppInfo returns the application information associated with the BidRequest.
func (*BidRequest) AuctionID ¶
func (r *BidRequest) AuctionID() string
AuctionID returns the auction ID of the BidRequest.
func (*BidRequest) AuctionType ¶
func (r *BidRequest) AuctionType() types.AuctionType
AuctionType returns the type of auction for the BidRequest.
func (*BidRequest) BrowserInfo ¶
func (r *BidRequest) BrowserInfo() *udetect.Browser
BrowserInfo returns the browser information associated with the BidRequest.
func (*BidRequest) CarrierInfo ¶
func (r *BidRequest) CarrierInfo() *udetect.Carrier
CarrierInfo returns the carrier information associated with the user's geography.
func (*BidRequest) Categories ¶
func (r *BidRequest) Categories() []uint64
Categories returns a slice of category IDs associated with the BidRequest. Currently, it returns the cached categoryArray. (Note: The implementation is incomplete and commented out for future development.)
func (*BidRequest) Clone ¶
func (r *BidRequest) Clone() *BidRequest
Clone creates and returns a shallow copy of the BidRequest.
func (*BidRequest) Context ¶
func (r *BidRequest) Context() context.Context
Context returns the context associated with the BidRequest.
func (*BidRequest) CurrentGeoTime ¶
func (r *BidRequest) CurrentGeoTime() time.Time
CurrentGeoTime returns the current time adjusted to the geographical location of the user.
func (*BidRequest) DeviceInfo ¶
func (r *BidRequest) DeviceInfo() *udetect.Device
DeviceInfo returns the device information associated with the BidRequest. It initializes default values if device, browser, or OS information is missing.
func (*BidRequest) Domain ¶
func (r *BidRequest) Domain() []string
Domain returns a list of domains associated with the site or app. It prepares the domain list by aggregating from Site and App information.
func (*BidRequest) DomainName ¶
func (r *BidRequest) DomainName() string
DomainName returns the primary domain name of the site or the bundle name of the app.
func (*BidRequest) Done ¶
func (r *BidRequest) Done() <-chan struct{}
Done returns a channel that is closed when the context of the BidRequest is done.
func (*BidRequest) ExtTargetIDs ¶
func (r *BidRequest) ExtTargetIDs() []string
ExtTargetIDs returns a slice of unique external target IDs from all impressions.
func (*BidRequest) ExternalAuctionID ¶
func (r *BidRequest) ExternalAuctionID() string
ExternalAuctionID returns the external auction ID of the BidRequest.
func (*BidRequest) ExternalID ¶
func (r *BidRequest) ExternalID() string
ExternalID returns the external ID of the BidRequest.
func (*BidRequest) Formats ¶
func (r *BidRequest) Formats() types.BidFormater
Formats returns the list of formats associated with the BidRequest. If the formats slice is empty, it aggregates formats from all impressions.
func (*BidRequest) GeoID ¶
func (r *BidRequest) GeoID() uint64
GeoID returns the geographical ID associated with the BidRequest.
func (*BidRequest) GeoInfo ¶
func (r *BidRequest) GeoInfo() *udetect.Geo
GeoInfo returns the geographical information associated with the BidRequest.
func (*BidRequest) Get ¶
func (r *BidRequest) Get(key string) any
Get retrieves a value from the BidRequest's extension map by key. Returns nil if the key does not exist.
func (*BidRequest) HTTPRequest ¶
func (r *BidRequest) HTTPRequest() *fasthttp.RequestCtx
HTTPRequest returns the underlying HTTP request context.
func (*BidRequest) ID ¶
func (r *BidRequest) ID() string
ID returns the unique ID of the BidRequest.
func (*BidRequest) ImpressionByID ¶
func (r *BidRequest) ImpressionByID(id string) *adtype.Impression
ImpressionByID returns a pointer to the Impression with the specified ID. Returns nil if no matching impression is found.
func (*BidRequest) ImpressionUpdate ¶
func (r *BidRequest) ImpressionUpdate(fn func(imp *adtype.Impression) bool)
ImpressionUpdate applies a provided function to each impression in the BidRequest. If the function returns true, the impression is updated.
func (*BidRequest) Impressions ¶
func (r *BidRequest) Impressions() []*adtype.Impression
Impressions returns a slice of impressions associated with the BidRequest.
func (*BidRequest) IsAdBlock ¶
func (r *BidRequest) IsAdBlock() bool
IsAdBlock checks if the user has an ad blocker enabled.
func (*BidRequest) IsDebug ¶
func (r *BidRequest) IsDebug() bool
IsDebug checks if the BidRequest is in debug mode.
func (*BidRequest) IsIPv6 ¶
func (r *BidRequest) IsIPv6() bool
IsIPv6 checks if the user's IP address is IPv6.
func (*BidRequest) IsPrivateBrowsing ¶
func (r *BidRequest) IsPrivateBrowsing() bool
IsPrivateBrowsing checks if the user is in private browsing mode.
func (*BidRequest) IsProxy ¶
func (r *BidRequest) IsProxy() bool
IsProxy checks if the user is using a proxy.
func (*BidRequest) IsRobot ¶
func (r *BidRequest) IsRobot() bool
IsRobot checks if the user is a robot.
func (*BidRequest) IsSecure ¶
func (r *BidRequest) IsSecure() bool
IsSecure checks if the request is made over a secure connection.
func (*BidRequest) Keywords ¶
func (r *BidRequest) Keywords() []string
Keywords returns a slice of keywords associated with the user. Returns nil if user information is unavailable.
func (*BidRequest) LanguageID ¶
func (r *BidRequest) LanguageID() uint64
LanguageID returns the language ID based on the primary language of the browser.
func (*BidRequest) MinECPM ¶
func (r *BidRequest) MinECPM() (minBid billing.Money)
MinECPM calculates and returns the minimum ECPM (Effective Cost Per Mille) acceptable for the BidRequest. It iterates through all impressions and selects the highest bid floor.
func (*BidRequest) OSInfo ¶
func (r *BidRequest) OSInfo() *udetect.OS
OSInfo returns the operating system information associated with the BidRequest.
func (*BidRequest) PrepareWithFormats ¶
func (r *BidRequest) PrepareWithFormats(formats types.FormatsAccessor) adtype.BidRequester
PrepareWithFormats prepares the BidRequest by initializing formats for each impression using the provided FormatsAccessor. It resets any existing formats and aggregates formats from all impressions into the BidRequest's formats.
func (*BidRequest) ProjectID ¶
func (r *BidRequest) ProjectID() uint64
ProjectID returns the Project ID associated with the BidRequest. Currently returns 0 as a placeholder.
func (*BidRequest) Release ¶
func (r *BidRequest) Release()
Release releases any resources associated with the BidRequest. If the original request implements the releaser interface, it calls the Release method.
func (*BidRequest) ServiceDomain ¶
func (r *BidRequest) ServiceDomain() string
ServiceDomain returns the domain of the service handling the request.
func (*BidRequest) Set ¶
func (r *BidRequest) Set(key string, val any)
Set sets a key-value pair in the BidRequest's extension map.
func (*BidRequest) SetContext ¶
func (r *BidRequest) SetContext(ctx context.Context)
SetContext sets the context for the BidRequest.
func (*BidRequest) SetSourceFilter ¶
func (r *BidRequest) SetSourceFilter(ids ...uint64)
SetSourceFilter sets the source filter IDs for the BidRequest. It replaces any existing source IDs with the provided ones.
func (*BidRequest) Sex ¶
func (r *BidRequest) Sex() uint
Sex returns the user's sex as an unsigned integer. Returns 0 if user information is unavailable.
func (*BidRequest) SiteInfo ¶
func (r *BidRequest) SiteInfo() *udetect.Site
SiteInfo returns the site information associated with the BidRequest. If the site is unavailable, it returns the default site information. Returns nil if neither site nor app information is available.
func (*BidRequest) Size ¶
func (r *BidRequest) Size() (w, h int)
Size returns the width and height of the browser's visible area
func (*BidRequest) SourceFilterCheck ¶
func (r *BidRequest) SourceFilterCheck(id uint64) bool
SourceFilterCheck checks if a given source ID is allowed by the current filter. Returns true if no filter is set or if the ID is present in the filter.
func (*BidRequest) String ¶
func (r *BidRequest) String() (res string)
String implements the fmt.Stringer interface for BidRequest. It returns a pretty-printed JSON representation of the BidRequest. If marshalling fails, it returns an error message in JSON format.
func (*BidRequest) Tags ¶
func (r *BidRequest) Tags() []string
Tags returns a list of tags associated with the BidRequest. It aggregates keywords from the user and site information.
func (*BidRequest) TargetID ¶
func (r *BidRequest) TargetID() uint64
TargetID returns the target ID if there is exactly one impression with a target. Otherwise, returns 0.
func (*BidRequest) TargetIDs ¶
func (r *BidRequest) TargetIDs() []uint64
TargetIDs returns a slice of unique target IDs from all impressions.
func (*BidRequest) Time ¶
func (r *BidRequest) Time() time.Time
Time returns the timestamp of the BidRequest.
func (*BidRequest) TrafficSourceID ¶
func (r *BidRequest) TrafficSourceID() uint64
TrafficSourceID returns the ID of the traffic source associated with the BidRequest. Returns 0 if the traffic source information is unavailable. (Direct by default)
func (*BidRequest) Unset ¶
func (r *BidRequest) Unset(keys ...string)
Unset removes one or more keys from the BidRequest's extension map.
func (*BidRequest) UserInfo ¶
func (r *BidRequest) UserInfo() *adtype.User
UserInfo returns the user information associated with the BidRequest. It initializes default values if user or geographical information is missing.
func (*BidRequest) Validate ¶
func (r *BidRequest) Validate() error
Validate performs validation on the BidRequest. Currently, it always returns nil, but can be extended to include validation logic.
func (*BidRequest) WithFormats ¶
func (r *BidRequest) WithFormats(formats types.FormatsAccessor) adtype.BidRequester
WithFormats sets the formats accessor for the BidRequest and returns the updated BidRequest.
type BidRequestFlags ¶
type BidRequestFlags uint8
BidRequestFlags defines flags for bid requests.
const ( // BidRequestFlagAdBlock indicates if adblock is enabled BidRequestFlagAdBlock BidRequestFlags = 1 << iota // BidRequestFlagPrivateBrowsing indicates if private browsing is enabled BidRequestFlagPrivateBrowsing // BidRequestFlagSecure indicates if the request is secure BidRequestFlagSecure // BidRequestFlagBot indicates if the request is from a bot BidRequestFlagBot // BidRequestFlagProxy indicates if the request is from a proxy BidRequestFlagProxy )