mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 20:57:31 +00:00
feat(console): allow to configure PostHog (#9135)
# Which Problems Are Solved The console has no information about where and how to send PostHog events. # How the Problems Are Solved A PostHog API URL and token are passed through as plain text from the Zitadel runtime config to the environment.json. By default, no values are configured and the keys in the environment.json are omitted. # Additional Context - Closes https://github.com/zitadel/zitadel/issues/9070 - Complements https://github.com/zitadel/zitadel/pull/9077
This commit is contained in:
@@ -611,6 +611,9 @@ Console:
|
||||
# 168h is 7 days, one week
|
||||
SharedMaxAge: 168h # ZITADEL_CONSOLE_LONGCACHE_SHAREDMAXAGE
|
||||
InstanceManagementURL: "" # ZITADEL_CONSOLE_INSTANCEMANAGEMENTURL
|
||||
PostHog:
|
||||
URL: "" # ZITADEL_CONSOLE_POSTHOG_URL
|
||||
Token: "" # ZITADEL_CONSOLE_POSTHOG_TOKEN
|
||||
|
||||
EncryptionKeys:
|
||||
DomainVerification:
|
||||
|
@@ -28,6 +28,10 @@ type Config struct {
|
||||
ShortCache middleware.CacheConfig
|
||||
LongCache middleware.CacheConfig
|
||||
InstanceManagementURL string
|
||||
PostHog struct {
|
||||
Token string
|
||||
URL string
|
||||
}
|
||||
}
|
||||
|
||||
type spaHandler struct {
|
||||
@@ -117,7 +121,7 @@ func Start(config Config, externalSecure bool, issuer op.IssuerFromRequest, call
|
||||
return
|
||||
}
|
||||
limited := limitingAccessInterceptor.Limit(w, r)
|
||||
environmentJSON, err := createEnvironmentJSON(url, issuer(r), instance.ConsoleClientID(), customerPortal, instanceMgmtURL, limited)
|
||||
environmentJSON, err := createEnvironmentJSON(url, issuer(r), instance.ConsoleClientID(), customerPortal, instanceMgmtURL, config.PostHog.URL, config.PostHog.Token, limited)
|
||||
if err != nil {
|
||||
http.Error(w, fmt.Sprintf("unable to marshal env for console: %v", err), http.StatusInternalServerError)
|
||||
return
|
||||
@@ -150,13 +154,15 @@ func csp() *middleware.CSP {
|
||||
return &csp
|
||||
}
|
||||
|
||||
func createEnvironmentJSON(api, issuer, clientID, customerPortal, instanceMgmtUrl string, exhausted bool) ([]byte, error) {
|
||||
func createEnvironmentJSON(api, issuer, clientID, customerPortal, instanceMgmtUrl, postHogURL, postHogToken string, exhausted bool) ([]byte, error) {
|
||||
environment := struct {
|
||||
API string `json:"api,omitempty"`
|
||||
Issuer string `json:"issuer,omitempty"`
|
||||
ClientID string `json:"clientid,omitempty"`
|
||||
CustomerPortal string `json:"customer_portal,omitempty"`
|
||||
InstanceManagementURL string `json:"instance_management_url,omitempty"`
|
||||
PostHogURL string `json:"posthog_url,omitempty"`
|
||||
PostHogToken string `json:"posthog_token,omitempty"`
|
||||
Exhausted bool `json:"exhausted,omitempty"`
|
||||
}{
|
||||
API: api,
|
||||
@@ -164,6 +170,8 @@ func createEnvironmentJSON(api, issuer, clientID, customerPortal, instanceMgmtUr
|
||||
ClientID: clientID,
|
||||
CustomerPortal: customerPortal,
|
||||
InstanceManagementURL: instanceMgmtUrl,
|
||||
PostHogURL: postHogURL,
|
||||
PostHogToken: postHogToken,
|
||||
Exhausted: exhausted,
|
||||
}
|
||||
return json.Marshal(environment)
|
||||
|
Reference in New Issue
Block a user