Skip to content

Commit

Permalink
Fix logs links for dev/staging user reports
Browse files Browse the repository at this point in the history
  • Loading branch information
Fizzadar committed Sep 26, 2024
1 parent b320c28 commit 5bbd404
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions grafana.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"net/url"
"strconv"
"strings"
"time"
)

Expand Down Expand Up @@ -45,12 +46,17 @@ func makeGrafanaLogURL(expr string) (string, error) {
}

func makeGrafanaLogsURLs(username string) (string, string, error) {
bridgeLogsURL, err := makeGrafanaLogURL(`{user_id="@` + username + `:beeper.com",app="bridges",env="prod"} | unpack`)
userID := username
if !strings.HasSuffix(userID, ":beeper-dev.com") && !strings.HasSuffix(userID, ":beeper-staging.com") {
userID = userID + ":beeper.com"
}

bridgeLogsURL, err := makeGrafanaLogURL(`{user_id="@` + userID + `",app="bridges",env="prod"} | unpack`)
if err != nil {
return "", "", err
}

megahungryLogsURL, err := makeGrafanaLogURL(`{user_id="@` + username + `:beeper.com",namespace="megahungry",env="prod"} | unpack`)
megahungryLogsURL, err := makeGrafanaLogURL(`{user_id="@` + userID + `",namespace="megahungry",env="prod"} | unpack`)
if err != nil {
return "", "", err
}
Expand Down
1 change: 1 addition & 0 deletions submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,7 @@ func getUsernameFromPayload(p parsedPayload) (string, bool) {
} else {
isVerified = true
}
// Note: for staging/dev we still return the entire userID so it's clear they're not prod
return strings.TrimPrefix(strings.TrimSuffix(userID, ":beeper.com"), "@"), isVerified
}

Expand Down

0 comments on commit 5bbd404

Please sign in to comment.