analytics

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2018 License: Apache-2.0 Imports: 3 Imported by: 44

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OnError = func(err error) {}

OnError is called whenever there was a problem sending analytics. By default errors are simply ignored.

Functions

func Disable

func Disable()

Disable turns off Google Analytics tracking.

func Enable

func Enable(ctx context.Context, clientID string, version AppVersion)

Enable turns on Google Analytics tracking functionality using the given clientID and version.

func Flush

func Flush()

Flush flushes any pending Payloads to be sent to the Google Analytics server.

func Send

func Send(p Payload)

Send queues the Payload p to be sent to the Google Analytics server if analytics is enabled with a prior call to Enable().

func SendBug

func SendBug(id int, extras ...Payload)

SendBug sends an event indicating that a known bug has been hit.

func SendEvent

func SendEvent(category, action, label string, extras ...Payload)

SendEvent sends the specific event to the Google Analytics server (if enabled).

func SendException

func SendException(description string, fatal bool, extras ...Payload)

SendException sends the exception to the Google Analytics server (if enabled).

Types

type AppVersion

type AppVersion struct {
	Name, Build         string
	Major, Minor, Point int
}

AppVersion holds information about the currently running application and its version.

type Count

type Count int

Count is a payload value for count values, usually number of items. Examples: Number of commands in a capture.

type ErrPayloadTooLarge

type ErrPayloadTooLarge struct {
	Payload Payload
	Size    int
}

ErrPayloadTooLarge is the error returned when attempting to send a payload that is too large to send.

func (ErrPayloadTooLarge) Error

func (e ErrPayloadTooLarge) Error() string

type Event

type Event struct {
	Category string
	Action   string
	Label    string
	Value    int
}

Event is a payload value that represents a single event.

type Exception

type Exception struct {
	Description string
	Fatal       bool
}

Exception is a payload value that represents an application exception or crash.

type Payload

type Payload interface{}

Payload is the interface implemented by Google Analytic payload types.

func TargetDevice

func TargetDevice(interface{}) Payload

TargetDevice returns a payload value that describes a target device.

type SessionEnd

type SessionEnd struct{}

SessionEnd is a payload value to indicate the end of a session.

type SessionStart

type SessionStart struct{}

SessionStart is a payload value to indicate the start of a session.

type Size

type Size int

Size is a payload value for size values, usually representing bytes. Examples: File size.

type Stop

type Stop func(extras ...Payload)

Stop is the function returned by SendTiming to end the timed region and send the result to the Google Analytics server (if enabled).

func SendTiming

func SendTiming(category, name string) Stop

SendTiming is a no-op when analytics are not enabled.

type Timing

type Timing struct {
	Category string
	Name     string
	Label    string
	Duration time.Duration
}

Timing is a payload value that represents a timing.

Directories

Path Synopsis
Package param holds Google Analytics parameter names.
Package param holds Google Analytics parameter names.

Jump to

Keyboard shortcuts

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