Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

Cpp API

Sergey Dikiy edited this page Jan 24, 2022 · 2 revisions

General API that you need to work with that project.

#include <Sentry.h>

After that please take notice of class: FSentryManager That the only class you need to access base functions of sending events.

// Will return instance of class to work with
auto SentryManager = FSentryManager::Get() 

// Will return structure that used to describe your application to Sentry plugin, information in that structure will be used in events
// NOTE: Filling Application Info not required, but its help to keep track of events you will send later
// NOTE: I recommend setup AppInfo before events will start sending around, good place where you can do it in: virtual UGameInsance::Init() function
auto& AppInfo = SentryManager->ApplicationInfo() 

// Set Environment of the application, helps with associating events with different backends envs or testing branches
AppInfo.SetEnvironment(TEXT("client-env"))

// Set release version of your app
AppInfo.SetRelease(TEXT("1.1.2"))

// Set distribution of app, usually means more detailed release version, with commit hash and etc
AppInfo.SetDistribution(TEXT("1.1.2.32-6b353d3"))

// Create Exception structure and start filling fields
FSentryException Exception;
Exception.Type = TEXT("WrongValue");
Exception.Value = TEXT("value X should not be == 0");
Exception.Module = TEXT("game");
// Sends filled exception event to Sentry! Exceptions means more for Error during execution, then Exception as real Cpp Exception. 
// By changing ESentryLevel you can tell sentry how important exception message are. 
SentryManager->SendException(ESentryLevel::Debug, Exception);

// Create log entry structure
FSentryLogEntry LogEntry;
// Log entry supports some sort of Printf stuff that will be parsed on Sentry side
// So you can use %s in message and after in Params adding format variables
// But you can go with just messages, Params just fancy Printf way. 
LogEntry.Message = TEXT("Variable X should equal %s instead of %s");
LogEntry.Params = { FString::FromInt(13), TEXT("0") };
// Send log entry to Sentry
SentryManager->SendLogEntry(ESentryLevel::Debug, LogEntry);

// Feel limited by api? Use this!
// But i'll will not describe all stuff inside that structure, curios what inside? I guess discover by yourself. 
// That structure is base for anything else, it will be converted to Json and then sended to Sentry
// Also can be used to set such variables as event_id timestamp and etc to meet very own requirements that you might have.
FSentryEvent_Json Event;
SentryManager->SendEventJson(Event)
Clone this wiki locally