usersync

package
v0.0.0-...-ea31b78 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_TTL = 14 * 24 * time.Hour

DEFAULT_TTL is the default amount of time which a cookie is considered valid.

View Source
const UID_COOKIE_NAME = "uids"

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 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, domain string, 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.
	//
	// gdpr should be 1 if GDPR is active, 0 if not, and an empty string if we're not sure.
	// consent should be an empty string or a raw base64 url-encoded IAB Vendor Consent String.
	//
	// For more information about user syncs, see http://clearcode.cc/2015/12/cookie-syncing/
	GetUsersyncInfo(gdpr string, consent string) (*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

	// GDPRVendorID returns the ID in the IAB Global Vendor List which refers to this Bidder.
	//
	// The Global Vendor list can be found here: https://vendorlist.consensu.org/vendorlist.json
	// Bidders can register for the list here: https://register.consensu.org/
	//
	// If you're not on the list, this should return 0. If cookie sync requests have GDPR consent info,
	// or the Prebid Server host company configures its deploy to be "cautious" when no GDPR info exists
	// in the request, it will _not_ sync user IDs with you.
	GDPRVendorID() uint16
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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