zero/telemetry: calculate DAU and MAU (#4810)

This commit is contained in:
Denis Mishin 2023-12-11 13:37:01 -05:00 committed by GitHub
parent e0ac870442
commit c4dd965f2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 485 additions and 0 deletions

View file

@ -0,0 +1,29 @@
package analytics_test
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/pomerium/pomerium/internal/zero/analytics"
)
func TestStorage(t *testing.T) {
t.Parallel()
now := time.Date(2020, 1, 2, 3, 4, 5, 6, time.UTC)
state := &analytics.MetricState{
Data: []byte("data"),
LastReset: now,
}
pbany := state.ToAny()
assert.NotNil(t, pbany)
var newState analytics.MetricState
err := newState.FromAny(pbany)
assert.NoError(t, err)
assert.EqualValues(t, state.Data, newState.Data)
assert.EqualValues(t, state.LastReset.Truncate(time.Second), newState.LastReset.Truncate(time.Second))
}