Documentation ¶
Index ¶
- func Onboarding()
- func TrackCommand(cmdName string) error
- type Client
- func (a *Client) Close() error
- func (a *Client) ConditionalFlush(aboveSize int, aboveDuration time.Duration) error
- func (a *Client) Events() (v []*Event, err error)
- func (a *Client) Flush() error
- func (a *Client) LastFlush() (time.Time, error)
- func (a *Client) LastFlushDuration() (time.Duration, error)
- func (a *Client) Size() (int, error)
- func (a *Client) Touch() error
- func (a *Client) Track(name string, props map[string]interface{}) error
- type Config
- type Event
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Onboarding ¶
func Onboarding()
func TrackCommand ¶
TrackCommand is the main entrypoint for analytics. This does all the checking for no tracking, the onboarding, and the actual tracking itself.
This should be called after your command has finished, because it will sometimes flush data over the network.
Any errors are assumed to be non-fatal and just sent to logs.
Types ¶
type Client ¶
type Client struct { *Config // contains filtered or unexported fields }
Client provides a thin layer over Segment's client for tracking CLI metrics.
Events are buffered on disk to improve user experience, only periodically flushing to the Segemnt API.
You should call Flush() when desired in order to flush to Segment. You may choose to do this after a certain number of events (see Size()) have been buffered, or after a given duration (see LastFlush()).
Based on https://github.com/tj/go-cli-analytics
func (*Client) ConditionalFlush ¶
ConditionalFlush flushes if event count is above `aboveSize`, or age is `aboveDuration`, otherwise Close() is called and the underlying file(s) are closed.
func (*Client) Flush ¶
Flush the events to Segment, removing them from disk. FIXME (bfirsh): two clients could potentially flush at the same time. Maybe this needs a lock, or something.
func (*Client) LastFlushDuration ¶
LastFlushDuration returns the last flush time delta.