Add frontend configuration to session for env, sentry, version

This commit is contained in:
Eli Ribble 2026-04-21 23:44:59 +00:00
parent 8d37e8fab5
commit 544ac78a3b
No known key found for this signature in database
3 changed files with 23 additions and 0 deletions

View file

@ -33,6 +33,7 @@ var (
PhoneNumberSupport phonenumbers.PhoneNumber
PhoneNumberSupportStr string
SentryDSN string
SentryDSNFrontend string
StadiaMapsAPIKey string
TextProvider string
TwilioAuthToken string
@ -168,6 +169,10 @@ func Parse() (err error) {
if SentryDSN == "" {
return fmt.Errorf("You must specify a non-empty SENTRY_DSN")
}
SentryDSNFrontend = os.Getenv("SENTRY_DSN_FRONTEND")
if SentryDSNFrontend == "" {
return fmt.Errorf("You must specify a non-empty SENTRY_DSN_FRONTEND")
}
StadiaMapsAPIKey = os.Getenv("STADIA_MAPS_API_KEY")
if StadiaMapsAPIKey == "" {
return fmt.Errorf("You must specify a non-empty STADIA_MAPS_API_KEY")

View file

@ -158,6 +158,7 @@ func main() {
chan_envelope := make(chan platform.Envelope, 10)
api.SetVersion(Version)
resource.SetVersion(Version)
platform.SetEventChannel(chan_envelope)
api.SetEventChannel(chan_envelope)

View file

@ -30,11 +30,17 @@ type organization struct {
type session struct {
Impersonating *string `json:"impersonating"`
Frontend sessionFrontend `json:"frontend"`
NotificationCounts sessionNotificationCounts `json:"notification_counts"`
Organization organization `json:"organization"`
Self user `json:"self"`
URLs sessionURL `json:"urls"`
}
type sessionFrontend struct {
Environment string `json:"environment"`
SentryDSN string `json:"sentry_dsn"`
Version string `json:"version"`
}
type sessionNotificationCounts struct {
Communications uint `json:"communication"`
Home uint `json:"home"`
@ -83,6 +89,11 @@ func (res *sessionR) Get(ctx context.Context, r *http.Request, user platform.Use
}
return &session{
Impersonating: impersonating,
Frontend: sessionFrontend{
Environment: config.Environment,
SentryDSN: config.SentryDSNFrontend,
Version: version,
},
NotificationCounts: sessionNotificationCounts{
Communications: counts.Communications,
Home: counts.Home,
@ -114,3 +125,9 @@ func (res *sessionR) Get(ctx context.Context, r *http.Request, user platform.Use
},
}, nil
}
var version string = "unknown"
func SetVersion(v string) {
version = v
}