Identify Users

Users consist of a few critical pieces of information that construct a unique identity in Sentry. Each of these is optional, but one must be present for the Sentry SDK to capture the user:

id
Your internal identifier for the user.

username
The username. Typically used as a better label than the internal id.

email
An alternative, or addition, to the username. Sentry is aware of email addresses and can display things such as Gravatars and unlock messaging capabilities.

ip_address
The user's IP address. If the user is unauthenticated, Sentry uses the IP address as a unique identifier for the user. Sentry will attempt to pull this from the HTTP request data, if available. That might require send_default_pii set to true in the SDK options. If set to "{{auto}}", Sentry will infer the IP address from the connection between your app and Sentry's server, which is useful for client-side applications such as JavaScript applications running on Web browsers, desktop applications, or mobile apps.

Additionally, you can provide arbitrary key/value pairs beyond the reserved names, and the Sentry SDK will store those with the user.

To identify the user:

Copied
TSharedPtr<FJsonObject> user = MakeShareable(new FJsonObject);
user->SetStringField("ip_address", "{{auto}}");
user->SetStringField("email", "jane.doe@example.com");

TSharedPtr<FJsonObject> config = MakeShareable(new FJsonObject);
config->SetObjectField("user", user);
}

Provide this configuration to the crash reporter during initialization.

You can also clear the currently set user:

Create a new __sentry config object without the "user" field. Then, call FGenericCrashContext::SetGameData from the initialization function with the new JSON data. You have to provide all other fields again, as call overrides the previously registered data.