Skip to content

Commit

Permalink
Attach the X-Sentry-Auth header to /envelope requests
Browse files Browse the repository at this point in the history
  • Loading branch information
cleptric committed Sep 4, 2023
1 parent 54d884a commit 9015523
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 0 additions & 1 deletion sentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const SDKIdentifier = "sentry.go"

// apiVersion is the minimum version of the Sentry API compatible with the
// sentry-go SDK.
// Deprecated: To be removed in 0.25.0.
const apiVersion = "7"

// Init initializes the SDK with options. The returned error is non-nil if
Expand Down
9 changes: 9 additions & 0 deletions transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,15 @@ func getRequestFromEvent(event *Event, dsn *Dsn) (r *http.Request, err error) {
if r != nil {
r.Header.Set("User-Agent", fmt.Sprintf("%s/%s", event.Sdk.Name, event.Sdk.Version))
r.Header.Set("Content-Type", "application/x-sentry-envelope")

auth := fmt.Sprintf("Sentry sentry_version=%s, "+
"sentry_client=%s/%s, sentry_key=%s", apiVersion, event.Sdk.Name, event.Sdk.Version, dsn.publicKey)

if dsn.secretKey != "" {
auth = fmt.Sprintf("%s, sentry_secret=%s", auth, dsn.secretKey)
}

Check warning on line 220 in transport.go

View check run for this annotation

Codecov / codecov/patch

transport.go#L219-L220

Added lines #L219 - L220 were not covered by tests

r.Header.Set("X-Sentry-Auth", auth)
}
}()
body := getRequestBodyFromEvent(event)
Expand Down

0 comments on commit 9015523

Please sign in to comment.