analytics

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2022 License: Apache-2.0 Imports: 8 Imported by: 4

Documentation

Index

Constants

View Source
const (
	EmptyFieldErr string = `Field is empty`
)
View Source
const SCHEMA_URI_REGEX string = `` /* 162-byte string literal not displayed */

Variables

This section is empty.

Functions

This section is empty.

Types

type Contexts

type Contexts struct {
	Schema string
	Data   []SelfDescribingData
}

type KeyFunctionPair

type KeyFunctionPair struct {
	Key           string
	ParseFunction ValueParser
}

type KeyVal

type KeyVal struct {
	Key   string
	Value interface{}
}

type ParsedEvent

type ParsedEvent []string

func ParseEvent

func ParseEvent(event string) (ParsedEvent, error)

ParseEvent takes a Snowplow Enriched event tsv string as input, and returns a 'ParsedEvent' typed slice of strings. Methods may then be called on the resulting ParsedEvent type to transform the event, or a subset of the event to Map or Json.

func (ParsedEvent) GetContextValue added in v0.2.0

func (event ParsedEvent) GetContextValue(contextName string, path ...interface{}) (interface{}, error)

GetContextValue returns the value for a provided atomic field inside an event's contexts or derived_contexts

func (ParsedEvent) GetSubsetJson

func (event ParsedEvent) GetSubsetJson(fields ...string) ([]byte, error)

GetSubsetJson returns a JSON object containing a subset of the event, containing only the atomic fields provided, without processing the rest of the event. For custom events and contexts, only "unstruct_event", "contexts", or "derived_contexts" may be provided, which will produce the entire data object for that field. For contexts, the resultant map will contain all occurrences of all contexts within the provided field.

func (ParsedEvent) GetSubsetMap

func (event ParsedEvent) GetSubsetMap(fields ...string) (map[string]interface{}, error)

GetSubsetMap returns a map of a subset of the event, containing only the atomic fields provided, without processing the rest of the event. For custom events and contexts, only "unstruct_event", "contexts", or "derived_contexts" may be provided, which will produce the entire data object for that field. For contexts, the resultant map will contain all occurrences of all contexts within the provided field.

func (ParsedEvent) GetUnstructEventValue added in v0.2.0

func (event ParsedEvent) GetUnstructEventValue(path ...interface{}) (interface{}, error)

GetUnstructEventValue returns the value for a provided atomic field inside an event's unstruct_event field

func (ParsedEvent) GetValue

func (event ParsedEvent) GetValue(field string) (interface{}, error)

GetValue returns the value for a provided atomic field, without processing the rest of the event. For unstruct_event, it returns a map of only the data for the unstruct event.

func (ParsedEvent) ToJson

func (event ParsedEvent) ToJson() ([]byte, error)

ToJson transforms a valid Snowplow ParsedEvent to a JSON object.

func (ParsedEvent) ToJsonWithGeo

func (event ParsedEvent) ToJsonWithGeo() ([]byte, error)

ToJsonWithGeo adds the geo_location field, and transforms a valid Snowplow ParsedEvent to a JSON object.

func (ParsedEvent) ToMap

func (event ParsedEvent) ToMap() (map[string]interface{}, error)

ToMap transforms a valid Snowplow ParsedEvent to a Go map.

func (ParsedEvent) ToMapWithGeo

func (event ParsedEvent) ToMapWithGeo() (map[string]interface{}, error)

ToMapWithGeo adds the geo_location field, and transforms a valid Snowplow ParsedEvent to a Go map.

type SchemaParts

type SchemaParts struct {
	Protocol string
	Vendor   string
	Name     string
	Format   string
	Model    string
	Revision string
}

type SelfDescribingData

type SelfDescribingData struct {
	Schema string
	Data   map[string]interface{} // TODO: See if leaving data as a string or byte array would work, and would be faster.
}

type UnstructEvent

type UnstructEvent struct {
	Schema string
	Data   SelfDescribingData
}

type ValueParser

type ValueParser func(string, string) ([]KeyVal, error)

Jump to

Keyboard shortcuts

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