Documentation ¶
Index ¶
- Constants
- type EventReceiver
- type Factory
- func (s Factory) BuildAddToBagEvent(productIdentifier string, productName string, qty int) domain.Event
- func (s Factory) BuildCartData(cart decorator.DecoratedCart) *domain.Cart
- func (s Factory) BuildChangeQtyEvent(productIdentifier string, productName string, qty int, qtyBefore int, ...) domain.Event
- func (s Factory) BuildForCurrentRequest(ctx context.Context, request *web.Request) domain.Datalayer
- func (s Factory) BuildProductData(product productDomain.BasicProduct) domain.Product
- func (s Factory) BuildTransactionData(ctx context.Context, cart decorator.DecoratedCart, ...) *domain.Transaction
- func (s *Factory) EvaluateBadgeHierarchy(product productDomain.BasicProduct) string
- func (s Factory) HashValueIfConfigured(value string) string
- func (s *Factory) Inject(router2 *web.Router, logger flamingo.Logger, provider domain.DatalayerProvider, ...)
- type Service
- func (s *Service) AddEvent(eventName string, params ...*pugjs.Map) error
- func (s *Service) AddProduct(product productDomain.BasicProduct) error
- func (s *Service) AddSessionEvents() error
- func (s *Service) AddTransactionAttribute(key string, value string) error
- func (s *Service) Get() domain.Datalayer
- func (s *Service) Init(ctx context.Context)
- func (s *Service) Inject(logger flamingo.Logger, factory *Factory, service productDomain.ProductService)
- func (s *Service) SetBreadCrumb(breadcrumb string) error
- func (s *Service) SetCartData(cart decorator.DecoratedCart) error
- func (s *Service) SetPageCategories(category string, subcategory1 string, subcategory2 string) error
- func (s *Service) SetPageInfoLanguage(language string) error
- func (s *Service) SetPageInfos(pageID string, pageName string) error
- func (s *Service) SetSearchData(keyword string, results interface{}) error
- func (s *Service) SetTransaction(cart decorator.DecoratedCart, decoratedItems []decorator.DecoratedCartItem, ...) error
- func (s *Service) SetUserEmail(mail string) error
- type ServiceProvider
Constants ¶
const ( SessionEventsKey = "w3cdatalayer_events" DatalayerReqKey = "w3cDatalayer" )
constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventReceiver ¶
type EventReceiver struct {
// contains filtered or unexported fields
}
EventReceiver struct with required dependencies
func (*EventReceiver) Inject ¶
func (e *EventReceiver) Inject(factory *Factory, cartFactory *decorator.DecoratedCartFactory, logger flamingo.Logger)
Inject method
func (*EventReceiver) Notify ¶
func (e *EventReceiver) Notify(ctx context.Context, event flamingo.Event)
Notify should get called by flamingo Eventlogic. We use it to listen to Events that are relevant for the Datalayer In case the events might be asycron (e.g. the origin action does a redirect to a success page) - we save the datalayer Event to a Session Flash - to make sure it is still available the first time the DatalayerService.Get is calles
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
Factory is used to build new datalayers
func (Factory) BuildAddToBagEvent ¶
func (s Factory) BuildAddToBagEvent(productIdentifier string, productName string, qty int) domain.Event
BuildAddToBagEvent builds the add to bag domain event
func (Factory) BuildCartData ¶
func (s Factory) BuildCartData(cart decorator.DecoratedCart) *domain.Cart
BuildCartData builds the domain cart data
func (Factory) BuildChangeQtyEvent ¶
func (s Factory) BuildChangeQtyEvent(productIdentifier string, productName string, qty int, qtyBefore int, cartID string) domain.Event
BuildChangeQtyEvent builds the change quantity domain event
func (Factory) BuildForCurrentRequest ¶
BuildForCurrentRequest builds the datalayer for the current request
func (Factory) BuildProductData ¶
func (s Factory) BuildProductData(product productDomain.BasicProduct) domain.Product
BuildProductData builds the domain product data
func (Factory) BuildTransactionData ¶
func (s Factory) BuildTransactionData(ctx context.Context, cart decorator.DecoratedCart, decoratedItems []decorator.DecoratedCartItem, orderID string, email string) *domain.Transaction
BuildTransactionData builds the domain transaction data
func (*Factory) EvaluateBadgeHierarchy ¶
func (s *Factory) EvaluateBadgeHierarchy(product productDomain.BasicProduct) string
EvaluateBadgeHierarchy get the active badge by product
func (Factory) HashValueIfConfigured ¶
HashValueIfConfigured returns the hashed `value` if hashing is configured
func (*Factory) Inject ¶
func (s *Factory) Inject( router2 *web.Router, logger flamingo.Logger, provider domain.DatalayerProvider, webIdentityService *auth.WebIdentityService, customerIdentityService customerDomain.CustomerIdentityService, config *struct { PageInstanceIDPrefix string `inject:"config:commerce.w3cDatalayer.pageInstanceIDPrefix,optional"` PageInstanceIDStage string `inject:"config:commerce.w3cDatalayer.pageInstanceIDStage,optional"` ProductMediaBaseURL string `inject:"config:commerce.w3cDatalayer.productMediaBaseUrl,optional"` ProductMediaURLPrefix string `inject:"config:commerce.w3cDatalayer.productMediaUrlPrefix,optional"` ProductMediaThumbnailURLPrefix string `inject:"config:commerce.w3cDatalayer.productMediaThumbnailUrlPrefix,optional"` PageNamePrefix string `inject:"config:commerce.w3cDatalayer.pageNamePrefix,optional"` SiteName string `inject:"config:commerce.w3cDatalayer.siteName,optional"` Locale string `inject:"config:locale.locale,optional"` DefaultCurrency string `inject:"config:commerce.w3cDatalayer.defaultCurrency,optional"` HashUserValues bool `inject:"config:commerce.w3cDatalayer.hashUserValues,optional"` HashEncoding string `inject:"config:commerce.w3cDatalayer.hashEncoding,optional"` }, )
Inject factory dependencies
type Service ¶
type Service struct { productDomain.ProductService // contains filtered or unexported fields }
Service can be used from outside is expected to be initialized with the current request context It stores a dataLayer Value object for the current request context and allows interaction with it
func (*Service) AddProduct ¶
func (s *Service) AddProduct(product productDomain.BasicProduct) error
AddProduct - appends the productData to the data layer
func (*Service) AddSessionEvents ¶
AddSessionEvents to data layer
func (*Service) AddTransactionAttribute ¶
AddTransactionAttribute to data layer
func (*Service) Get ¶
Get gets the data layer value object stored in the current context - or a freshly new build one if its the first call
func (*Service) Inject ¶
func (s *Service) Inject(logger flamingo.Logger, factory *Factory, service productDomain.ProductService)
Inject method
func (*Service) SetBreadCrumb ¶
SetBreadCrumb to data layer
func (*Service) SetCartData ¶
func (s *Service) SetCartData(cart decorator.DecoratedCart) error
SetCartData to data layer
func (*Service) SetPageCategories ¶
func (s *Service) SetPageCategories(category string, subcategory1 string, subcategory2 string) error
SetPageCategories to data layer
func (*Service) SetPageInfoLanguage ¶ added in v3.0.1
SetPageInfoLanguage to the layer
func (*Service) SetPageInfos ¶
SetPageInfos to data layer
func (*Service) SetSearchData ¶
SetSearchData to data layer
func (*Service) SetTransaction ¶
func (s *Service) SetTransaction(cart decorator.DecoratedCart, decoratedItems []decorator.DecoratedCartItem, orderID string, email string) error
SetTransaction information to data layer
func (*Service) SetUserEmail ¶
SetUserEmail to a User object