-
Notifications
You must be signed in to change notification settings - Fork 21
/
type-event.go
58 lines (49 loc) · 987 Bytes
/
type-event.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package ga
import "net/url"
//WARNING: This file was generated. Do not edit.
//Event Hit Type
type Event struct {
category string
action string
label string
labelSet bool
value int64
valueSet bool
}
// NewEvent creates a new Event Hit Type.
// Specifies the event category.
// Specifies the event action.
func NewEvent(category string, action string) *Event {
h := &Event{
category: category,
action: action,
}
return h
}
func (h *Event) addFields(v url.Values) error {
v.Add("ec", h.category)
v.Add("ea", h.action)
if h.labelSet {
v.Add("el", h.label)
}
if h.valueSet {
v.Add("ev", int2str(h.value))
}
return nil
}
// Specifies the event label.
func (h *Event) Label(label string) *Event {
h.label = label
h.labelSet = true
return h
}
// Specifies the event value. Values must be non-negative.
func (h *Event) Value(value int64) *Event {
h.value = value
h.valueSet = true
return h
}
func (h *Event) Copy() *Event {
c := *h
return &c
}