meter

package
v0.0.0-...-28092d6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMeterRedisIsNotConfigured = errors.New("meter redis is not configured")

Functions

This section is empty.

Types

type AuditDBReadStore

type AuditDBReadStore struct {
	SQLBuilder  *auditdb.SQLBuilder
	SQLExecutor *auditdb.ReadSQLExecutor
}

func (*AuditDBReadStore) GetCountByActivityType

func (s *AuditDBReadStore) GetCountByActivityType(appID string, activityType string, rangeFrom *time.Time, rangeTo *time.Time) (int, error)

func (*AuditDBReadStore) QueryPage

func (s *AuditDBReadStore) QueryPage(appID string, opts audit.QueryPageOptions, pageArgs graphqlutil.PageArgs) ([]*audit.Log, uint64, error)

QueryPage is copied from pkg/lib/audit/read_store.go The ReadStore cannot be used here as it requires appID during initialization through injection

type CounterStore

type CounterStore interface {
	TrackActiveUser(userID string) error
	TrackPageView(visitorID string, pageType PageType) error
}

type PageType

type PageType string
const (
	PageTypeSignup PageType = "signup"
	PageTypeLogin  PageType = "login"
)

type ReadStoreRedis

type ReadStoreRedis struct {
	Context context.Context
	Redis   *analyticredis.Handle
}

ReadStoreRedis provides methods to get analytic counts and set expiry to the keys after those count are collected

func (*ReadStoreRedis) GetDailyActiveUserCount

func (s *ReadStoreRedis) GetDailyActiveUserCount(appID config.AppID, date *time.Time) (count int, redisKey string, err error)

func (*ReadStoreRedis) GetDailyPageViewCount

func (s *ReadStoreRedis) GetDailyPageViewCount(
	appID config.AppID,
	pageType PageType,
	date *time.Time,
) (pageView int, uniquePageView int, redisKeys []string, err error)

func (*ReadStoreRedis) GetMonthlyActiveUserCount

func (s *ReadStoreRedis) GetMonthlyActiveUserCount(appID config.AppID, year int, month int) (count int, redisKey string, err error)

func (*ReadStoreRedis) GetWeeklyActiveUserCount

func (s *ReadStoreRedis) GetWeeklyActiveUserCount(appID config.AppID, year int, week int) (count int, redisKey string, err error)

func (*ReadStoreRedis) SetKeysExpire

func (s *ReadStoreRedis) SetKeysExpire(keys []string, expiration time.Duration) error

type Service

type Service struct {
	Counter CounterStore
}

Service provides methods for the app to record analytic count

func (*Service) TrackActiveUser

func (s *Service) TrackActiveUser(userID string) error

func (*Service) TrackPageView

func (s *Service) TrackPageView(visitorID string, pageType PageType) error

type StoreRedisLogger

type StoreRedisLogger struct{ *log.Logger }

func NewStoreRedisLogger

func NewStoreRedisLogger(lf *log.Factory) StoreRedisLogger

type WriteStoreRedis

type WriteStoreRedis struct {
	Context context.Context
	Redis   *analyticredis.Handle
	AppID   config.AppID
	Clock   clock.Clock
	Logger  StoreRedisLogger
}

func (*WriteStoreRedis) TrackActiveUser

func (s *WriteStoreRedis) TrackActiveUser(userID string) (err error)

func (*WriteStoreRedis) TrackPageView

func (s *WriteStoreRedis) TrackPageView(visitorID string, pageType PageType) (err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL