feat: report GA events with version

This commit is contained in:
debugtalk
2021-12-22 20:11:28 +08:00
parent e428a7b6b5
commit fe9c4617fc
4 changed files with 9 additions and 6 deletions

View File

@@ -3,8 +3,9 @@
## v0.3.0 (2021-12-22)
- feat: implement transaction mechanism for load test
- feat: support `--continue-on-failure` flag to continue running next step when failure occurs
- feat: support `--continue-on-failure` flag to continue running next step when failure occurs, default to failfast
- refactor: fork [boomer] as sub module
- feat: report GA events with version
## v0.2.2 (2021-12-07)

View File

@@ -2,6 +2,4 @@
This module is initially forked from [myzhan/boomer] and made a lot of changes.
- remove distribute runner
[myzhan/boomer]: https://github.com/myzhan/boomer

View File

@@ -20,11 +20,11 @@ func TestStructToUrlValues(t *testing.T) {
event := EventTracking{
Category: "unittest",
Action: "convert",
Label: "StructToUrlValues",
Label: "v0.3.0",
Value: "123",
}
val := structToUrlValues(event)
if val.Encode() != "ea=convert&ec=unittest&el=StructToUrlValues&ev=123" {
if val.Encode() != "ea=convert&ec=unittest&el=v0.3.0&ev=123" {
t.Fail()
}
}

View File

@@ -4,6 +4,8 @@ import (
"fmt"
"net/url"
"time"
"github.com/httprunner/hrp/internal/version"
)
type IEvent interface {
@@ -14,7 +16,7 @@ type EventTracking struct {
HitType string `form:"t"` // Event hit type = event
Category string `form:"ec"` // Required. Event Category.
Action string `form:"ea"` // Required. Event Action.
Label string `form:"el"` // Optional. Event label
Label string `form:"el"` // Optional. Event label, used as version.
Value string `form:"ev"` // Optional. Event value, must be digits, "123"
}
@@ -30,6 +32,7 @@ func (e EventTracking) StartTiming(variable string) UserTimingTracking {
func (e EventTracking) ToUrlValues() url.Values {
e.HitType = "event"
e.Label = version.VERSION
return structToUrlValues(e)
}
@@ -45,6 +48,7 @@ type UserTimingTracking struct {
func (e UserTimingTracking) ToUrlValues() url.Values {
e.HitType = "timing"
e.Label = version.VERSION
e.Duration = fmt.Sprintf("%d", int64(e.duration.Seconds()*1000))
return structToUrlValues(e)
}