日志优化

This commit is contained in:
hahwu 2026-01-21 17:56:16 +08:00
parent 892b6408d3
commit 94a056c18a

View File

@ -1,6 +1,7 @@
package thinkingdata
import (
"encoding/json"
"errors"
"sync"
"time"
@ -36,6 +37,7 @@ type Data struct {
UUID string `json:"#uuid,omitempty"`
AppId string `json:"#app_id,omitempty"`
Properties map[string]interface{} `json:"properties"`
PropertiesSummary string `json:"properties_summary,omitempty"`
}
// TDConsumer define operation interface
@ -275,7 +277,10 @@ func (ta *TDAnalytics) add(accountId, distinctId, dataType, eventName, eventId s
if len(uuid) == 0 {
uuid = generateUUID()
}
properties_summary, err := json.Marshal(properties)
if err != nil {
properties_summary = []byte{}
}
data := Data{
AccountId: accountId,
DistinctId: distinctId,
@ -288,13 +293,14 @@ func (ta *TDAnalytics) add(accountId, distinctId, dataType, eventName, eventId s
Ip: ip,
UUID: uuid,
Properties: properties,
PropertiesSummary: string(properties_summary),
}
if len(appId) > 0 {
data.AppId = appId
}
err := formatProperties(&data, ta)
err = formatProperties(&data, ta)
if err != nil {
return err
}