Sentry SDK
Forward Sentry events to Sazabi alongside your Sentry project
Forward Sentry events (errors, transactions) to Sazabi alongside your Sentry project for AI-powered analysis and correlation.
About this data source
Sentry SDKs provide a beforeSend hook that allows you to intercept and
forward events before they are sent to Sentry. This enables you to send a copy
of every Sentry event to Sazabi without blocking your error reporting flow.
With this integration, you can:
- Keep Sentry as your primary error tracking platform
- Leverage Sazabi's AI to analyze errors alongside your logs and traces
- Correlate Sentry events with other telemetry in Sazabi
- Forward all captured events without changing your error handling code
Prerequisites
Before you begin, make sure you have:
- Sentry SDK installed in your application
- A Sazabi public API key (project-scoped)
Get your API key
Create a public key
Click Create API key and select Public as the key type. Public keys are safe to use in client-side code and are scoped to a single project.
Copy the key and store it securely. You will not be able to see it again.
Configuration
Configure the Sentry SDK to forward events using the beforeSend hook:
import * as Sentry from "@sentry/node";
Sentry.init({
dsn: "YOUR_SENTRY_DSN",
beforeSend(event) {
// Forward to Sazabi (non-blocking)
fetch("https://intake.sazabi.com/v1/events", {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-sazabi-key": process.env.SAZABI_PUBLIC_KEY,
},
body: JSON.stringify({
type: "sentry_event",
event,
}),
}).catch(() => {}); // Don't block on Sazabi
return event; // Continue to Sentry
},
});The beforeSend hook returns the event synchronously while the fetch to
Sazabi happens in the background. This ensures your error reporting to
Sentry is never delayed or blocked.
Configure the Sentry SDK to forward events using the before_send hook:
import os
import sentry_sdk
import requests
def before_send(event, hint):
# Forward to Sazabi (non-blocking with timeout)
try:
requests.post(
"https://intake.sazabi.com/v1/events",
headers={
"Content-Type": "application/json",
"x-sazabi-key": os.environ.get("SAZABI_PUBLIC_KEY"),
},
json={"type": "sentry_event", "event": event},
timeout=1, # Short timeout to avoid blocking
)
except Exception:
pass # Don't block on Sazabi errors
return event # Continue to Sentry
sentry_sdk.init(
dsn="YOUR_SENTRY_DSN",
before_send=before_send,
)The short timeout ensures that network issues with Sazabi do not delay your error reporting to Sentry. For truly non-blocking behavior, consider using a background thread or async task queue.
Configure the Sentry SDK to forward events using the BeforeSend hook:
package main
import (
"bytes"
"encoding/json"
"net/http"
"os"
"time"
"github.com/getsentry/sentry-go"
)
func main() {
err := sentry.Init(sentry.ClientOptions{
Dsn: "YOUR_SENTRY_DSN",
BeforeSend: func(event *sentry.Event, hint *sentry.EventHint) *sentry.Event {
// Forward to Sazabi in a goroutine (non-blocking)
go forwardToSazabi(event)
return event // Continue to Sentry
},
})
if err != nil {
panic(err)
}
defer sentry.Flush(2 * time.Second)
}
func forwardToSazabi(event *sentry.Event) {
payload := map[string]interface{}{
"type": "sentry_event",
"event": event,
}
body, err := json.Marshal(payload)
if err != nil {
return
}
client := &http.Client{Timeout: 2 * time.Second}
req, err := http.NewRequest("POST", "https://intake.sazabi.com/v1/events", bytes.NewReader(body))
if err != nil {
return
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("x-sazabi-key", os.Getenv("SAZABI_PUBLIC_KEY"))
client.Do(req) // Ignore response/errors
}Configure the Sentry SDK to forward events using the before_send hook:
require "sentry-ruby"
require "net/http"
require "json"
Sentry.init do |config|
config.dsn = "YOUR_SENTRY_DSN"
config.before_send = lambda do |event, hint|
# Forward to Sazabi in a thread (non-blocking)
Thread.new do
begin
uri = URI("https://intake.sazabi.com/v1/events")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.open_timeout = 1
http.read_timeout = 1
request = Net::HTTP::Post.new(uri.path)
request["Content-Type"] = "application/json"
request["x-sazabi-key"] = ENV["SAZABI_PUBLIC_KEY"]
request.body = { type: "sentry_event", event: event.to_hash }.to_json
http.request(request)
rescue StandardError
# Don't block on Sazabi errors
end
end
event # Continue to Sentry
end
endHow it works
When you configure the beforeSend hook, the Sentry SDK intercepts every event
before it is sent to Sentry:
- Your application captures an error or transaction
- The
beforeSendhook is called with the event data - A non-blocking request forwards the event to Sazabi
- The original event is returned and sent to Sentry
- Both platforms receive and process the event independently
This approach requires no changes to how you capture errors or use Sentry in your application code.
Verifying events are flowing
Once you have configured the SDK, verify that events are flowing to Sazabi:
Trigger a test error
Capture a test error to verify the integration:
// Node.js
Sentry.captureException(new Error("Test error for Sazabi integration"));# Python
sentry_sdk.capture_exception(Exception("Test error for Sazabi integration"))Ask the assistant
Open a thread in Sazabi and ask "Show me recent Sentry events" or "What errors have come in from Sentry in the last 5 minutes?"
Troubleshooting
Events not appearing in Sazabi
- Verify the
beforeSendhook is configured in your Sentry initialization - Check that your Sazabi API key is correct and has the Public scope
- Ensure the environment variable
SAZABI_PUBLIC_KEYis set - Test by adding a console log inside
beforeSendto confirm it is called
Performance impact
- Ensure the fetch/request to Sazabi is non-blocking
- In Node.js, use
.catch(() => {})to prevent unhandled promise rejections - In Python, use a short timeout (1 second) or async task queue
- In Go, use a goroutine to avoid blocking the main thread
401 Unauthorized errors
- Your API key may be invalid or expired
- Create a new public API key in Settings -> API Keys
- Verify the key is for the correct project
Events missing data
- The
beforeSendhook receives the full event object - If you have other
beforeSendprocessors, ensure they run before the Sazabi forwarder and return the complete event - Check that you are not accidentally modifying or filtering the event