mukan-ignite/ignite/internal/sentry/sentry.go
Mukan Erkin Törük c32551b6f7
Some checks failed
Docs Deploy / build_and_deploy (push) Has been cancelled
Generate Docs / cli (push) Has been cancelled
Generate Config Doc / cli (push) Has been cancelled
Go formatting / go-formatting (push) Has been cancelled
Check links / markdown-link-check (push) Has been cancelled
Integration / pre-test (push) Has been cancelled
Integration / test on (push) Has been cancelled
Integration / status (push) Has been cancelled
Lint / Lint Go code (push) Has been cancelled
Test / test (ubuntu-latest) (push) Has been cancelled
refactor: replace all github.com upstream refs with git.cw.tr/mukan-network
2026-05-11 03:36:24 +03:00

48 lines
1.2 KiB
Go

package sentry
import (
"context"
"fmt"
"strings"
"time"
"github.com/getsentry/sentry-go"
"git.cw.tr/mukan-network/mukan-ignite/ignite/pkg/errors"
"git.cw.tr/mukan-network/mukan-ignite/ignite/version"
)
const IgniteDNS = "https://1d862300ead01c5814d8ead3732fd41f@o1152630.ingest.us.sentry.io/4507891348930560"
func InitSentry(ctx context.Context) (deferMe func(), err error) {
sentrySyncTransport := sentry.NewHTTPSyncTransport()
sentrySyncTransport.Timeout = time.Second * 3
igniteInfo, err := version.GetInfo(ctx)
if err != nil {
return nil, errors.Errorf("failed to init sentry: %w", err)
}
if err := sentry.Init(sentry.ClientOptions{
Dsn: IgniteDNS,
Transport: sentrySyncTransport,
Environment: getEnvironment(igniteInfo.CLIVersion),
Release: fmt.Sprintf("ignite@%s", igniteInfo.CLIVersion),
SampleRate: 1.0, // get all events
}); err != nil {
return nil, errors.Errorf("failed to init sentry: %w", err)
}
return func() {
sentry.Recover()
sentry.Flush(time.Second * 2)
}, nil
}
func getEnvironment(igniteVersion string) string {
if strings.Contains(igniteVersion, "dev") {
return "development"
}
return "production"
}