-
Notifications
You must be signed in to change notification settings - Fork 0
/
send_event_options.go
59 lines (50 loc) · 1.23 KB
/
send_event_options.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
59
package ga4m
import (
"context"
"time"
)
// SendEventOption allows for optional parameters when sending events.
type SendEventOption func(*sendEventOptions)
type sendEventOptions struct {
ctx context.Context
debug bool
userID string
timestamp time.Time
sessionID string
}
func defaultSendEventOptions() *sendEventOptions {
return &sendEventOptions{
ctx: context.Background(),
debug: false,
}
}
// WithContext sets a custom context for the request.
func WithContext(ctx context.Context) SendEventOption {
return func(o *sendEventOptions) {
o.ctx = ctx
}
}
// WithDebug enables or disables debug mode.
func WithDebug(debug bool) SendEventOption {
return func(o *sendEventOptions) {
o.debug = debug
}
}
// WithUserID sets the user ID for the event.
func WithUserID(userID string) SendEventOption {
return func(o *sendEventOptions) {
o.userID = userID
}
}
// WithTimestamp sets a custom timestamp for the event.
func WithTimestamp(timestamp time.Time) SendEventOption {
return func(o *sendEventOptions) {
o.timestamp = timestamp
}
}
// WithSessionID sets the session ID for the event.
func WithSessionID(sessionID string) SendEventOption {
return func(o *sendEventOptions) {
o.sessionID = sessionID
}
}