Documentation ¶
Index ¶
- Constants
- func Webalize(s string) (string, error)
- type AggregateOptions
- type AvgRow
- type AvgRowCollection
- type BrowserSet
- type Commerce
- type CommerceElastic
- func (cDB *CommerceElastic) Actions(category string) ([]string, error)
- func (cDB *CommerceElastic) Categories() ([]string, error)
- func (cDB *CommerceElastic) Count(options AggregateOptions) (CountRowCollection, bool, error)
- func (cDB *CommerceElastic) Flags() []string
- func (cDB *CommerceElastic) List(options ListOptions) (CommerceRowCollection, error)
- func (cDB *CommerceElastic) Sum(options AggregateOptions) (SumRowCollection, bool, error)
- type CommerceOptions
- type CommerceRow
- type CommerceRowCollection
- type CommerceStorage
- type ConcurrentElastic
- type ConcurrentsStorage
- type CountHistogram
- type CountHistogramItem
- type CountRow
- type CountRowCollection
- type ElasticDB
- type EntitySchema
- type EntitySchemaCollection
- type EntitySchemaDB
- type EntitySchemaParam
- type EntitySchemaParamsCollection
- type EntitySchemaStorage
- type Event
- type EventElastic
- func (eDB *EventElastic) Actions(category string) ([]string, error)
- func (eDB *EventElastic) Cache() error
- func (eDB *EventElastic) Categories() ([]string, error)
- func (eDB *EventElastic) Count(options AggregateOptions) (CountRowCollection, bool, error)
- func (eDB *EventElastic) Flags() []string
- func (eDB *EventElastic) List(options ListOptions) (EventRowCollection, error)
- func (eDB *EventElastic) Users() ([]string, error)
- type EventOptions
- type EventRow
- type EventRowCollection
- type EventRules
- type EventStorage
- type FilterBy
- type FilterType
- type Flags
- type Intersector
- type JSONMap
- type ListOptions
- type ListPageviewsOptions
- type OverridableFields
- type PCEStorage
- type Pageview
- type PageviewElastic
- func (pDB *PageviewElastic) Actions(category string) ([]string, error)
- func (pDB *PageviewElastic) Avg(options AggregateOptions) (AvgRowCollection, bool, error)
- func (pDB *PageviewElastic) Categories() ([]string, error)
- func (pDB *PageviewElastic) Count(options AggregateOptions) (CountRowCollection, bool, error)
- func (pDB *PageviewElastic) Flags() []string
- func (pDB *PageviewElastic) List(options ListPageviewsOptions) (PageviewRowCollection, error)
- func (pDB *PageviewElastic) Sum(options AggregateOptions) (SumRowCollection, bool, error)
- func (pDB *PageviewElastic) Unique(options AggregateOptions, item string) (CountRowCollection, bool, error)
- func (pDB *PageviewElastic) Users() ([]string, error)
- type PageviewOptions
- type PageviewRow
- type PageviewRowCollection
- type PageviewStorage
- type Property
- type PropertyCollection
- type PropertyDB
- type PropertyStorage
- type RuleOverrides
- type Segment
- type SegmentBlueprintDB
- type SegmentBlueprintStorage
- type SegmentBlueprintTable
- type SegmentBlueprintTableCollection
- type SegmentBlueprintTableCriterion
- type SegmentBlueprintTableCriterionCollection
- type SegmentBlueprintTableCriterionParam
- type SegmentCache
- type SegmentCollection
- type SegmentCriteria
- type SegmentCriteriaNode
- type SegmentCriteriaNodeCollection
- type SegmentCriteriaOperatorNode
- type SegmentCriteriaOperatorNodeCollection
- type SegmentCriteriaValuesDatetime
- type SegmentCriteriaValuesDatetimeAbsolute
- type SegmentCriteriaValuesDatetimeInterval
- type SegmentDB
- func (sDB *SegmentDB) BuildRules(s *Segment) ([]SegmentRule, bool, error)
- func (sDB *SegmentDB) Cache() error
- func (sDB *SegmentDB) CacheExplicitSegments() error
- func (sDB *SegmentDB) CheckBrowser(segment *Segment, browserID string, now time.Time, cache SegmentCache, ...) (SegmentCache, bool, error)
- func (sDB *SegmentDB) CheckUser(segment *Segment, userID string, now time.Time, cache SegmentCache, ...) (SegmentCache, bool, error)
- func (sDB *SegmentDB) CountAll() (int, error)
- func (sDB *SegmentDB) Create(sd SegmentData) (*Segment, error)
- func (sDB *SegmentDB) EventRules() EventRules
- func (sDB *SegmentDB) Flags() Flags
- func (sDB *SegmentDB) Get(code string) (*Segment, bool, error)
- func (sDB *SegmentDB) GetByID(id int) (*Segment, bool, error)
- func (sDB *SegmentDB) Groups() (SegmentGroupCollection, error)
- func (sDB *SegmentDB) List() (SegmentCollection, error)
- func (sDB *SegmentDB) OverridableFields() OverridableFields
- func (sDB *SegmentDB) Related(criteria SegmentCriteria) (SegmentCollection, error)
- func (sDB *SegmentDB) Update(id int, sd SegmentData) (*Segment, bool, error)
- func (sDB *SegmentDB) Users(segment *Segment, now time.Time, ro RuleOverrides) ([]string, error)
- type SegmentData
- type SegmentGroup
- type SegmentGroupCollection
- type SegmentRule
- type SegmentRuleCache
- type SegmentStorage
- type SumRow
- type SumRowCollection
- type TimeHistogram
- type TimeHistogramItem
- type UnwrapCallback
- type User
- type UserCollection
- type UserSet
Constants ¶
const ( CategoryCommerce = "commerce" TableCommerce = "commerce" )
Exported constants for services writing to EventStorage indirectly (e.g. Kafka).
const ( CategoryPageview = "pageview" ActionPageviewLoad = "load" ActionPageviewTimespent = "timespent" ActionPageviewProgress = "progress" UniqueCountBrowsers = "browsers" UniqueCountUsers = "users" TablePageviews = "pageviews" TableTimespent = "pageviews_time_spent" TableProgress = "pageviews_progress" FlagArticle = "_article" )
Exported constants for services writing to EventStorage indirectly (e.g. Kafka) and reading from enumerated values.
const (
TableConcurrents = "concurrents_by_browser"
)
Exported constants
const (
TableEntities = "entities"
)
Exported constants for services writing to EventStorage indirectly (e.g. Kafka).
const (
TableEvents = "events_v2"
)
Exported constants for services writing to EventStorage indirectly (e.g. Kafka).
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AggregateOptions ¶
type AggregateOptions struct { Category string Action string Step string FilterBy []*FilterBy GroupBy []string TimeAfter time.Time TimeBefore time.Time TimeHistogram *TimeHistogram CountHistogram *CountHistogram }
AggregateOptions represent filter options for aggregate-related calls.
type AvgRow ¶
type AvgRow struct { Tags map[string]string Avg float64 TimeHistogram []TimeHistogramItem }
AvgRow represents one row of grouped sum.
type AvgRowCollection ¶
type AvgRowCollection []AvgRow
AvgRowCollection represents collection of rows of grouped sum.
type Commerce ¶
type Commerce struct { ID string Step string Token string Time time.Time Host string IP string UserID string `json:"user_id"` URL string `json:"url"` UserAgent string `json:"user_agent"` FunnelID string `json:"funnel_id"` ProductIDs string `json:"product_ids"` Revenue float64 `json:"revenue"` Currency string `json:"currency"` UtmCampaign string `json:"utm_campaign"` UtmContent string `json:"utm_content"` UtmMedium string `json:"utm_medium"` UtmSource string `json:"utm_source"` }
Commerce represents commerce event data.
type CommerceElastic ¶
type CommerceElastic struct {
DB *ElasticDB
}
CommerceElastic is ElasticDB implementation of CommerceStorage.
func (*CommerceElastic) Actions ¶
func (cDB *CommerceElastic) Actions(category string) ([]string, error)
Actions lists all available actions under the given category.
func (*CommerceElastic) Categories ¶
func (cDB *CommerceElastic) Categories() ([]string, error)
Categories lists all available categories.
func (*CommerceElastic) Count ¶
func (cDB *CommerceElastic) Count(options AggregateOptions) (CountRowCollection, bool, error)
Count returns count of events based on the provided filter options.
func (*CommerceElastic) Flags ¶
func (cDB *CommerceElastic) Flags() []string
Flags lists all available flags.
func (*CommerceElastic) List ¶
func (cDB *CommerceElastic) List(options ListOptions) (CommerceRowCollection, error)
List returns list of all events based on given CommerceOptions.
func (*CommerceElastic) Sum ¶
func (cDB *CommerceElastic) Sum(options AggregateOptions) (SumRowCollection, bool, error)
Sum returns sum of events based on the provided filter options.
type CommerceOptions ¶
type CommerceOptions struct { IDs []string FilterBy FilterType Group bool Step string TimeAfter time.Time TimeBefore time.Time }
CommerceOptions represent filter options for commerce-related calls.
type CommerceRow ¶
CommerceRow represents one row of grouped list.
type CommerceRowCollection ¶
type CommerceRowCollection []*CommerceRow
CommerceRowCollection represents collection of rows of grouped list.
type CommerceStorage ¶
type CommerceStorage interface { // Count returns count of events based on the provided filter options. Count(o AggregateOptions) (CountRowCollection, bool, error) // Sum returns sum of events based on the provided filter options. Sum(o AggregateOptions) (SumRowCollection, bool, error) // List returns list of all events based on given CommerceOptions. List(o ListOptions) (CommerceRowCollection, error) // Categories lists all available categories. Categories() ([]string, error) // Flags lists all available flags. Flags() []string // Actions lists all available actions under the given category. Actions(category string) ([]string, error) }
CommerceStorage is an interface to get commerce event related data.
type ConcurrentElastic ¶
type ConcurrentElastic struct { DB *ElasticDB // contains filtered or unexported fields }
ConcurrentElastic is ElasticDB implementation of ConcurrentStorage.
func (*ConcurrentElastic) Count ¶
func (pDB *ConcurrentElastic) Count(options AggregateOptions) (CountRowCollection, bool, error)
Count returns number of Concurrents matching the filter defined by AggregateOptions.
type ConcurrentsStorage ¶
type ConcurrentsStorage interface { // Count returns count of concurrents based on the provided filter options. Count(o AggregateOptions) (CountRowCollection, bool, error) }
ConcurrentsStorage is an interface to get data about last concurrent connections.
type CountHistogram ¶
CountHistogram is used to split count of matched results based on provided Field within specified Interval.
type CountHistogramItem ¶
CountHistogramItem represents one row of count-based histogram results.
type CountRow ¶
type CountRow struct { Tags map[string]string Count int TimeHistogram []TimeHistogramItem CountHistogram []CountHistogramItem }
CountRow represents one row of grouped count.
type CountRowCollection ¶
type CountRowCollection []CountRow
CountRowCollection represents collection of rows of grouped count.
type ElasticDB ¶
type ElasticDB struct { Client *elastic.Client Debug bool Context context.Context // contains filtered or unexported fields }
ElasticDB represents data layer based on ElasticSearch.
func NewElasticDB ¶
NewElasticDB returns new instance of ElasticSearch DB implementation
func (*ElasticDB) UnwrapAggregation ¶
func (eDB *ElasticDB) UnwrapAggregation(docCount int64, aggregations elastic.Aggregations, groupBy []string, tags map[string]string, cb UnwrapCallback) error
UnwrapAggregation traverses through all the aggregations and calls the provided callback on the lowest level providing tags of the fields and resulting count.
func (*ElasticDB) WrapAggregation ¶
func (eDB *ElasticDB) WrapAggregation(index string, groupBy []string, search *elastic.SearchService, extras map[string]elastic.Aggregation, dateHistogramAgg *elastic.DateHistogramAggregation, agg *elastic.TermsAggregation) (*elastic.SearchService, *elastic.TermsAggregation, error)
WrapAggregation recursivelly wraps aggregations based on provided groupBy fields.
It includes any extra aggregations on the lowest level.
Initially the implementation used ElasticDB::addCompositeGroupBy(), but it was a beta feature and elastic didn't allow us to link sum aggregation to the results.
Following is a standard wrapping via SubAggregation() endorsed by official docs.
type EntitySchema ¶
type EntitySchema struct { ID int `db:"id"` ParentID sql.NullInt64 `db:"parent_id"` Name string `db:"name"` CreatedAt time.Time `db:"created_at"` UpdatedAt mysql.NullTime `db:"updated_at"` DeletedAt mysql.NullTime `db:"deleted_at"` Params map[string]*EntitySchemaParam }
EntitySchema represents definition of Entity.
type EntitySchemaCollection ¶
type EntitySchemaCollection []*EntitySchema
EntitySchemaCollection is list of EntitySchemas.
type EntitySchemaDB ¶
type EntitySchemaDB struct { MySQL *sqlx.DB Entities map[string]*EntitySchema }
EntitySchemaDB represents EntitySchemaStorage MySQL implementation.
func (*EntitySchemaDB) Cache ¶
func (eDB *EntitySchemaDB) Cache() error
Cache caches entity definitions.
func (*EntitySchemaDB) Get ¶
func (eDB *EntitySchemaDB) Get(name string) (*EntitySchema, bool, error)
Get returns EntitySchema based on provided EntityName.
type EntitySchemaParam ¶
EntitySchemaParam represents single parameter of EntitySchema.
type EntitySchemaParamsCollection ¶
type EntitySchemaParamsCollection []*EntitySchemaParam
EntitySchemaParamsCollection is list of EntitySchemaParams.
type EntitySchemaStorage ¶
type EntitySchemaStorage interface { // Get returns EntitySchema based on provided EntityName. Get(name string) (*EntitySchema, bool, error) // Cache caches entity definitions. Cache() error }
EntitySchemaStorage represents schemas storage interaface.
type Event ¶
type Event struct { ID string Category string `json:"category"` Action string `json:"action"` Token string `json:"token"` Time time.Time `json:"time"` Host string `json:"host"` IP string `json:"ip"` UserID string `json:"user_id"` URL string `json:"url"` UserAgent string `json:"user_agent"` ArticleID string `json:"article_id"` UtmSource string `json:"utm_source"` UtmCampaign string `json:"utm_campaign"` UtmContent string `json:"utm_content"` UtmMedium string `json:"utm_medium"` }
Event represents event data.
type EventElastic ¶
type EventElastic struct { DB *ElasticDB // contains filtered or unexported fields }
EventElastic is ElasticDB implementation of EventStorage.
func (*EventElastic) Actions ¶
func (eDB *EventElastic) Actions(category string) ([]string, error)
Actions lists all tracked actions under the given category.
func (*EventElastic) Cache ¶
func (eDB *EventElastic) Cache() error
Cache stores event categories and activities in memory.
func (*EventElastic) Categories ¶
func (eDB *EventElastic) Categories() ([]string, error)
Categories lists all tracked categories.
func (*EventElastic) Count ¶
func (eDB *EventElastic) Count(options AggregateOptions) (CountRowCollection, bool, error)
Count returns number of events matching the filter defined by EventOptions.
func (*EventElastic) Flags ¶
func (eDB *EventElastic) Flags() []string
Flags lists all available flags.
func (*EventElastic) List ¶
func (eDB *EventElastic) List(options ListOptions) (EventRowCollection, error)
List returns list of all events based on given EventOptions.
func (*EventElastic) Users ¶
func (eDB *EventElastic) Users() ([]string, error)
Users lists all tracked users.
type EventOptions ¶
type EventOptions struct { UserID string Action string Category string TimeAfter time.Time TimeBefore time.Time }
EventOptions represent filter options for event-related calls.
type EventRowCollection ¶
type EventRowCollection []*EventRow
EventRowCollection represents collection of rows of grouped list.
type EventRules ¶
EventRules represent map of rules with given "category/event" assigned
type EventStorage ¶
type EventStorage interface { // Count returns number of events matching the filter defined by EventOptions. Count(o AggregateOptions) (CountRowCollection, bool, error) // List returns list of all events based on given EventOptions. List(o ListOptions) (EventRowCollection, error) // Categories lists all tracked categories. Categories() ([]string, error) // Flags lists all available flags. Flags() []string // Actions lists all tracked actions under the given category. Actions(category string) ([]string, error) // Users lists all tracked users. Users() ([]string, error) // Cache creates internal cache of available categories and actions so they're not polled repeatedly. Cache() error }
EventStorage is an interface to get generic event related data.
type FilterType ¶
type FilterType string
FilterType represents special enum layer for data filtering.
func NewFilterType ¶
func NewFilterType(t string) (FilterType, error)
NewFilterType validates support for provided type and returns FilterType instance.
type Intersector ¶
Intersector responds to ability to intersect provided userID with some other collection structure.
type JSONMap ¶
JSONMap represents key-value string pairs stored as string JSON [{"key": "foo", "value": "bar"}].
type ListOptions ¶
type ListOptions struct { AggregateOptions SelectFields []string }
ListOptions represent select and filter options for listing-related calls.
type ListPageviewsOptions ¶
type ListPageviewsOptions struct { AggregateOptions SelectFields []string LoadTimespent bool }
ListPageviewsOptions represents select and filter options for listing of pageviews
type OverridableFields ¶
OverridableFields represent array of fields (key-value pairs) keyed by Rule ID.
type PCEStorage ¶
type PCEStorage interface { // Categories lists all tracked categories. Categories() ([]string, error) // Actions lists all tracked actions under the given category. Actions(category string) ([]string, error) }
PCEStorage is interface which ensures provided storage (Pageview/Commerce/Event) can return categories and actions of given category.
type Pageview ¶
type Pageview struct { ID string ArticleID string `json:"article_id"` ArticleLocked bool `json:"locked"` TitleVariant string `json:"title_variant"` ImageVariant string `json:"image_variant"` AuthorID string `json:"author_id"` UTMSource string `json:"utm_source"` UTMCampaign string `json:"utm_campaign"` UTMMedium string `json:"utm_medium"` UTMContent string `json:"utm_content"` Token string `json:"token"` Time time.Time `json:"time"` IP string `json:"ip"` UserID string `json:"user_id"` URL string `json:"url"` UserAgent string `json:"user_agent"` BrowserID string `json:"browser_id"` SessionID string `json:"remp_session_id"` Referer string `json:"referer"` Cookies bool `json:"cookies"` SignedIn bool `json:"signed_in"` Subscriber bool `json:"subscriber"` WindowWidth int `json:"window_width"` WindowHeight int `json:"window_height"` Timespent int `json:"timespent"` }
Pageview represents pageview data.
type PageviewElastic ¶
type PageviewElastic struct { DB *ElasticDB // contains filtered or unexported fields }
PageviewElastic is ElasticDB implementation of PageviewStorage.
func (*PageviewElastic) Actions ¶
func (pDB *PageviewElastic) Actions(category string) ([]string, error)
Actions lists all tracked actions under the given category.
func (*PageviewElastic) Avg ¶
func (pDB *PageviewElastic) Avg(options AggregateOptions) (AvgRowCollection, bool, error)
Avg returns average count of Pageviews/Timespent records matching the filter defined by AggregateOptions.
func (*PageviewElastic) Categories ¶
func (pDB *PageviewElastic) Categories() ([]string, error)
Categories lists all tracked categories.
func (*PageviewElastic) Count ¶
func (pDB *PageviewElastic) Count(options AggregateOptions) (CountRowCollection, bool, error)
Count returns number of Pageviews matching the filter defined by PageviewOptions.
func (*PageviewElastic) Flags ¶
func (pDB *PageviewElastic) Flags() []string
Flags lists all available flags.
func (*PageviewElastic) List ¶
func (pDB *PageviewElastic) List(options ListPageviewsOptions) (PageviewRowCollection, error)
List returns list of all Pageviews based on given PageviewOptions.
func (*PageviewElastic) Sum ¶
func (pDB *PageviewElastic) Sum(options AggregateOptions) (SumRowCollection, bool, error)
Sum returns number of Pageviews matching the filter defined by AggregateOptions.
func (*PageviewElastic) Unique ¶
func (pDB *PageviewElastic) Unique(options AggregateOptions, item string) (CountRowCollection, bool, error)
Unique returns unique count of Pageviews records matching the filter defined by AggregateOptions.
func (*PageviewElastic) Users ¶
func (pDB *PageviewElastic) Users() ([]string, error)
Users lists all tracked users.
type PageviewOptions ¶
type PageviewOptions struct { Action string IDs []string FilterBy string GroupBy []string TimeAfter time.Time TimeBefore time.Time }
PageviewOptions represent filter options for pageview-related calls.
type PageviewRow ¶
PageviewRow represents one row of grouped list.
type PageviewRowCollection ¶
type PageviewRowCollection []*PageviewRow
PageviewRowCollection represents collection of rows of grouped list.
type PageviewStorage ¶
type PageviewStorage interface { // Count returns count of pageviews based on the provided filter options. Count(o AggregateOptions) (CountRowCollection, bool, error) // Sum returns sum of pageviews based on the provided filter options. Sum(o AggregateOptions) (SumRowCollection, bool, error) // Avg returns average of pageviews based on the provided filter options. Avg(o AggregateOptions) (AvgRowCollection, bool, error) // Unique returns unique count of given item based on the provided filter options. Unique(o AggregateOptions, item string) (CountRowCollection, bool, error) // List returns list of all pageviews based on given PageviewOptions. List(o ListPageviewsOptions) (PageviewRowCollection, error) // Categories lists all tracked categories. Categories() ([]string, error) // Flags lists all available flags. Flags() []string // Actions lists all tracked actions under the given category. Actions(category string) ([]string, error) }
PageviewStorage is an interface to get pageview events related data.
type Property ¶
type Property struct { ID int UUID string Name string AccountID int `db:"account_id"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` }
Property structure.
type PropertyCollection ¶
type PropertyCollection []*Property
PropertyCollection is list of Properties.
type PropertyDB ¶
PropertyDB represents Property's storage MySQL implementation.
func (*PropertyDB) Cache ¶
func (pDB *PropertyDB) Cache() error
Cache stores the properties in memory.
type PropertyStorage ¶
type PropertyStorage interface { // Get returns instance of Property based on the given UUID. Get(UUID string) (*Property, bool, error) }
PropertyStorage represents property's storage interface.
type RuleOverrides ¶
RuleOverrides represent key-value string pairs for overriding stored tags in segment rules.
type Segment ¶
type Segment struct { ID int SegmentData CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` Group SegmentGroup `db:"segment_group"` Rules []SegmentRule `db:"segment_rules"` }
Segment structure.
type SegmentBlueprintDB ¶
type SegmentBlueprintDB struct { EventStorage EventStorage PageviewStorage PageviewStorage CommerceStorage CommerceStorage }
SegmentBlueprintDB represents SegmentBlueprintStorage implementation.
func (*SegmentBlueprintDB) Get ¶
func (sbdb *SegmentBlueprintDB) Get() (SegmentBlueprintTableCollection, error)
Get returns all criteria / blueprint for creating new or editing segment.
type SegmentBlueprintStorage ¶
type SegmentBlueprintStorage interface { // Get returns SegmentBlueprintTableCollection. Get() (SegmentBlueprintTableCollection, error) }
SegmentBlueprintStorage represents interface for segment blueprint related interactions.
type SegmentBlueprintTable ¶
type SegmentBlueprintTable struct { Table string Fields []string Criteria SegmentBlueprintTableCriterionCollection }
SegmentBlueprintTable represents blueprint for one segment field (table).
type SegmentBlueprintTableCollection ¶
type SegmentBlueprintTableCollection []*SegmentBlueprintTable
SegmentBlueprintTableCollection is list of SegmentBlueprintTable.
type SegmentBlueprintTableCriterion ¶
type SegmentBlueprintTableCriterion struct { Key string Label string Params map[string]SegmentBlueprintTableCriterionParam Fields []string }
SegmentBlueprintTableCriterion represents one criterion of segment blueprint.
type SegmentBlueprintTableCriterionCollection ¶
type SegmentBlueprintTableCriterionCollection []*SegmentBlueprintTableCriterion
SegmentBlueprintTableCriterionCollection is list of SegmentBlueprintTableCriterion.
type SegmentBlueprintTableCriterionParam ¶
type SegmentBlueprintTableCriterionParam struct { Type string `json:"type"` Required bool `json:"required"` Default *string `json:"default"` Help string `json:"help"` Label string `json:"label"` Group *string `json:"group"` Available []string `json:"available"` }
SegmentBlueprintTableCriterionParam represents one parameter of Segment Criterion.
type SegmentCache ¶
type SegmentCache map[int]*SegmentRuleCache
SegmentCache represents event count information for SegmentRules indexed by SegmentRule ID.
type SegmentCriteria ¶
type SegmentCriteria struct { Version string Nodes SegmentCriteriaOperatorNodeCollection }
SegmentCriteria represents segment's criteria.
func (*SegmentCriteria) Scan ¶
func (sc *SegmentCriteria) Scan(criteria string) error
Scan scans provided input to SegmentCriteria.
type SegmentCriteriaNode ¶
type SegmentCriteriaNode struct { Type string Key string Negation bool Values map[string]interface{} }
SegmentCriteriaNode represents one node of segment's criteria.
type SegmentCriteriaNodeCollection ¶
type SegmentCriteriaNodeCollection []SegmentCriteriaNode
SegmentCriteriaNodeCollection represents collection of SegmentCriteriaNode.
type SegmentCriteriaOperatorNode ¶
type SegmentCriteriaOperatorNode struct { Type string Operator string Nodes SegmentCriteriaNodeCollection }
SegmentCriteriaOperatorNode represents one operator node of criteria. TODO: merge SegmentCriteriaOperatorNode and SegmentCriteriaNode into one type?
type SegmentCriteriaOperatorNodeCollection ¶
type SegmentCriteriaOperatorNodeCollection []SegmentCriteriaOperatorNode
SegmentCriteriaOperatorNodeCollection represents collection of SegmentCriteriaOperatorNode.
type SegmentCriteriaValuesDatetime ¶
type SegmentCriteriaValuesDatetime struct { Type string Absolute *SegmentCriteriaValuesDatetimeAbsolute Interval *SegmentCriteriaValuesDatetimeInterval }
SegmentCriteriaValuesDatetime represents datetime type of criteria values.
func (*SegmentCriteriaValuesDatetime) Scan ¶
func (scvd *SegmentCriteriaValuesDatetime) Scan(datetime interface{}) error
Scan scans datetime from values to SegmentCriteriaValuesDatetime type.
type SegmentCriteriaValuesDatetimeAbsolute ¶
SegmentCriteriaValuesDatetimeAbsolute represents absolute datetime type of criteria values.
type SegmentCriteriaValuesDatetimeInterval ¶
SegmentCriteriaValuesDatetimeInterval represents interval datetime type of criteria values.
type SegmentDB ¶
type SegmentDB struct { MySQL *sqlx.DB CountCache *cache.Cache EventStorage EventStorage PageviewStorage PageviewStorage CommerceStorage CommerceStorage Segments map[string]*Segment ExplicitSegmentsUsers map[string]UserSet ExplicitSegmentsBrowsers map[string]BrowserSet }
SegmentDB represents Segment's storage implementation.
func (*SegmentDB) BuildRules ¶
func (sDB *SegmentDB) BuildRules(s *Segment) ([]SegmentRule, bool, error)
BuildRules builds segment rules from segment criteria.
func (*SegmentDB) CacheExplicitSegments ¶
CacheExplicitSegments caches segments data in memory
func (*SegmentDB) CheckBrowser ¶
func (sDB *SegmentDB) CheckBrowser(segment *Segment, browserID string, now time.Time, cache SegmentCache, ro RuleOverrides) (SegmentCache, bool, error)
CheckBrowser verifies presence of browser within provided segment.
func (*SegmentDB) CheckUser ¶
func (sDB *SegmentDB) CheckUser(segment *Segment, userID string, now time.Time, cache SegmentCache, ro RuleOverrides) (SegmentCache, bool, error)
CheckUser verifies presence of user within provided segment.
func (*SegmentDB) Create ¶
func (sDB *SegmentDB) Create(sd SegmentData) (*Segment, error)
Create creates new Segment from provided data and returns it.
func (*SegmentDB) EventRules ¶
func (sDB *SegmentDB) EventRules() EventRules
EventRules returns map of rules assigned to given "category/event" key
func (*SegmentDB) GetByID ¶
GetByID returns instance of Segment based on the given segment ID. TODO: how to get segment from sDB.Segments?
func (*SegmentDB) Groups ¶
func (sDB *SegmentDB) Groups() (SegmentGroupCollection, error)
Groups returns all available segment groups configured via Beam admin.
func (*SegmentDB) List ¶
func (sDB *SegmentDB) List() (SegmentCollection, error)
List returns all available segments configured via Beam admin.
func (*SegmentDB) OverridableFields ¶
func (sDB *SegmentDB) OverridableFields() OverridableFields
OverridableFields returns array of fields that expect to be overriden when rule is checked.
func (*SegmentDB) Related ¶
func (sDB *SegmentDB) Related(criteria SegmentCriteria) (SegmentCollection, error)
Related compares provided criteria to existing segments and returns segments with same criteria.
type SegmentData ¶
type SegmentData struct { Name string Code string Active bool SegmentGroupID int `db:"segment_group_id"` Criteria sql.NullString }
SegmentData contains data of segment
type SegmentGroup ¶
type SegmentGroup struct { ID int Name string Code string Type string Sorting int CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` }
SegmentGroup represents metadata about group, in which Segments can be placed in.
type SegmentGroupCollection ¶
type SegmentGroupCollection []*SegmentGroup
SegmentGroupCollection is list of SegmentGroups.
type SegmentRule ¶
type SegmentRule struct { ID int ParentID sql.NullInt64 `db:"parent_id"` SegmentID int `db:"segment_id"` EventCategory string `db:"event_category"` EventAction string `db:"event_action"` Timespan sql.NullInt64 Operator string Operator2 *string Count int Count2 *int CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` Fields JSONMap Flags JSONMap Segment *Segment `db:"segment"` // contains filtered or unexported fields }
SegmentRule represent single rule of a Segment
func (*SegmentRule) CacheDuration ¶
func (sr *SegmentRule) CacheDuration(count int) (time.Duration, bool)
CacheDuration returns duration to cache the item for and whether the item should be cached at all.
type SegmentRuleCache ¶
SegmentRuleCache represents event count information for single SegmentRule.
type SegmentStorage ¶
type SegmentStorage interface { // Create creates new Segment from provided data and returns it. Create(sd SegmentData) (*Segment, error) // Update updates existing Segment from provided data and returns it. Update(id int, sd SegmentData) (*Segment, bool, error) // Get returns instance of Segment based on the given code. Get(code string) (*Segment, bool, error) // GetByID returns instance of Segment based on the given segment ID. GetByID(id int) (*Segment, bool, error) // List returns all available segments configured via Beam admin. List() (SegmentCollection, error) // Groups returns all available segment groups. Groups() (SegmentGroupCollection, error) // CheckUser verifies presence of user within provided segment. CheckUser(segment *Segment, userID string, now time.Time, cache SegmentCache, ro RuleOverrides) (SegmentCache, bool, error) // CheckBrowser verifies presence of browser within provided segment. CheckBrowser(segment *Segment, browserID string, now time.Time, cache SegmentCache, ro RuleOverrides) (SegmentCache, bool, error) // Users return list of all users within segment. Users(segment *Segment, now time.Time, ro RuleOverrides) ([]string, error) // CountAll returns count of unique tracked users. CountAll() (int, error) // EventRules returns map of rules assigned to given "category/event" key. EventRules() EventRules // OverridableFields returns array of fields that expect to be overriden when rule is checked. OverridableFields() OverridableFields // Flags returns array of flags available for rules. Flags() Flags // Related compares provided criteria to existing segments and returns segments with same criteria. Related(SegmentCriteria) (SegmentCollection, error) // BuildRules builds segment rules from segment criteria. BuildRules(segment *Segment) ([]SegmentRule, bool, error) }
SegmentStorage represents interface to get segment related data.
type SumRow ¶
type SumRow struct { Tags map[string]string Sum float64 TimeHistogram []TimeHistogramItem }
SumRow represents one row of grouped sum.
type SumRowCollection ¶
type SumRowCollection []SumRow
SumRowCollection represents collection of rows of grouped sum.
type TimeHistogram ¶
TimeHistogram is used to split response to time-based buckets.
type TimeHistogramItem ¶
TimeHistogramItem represents one row of time-based histogram results.
type UnwrapCallback ¶
type UnwrapCallback func(tags map[string]string, docCount int64, aggregations elastic.Aggregations) error
UnwrapCallback represents final callback that should be called when all aggregations are unwrapped and the final set of tags and count can be provided