|
6 | 6 | "fmt"
|
7 | 7 | "log"
|
8 | 8 | "path/filepath"
|
| 9 | + "strconv" |
9 | 10 | "strings"
|
10 | 11 |
|
11 | 12 | "github.com/getsentry/sentry-go"
|
@@ -87,16 +88,7 @@ func (a *Approver) Approve() {
|
87 | 88 | )
|
88 | 89 | }
|
89 | 90 |
|
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() |
100 | 92 | }
|
101 | 93 |
|
102 | 94 | 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
|
125 | 117 |
|
126 | 118 | Welcome to the program and happy coding! 🧑💻`, a.application.ApproverUsername))
|
127 | 119 | }
|
| 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