Skip to content

Commit 636a0af

Browse files
committed
address comment
1 parent 9267dc9 commit 636a0af

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

cmd/gateway/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func main() {
128128
loginOptions := []login.LoginServerOption{login.WithConfig(gwConfig.Login), login.WithSessionStore(sessionStore), login.WithTokenStore(tokenStore)}
129129

130130
if gwConfig.Posthog.Enabled {
131-
metricsClient, err := metrics.NewPosthogClient(gwConfig.Posthog.ApiKey, gwConfig.Posthog.Host, gwConfig.Posthog.Environment)
131+
metricsClient, err := metrics.NewPosthogClient(gwConfig.Posthog)
132132
if err != nil {
133133
slog.Error("posthog client initializtion failed", "error", err)
134134
os.Exit(1)

internal/config/other.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type RateLimits struct {
3232

3333
type PosthogConfig struct {
3434
Enabled bool
35-
ApiKey string
35+
ApiKey RedactedString
3636
Host string
3737
Environment string
3838
}

internal/metrics/posthog.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"crypto/md5"
55
"encoding/hex"
66

7+
"github.com/SwissDataScienceCenter/renku-gateway/internal/config"
78
"github.com/posthog/posthog-go"
89
)
910

@@ -24,12 +25,12 @@ func (p *PosthogMetricsClient) Close() {
2425
p.posthogClient.Close()
2526
}
2627

27-
func NewPosthogClient(apiKey string, host string, environment string) (*PosthogMetricsClient, error) {
28+
func NewPosthogClient(c config.PosthogConfig) (*PosthogMetricsClient, error) {
2829
client, err := posthog.NewWithConfig(
29-
apiKey,
30+
string(c.ApiKey),
3031
posthog.Config{
31-
Endpoint: host,
32-
DefaultEventProperties: posthog.Properties{"environment": environment},
32+
Endpoint: c.Host,
33+
DefaultEventProperties: posthog.Properties{"environment": c.Environment},
3334
},
3435
)
3536
if err != nil {

0 commit comments

Comments
 (0)