usersync

package
v0.163.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2021 License: Apache-2.0 Imports: 9 Imported by: 90

Documentation

Index

Constants

View Source
const (
	// DEFAULT_TTL is the default amount of time which a cookie is considered valid.
	DEFAULT_TTL         = 14 * 24 * time.Hour
	UID_COOKIE_NAME     = "uids"
	SameSiteCookieName  = "SSCookie"
	SameSiteCookieValue = "1"
	SameSiteAttribute   = "; SameSite=None"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CookieSyncBidders

type CookieSyncBidders struct {
	BidderCode   string        `json:"bidder"`
	NoCookie     bool          `json:"no_cookie,omitempty"`
	UsersyncInfo *UsersyncInfo `json:"usersync,omitempty"`
}

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 NewPBSCookie

func NewPBSCookie() *PBSCookie

NewPBSCookie returns an empty PBSCookie

func NewPBSCookieWithOptOut

func NewPBSCookieWithOptOut() *PBSCookie

NewPBSCookie returns an empty PBSCookie with optOut enabled

func ParsePBSCookie

func ParsePBSCookie(uidCookie *http.Cookie) *PBSCookie

ParsePBSCookie parses the UserSync cookie from a raw HTTP cookie.

func ParsePBSCookieFromRequest

func ParsePBSCookieFromRequest(r *http.Request, cookie *config.HostCookie) *PBSCookie

ParsePBSCookieFromRequest parses the UserSyncMap from an HTTP Request.

func (*PBSCookie) AllowSyncs

func (cookie *PBSCookie) AllowSyncs() bool

AllowSyncs is true if the user lets bidders sync cookies, and false otherwise.

func (*PBSCookie) GetId

func (cookie *PBSCookie) GetId(bidderName openrtb_ext.BidderName) (id string, exists bool)

GetId wraps GetUID, letting callers fetch the ID given an OpenRTB BidderName.

func (*PBSCookie) GetUID

func (cookie *PBSCookie) GetUID(familyName string) (string, bool, bool)

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) GetUIDs

func (cookie *PBSCookie) GetUIDs() map[string]string

GetUIDs returns this user's ID for all the bidders

func (*PBSCookie) HasLiveSync

func (cookie *PBSCookie) HasLiveSync(familyName string) bool

HasLiveSync returns true if we have an active UID for the given family, and false otherwise.

func (*PBSCookie) LiveSyncCount

func (cookie *PBSCookie) LiveSyncCount() int

LiveSyncCount returns the number of families which have active UIDs for this user.

func (*PBSCookie) MarshalJSON

func (cookie *PBSCookie) MarshalJSON() ([]byte, error)

func (*PBSCookie) SetCookieOnResponse

func (cookie *PBSCookie) SetCookieOnResponse(w http.ResponseWriter, setSiteCookie bool, cfg *config.HostCookie, ttl time.Duration)

SetCookieOnResponse is a shortcut for "ToHTTPCookie(); cookie.setDomain(domain); setCookie(w, cookie)"

func (*PBSCookie) SetPreference

func (cookie *PBSCookie) SetPreference(allow bool)

SetPreference is used to change whether or not we're allowed to sync cookies for this user.

func (*PBSCookie) ToHTTPCookie

func (cookie *PBSCookie) ToHTTPCookie(ttl time.Duration) *http.Cookie

Gets an HTTP cookie containing all the data from this UserSyncMap. This is a snapshot--not a live view.

func (*PBSCookie) TrySync

func (cookie *PBSCookie) TrySync(familyName string, uid string) error

TrySync tries to set the UID for some family name. It returns an error if the set didn't happen.

func (*PBSCookie) UnmarshalJSON

func (cookie *PBSCookie) UnmarshalJSON(b []byte) error

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.

func (*PBSCookie) Unsync

func (cookie *PBSCookie) Unsync(familyName string)

Unsync removes the user's ID for the given family from this cookie.

type UsersyncInfo

type UsersyncInfo struct {
	URL         string `json:"url,omitempty"`
	Type        string `json:"type,omitempty"`
	SupportCORS bool   `json:"supportCORS,omitempty"`
}

type Usersyncer

type Usersyncer interface {
	// GetUsersyncInfo returns basic info the browser needs in order to run a user sync.
	// The returned UsersyncInfo object must not be mutated by callers.
	//
	// For more information about user syncs, see http://clearcode.cc/2015/12/cookie-syncing/
	GetUsersyncInfo(privacyPolicies privacy.Policies) (*UsersyncInfo, error)

	// FamilyName should be the same as the `BidderName` for this Usersyncer.
	// This function only exists for legacy reasons.
	// TODO #362: when the appnexus usersyncer is consistent, delete this and use the key
	// of NewSyncerMap() here instead.
	FamilyName() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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