Skip to content

Commit

Permalink
feat(submission-url): Allow submit.backtrace.io submission url
Browse files Browse the repository at this point in the history
  • Loading branch information
MateuszKepczynskiSauce committed Nov 20, 2024
1 parent 251c7db commit e4b2e34
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,14 @@ func checkOptions() bool {
}
panic("must set bt.Options.Endpoint")
}
if len(Options.Token) == 0 {
if !Options.DebugBacktrace {
return false

if !strings.HasPrefix(Options.Endpoint, "https://submit.backtrace.io") {
if len(Options.Token) == 0 {
if !Options.DebugBacktrace {
return false
}
panic("must set bt.Options.Token")
}
panic("must set bt.Options.Token")
}
return true
}
Expand Down Expand Up @@ -256,7 +259,12 @@ func processAndSend(payload *reportPayload) {
report["sourceCode"] = sourceCode
report["classifiers"] = []string{payload.classifier}

fullUrl := fmt.Sprintf("%s/post?format=json&token=%s", Options.Endpoint, url.QueryEscape(Options.Token))
fullUrl := Options.Endpoint

if len(Options.Token) != 0 { // if token is set that means its old URL.
fullUrl = fmt.Sprintf("%s/post?format=json&token=%s", Options.Endpoint, url.QueryEscape(Options.Token))
}

if Options.DebugBacktrace {
fmt.Fprintf(os.Stderr, "POST %s\n", fullUrl)
var err error
Expand Down

0 comments on commit e4b2e34

Please sign in to comment.