diff --git a/src/types/config/types/sentry_configuration.rs b/src/types/config/types/sentry_configuration.rs index 256bab9..99de4ff 100644 --- a/src/types/config/types/sentry_configuration.rs +++ b/src/types/config/types/sentry_configuration.rs @@ -11,6 +11,20 @@ pub struct SentryConfiguration { pub environment: String, } +impl SentryConfiguration { + #[cfg(not(target_arch = "wasm32"))] + fn get_hostname() -> std::io::Result { + hostname::get() + } + #[cfg(target_arch = "wasm32")] + fn get_hostname() -> std::io::Result { + Err(std::io::Error::new( + std::io::ErrorKind::Unsupported, + "Unsupported: wasm targets do not have a hostname", + )) + } +} + impl Default for SentryConfiguration { fn default() -> Self { Self { @@ -19,7 +33,7 @@ impl Default for SentryConfiguration { "https://241c6fb08adb469da1bb82522b25c99f@sentry.quartzinc.space/3", ), trace_sample_rate: 1.0, - environment: hostname::get() + environment: SentryConfiguration::get_hostname() .unwrap_or_else(|_| OsString::new()) .to_string_lossy() .to_string(),