analytics

package
v2.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: Apache-2.0 Imports: 26 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	Name  string
	Value interface{}
}

An Attribute is used to record custom Record values. Name will be forced to have "dc." prefix. Value will be limited to 400 bytes, truncated on rune boundary.

type Manager

type Manager interface {
	Start()
	Close()
	SendRecords(authContext *auth.Context, records []Record) error
}

A Manager wraps all things related to analytics processing

func NewManager

func NewManager(opts Options) (Manager, error)

NewManager constructs and starts a new manager. Call Close when you are done.

type Options

type Options struct {
	// LegacyEndpoint is true if using older direct-submit protocol (opdk)
	LegacyEndpoint bool
	// BufferPath is the directory where the adapter will buffer analytics records.
	BufferPath string
	// StagingFileLimit is the maximum number of files stored in the staging directory.
	// Once this is reached, the oldest files will start being removed.
	StagingFileLimit int
	// Base Apigee URL (legacy saas)
	BaseURL *url.URL
	// Client is a configured HTTPClient
	Client *http.Client
	// SendChannelSize is the size of the records channel
	SendChannelSize int
	// collection interval
	CollectionInterval time.Duration
	// contains filtered or unexported fields
}

Options allows us to specify options for how this analytics manager will run.

type Record

type Record struct {
	ClientReceivedStartTimestamp int64       `json:"client_received_start_timestamp"`
	ClientReceivedEndTimestamp   int64       `json:"client_received_end_timestamp"`
	TargetSentStartTimestamp     int64       `json:"target_sent_start_timestamp,omitempty"`
	TargetSentEndTimestamp       int64       `json:"target_sent_end_timestamp,omitempty"`
	TargetReceivedStartTimestamp int64       `json:"target_received_start_timestamp,omitempty"`
	TargetReceivedEndTimestamp   int64       `json:"target_received_end_timestamp,omitempty"`
	ClientSentStartTimestamp     int64       `json:"client_sent_start_timestamp"`
	ClientSentEndTimestamp       int64       `json:"client_sent_end_timestamp"`
	RecordType                   string      `json:"recordType"`
	APIProxy                     string      `json:"apiproxy"`
	RequestURI                   string      `json:"request_uri"`
	RequestPath                  string      `json:"request_path"`
	RequestVerb                  string      `json:"request_verb"`
	ClientIP                     string      `json:"client_ip,omitempty"`
	UserAgent                    string      `json:"useragent"`
	APIProxyRevision             int         `json:"apiproxy_revision"`
	ResponseStatusCode           int         `json:"response_status_code"`
	DeveloperEmail               string      `json:"developer_email,omitempty"`
	DeveloperApp                 string      `json:"developer_app,omitempty"`
	AccessToken                  string      `json:"access_token,omitempty"`
	ClientID                     string      `json:"client_id,omitempty"`
	APIProduct                   string      `json:"api_product,omitempty"`
	Organization                 string      `json:"organization"`
	Environment                  string      `json:"environment"`
	GatewaySource                string      `json:"gateway_source"`
	GatewayFlowID                string      `json:"gateway_flow_id"`
	Attributes                   []Attribute `json:"-"`
}

A Record is a single event that is tracked via Apigee analytics. A limit of 100 Attributes will be transmitted. Attributes values may be boolean, number, or string.

func (Record) EnsureFields

func (r Record) EnsureFields(authContext *auth.Context) Record

func (Record) MarshalJSON

func (r Record) MarshalJSON() ([]byte, error)

MarshalJSON marshalls Attributes with keys that must begin with a "dc." prefix and values that are limited to 400 bytes.

Jump to

Keyboard shortcuts

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