thinkingdata

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: Apache-2.0 Imports: 17 Imported by: 3

Documentation

Index

Constants

View Source
const (
	DefaultTimeOut       = 30000
	DefaultBatchSize     = 20
	MaxBatchSize         = 200
	DefaultInterval      = 30
	DefaultCacheCapacity = 50
)
View Source
const (
	Track          = "track"
	TrackUpdate    = "track_update"
	TrackOverwrite = "track_overwrite"
	UserSet        = "user_set"
	UserUnset      = "user_unset"
	UserSetOnce    = "user_setOnce"
	UserAdd        = "user_add"
	UserAppend     = "user_append"
	UserUniqAppend = "user_uniq_append"
	UserDel        = "user_del"

	SdkVersion = "1.7.0"
	LibName    = "Golang"
)
View Source
const (
	DATE_FORMAT = "2006-01-02 15:04:05.000"
	KEY_PATTERN = "^[a-zA-Z#][A-Za-z0-9_]{0,49}$"
)

Variables

This section is empty.

Functions

func Logger added in v1.6.6

func Logger(format string, v ...interface{})

func SetLoggerConfig added in v1.6.6

func SetLoggerConfig(config LoggerConfig)

SetLoggerConfig set config

Types

type BatchConfig added in v1.3.0

type BatchConfig struct {
	ServerUrl     string // serverUrl
	AppId         string // appId
	BatchSize     int    // flush event count each time
	Timeout       int    // http timeout (mill second)
	Compress      bool   // enable compress data
	AutoFlush     bool   // enable auto flush
	Interval      int    // auto flush spacing (second)
	CacheCapacity int    // cache event count
}

type BatchConsumer

type BatchConsumer struct {
	// contains filtered or unexported fields
}

BatchConsumer upload data to TE by http

func (*BatchConsumer) Add

func (c *BatchConsumer) Add(d Data) error

func (*BatchConsumer) Close

func (c *BatchConsumer) Close() error

func (*BatchConsumer) Flush

func (c *BatchConsumer) Flush() error

func (*BatchConsumer) FlushAll added in v1.4.0

func (c *BatchConsumer) FlushAll() error

func (*BatchConsumer) IsStringent added in v1.6.6

func (c *BatchConsumer) IsStringent() bool

type Consumer

type Consumer interface {
	Add(d Data) error
	Flush() error
	Close() error
	IsStringent() bool // check data or not.
}

Consumer define operation interface

func NewBatchConsumer

func NewBatchConsumer(serverUrl string, appId string) (Consumer, error)

NewBatchConsumer create BatchConsumer

func NewBatchConsumerWithBatchSize

func NewBatchConsumerWithBatchSize(serverUrl string, appId string, batchSize int) (Consumer, error)

NewBatchConsumerWithBatchSize create BatchConsumer serverUrl appId batchSize: flush event count each time

func NewBatchConsumerWithCompress added in v1.1.0

func NewBatchConsumerWithCompress(serverUrl string, appId string, compress bool) (Consumer, error)

NewBatchConsumerWithCompress create BatchConsumer serverUrl appId compress: enable data compress

func NewBatchConsumerWithConfig added in v1.3.0

func NewBatchConsumerWithConfig(config BatchConfig) (Consumer, error)

func NewDebugConsumer

func NewDebugConsumer(serverUrl string, appId string) (Consumer, error)

NewDebugConsumer init DebugConsumer

func NewDebugConsumerWithDeviceId added in v1.6.7

func NewDebugConsumerWithDeviceId(serverUrl string, appId string, writeData bool, deviceId string) (Consumer, error)

func NewDebugConsumerWithWriter added in v1.1.0

func NewDebugConsumerWithWriter(serverUrl string, appId string, writeData bool) (Consumer, error)

func NewLogConsumer

func NewLogConsumer(directory string, r RotateMode) (Consumer, error)

func NewLogConsumerWithConfig added in v1.3.0

func NewLogConsumerWithConfig(config LogConfig) (Consumer, error)

func NewLogConsumerWithFileSize

func NewLogConsumerWithFileSize(directory string, r RotateMode, size int) (Consumer, error)

NewLogConsumerWithFileSize init LogConsumer directory: directory of log file r: rotate mode of log file. (in days / hours) size: max size of single log file (MByte)

type Data

type Data struct {
	IsComplex    bool                   `json:"-"` // properties are nested or not
	AccountId    string                 `json:"#account_id,omitempty"`
	DistinctId   string                 `json:"#distinct_id,omitempty"`
	Type         string                 `json:"#type"`
	Time         string                 `json:"#time"`
	EventName    string                 `json:"#event_name,omitempty"`
	EventId      string                 `json:"#event_id,omitempty"`
	FirstCheckId string                 `json:"#first_check_id,omitempty"`
	Ip           string                 `json:"#ip,omitempty"`
	UUID         string                 `json:"#uuid,omitempty"`
	AppId        string                 `json:"#app_id,omitempty"`
	Properties   map[string]interface{} `json:"properties"`
}

type DebugConsumer

type DebugConsumer struct {
	// contains filtered or unexported fields
}

DebugConsumer The data is reported one by one, and when an error occurs, the log will be printed on the console.

func (*DebugConsumer) Add

func (c *DebugConsumer) Add(d Data) error

func (*DebugConsumer) Close

func (c *DebugConsumer) Close() error

func (*DebugConsumer) Flush

