-
Notifications
You must be signed in to change notification settings - Fork 246
/
api.go
34 lines (26 loc) · 924 Bytes
/
api.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
package appmetrics
import (
"context"
"github.com/pborman/uuid"
"github.com/ethereum/go-ethereum/log"
"github.com/status-im/status-go/appmetrics"
)
func NewAPI(db *appmetrics.Database) *API {
return &API{db: db, sessionID: uuid.NewRandom().String()}
}
type API struct {
db *appmetrics.Database
sessionID string
}
func (api *API) ValidateAppMetrics(ctx context.Context, appMetrics []appmetrics.AppMetric) error {
log.Debug("[AppMetricsAPI::ValidateAppMetrics]")
return api.db.ValidateAppMetrics(appMetrics)
}
func (api *API) SaveAppMetrics(ctx context.Context, appMetrics []appmetrics.AppMetric) error {
log.Debug("[AppMetricsAPI::SaveAppMetrics]")
return api.db.SaveAppMetrics(appMetrics, api.sessionID)
}
func (api *API) GetAppMetrics(ctx context.Context, limit int, offset int) (appmetrics.Page, error) {
log.Debug("[AppMetricsAPI::GetAppMetrics]")
return api.db.GetAppMetrics(limit, offset)
}