aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/zenserver.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2023-05-10 23:18:27 +0200
committerGitHub <[email protected]>2023-05-10 23:18:27 +0200
commit158ddf2f8dcc34e5360ca24b03d5a8a0d295ec59 (patch)
tree9a501c0ff969cab3ff6b8bf7ec784ab84bc28e71 /src/zenserver/zenserver.cpp
parentOnly rewrite state_marker file if it does not exist so we can see the age of it (diff)
downloadzen-158ddf2f8dcc34e5360ca24b03d5a8a0d295ec59.tar.xz
zen-158ddf2f8dcc34e5360ca24b03d5a8a0d295ec59.zip
need to set 'id' for user info in sentry (#287)
Diffstat (limited to 'src/zenserver/zenserver.cpp')
-rw-r--r--src/zenserver/zenserver.cpp60
1 files changed, 35 insertions, 25 deletions
diff --git a/src/zenserver/zenserver.cpp b/src/zenserver/zenserver.cpp
index 5e60ec753..f041332e5 100644
--- a/src/zenserver/zenserver.cpp
+++ b/src/zenserver/zenserver.cpp
@@ -1009,6 +1009,7 @@ ZenEntryPoint::Run()
#if ZEN_USE_SENTRY
int SentryErrorCode = 0;
std::unique_ptr<zen::utils::SentryAssertImpl> SentryAssert;
+ std::string SentryUserName;
if (m_ServerOptions.NoSentry == false)
{
@@ -1029,36 +1030,38 @@ ZenEntryPoint::Run()
sentry_options_add_attachment(SentryOptions, SentryAttachmentPath.c_str());
sentry_options_set_release(SentryOptions, ZEN_CFG_VERSION);
- if (m_ServerOptions.SentryAllowPII)
- {
- sentry_value_t user = sentry_value_new_object();
-
-# if ZEN_PLATFORM_WINDOWS
- CHAR UserNameBuffer[511 + 1];
- DWORD UserNameLength = sizeof(UserNameBuffer) / sizeof(CHAR);
- BOOL OK = GetUserNameA(UserNameBuffer, &UserNameLength);
- if (OK)
- {
- sentry_value_set_by_key(user, "username", sentry_value_new_string(UserNameBuffer));
- }
-# endif // ZEN_PLATFORM_WINDOWS
-# if (ZEN_PLATFORM_LINUX || ZEN_PLATFORM_MAC)
- uid_t uid = geteuid();
- struct passwd* pw = getpwuid(uid);
- if (pw)
- {
- sentry_value_set_by_key(user, "username", sentry_value_new_string(pw->pw_name));
- }
-# endif
- sentry_value_set_by_key(user, "ip_address", sentry_value_new_string("{{auto}}"));
- sentry_set_user(user);
- }
// sentry_options_set_debug(SentryOptions, 1);
SentryErrorCode = sentry_init(SentryOptions);
if (SentryErrorCode == 0)
{
+ if (m_ServerOptions.SentryAllowPII)
+ {
+# if ZEN_PLATFORM_WINDOWS
+ CHAR UserNameBuffer[511 + 1];
+ DWORD UserNameLength = sizeof(UserNameBuffer) / sizeof(CHAR);
+ BOOL OK = GetUserNameA(UserNameBuffer, &UserNameLength);
+ if (OK)
+ {
+ SentryUserName = std::string(UserNameBuffer, UserNameLength);
+ }
+# endif // ZEN_PLATFORM_WINDOWS
+# if (ZEN_PLATFORM_LINUX || ZEN_PLATFORM_MAC)
+ uid_t uid = geteuid();
+ struct passwd* pw = getpwuid(uid);
+ if (pw)
+ {
+ SentryUserName = std::string(pw->pw_name);
+ }
+# endif
+ sentry_value_t SentryUserObject = sentry_value_new_object();
+ sentry_value_set_by_key(SentryUserObject, "id", sentry_value_new_string(SentryUserName.c_str()));
+ sentry_value_set_by_key(SentryUserObject, "username", sentry_value_new_string(SentryUserName.c_str()));
+ sentry_value_set_by_key(SentryUserObject, "ip_address", sentry_value_new_string("{{auto}}"));
+ sentry_set_user(SentryUserObject);
+ }
+
auto SentrySink = spdlog::create<utils::sentry_sink>("sentry");
zen::logging::SetErrorLog(std::move(SentrySink));
@@ -1139,7 +1142,14 @@ ZenEntryPoint::Run()
{
if (SentryErrorCode == 0)
{
- ZEN_INFO("sentry initialized");
+ if (m_ServerOptions.SentryAllowPII)
+ {
+ ZEN_INFO("sentry initialized, username: '{}'", SentryUserName);
+ }
+ else
+ {
+ ZEN_INFO("sentry initialized with anonymous reports");
+ }
}
else
{