-
Notifications
You must be signed in to change notification settings - Fork 3
/
eventexporter.go
46 lines (38 loc) · 1.23 KB
/
eventexporter.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
package eventexporter
import "time"
const (
TextBodyType BodyType = iota
HtmlBodyType
)
// Exporter is the interface to export events to a 3rd party service.
// Currently third party services: SegementIO and Sendgrid are implemented.
type Exporter interface {
Send(*Event) error
Name() string
Close() error
}
// Event represent an action in time that is done by an user, has body
// and optionally some properties.
type Event struct {
Name string // name of event
User *User // user who did event
Body *Body // body of event; text or html
Properties map[string]interface{} // any additional properties
Context map[string]interface{} // any additional context
Count int64 // count of the event
Duration time.Duration // duration of the event
// Publish this events to only whitelisted upstreams
WhitelistedUpstreams []string
}
type BodyType int
// Body is used to send text or html of event directly to 3rd party.
// Ideally none of html should exist in codebase so it's easy to change,
// however legacy html code still exists.
type Body struct {
Type BodyType // text or html
Content string
}
type User struct {
Email string
Username string
}