mirror of
https://github.com/warmbly/warmbly.git
synced 2026-09-13 00:03:42 +00:00
feat: apply WARMBLY_POSTHOG_ERROR_TRACKING to the public form pages too, by having cmd/forms stamp an empty browser key when it is false, since the page can only act on whether a key arrived and the flag otherwise silenced the dashboard and the admin panel while leaving form pages reporting
This commit is contained in:
+18
-1
@@ -62,7 +62,7 @@ func main() {
|
||||
// own credentials: form pages are public and their errors belong in a
|
||||
// frontend project, not the service's. Empty means the page loads no
|
||||
// reporting SDK at all, which is the self-host default.
|
||||
BrowserPostHogKey: strings.TrimSpace(os.Getenv("WARMBLY_POSTHOG_KEY")),
|
||||
BrowserPostHogKey: browserPostHogKey(),
|
||||
BrowserPostHogHost: strings.TrimSpace(os.Getenv("WARMBLY_POSTHOG_HOST")),
|
||||
BrowserSentryDSN: strings.TrimSpace(os.Getenv("WARMBLY_SENTRY_DSN")),
|
||||
Release: observability.Release(),
|
||||
@@ -91,6 +91,23 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
// browserPostHogKey is the key stamped into the form page, or nothing when the
|
||||
// operator turned browser error tracking off.
|
||||
//
|
||||
// The toggle is applied here rather than in the page because the page has no
|
||||
// way to be told: it is served to a stranger's browser and the only thing it
|
||||
// can act on is whether a key arrived. Without this,
|
||||
// WARMBLY_POSTHOG_ERROR_TRACKING would silence the dashboard and the admin
|
||||
// panel and leave form pages reporting.
|
||||
func browserPostHogKey() string {
|
||||
if raw := strings.TrimSpace(os.Getenv("WARMBLY_POSTHOG_ERROR_TRACKING")); raw != "" {
|
||||
if enabled, err := strconv.ParseBool(raw); err == nil && !enabled {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
return strings.TrimSpace(os.Getenv("WARMBLY_POSTHOG_KEY"))
|
||||
}
|
||||
|
||||
// appEnv is the deployment label, matching what InitEnv reports for this
|
||||
// process so the browser and the server halves agree.
|
||||
func appEnv() string {
|
||||
|
||||
Reference in New Issue
Block a user