application

package
v3.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2020 License: OSL-3.0 Imports: 20 Imported by: 2

Documentation

Index

Constants

View Source
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

func (s Factory) BuildForCurrentRequest(ctx context.Context, request *web.Request) domain.Datalayer

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

func (s Factory) HashValueIfConfigured(value string) string

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

func (s *Service) AddEvent(eventName string, params ...*pugjs.Map) error

AddEvent - adds an event with the given eventName to the data layer

func (*Service) AddProduct

func (s *Service) AddProduct(product productDomain.BasicProduct) error

AddProduct - appends the productData to the data layer

func (*Service) AddSessionEvents

func (s *Service) AddSessionEvents() error

AddSessionEvents to data layer

func (*Service) AddTransactionAttribute

func (s *Service) AddTransactionAttribute(key string, value string) error

AddTransactionAttribute to data layer

func (*Service) Get

func (s *Service) Get() domain.Datalayer

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

func (s *Service) Init(ctx context.Context)

Init method - sets the context

func (*Service) Inject

func (s *Service) Inject(logger flamingo.Logger, factory *Factory, service productDomain.ProductService)

Inject method

func (*Service) SetBreadCrumb

func (s *Service) SetBreadCrumb(breadcrumb string) error

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

func (s *Service) SetPageInfoLanguage(language string) error

SetPageInfoLanguage to the layer

func (*Service) SetPageInfos

func (s *Service) SetPageInfos(pageID string, pageName string) error

SetPageInfos to data layer

func (*Service) SetSearchData

func (s *Service) SetSearchData(keyword string, results interface{}) error

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

func (s *Service) SetUserEmail(mail string) error

SetUserEmail to a User object

type ServiceProvider

type ServiceProvider func() *Service

ServiceProvider func

Jump to

Keyboard shortcuts

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