github.com/prebid/prebid-server/v2@v2.18.0/usersync/synctype.go (about)

     1  package usersync
     2  
     3  // SyncType specifies the mechanism used to perform a user sync.
     4  type SyncType string
     5  
     6  const (
     7  	// SyncTypeUnknown specifies the user sync type is invalid or not specified.
     8  	SyncTypeUnknown SyncType = ""
     9  
    10  	// SyncTypeIFrame specifies the user sync is to be performed within an HTML iframe
    11  	// and to expect the server to return a valid HTML page with an embedded script.
    12  	SyncTypeIFrame SyncType = "iframe"
    13  
    14  	// SyncTypeRedirect specifies the user sync is to be performed within an HTML image
    15  	// and to expect the server to return a 302 redirect.
    16  	SyncTypeRedirect SyncType = "redirect"
    17  )
    18  
    19  // SyncTypeFilter determines which sync types, if any, the bidder is permitted to use.
    20  type SyncTypeFilter struct {
    21  	IFrame   BidderFilter
    22  	Redirect BidderFilter
    23  }
    24  
    25  // ForBidder returns a slice of sync types the bidder is permitted to use.
    26  func (t SyncTypeFilter) ForBidder(bidder string) []SyncType {
    27  	var syncTypes []SyncType
    28  
    29  	if t.IFrame.Allowed(bidder) {
    30  		syncTypes = append(syncTypes, SyncTypeIFrame)
    31  	}
    32  
    33  	if t.Redirect.Allowed(bidder) {
    34  		syncTypes = append(syncTypes, SyncTypeRedirect)
    35  	}
    36  
    37  	return syncTypes
    38  }