@tanagram/cli 0.4.18 → 0.4.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
Binary file
Binary file
Binary file
Binary file
package/go.mod CHANGED
@@ -19,6 +19,7 @@ require (
19
19
  github.com/charmbracelet/x/term v0.2.1 // indirect
20
20
  github.com/danieljoos/wincred v1.2.2 // indirect
21
21
  github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
22
+ github.com/getsentry/sentry-go v0.40.0 // indirect
22
23
  github.com/go-ole/go-ole v1.2.6 // indirect
23
24
  github.com/godbus/dbus/v5 v5.1.0 // indirect
24
25
  github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
package/go.sum CHANGED
@@ -22,6 +22,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
22
22
  github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
23
23
  github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
24
24
  github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
25
+ github.com/getsentry/sentry-go v0.40.0 h1:VTJMN9zbTvqDqPwheRVLcp0qcUcM+8eFivvGocAaSbo=
26
+ github.com/getsentry/sentry-go v0.40.0/go.mod h1:eRXCoh3uvmjQLY6qu63BjUZnaBu5L5WhMV1RwYO8W5s=
25
27
  github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
26
28
  github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
27
29
  github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
package/main.go CHANGED
@@ -9,7 +9,9 @@ import (
9
9
  "os"
10
10
  "path/filepath"
11
11
  "strings"
12
+ "time"
12
13
 
14
+ "github.com/getsentry/sentry-go"
13
15
  "github.com/tanagram/cli/commands"
14
16
  "github.com/tanagram/cli/metrics"
15
17
  "github.com/tanagram/cli/tui"
@@ -30,14 +32,28 @@ func main() {
30
32
  metrics.SetVersion(Version)
31
33
  metrics.Init()
32
34
 
35
+ if err := sentry.Init(sentry.ClientOptions{
36
+ Dsn: "https://a967718dd129e143907fe01b4e80cad2@o4509017064472576.ingest.us.sentry.io/4510649104007168",
37
+ Release: "tanagram-cli@" + Version,
38
+ Environment: getEnvironment(),
39
+ EnableTracing: true,
40
+ TracesSampleRate: 0.1,
41
+ }); err != nil {
42
+ slog.Warn("Sentry initialization failed", "error", err)
43
+ }
44
+
33
45
  exitCode := 0
34
46
  defer func() {
47
+ if r := recover(); r != nil {
48
+ sentry.CurrentHub().Recover(r)
49
+ slog.Error("Panic recovered", "panic", r)
50
+ exitCode = 1
51
+ }
52
+ sentry.Flush(2 * time.Second)
35
53
  metrics.Track("cli.exit", map[string]interface{}{
36
54
  "exit_code": exitCode,
37
55
  })
38
56
  metrics.Close()
39
- // os.Exit immediately exits without calling other `defer`s, so we need to group these two statements
40
- // and call them in the right order.
41
57
  os.Exit(exitCode)
42
58
  }()
43
59
 
@@ -236,6 +252,10 @@ func main() {
236
252
  }
237
253
 
238
254
  if err != nil {
255
+ sentry.WithScope(func(scope *sentry.Scope) {
256
+ scope.SetTag("command", subcommand)
257
+ sentry.CaptureException(err)
258
+ })
239
259
  metrics.Track("cli.command.error", map[string]interface{}{
240
260
  "command": subcommand,
241
261
  "error": err.Error(),
@@ -246,6 +266,13 @@ func main() {
246
266
  }
247
267
  }
248
268
 
269
+ func getEnvironment() string {
270
+ if env := os.Getenv("SENTRY_ENVIRONMENT"); env != "" {
271
+ return env
272
+ }
273
+ return "unconfigured"
274
+ }
275
+
249
276
  func printHelp() {
250
277
  help := `Tanagram - Policy enforcement for git changes
251
278
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanagram/cli",
3
- "version": "0.4.18",
3
+ "version": "0.4.19",
4
4
  "description": "Tanagram - Catch sloppy code before it ships",
5
5
  "main": "index.js",
6
6
  "bin": {