make SentryConfiguration wasm-compatible
- Moved `hostname` lib behind conditional compiling - provided alternative implementation of hostname::get for wasm-targets
This commit is contained in:
parent
6ad5a5851f
commit
7f48eedb2c
|
@ -11,6 +11,20 @@ pub struct SentryConfiguration {
|
|||
pub environment: String,
|
||||
}
|
||||
|
||||
impl SentryConfiguration {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn get_hostname() -> std::io::Result<OsString> {
|
||||
hostname::get()
|
||||
}
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
fn get_hostname() -> std::io::Result<OsString> {
|
||||
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(),
|
||||
|
|
Loading…
Reference in New Issue