Skip to content

Commit 3ed3aa6

Browse files
authored
Merge pull request #10 from unloop/master
update sentry flags
2 parents 4554c07 + 57b3f0f commit 3ed3aa6

1 file changed

Lines changed: 16 additions & 18 deletions

File tree

sentry/plugin.go

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ package sentry
1818

1919
import (
2020
"context"
21-
"fmt"
22-
"strings"
2321
"time"
2422

2523
"github.com/getsentry/sentry-go"
@@ -34,7 +32,7 @@ const (
3432

3533
type Plugin interface {
3634
toolkit.Plugin
37-
Client() *sentry.Client
35+
Client() *sentry.Hub
3836
Info()
3937
}
4038

@@ -43,9 +41,12 @@ type Options struct {
4341
}
4442

4543
type Config struct {
46-
DSN string `env:"DSN" envDefault:"" comment:"Sentry DSN"`
47-
Environment string `env:"ENVIRONMENT" envDefault:"production" comment:"Environment"`
48-
Disable bool `env:"DISABLE" envDefault:"" comment:"disable sentry"`
44+
DSN string `env:"DSN" envDefault:"" comment:"The DSN to use. If the DSN is not set, the client is effectively disabled."`
45+
Environment string `env:"ENVIRONMENT" envDefault:"production" comment:"The environment to be sent with events."`
46+
Release string `env:"RELEASE" envDefault:"" comment:"The release to be sent with events."`
47+
Dist string `env:"DIST" envDefault:"" comment:"The dist to be sent with events."`
48+
AttachStacktrace bool `env:"ATTACH_STACKTRACE" envDefault:"false" comment:"Configures whether SDK should generate and attach stacktraces to pure capture message calls."`
49+
Debug bool `env:"DEBUG" envDefault:"false" comment:"In debug mode, the debug information is printed to stdout to help you understand what sentry is doing."`
4950
}
5051

5152
type plugin struct {
@@ -57,12 +58,12 @@ type plugin struct {
5758

5859
opts Config
5960

60-
client *sentry.Client
61+
client *sentry.Hub
6162

6263
isRunning bool
6364
}
6465

65-
func (p *plugin) Client() *sentry.Client {
66+
func (p *plugin) Client() *sentry.Hub {
6667
return p.client
6768
}
6869

@@ -71,22 +72,19 @@ func (p *plugin) Info() {
7172
}
7273

7374
func (p *plugin) PreStart(ctx context.Context) (err error) {
74-
if p.opts.Disable {
75-
return nil
76-
}
77-
if p.opts.DSN == "" {
78-
return fmt.Errorf("%s_DSN environment variable required but not set", strings.ToUpper(p.prefix))
79-
}
80-
8175
err = sentry.Init(sentry.ClientOptions{
82-
Dsn: p.opts.DSN,
83-
Environment: p.opts.Environment,
76+
Debug: p.opts.Debug,
77+
Dsn: p.opts.DSN,
78+
Environment: p.opts.Environment,
79+
Release: p.opts.Release,
80+
Dist: p.opts.Dist,
81+
AttachStacktrace: p.opts.AttachStacktrace,
8482
})
8583
if err != nil {
8684
return err
8785
}
8886

89-
p.client = sentry.CurrentHub().Client()
87+
p.client = sentry.CurrentHub()
9088

9189
p.isRunning = true
9290

0 commit comments

Comments
 (0)