meter

package
v0.0.0-...-ee57881 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 18 Imported by: 1

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(ctx context.Context, appID string, activityType string, rangeFrom *time.Time, rangeTo *time.Time) (int, error)

func (*AuditDBReadStore) QueryPage

func (s *AuditDBReadStore) QueryPage(ctx context.Context, 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(ctx context.Context, userID string) error
	TrackPageView(ctx context.Context, visitorID string, pageType PageType) error
}

type PageType

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

type ReadStoreRedis

type ReadStoreRedis struct {
	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(ctx context.Context, appID config.AppID, date *time.Time) (count int, redisKey string, err error)

func (*ReadStoreRedis) GetDailyPageViewCount

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

func (*ReadStoreRedis) GetMonthlyActiveUserCount

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

func (*ReadStoreRedis) GetWeeklyActiveUserCount

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

func (*ReadStoreRedis) SetKeysExpire

func (s *ReadStoreRedis) SetKeysExpire(ctx context.Context, 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(ctx context.Context, userID string) error

func (*Service) TrackPageView

func (s *Service) TrackPageView(ctx context.Context, 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 {
	Redis  *analyticredis.Handle
	AppID  config.AppID
	Clock  clock.Clock
	Logger StoreRedisLogger
}

func (*WriteStoreRedis) TrackActiveUser

func (s *WriteStoreRedis) TrackActiveUser(ctx context.Context, userID string) (err error)

func (*WriteStoreRedis) TrackPageView

func (s *WriteStoreRedis) TrackPageView(ctx context.Context, visitorID string, pageType PageType) (err error)

Jump to

Keyboard shortcuts

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