From a8d43aa9a739e6a09d793c727eb515e0f2ac3fb1 Mon Sep 17 00:00:00 2001 From: Arpad Borsos Date: Thu, 15 Oct 2020 11:25:54 +0200 Subject: [PATCH] fix: Set a default environment based on debug_assertions --- sentry-core/src/clientoptions.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sentry-core/src/clientoptions.rs b/sentry-core/src/clientoptions.rs index c53e3ee0c..51cb917e6 100644 --- a/sentry-core/src/clientoptions.rs +++ b/sentry-core/src/clientoptions.rs @@ -38,6 +38,9 @@ pub struct ClientOptions { /// The release to be sent with events. pub release: Option>, /// The environment to be sent with events. + /// + /// Defaults to either `"development"` or `"production"` depending on the + /// `debug_assertions` cfg-attribute. pub environment: Option>, /// The sample rate for event submission. (0.0 - 1.0, defaults to 1.0) pub sample_rate: f32, @@ -163,11 +166,16 @@ impl fmt::Debug for ClientOptions { impl Default for ClientOptions { fn default() -> ClientOptions { + let env = if cfg!(debug_assertions) { + "development" + } else { + "production" + }; ClientOptions { dsn: None, debug: false, release: None, - environment: None, + environment: Some(env.into()), sample_rate: 1.0, max_breadcrumbs: 100, attach_stacktrace: false,