feat: use unique machine ID for reporting GA

This commit is contained in:
debugtalk
2021-11-26 16:21:55 +08:00
parent 5880041c70
commit b0c2a5e5af
4 changed files with 16 additions and 6 deletions
+11 -1
View File
@@ -1,5 +1,10 @@
package ga
import (
"github.com/denisbrodbeck/machineid"
"github.com/google/uuid"
)
const (
trackingID = "UA-114587036-1" // Tracking ID for Google Analytics
)
@@ -7,7 +12,12 @@ const (
var gaClient *GAClient
func init() {
gaClient = NewGAClient(trackingID)
clientID, err := machineid.ProtectedID("hrp")
if err != nil {
nodeUUID, _ := uuid.NewUUID()
clientID = nodeUUID.String()
}
gaClient = NewGAClient(trackingID, clientID)
}
func SendEvent(e IEvent) error {