diff --git a/src/sentry/contexts.cpp b/src/sentry/contexts.cpp index 03f9ddd..f814315 100644 --- a/src/sentry/contexts.cpp +++ b/src/sentry/contexts.cpp @@ -2,6 +2,7 @@ #include "sentry/environment.h" #include "sentry/uuid.h" +#include "sentry_options.h" #include #include @@ -61,12 +62,13 @@ Dictionary make_device_context(const Ref &p_runtime_config) { device_context["orientation"] = orientation; } - // TODO: Need platform-specific solutions - this doesn't work well. - String host = OS::get_singleton()->get_environment("HOST"); - if (host.is_empty()) { - host = "localhost"; + if (SentryOptions::get_singleton()->is_send_default_pii_enabled()) { + // TODO: Need platform-specific solutions - this doesn't work well. + String host = OS::get_singleton()->get_environment("HOST"); + if (!host.is_empty()) { + device_context["name"] = host; + } } - device_context["name"] = host; String model = OS::get_singleton()->get_model_name(); if (!model.is_empty() && model != "GenericDevice") { diff --git a/src/sentry_options.cpp b/src/sentry_options.cpp index b97b695..308e763 100644 --- a/src/sentry_options.cpp +++ b/src/sentry_options.cpp @@ -22,6 +22,7 @@ void SentryOptions::_load_project_settings() { sample_rate = ProjectSettings::get_singleton()->get_setting("sentry/config/sample_rate", sample_rate); attach_log = ProjectSettings::get_singleton()->get_setting("sentry/config/attach_log", attach_log); max_breadcrumbs = ProjectSettings::get_singleton()->get_setting("sentry/config/max_breadcrumbs", max_breadcrumbs); + send_default_pii = ProjectSettings::get_singleton()->get_setting("sentry/config/send_default_pii", send_default_pii); error_logger_enabled = ProjectSettings::get_singleton()->get_setting("sentry/config/error_logger/enabled", error_logger_enabled); error_logger_max_lines = ProjectSettings::get_singleton()->get_setting("sentry/config/error_logger/max_lines", error_logger_max_lines); @@ -64,6 +65,7 @@ void SentryOptions::_define_project_settings() { _define_setting(PropertyInfo(Variant::FLOAT, "sentry/config/sample_rate", PROPERTY_HINT_RANGE, "0.0,1.0"), sample_rate); _define_setting("sentry/config/attach_log", attach_log); _define_setting(PropertyInfo(Variant::INT, "sentry/config/max_breadcrumbs", PROPERTY_HINT_RANGE, "0, 500"), max_breadcrumbs); + _define_setting("sentry/config/send_default_pii", send_default_pii); _define_setting("sentry/config/error_logger/enabled", error_logger_enabled); _define_setting("sentry/config/error_logger/max_lines", error_logger_max_lines); diff --git a/src/sentry_options.h b/src/sentry_options.h index d09dd6e..baf0498 100644 --- a/src/sentry_options.h +++ b/src/sentry_options.h @@ -25,6 +25,7 @@ class SentryOptions { bool attach_log = true; int32_t config_value_order = 0; int max_breadcrumbs = 100; + bool send_default_pii = false; bool error_logger_enabled = true; int error_logger_max_lines = 30; @@ -47,6 +48,7 @@ class SentryOptions { double get_sample_rate() const { return sample_rate; } bool is_attach_log_enabled() const { return attach_log; } int get_max_breadcrumbs() const { return max_breadcrumbs; } + bool is_send_default_pii_enabled() const { return send_default_pii; } bool is_error_logger_enabled() const { return error_logger_enabled; } int get_error_logger_max_lines() const { return error_logger_max_lines; } diff --git a/src/sentry_sdk.cpp b/src/sentry_sdk.cpp index 34e678f..169f67f 100644 --- a/src/sentry_sdk.cpp +++ b/src/sentry_sdk.cpp @@ -48,12 +48,9 @@ void SentrySDK::set_user(const Ref &p_user) { // Initialize user ID if not supplied. if (p_user->get_id().is_empty()) { - // Take user ID from the runtime config or generate a new one if it's empty. - String user_id = get_user()->get_id(); - if (user_id.is_empty()) { - user_id = sentry::uuid::make_uuid(); + if (get_user()->get_id().is_empty() && SentryOptions::get_singleton()->is_send_default_pii_enabled()) { + p_user->generate_new_id(); } - p_user->set_id(user_id); } // Save user in a runtime conf-file.