thinkingdata

package
v1.20.76 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

BatchConsumer 实现了批量同步的向接收端传送数据的功能

DebugConsumer 逐条上传数据到接收端,并在出错时打印错误信息

Index

Constants

View Source
const (
	DEFAULT_TIME_OUT   = 30000 // 默认超时时长 30 秒
	DEFAULT_BATCH_SIZE = 20    // 默认批量发送条数
	MAX_BATCH_SIZE     = 200   // 最大批量发送条数
	BATCH_CHANNEL_SIZE = 1000  // 数据缓冲区大小, 超过此值时会阻塞

	TYPE_DATA  batchDataType = 0 // 数据类型
	TYPE_FLUSH batchDataType = 1 // 立即发送数据
)
View Source
const (
	DEFAULT_PROD_TIME_OUT   = 10   // 默认超时时长 10 秒
	DEFAULT_PROD_BATCH_SIZE = 20   // 默认批量发送条数
	MAX_PROD_BATCH_SIZE     = 200  // 最大批量发送条数
	PROD_CHANNEL_SIZE       = 1000 // 数据通道缓冲
	DEFAULT_CONSUMER_COUNT  = 3    // 默认消费者数量
)
View Source
const (
	TRACK         = "track"
	USER_SET      = "user_set"
	USER_SET_ONCE = "user_setOnce"
	USER_ADD      = "user_add"
	USER_DEL      = "user_del"

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

Variables

This section is empty.

Functions

func Track

func Track(eventName, accountId, distinctId string, data map[string]interface{})

Types

type BatchConsumer

type BatchConsumer struct {
	Timeout time.Duration // 网络请求超时时间, 单位毫秒
	// contains filtered or unexported fields
}

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

type Consumer

type Consumer interface {
	Add(d Data) error
	Flush() error
	Close() error
}

Consumer 为数据实现 IO 操作(写入磁盘或者发送到接收端)

func GetProdBatchConsumer

func GetProdBatchConsumer(serverUrl string, appId string, args ...int) Consumer

func NewBatchConsumer

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

创建 BatchConsumer

func NewBatchConsumerWithBatchSize

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

创建指定批量发送条数的 BatchConsumer serverUrl 接收端地址 appId 项目的 APP ID batchSize 批量发送条数

func NewDebugConsumer

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

创建 DebugConsumer. DebugConsumer 实现逐条上报数据,并返回数据校验的详细错误信息.

func NewLogConsumer

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

创建 LogConsumer. 传入日志目录和切分模式

func NewLogConsumerWithFileSize

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

创建 LogConsumer. 传入日志目录和切分模式和单个文件大小限制 directory: 日志文件存放目录 r: 文件切分模式(按日切分、按小时切分) size: 但个日志文件上限,单位 MB

type Data

type Data struct {
	AccountId  string                 `json:"#account_id"`
	DistinctId string                 `json:"#distinct_id"`
	Type       string                 `json:"#type"`
	Time       string                 `json:"#time"`
	EventName  string                 `json:"#event_name"`
	Ip         string                 `json:"#ip"`
	Properties map[string]interface{} `json:"properties"`
}

数据信息

type DebugConsumer

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

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

type LogConsumer

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

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

type ProdBatchConsumer

type ProdBatchConsumer struct {
	Timeout time.Duration // 网络请求超时时间, 单位毫秒
	// contains filtered or unexported fields
}

func (*ProdBatchConsumer) Add

func (this *ProdBatchConsumer) Add(d Data) error

func (*ProdBatchConsumer) Close

func (this *ProdBatchConsumer) Close() error

func (*ProdBatchConsumer) Flush

func (this *ProdBatchConsumer) Flush() error

Flush 不支持flush

type RotateMode

type RotateMode int32
const (
	CHANNEL_SIZE             = 1000 // channel 缓冲区
	ROTATE_DAILY  RotateMode = 0    // 按天切分
	ROTATE_HOURLY RotateMode = 1    // 按小时切分
)

type TDAnalytics

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

func GetTaAnalyst

func GetTaAnalyst(args ...int) TDAnalytics

func New

func New(c Consumer) TDAnalytics

初始化 TDAnalytics

func (*TDAnalytics) ClearSuperProperties

func (ta *TDAnalytics) ClearSuperProperties()

清除公共事件属性

func (*TDAnalytics) Close

func (ta *TDAnalytics) Close()

关闭 TDAnalytics

func (*TDAnalytics) Flush

func (ta *TDAnalytics) Flush()

立即开始数据 IO 操作

func (*TDAnalytics) GetSuperProperties

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

返回公共事件属性

func (*TDAnalytics) SetSuperProperties

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

设置公共事件属性

func (*TDAnalytics) Track

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

追踪一个事件

func (*TDAnalytics) UserAdd

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

对数值类型的属性做累加操作

func (*TDAnalytics) UserDelete

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

删除用户数据, 之后无法查看用户属性, 但是之前已经入库的事件数据不会被删除. 此操作不可逆

func (*TDAnalytics) UserSet

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

设置用户属性. 如果同名属性已存在,则用传入的属性覆盖同名属性.

func (*TDAnalytics) UserSetOnce

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

设置用户属性. 不会覆盖同名属性.

Jump to

Keyboard shortcuts

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