func (c *DebugConsumer) Flush() error

func (*DebugConsumer) IsStringent added in v1.6.6

func (c *DebugConsumer) IsStringent() bool

type LogConfig added in v1.3.0

type LogConfig struct {
	Directory      string     // directory of log file
	RotateMode     RotateMode // rotate mode of log file
	FileSize       int        // max size of single log file (MByte)
	FileNamePrefix string     // prefix of log file
	ChannelSize    int
}

type LogConsumer

type LogConsumer struct {
	// contains filtered or unexported fields
}

LogConsumer write data to file, it works with LogBus

func (*LogConsumer) Add

func (c *LogConsumer) Add(d Data) error

func (*LogConsumer) Close

func (c *LogConsumer) Close() error

func (*LogConsumer) Flush

func (c *LogConsumer) Flush() error

func (*LogConsumer) IsStringent added in v1.6.6

func (c *LogConsumer) IsStringent() bool

type LogType added in v1.6.6

type LogType int32
const (
	LoggerTypeOff               LogType = 1 << 0                                // disable log
	LoggerTypePrint             LogType = 1 << 1                                // print on console
	LoggerTypeWriteFile         LogType = 1 << 2                                // print to file
	LoggerTypePrintAndWriteFile         = LoggerTypePrint | LoggerTypeWriteFile // print both on console and file
)

logger level

type LoggerConfig added in v1.6.6

type LoggerConfig struct {
	Type LogType
	Path string
}

type RotateMode

type RotateMode int32
const (
	DefaultChannelSize            = 1000 // channel size
	ROTATE_DAILY       RotateMode = 0    // by the day
	ROTATE_HOURLY      RotateMode = 1    // by the hour
)

type TDAnalytics

type TDAnalytics struct {
	// contains filtered or unexported fields
}

func New

func New(c Consumer) TDAnalytics

New init SDK

func (*TDAnalytics) ClearSuperProperties

func (ta *TDAnalytics) ClearSuperProperties()

ClearSuperProperties clear common properties

func (*TDAnalytics) Close

func (ta *TDAnalytics) Close() error

Close and exit sdk

func (*TDAnalytics) Flush

func (ta *TDAnalytics) Flush() error

Flush report data immediately.

func (*TDAnalytics) GetDynamicSuperProperties added in v1.6.0

func (ta *TDAnalytics) GetDynamicSuperProperties() map[string]interface{}

GetDynamicSuperProperties dynamic common properties

func (*TDAnalytics) GetSuperProperties

func (ta *TDAnalytics) GetSuperProperties() map[string]interface{}

GetSuperProperties get common properties

func (*TDAnalytics) SetDynamicSuperProperties added in v1.6.0

func (ta *TDAnalytics) SetDynamicSuperProperties(action func() map[string]interface{})

SetDynamicSuperProperties set common properties dynamically. not recommend to add the operation which with a lot of computation

func (*TDAnalytics) SetSuperProperties

func (ta *TDAnalytics) SetSuperProperties(superProperties map[string]interface{})

SetSuperProperties set common properties

func (*TDAnalytics) Track

func (ta *TDAnalytics) Track(accountId, distinctId, eventName string, properties map[string]interface{}) error

Track report ordinary event

func (*TDAnalytics) TrackFirst added in v1.6.0

func (ta *TDAnalytics) TrackFirst(accountId, distinctId, eventName, firstCheckId string, properties map[string]interface{}) error

TrackFirst report first event. (must add "#first_check_id" in properties, because it is flag of the first event)

func (*TDAnalytics) TrackOverwrite added in v1.2.0

func (ta *TDAnalytics) TrackOverwrite(accountId, distinctId, eventName, eventId string, properties map[string]interface{}) error

TrackOverwrite report overridable event

func (*TDAnalytics) TrackUpdate added in v1.2.0

func (ta *TDAnalytics) TrackUpdate(accountId, distinctId, eventName, eventId string, properties map[string]interface{}) error

TrackUpdate report updatable event

func (*TDAnalytics) UserAdd

func (ta *TDAnalytics) UserAdd(accountId string, distinctId string, properties map[string]interface{}) error

UserAdd to accumulate operations against the property.

func (*TDAnalytics) UserAppend added in v1.1.0

func (ta *TDAnalytics) UserAppend(accountId string, distinctId string, properties map[string]interface{}) error

UserAppend to add user properties of array type.

func (*TDAnalytics) UserDelete

func (ta *TDAnalytics) UserDelete(accountId string, distinctId string) error

UserDelete delete a user, This operation cannot be undone.

func (*TDAnalytics) UserSet

func (ta *TDAnalytics) UserSet(accountId string, distinctId string, properties map[string]interface{}) error

UserSet set user properties. would overwrite existing names.

func (*TDAnalytics) UserSetOnce

func (ta *TDAnalytics) UserSetOnce(accountId string, distinctId string, properties map[string]interface{}) error

UserSetOnce set user properties, If such property had been set before, this message would be neglected.

func (*TDAnalytics) UserUniqAppend added in v1.6.0

func (ta *TDAnalytics) UserUniqAppend(accountId string, distinctId string, properties map[string]interface{}) error

UserUniqAppend append user properties to array type by unique.

func (*TDAnalytics) UserUnset added in v1.0.2

func (ta *TDAnalytics) UserUnset(accountId string, distinctId string, s []string) error

UserUnset clear the user properties of users.

Jump to

Keyboard shortcuts

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