Documentation ¶
Index ¶
- Constants
- func OptionAppId(appId string) func(t *Tracker)
- func OptionBase64Encode(base64Encode bool) func(t *Tracker)
- func OptionByteLimitGet(byteLimitGet int) func(e *Emitter)
- func OptionByteLimitPost(byteLimitPost int) func(e *Emitter)
- func OptionCallback(callback func(successCount []CallbackResult, failureCount []CallbackResult)) func(e *Emitter)
- func OptionHttpClient(client *http.Client) func(e *Emitter)
- func OptionNamespace(namespace string) func(t *Tracker)
- func OptionPlatform(platform string) func(t *Tracker)
- func OptionProtocol(protocol string) func(e *Emitter)
- func OptionRequestType(requestType string) func(e *Emitter)
- func OptionSendLimit(sendLimit int) func(e *Emitter)
- func OptionSubject(subject *Subject) func(t *Tracker)
- func RequireCollectorUri(collectorUri string) func(e *Emitter)
- func RequireEmitter(emitter *Emitter) func(t *Tracker)
- func RequireStorage(storage storageiface.Storage) func(e *Emitter)
- type CallbackResult
- type EcommerceTransactionEvent
- type EcommerceTransactionItemEvent
- type Emitter
- func (e *Emitter) Add(payload payload.Payload)
- func (e *Emitter) Flush()
- func (e Emitter) GetCollectorUrl() string
- func (e Emitter) IsSending() bool
- func (e *Emitter) SetCollectorUri(collectorUri string)
- func (e *Emitter) SetProtocol(protocol string)
- func (e *Emitter) SetRequestType(requestType string)
- func (e *Emitter) Stop()
- type PageViewEvent
- type ScreenViewEvent
- type SelfDescribingEvent
- type SelfDescribingJson
- func (s SelfDescribingJson) Get() map[string]interface{}
- func (s *SelfDescribingJson) SetDataWithMap(data map[string]interface{})
- func (s *SelfDescribingJson) SetDataWithPayload(data payload.Payload)
- func (s *SelfDescribingJson) SetDataWithSelfDescribingJson(data SelfDescribingJson)
- func (s SelfDescribingJson) String() string
- type SendResult
- type StructuredEvent
- type Subject
- func (s Subject) Get() map[string]string
- func (s Subject) SetColorDepth(depth int)
- func (s Subject) SetDomainUserId(domainUserId string)
- func (s Subject) SetIpAddress(ipAddress string)
- func (s Subject) SetLanguage(language string)
- func (s Subject) SetNetworkUserId(networkUserId string)
- func (s Subject) SetScreenResolution(width int, height int)
- func (s Subject) SetTimeZone(timezone string)
- func (s Subject) SetUserId(userId string)
- func (s Subject) SetUseragent(useragent string)
- func (s Subject) SetViewPort(width int, height int)
- type TimingEvent
- type Tracker
- func (t *Tracker) BlockingFlush(flushAttempts int, flushSleepTimeMs int) int
- func (t Tracker) FlushEmitter()
- func (t *Tracker) SetAppId(appId string)
- func (t *Tracker) SetBase64Encode(base64Encode bool)
- func (t *Tracker) SetEmitter(emitter *Emitter)
- func (t *Tracker) SetNamespace(namespace string)
- func (t *Tracker) SetPlatform(platform string)
- func (t *Tracker) SetSubject(subject *Subject)
- func (t Tracker) TrackEcommerceTransaction(e EcommerceTransactionEvent)
- func (t Tracker) TrackPageView(e PageViewEvent)
- func (t Tracker) TrackScreenView(e ScreenViewEvent)
- func (t Tracker) TrackSelfDescribingEvent(e SelfDescribingEvent)
- func (t Tracker) TrackStructEvent(e StructuredEvent)
- func (t Tracker) TrackTiming(e TimingEvent)
Constants ¶
const ( TRACKER_VERSION = "golang-3.0.0" // POST Requests POST_PROTOCOL_VENDOR = "com.snowplowanalytics.snowplow" POST_PROTOCOL_VERSION = "tp2" POST_CONTENT_TYPE = "application/json; charset=utf-8" // GET Requests GET_PROTOCOL_PATH = "i" // Schema Versions SCHEMA_PAYLOAD_DATA = "iglu:com.snowplowanalytics.snowplow/payload_data/jsonschema/1-0-4" SCHEMA_CONTEXTS = "iglu:com.snowplowanalytics.snowplow/contexts/jsonschema/1-0-1" SCHEMA_UNSTRUCT_EVENT = "iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0" SCHEMA_SCREEN_VIEW = "iglu:com.snowplowanalytics.snowplow/screen_view/jsonschema/1-0-0" SCHEMA_USER_TIMINGS = "iglu:com.snowplowanalytics.snowplow/timing/jsonschema/1-0-0" // Event Types EVENT_PAGE_VIEW = "pv" EVENT_STRUCTURED = "se" EVENT_UNSTRUCTURED = "ue" EVENT_ECOMM = "tr" EVENT_ECOMM_ITEM = "ti" // General SCHEMA = "schema" DATA = "data" EVENT = "e" EID = "eid" TIMESTAMP = "dtm" SENT_TIMESTAMP = "stm" TRUE_TIMESTAMP = "ttm" T_VERSION = "tv" APP_ID = "aid" NAMESPACE = "tna" PLATFORM = "p" CONTEXT = "co" CONTEXT_ENCODED = "cx" UNSTRUCTURED = "ue_pr" UNSTRUCTURED_ENCODED = "ue_px" // Subject class UID = "uid" RESOLUTION = "res" VIEWPORT = "vp" COLOR_DEPTH = "cd" TIMEZONE = "tz" LANGUAGE = "lang" IP_ADDRESS = "ip" USERAGENT = "ua" DOMAIN_UID = "duid" NETWORK_UID = "tnuid" // Page View PAGE_URL = "url" PAGE_TITLE = "page" PAGE_REFR = "refr" // Structured Event SE_CATEGORY = "se_ca" SE_ACTION = "se_ac" SE_LABEL = "se_la" SE_PROPERTY = "se_pr" SE_VALUE = "se_va" // Ecomm Transaction TR_ID = "tr_id" TR_TOTAL = "tr_tt" TR_AFFILIATION = "tr_af" TR_TAX = "tr_tx" TR_SHIPPING = "tr_sh" TR_CITY = "tr_ci" TR_STATE = "tr_st" TR_COUNTRY = "tr_co" TR_CURRENCY = "tr_cu" // Transaction Item TI_ITEM_ID = "ti_id" TI_ITEM_SKU = "ti_sk" TI_ITEM_NAME = "ti_nm" TI_ITEM_CATEGORY = "ti_ca" TI_ITEM_PRICE = "ti_pr" TI_ITEM_QUANTITY = "ti_qu" TI_ITEM_CURRENCY = "ti_cu" // Screen View SV_ID = "id" SV_NAME = "name" // User Timing UT_CATEGORY = "category" UT_VARIABLE = "variable" UT_TIMING = "timing" UT_LABEL = "label" )
const ( DEFAULT_REQ_TYPE = "POST" DEFAULT_PROTOCOL = "http" DEFAULT_SEND_LIMIT = 500 DEFAULT_BYTE_LIMIT_GET = 40000 DEFAULT_BYTE_LIMIT_POST = 40000 DEFAULT_DB_NAME = "events.db" POST_WRAPPER_BYTES = 88 // "schema":"iglu:com.snowplowanalytics.snowplow/payload_data/jsonschema/1-0-3","data":[] POST_STM_BYTES = 22 // "stm":"1443452851000" )
const ( DEFAULT_PLATFORM = "srv" DEFAULT_BASE_64 = true )
Variables ¶
This section is empty.
Functions ¶
func OptionAppId ¶
OptionAppId sets the Tracker Application ID
func OptionBase64Encode ¶
OptionBase64Encode sets the Tracker base64encode
func OptionByteLimitGet ¶
OptionByteLimitGet sets the byte limit for GET requests.
func OptionByteLimitPost ¶
OptionByteLimitPost sets the byte limit for POST requests.
func OptionCallback ¶
func OptionCallback(callback func(successCount []CallbackResult, failureCount []CallbackResult)) func(e *Emitter)
OptionCallback sets a custom callback for the emitter loop.
func OptionHttpClient ¶
OptionHttpClient sets a custom client for HTTP connections.
func OptionNamespace ¶
OptionNamespace sets the Tracker Namespace
func OptionPlatform ¶
OptionPlatform sets the Tracker Platform
func OptionProtocol ¶
OptionProtocol sets the protocol type to use (http or https).
func OptionRequestType ¶
OptionRequestType sets the request type to use (GET or POST).
func OptionSendLimit ¶
OptionSendLimit sets the send limit for the emitter.
func OptionSubject ¶
OptionSubject sets the Tracker Subject
func RequireCollectorUri ¶
RequireCollectorUri sets the Emitters collector URI.
func RequireEmitter ¶
RequireEmitter sets the Tracker Emitter
func RequireStorage ¶
func RequireStorage(storage storageiface.Storage) func(e *Emitter)
RequireStorage sets a custom event Storage target which implements the Storage interface
Types ¶
type CallbackResult ¶
type EcommerceTransactionEvent ¶
type EcommerceTransactionEvent struct { OrderId *string // Required TotalValue *float64 // Required Affiliation *string // Optional TaxValue *float64 // Optional Shipping *float64 // Optional City *string // Optional State *string // Optional Country *string // Optional Currency *string // Optional Items []EcommerceTransactionItemEvent // Optional Timestamp *int64 // Optional EventId *string // Optional TrueTimestamp *int64 // Optional Contexts []SelfDescribingJson // Optional Subject *Subject // Optional }
func (EcommerceTransactionEvent) Get ¶
func (e EcommerceTransactionEvent) Get() payload.Payload
Get returns the event payload.
func (*EcommerceTransactionEvent) Init ¶
func (e *EcommerceTransactionEvent) Init()
Init checks and validates the struct.
func (*EcommerceTransactionEvent) SetSubjectIfNil ¶
func (e *EcommerceTransactionEvent) SetSubjectIfNil(subject *Subject)
SetSubjectIfNil will set the event level subject if a Subject isn't already set
type EcommerceTransactionItemEvent ¶
type EcommerceTransactionItemEvent struct { Sku *string // Required Price *float64 // Required Quantity *int64 // Required Name *string // Optional Category *string // Optional EventId *string // Optional Contexts []SelfDescribingJson // Optional Subject *Subject // Optional }
func (EcommerceTransactionItemEvent) Get ¶
func (e EcommerceTransactionItemEvent) Get() payload.Payload
Get returns the event payload.
func (*EcommerceTransactionItemEvent) Init ¶
func (e *EcommerceTransactionItemEvent) Init()
Init checks and validates the struct.
func (*EcommerceTransactionItemEvent) SetSubjectIfNil ¶
func (e *EcommerceTransactionItemEvent) SetSubjectIfNil(subject *Subject)
SetSubjectIfNil will set the event level subject if a Subject isn't already set
type Emitter ¶
type Emitter struct { CollectorUri string CollectorUrl url.URL RequestType string Protocol string SendLimit int ByteLimitGet int ByteLimitPost int Storage storageiface.Storage SendChannel chan bool Callback func(successCount []CallbackResult, failureCount []CallbackResult) HttpClient *http.Client }
func InitEmitter ¶
InitEmitter creates a new Emitter object which handles storing and sending Snowplow Events.
func (*Emitter) Flush ¶
func (e *Emitter) Flush()
Flush will attempt to start the send loop regardless of an event coming in.
func (Emitter) GetCollectorUrl ¶
GetCollectorUrl returns the stringified collector URL.
func (*Emitter) SetCollectorUri ¶
SetCollectorUri sets a new Collector URI and updates the Collector URL.
func (*Emitter) SetProtocol ¶
SetProtocol sets a new Protocol and updates the Collector URL.
func (*Emitter) SetRequestType ¶
SetRequestType sets a new Request Type and updates the Collector URL.
type PageViewEvent ¶
type PageViewEvent struct { PageUrl *string // Required PageTitle *string // Optional Referrer *string // Optional Timestamp *int64 // Optional EventId *string // Optional TrueTimestamp *int64 // Optional Contexts []SelfDescribingJson // Optional Subject *Subject // Optional }
func (PageViewEvent) Get ¶
func (e PageViewEvent) Get() payload.Payload
Get returns the event payload.
func (*PageViewEvent) SetSubjectIfNil ¶
func (e *PageViewEvent) SetSubjectIfNil(subject *Subject)
SetSubjectIfNil will set the event level subject if a Subject isn't already set
type ScreenViewEvent ¶
type ScreenViewEvent struct { Name *string // Optional Id *string // Optional Timestamp *int64 // Optional EventId *string // Optional TrueTimestamp *int64 // Optional Contexts []SelfDescribingJson // Optional Subject *Subject // Optional }
func (ScreenViewEvent) Get ¶
func (e ScreenViewEvent) Get() SelfDescribingEvent
Get returns the event payload.
func (*ScreenViewEvent) Init ¶
func (e *ScreenViewEvent) Init()
Init checks and validates the struct.
type SelfDescribingEvent ¶
type SelfDescribingEvent struct { Event *SelfDescribingJson // Required Timestamp *int64 // Optional EventId *string // Optional TrueTimestamp *int64 // Optional Contexts []SelfDescribingJson // Optional Subject *Subject // Optional }
func (SelfDescribingEvent) Get ¶
func (e SelfDescribingEvent) Get(base64Encode bool) payload.Payload
Get returns the event payload.
func (*SelfDescribingEvent) Init ¶
func (e *SelfDescribingEvent) Init()
Init checks and validates the struct.
func (*SelfDescribingEvent) SetSubjectIfNil ¶
func (e *SelfDescribingEvent) SetSubjectIfNil(subject *Subject)
SetSubjectIfNil will set the event level subject if a Subject isn't already set
type SelfDescribingJson ¶
type SelfDescribingJson struct {
// contains filtered or unexported fields
}
func InitSelfDescribingJson ¶
func InitSelfDescribingJson(schema string, data interface{}) *SelfDescribingJson
InitSelfDescribingJson creates a new SelfDescribingJson object.
func (SelfDescribingJson) Get ¶
func (s SelfDescribingJson) Get() map[string]interface{}
Get wraps the schema and data into a JSON.
func (*SelfDescribingJson) SetDataWithMap ¶
func (s *SelfDescribingJson) SetDataWithMap(data map[string]interface{})
SetDataWithMap updates the structs data to a new map.
func (*SelfDescribingJson) SetDataWithPayload ¶
func (s *SelfDescribingJson) SetDataWithPayload(data payload.Payload)
SetDataWithPayload updates the structs data to the contents of a Payload object.
func (*SelfDescribingJson) SetDataWithSelfDescribingJson ¶
func (s *SelfDescribingJson) SetDataWithSelfDescribingJson(data SelfDescribingJson)
SetDataWithSelfDescribingJson updates the structs data to a JSON. Used for nesting SelfDescribingJsons.
func (SelfDescribingJson) String ¶
func (s SelfDescribingJson) String() string
String returns the JSON as a String.
type SendResult ¶
type SendResult struct {
// contains filtered or unexported fields
}
type StructuredEvent ¶
type StructuredEvent struct { Category *string // Required Action *string // Required Label *string // Optional Property *string // Optional Value *float64 // Optional Timestamp *int64 // Optional EventId *string // Optional TrueTimestamp *int64 // Optional Contexts []SelfDescribingJson // Optional Subject *Subject // Optional }
func (StructuredEvent) Get ¶
func (e StructuredEvent) Get() payload.Payload
Get returns the event payload.
func (*StructuredEvent) Init ¶
func (e *StructuredEvent) Init()
Init checks and validates the struct.
func (*StructuredEvent) SetSubjectIfNil ¶
func (e *StructuredEvent) SetSubjectIfNil(subject *Subject)
SetSubjectIfNil will set the event level subject if a Subject isn't already set
type Subject ¶
type Subject struct {
// contains filtered or unexported fields
}
func (Subject) SetColorDepth ¶
SetColorDepth adds the color-depth measurement to the key-value store.
func (Subject) SetDomainUserId ¶
SetDomainUserId adds a domain user id to the key-value store.
func (Subject) SetIpAddress ¶
SetIpAddress adds an ip address to the key-value store.
func (Subject) SetLanguage ¶
SetLanguage adds a language to the key-value store.
func (Subject) SetNetworkUserId ¶
SetNetworkUserId adds a network user id to the key-value store.
func (Subject) SetScreenResolution ¶
SetScreenResolution adds the screen-resolution mesaurement to the key-value store.
func (Subject) SetTimeZone ¶
SetTimeZone adds a timezone to the key-value store.
func (Subject) SetUseragent ¶
SetUseragent adds a useragent to the key-value store.
func (Subject) SetViewPort ¶
SetViewPort adds the view-port measurement to the key-value store.
type TimingEvent ¶
type TimingEvent struct { Category *string // Required Variable *string // Required Timing *int64 // Required Label *string // Optional Timestamp *int64 // Optional EventId *string // Optional TrueTimestamp *int64 // Optional Contexts []SelfDescribingJson // Optional Subject *Subject // Optional }
func (TimingEvent) Get ¶
func (e TimingEvent) Get() SelfDescribingEvent
Get returns the event payload.
type Tracker ¶
type Tracker struct { Emitter *Emitter Subject *Subject Namespace string AppId string Platform string Base64Encode bool }
func InitTracker ¶
InitTracker creates a new tracker instance linked to an emitter and subject. Will assert that the Emitter is valid and not nil.
func (*Tracker) BlockingFlush ¶
BlockingFlush will block the executing thread until the tracker has fired all events from the queue. Useful for short-lived applications that have to wait for events to be fired.
func (Tracker) FlushEmitter ¶
func (t Tracker) FlushEmitter()
FlushEmitter will force-send all events in the emitter buffer.
func (*Tracker) SetBase64Encode ¶
SetBase64Encode updates whether to base64 encode contexts and unstructured events.
func (*Tracker) SetEmitter ¶
SetEmitter updates the tracker with a new emitter.
func (*Tracker) SetNamespace ¶
SetNamespace updates the Tracker namespace value.
func (*Tracker) SetPlatform ¶
SetPlatform updates the platform from which the event is fired.
func (*Tracker) SetSubject ¶
SetSubject updates the tracker with a new subject.
func (Tracker) TrackEcommerceTransaction ¶
func (t Tracker) TrackEcommerceTransaction(e EcommerceTransactionEvent)
TrackEcommerceTransaction sends an ecommerce transaction event.
func (Tracker) TrackPageView ¶
func (t Tracker) TrackPageView(e PageViewEvent)
TrackPageView sends a page view event.
func (Tracker) TrackScreenView ¶
func (t Tracker) TrackScreenView(e ScreenViewEvent)
TrackScreenView sends a screen view event.
func (Tracker) TrackSelfDescribingEvent ¶
func (t Tracker) TrackSelfDescribingEvent(e SelfDescribingEvent)
TrackSelfDescribingEvent sends a self-described event.
func (Tracker) TrackStructEvent ¶
func (t Tracker) TrackStructEvent(e StructuredEvent)
TrackStructEvent sends a structured event.
func (Tracker) TrackTiming ¶
func (t Tracker) TrackTiming(e TimingEvent)
TrackTiming sends a timing event.