Filtering for Unreal Engine
Learn more about how to configure your Sentry Unreal SDK to filter events reported to Sentry.
When you add Sentry to your app, you get a lot of valuable information about errors and performance. And lots of information is good -- as long as it's the right information, at a reasonable volume.
The Sentry SDKs have several configuration options to help you filter out events.
We also offer Inbound Filters to filter events in sentry.io. We recommend filtering at the client level though, because it removes the overhead of sending events you don't actually want. Learn more about the fields available in an event.
Configure your SDK to filter error events by using the BeforeSend callback method and configuring, enabling, or disabling integrations.
All Sentry SDKs support the BeforeSend callback method. Because it's called immediately before the event is sent to the server, this is your last chance to decide not to send data or to edit it. BeforeSend receives the event object as a parameter, which you can use to either modify the event’s data or drop it completely by returning null, based on custom logic and the data available on the event.
UCLASS()
class USomeBeforeSendHandler : public USentryBeforeSendHandler
{
GENERATED_BODY()
public:
virtual USentryEvent* HandleBeforeSend_Implementation(USentryEvent* Event, USentryHint* Hint) override
{
UE_LOG(LogTemp, Log, TEXT("Hello from CPP beforeSend handler"));
return Super::HandleBeforeSend_Implementation(Event, Hint);
}
};
...
FConfigureSettingsDelegate SettingsDelegate;
SettingsDelegate.BindDynamic(this, &USomeClass::HandleSettingsDelegate);
void USomeClass::HandleSettingsDelegate(USentrySettings* Settings)
{
Settings->BeforeSendHandler = USomeBeforeSendHandler::StaticClass();
}
...
USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem<USentrySubsystem>();
SentrySubsystem->InitializeWithSettings(SettingsDelegate);
UCLASS()
class USomeBeforeSendHandler : public USentryBeforeSendHandler
{
GENERATED_BODY()
public:
virtual USentryEvent* HandleBeforeSend_Implementation(USentryEvent* Event, USentryHint* Hint) override
{
UE_LOG(LogTemp, Log, TEXT("Hello from CPP beforeSend handler"));
return Super::HandleBeforeSend_Implementation(Event, Hint);
}
};
...
FConfigureSettingsDelegate SettingsDelegate;
SettingsDelegate.BindDynamic(this, &USomeClass::HandleSettingsDelegate);
void USomeClass::HandleSettingsDelegate(USentrySettings* Settings)
{
Settings->BeforeSendHandler = USomeBeforeSendHandler::StaticClass();
}
...
USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem<USentrySubsystem>();
SentrySubsystem->InitializeWithSettings(SettingsDelegate);
The hint passed to BeforeSend can also be used to add or remove attachments, as described in Attachments.
Note also that breadcrumbs can be filtered, as discussed in our Breadcrumbs documentation.
Configure your SDK to filter user feedback by using the beforeSendFeedback callback method.
The beforeSendFeedback callback is called immediately before user feedback is sent to Sentry. It receives the feedback event as a parameter, which you can use to modify or enrich the event (for example, adjusting the feedback message, tags, or contexts, or scrubbing sensitive data), or drop it completely by returning null.
beforeSendFeedback is currently not supported on macOS and iOS.
UCLASS()
class USomeBeforeSendFeedbackHandler : public USentryBeforeSendFeedbackHandler
{
GENERATED_BODY()
public:
virtual USentryEvent* HandleBeforeSendFeedback_Implementation(USentryEvent* Event, USentryHint* Hint) override
{
// The feedback fields are available through the event
if (USentryFeedback* Feedback = Event->GetFeedback())
{
// Scrub or modify the feedback before it's sent
Feedback->SetContactEmail(TEXT("redacted@example.com"));
}
return Super::HandleBeforeSendFeedback_Implementation(Event, Hint);
}
};
...
FConfigureSettingsDelegate SettingsDelegate;
SettingsDelegate.BindDynamic(this, &USomeClass::HandleSettingsDelegate);
void USomeClass::HandleSettingsDelegate(USentrySettings* Settings)
{
Settings->BeforeSendFeedbackHandler = USomeBeforeSendFeedbackHandler::StaticClass();
}
...
USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem<USentrySubsystem>();
SentrySubsystem->InitializeWithSettings(SettingsDelegate);
UCLASS()
class USomeBeforeSendFeedbackHandler : public USentryBeforeSendFeedbackHandler
{
GENERATED_BODY()
public:
virtual USentryEvent* HandleBeforeSendFeedback_Implementation(USentryEvent* Event, USentryHint* Hint) override
{
// The feedback fields are available through the event
if (USentryFeedback* Feedback = Event->GetFeedback())
{
// Scrub or modify the feedback before it's sent
Feedback->SetContactEmail(TEXT("redacted@example.com"));
}
return Super::HandleBeforeSendFeedback_Implementation(Event, Hint);
}
};
...
FConfigureSettingsDelegate SettingsDelegate;
SettingsDelegate.BindDynamic(this, &USomeClass::HandleSettingsDelegate);
void USomeClass::HandleSettingsDelegate(USentrySettings* Settings)
{
Settings->BeforeSendFeedbackHandler = USomeBeforeSendFeedbackHandler::StaticClass();
}
...
USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem<USentrySubsystem>();
SentrySubsystem->InitializeWithSettings(SettingsDelegate);
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").