Skip to content

Commit 6a13f5c

Browse files
committed
Improve sentry reporting for approved applications
1 parent cce9733 commit 6a13f5c

File tree

1 file changed

+37
-10
lines changed

1 file changed

+37
-10
lines changed

script/approver.go

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"log"
88
"path/filepath"
9+
"strconv"
910
"strings"
1011

1112
"github.com/getsentry/sentry-go"
@@ -87,16 +88,7 @@ func (a *Approver) Approve() {
8788
)
8889
}
8990

90-
var appData map[string]interface{}
91-
err := json.Unmarshal(a.application.GetData(), &appData)
92-
if err != nil {
93-
log.Fatal(err)
94-
}
95-
sentry.CaptureEvent(&sentry.Event{
96-
Message: "Application approved",
97-
Level: sentry.LevelInfo,
98-
Extra: appData,
99-
})
91+
a.createSentryEvent()
10092
}
10193

10294
func (a *Approver) logErrorAndExit(message string, err error) {
@@ -125,3 +117,38 @@ Finally, we’d love to hear more about your experience using 1Password in your
125117
126118
Welcome to the program and happy coding! 🧑‍💻`, a.application.ApproverUsername))
127119
}
120+
121+
func (a *Approver) createSentryEvent() {
122+
var appData map[string]interface{}
123+
err := json.Unmarshal(a.application.GetData(), &appData)
124+
if err != nil {
125+
sentry.CaptureException(err)
126+
log.Fatal(err)
127+
}
128+
129+
var applicationType string
130+
if a.application.Project.IsTeam {
131+
applicationType = "team"
132+
} else if a.application.Project.IsEvent {
133+
applicationType = "event"
134+
} else {
135+
applicationType = "project"
136+
}
137+
138+
tags := map[string]string{
139+
"project_name": a.application.Project.Name,
140+
"homepage_url": a.application.Project.HomeURL,
141+
"application_type": applicationType,
142+
"team_size": strconv.Itoa(a.application.Project.Contributors),
143+
"issue_number": strconv.Itoa(a.application.IssueNumber),
144+
"approved_by": fmt.Sprintf("@%s", a.application.ApproverUsername),
145+
"can_contact": strconv.FormatBool(a.application.CanContact),
146+
}
147+
148+
sentry.CaptureEvent(&sentry.Event{
149+
Message: fmt.Sprintf("Application approved for \"%s\"", a.application.Project.Name),
150+
Level: sentry.LevelInfo,
151+
Extra: appData,
152+
Tags: tags,
153+
})
154+
}

0 commit comments

Comments
 (0)