/
usage_record.go
57 lines (49 loc) · 1.73 KB
/
usage_record.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
package usage
import (
"time"
"github.com/authgear/authgear-server/pkg/util/periodical"
"github.com/authgear/authgear-server/pkg/util/uuid"
)
type RecordName string
const (
RecordNameActiveUser RecordName = "active-user"
RecordNameSMSSentNorthAmerica RecordName = "sms-sent.north-america"
RecordNameSMSSentOtherRegions RecordName = "sms-sent.other-regions"
RecordNameSMSSentTotal RecordName = "sms-sent.total"
RecordNameWhatsappSentNorthAmerica RecordName = "whatsapp-sent.north-america"
RecordNameWhatsappSentOtherRegions RecordName = "whatsapp-sent.other-regions"
RecordNameWhatsappSentTotal RecordName = "whatsapp-sent.total"
RecordNameEmailSent RecordName = "email-sent"
RecordNameWhatsappOTPVerified RecordName = "whatsapp-otp-verified"
)
type RecordType string
const (
RecordTypeActiveUser RecordType = "active-user"
RecordTypeSMSSent RecordType = "sms-sent"
RecordTypeEmailSent RecordType = "email-sent"
RecordTypeWhatsappSent RecordType = "whatsapp-sent"
RecordTypeWhatsappOTPVerified RecordType = "whatsapp-otp-verified"
)
// nolint:golint
type UsageRecord struct {
ID string
AppID string
Name RecordName
Period string
StartTime time.Time
EndTime time.Time
Count int
AlertData map[string]interface{}
StripeTimestamp *time.Time
}
func NewUsageRecord(appID string, name RecordName, count int, period periodical.Type, startTime time.Time, endTime time.Time) *UsageRecord {
return &UsageRecord{
ID: uuid.New(),
AppID: appID,
Name: name,
Count: count,
Period: string(period),
StartTime: startTime,
EndTime: endTime,
}
}