1 Star 0 Fork 0

Sensors Data/sa-sdk-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
identities.go 3.20 KB
一键复制 编辑 原始数据 按行查看 历史
周倩 提交于 2022-06-22 14:53 +08:00 . Release 2.1.0
// Package sensorsanalytics /*
package sensorsanalytics
import (
"errors"
"github.com/sensorsdata/sa-sdk-go/utils"
)
const (
BIND = "track_id_bind"
UNBIND = "track_id_unbind"
BIND_EVENT = "$BindID"
UNBIND_EVENT = "$UnbindID"
LOGIN_ID = "$identity_login_id"
MOBILE = "$identity_mobile"
EMAIL = "$identity_email"
)
type Identity struct {
Identities map[string]string
}
func (sa *SensorsAnalytics) Bind(identity Identity) error {
if identity.Identities == nil || len(identity.Identities) < 2 {
return errors.New("identity is invalid")
}
return TrackEventID3(sa, identity, BIND, BIND_EVENT, nil)
}
func (sa *SensorsAnalytics) UnBind(identity Identity) error {
if identity.Identities == nil {
return errors.New("identity is nil")
}
return TrackEventID3(sa, identity, UNBIND, UNBIND_EVENT, nil)
}
func (sa *SensorsAnalytics) TrackById(identity Identity, event string, properties map[string]interface{}) error {
var nproperties map[string]interface{}
// merge properties
if properties == nil {
nproperties = make(map[string]interface{})
} else {
nproperties = utils.DeepCopy(properties)
}
// merge super properties
if superProperties != nil {
utils.MergeSuperProperty(superProperties, nproperties)
}
return TrackEventID3(sa, identity, TRACK, event, nproperties)
}
func (sa *SensorsAnalytics) ProfileSetById(identity Identity, properties map[string]interface{}) error {
var nproperties map[string]interface{}
if properties == nil {
return errors.New("property should not be nil")
} else {
nproperties = utils.DeepCopy(properties)
}
return TrackEventID3(sa, identity, PROFILE_SET, "", nproperties)
}
func (sa *SensorsAnalytics) ProfileSetOnceById(identity Identity, properties map[string]interface{}) error {
var nproperties map[string]interface{}
if properties == nil {
return errors.New("property should not be nil")
} else {
nproperties = utils.DeepCopy(properties)
}
return TrackEventID3(sa, identity, PROFILE_SET_ONCE, "", nproperties)
}
func (sa *SensorsAnalytics) ProfileIncrementById(identity Identity, properties map[string]interface{}) error {
var nproperties map[string]interface{}
if properties == nil {
return errors.New("property should not be nil")
} else {
nproperties = utils.DeepCopy(properties)
}
return TrackEventID3(sa, identity, PROFILE_INCREMENT, "", nproperties)
}
func (sa *SensorsAnalytics) ProfileAppendById(identity Identity, properties map[string]interface{}) error {
var nproperties map[string]interface{}
if properties == nil {
return errors.New("property should not be nil")
} else {
nproperties = utils.DeepCopy(properties)
}
return TrackEventID3(sa, identity, PROFILE_APPEND, "", nproperties)
}
func (sa *SensorsAnalytics) ProfileUnsetById(identity Identity, properties map[string]interface{}) error {
var nproperties map[string]interface{}
if properties == nil {
return errors.New("property should not be nil")
} else {
nproperties = utils.DeepCopy(properties)
}
return TrackEventID3(sa, identity, PROFILE_UNSET, "", nproperties)
}
func (sa *SensorsAnalytics) ProfileDeleteById(identity Identity) error {
nproperties := make(map[string]interface{})
return TrackEventID3(sa, identity, PROFILE_DELETE, "", nproperties)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/sensorsdata/sa-sdk-go.git
git@gitee.com:sensorsdata/sa-sdk-go.git
sensorsdata
sa-sdk-go
sa-sdk-go
master

搜索帮助