Skip to content

Commit

Permalink
Improve sentry reporting for approved applications
Browse files Browse the repository at this point in the history
  • Loading branch information
jodyheavener committed Apr 5, 2024
1 parent cce9733 commit 6a13f5c
Showing 1 changed file with 37 additions and 10 deletions.
47 changes: 37 additions & 10 deletions script/approver.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"log"
"path/filepath"
"strconv"
"strings"

"github.com/getsentry/sentry-go"
Expand Down Expand Up @@ -87,16 +88,7 @@ func (a *Approver) Approve() {
)
}

var appData map[string]interface{}
err := json.Unmarshal(a.application.GetData(), &appData)
if err != nil {
log.Fatal(err)
}
sentry.CaptureEvent(&sentry.Event{
Message: "Application approved",
Level: sentry.LevelInfo,
Extra: appData,
})
a.createSentryEvent()
}

func (a *Approver) logErrorAndExit(message string, err error) {
Expand Down Expand Up @@ -125,3 +117,38 @@ Finally, we’d love to hear more about your experience using 1Password in your
Welcome to the program and happy coding! 🧑‍💻`, a.application.ApproverUsername))
}

func (a *Approver) createSentryEvent() {
var appData map[string]interface{}
err := json.Unmarshal(a.application.GetData(), &appData)
if err != nil {
sentry.CaptureException(err)
log.Fatal(err)
}

var applicationType string
if a.application.Project.IsTeam {
applicationType = "team"
} else if a.application.Project.IsEvent {
applicationType = "event"
} else {
applicationType = "project"
}

tags := map[string]string{
"project_name": a.application.Project.Name,
"homepage_url": a.application.Project.HomeURL,
"application_type": applicationType,
"team_size": strconv.Itoa(a.application.Project.Contributors),
"issue_number": strconv.Itoa(a.application.IssueNumber),
"approved_by": fmt.Sprintf("@%s", a.application.ApproverUsername),
"can_contact": strconv.FormatBool(a.application.CanContact),
}

sentry.CaptureEvent(&sentry.Event{
Message: fmt.Sprintf("Application approved for \"%s\"", a.application.Project.Name),
Level: sentry.LevelInfo,
Extra: appData,
Tags: tags,
})
}

0 comments on commit 6a13f5c

Please sign in to comment.