File tree Expand file tree Collapse file tree 3 files changed +10
-3
lines changed Expand file tree Collapse file tree 3 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -52,15 +52,15 @@ func ApqCache(redisClient rueidis.Client) graphql.Cache[string] {
5252}
5353
5454func PostHogClient (lifecycle fx.Lifecycle , cfg config.Config ) (posthog.Client , error ) {
55- if cfg .PostHog .APIKey == nil {
56- slog .Warn ("PostHog client is not initialized, because you did not configure a PostHog API key." )
55+ if cfg .PostHog .APIKey == nil || cfg . PostHog . Host == nil {
56+ slog .Warn ("PostHog client is not initialized, because you did not configure a PostHog API key and a host ." )
5757 return nil , nil
5858 }
5959
6060 client , err := posthog .NewWithConfig (
6161 * cfg .PostHog .APIKey ,
6262 posthog.Config {
63- Endpoint : "https://us.i.posthog.com" ,
63+ Endpoint : * cfg . PostHog . Host ,
6464 },
6565 )
6666 if err != nil {
Original file line number Diff line number Diff line change @@ -65,3 +65,5 @@ PostHog 是一個產品統計平台。這個專案使用 [posthog-go](https://po
6565如果不填寫 API Key 則代表不送出任何統計。
6666
6767- ` POSTHOG_API_KEY ` : PostHog 的 API key。可以在 PostHog 的 Settings > Project > General > Project API key 中取得。
68+ - ` POSTHOG_HOST ` : PostHog API 的主機。可以在 PostHog 的 Settings > Project > General > Web snippet 中的 ` api_host ` 取得。
69+ - e.g. ` https://us.i.posthog.com `
Original file line number Diff line number Diff line change @@ -157,12 +157,17 @@ func (c SqlRunnerConfig) Validate() error {
157157
158158type PostHogConfig struct {
159159 APIKey * string `env:"API_KEY"`
160+ Host * string `env:"HOST"`
160161}
161162
162163func (c PostHogConfig ) Validate () error {
163164 if c .APIKey != nil && * c .APIKey == "" {
164165 return errors .New ("POSTHOG_API_KEY cannot be empty" )
165166 }
166167
168+ if c .Host != nil && * c .Host == "" {
169+ return errors .New ("POSTHOG_HOST cannot be empty" )
170+ }
171+
167172 return nil
168173}
You can’t perform that action at this time.
0 commit comments