Skip to content

Commit

Permalink
Merge pull request #811 from ww24/add-release-version-to-sentry-event
Browse files Browse the repository at this point in the history
fix(sentry): add release prop
  • Loading branch information
ww24 authored Jan 14, 2024
2 parents 848b9e6 + cdeacf1 commit 85e4370
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions presentation/http/sentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/getsentry/sentry-go"
sentryhttp "github.com/getsentry/sentry-go/http"

"github.com/ww24/linebot/internal/buildinfo"
"github.com/ww24/linebot/internal/config"
)

Expand All @@ -20,6 +21,15 @@ func newSentryMiddleware(cfg *config.Sentry) (*sentryhttp.Handler, error) {
// of transactions for performance monitoring.
// We recommend adjusting this value in production,
TracesSampleRate: 1.0,
BeforeSend: func(event *sentry.Event, hint *sentry.EventHint) *sentry.Event {
const releasePrefix = "linebot@"
if buildinfo.Version() != "" {
event.Release = releasePrefix + buildinfo.Version()
} else {
event.Release = releasePrefix + "dev-" + buildinfo.Revision()
}
return event
},
}); err != nil {
return nil, fmt.Errorf("failed to initialize Sentry: %w", err)
}
Expand Down

0 comments on commit 85e4370

Please sign in to comment.