fix: EventTracking ev field type

This commit is contained in:
debugtalk
2021-11-26 16:42:28 +08:00
parent 9415ab6d9f
commit 67690a06a4
2 changed files with 4 additions and 2 deletions

View File

@@ -8,6 +8,7 @@ func TestSendEvents(t *testing.T) {
event := EventTracking{
Category: "unittest",
Action: "SendEvents",
Value: "123",
}
err := gaClient.SendEvent(event)
if err != nil {
@@ -20,9 +21,10 @@ func TestStructToUrlValues(t *testing.T) {
Category: "unittest",
Action: "convert",
Label: "StructToUrlValues",
Value: "123",
}
val := structToUrlValues(event)
if val.Encode() != "ea=convert&ec=unittest&el=StructToUrlValues" {
if val.Encode() != "ea=convert&ec=unittest&el=StructToUrlValues&ev=123" {
t.Fail()
}
}

View File

@@ -15,7 +15,7 @@ type EventTracking struct {
Category string `form:"ec"` // Required. Event Category.
Action string `form:"ea"` // Required. Event Action.
Label string `form:"el"` // Optional. Event label
Value int `form:"ev"` // Optional. Event value
Value string `form:"ev"` // Optional. Event value, must be digits, "123"
}
func (e EventTracking) StartTiming(variable string) UserTimingTracking {