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
af0178e15a
commit
7f3bb944b7
|
@ -11,6 +11,20 @@ pub struct SentryConfiguration {
|
||||||
pub environment: String,
|
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 {
|
impl Default for SentryConfiguration {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
@ -19,7 +33,7 @@ impl Default for SentryConfiguration {
|
||||||
"https://241c6fb08adb469da1bb82522b25c99f@sentry.quartzinc.space/3",
|
"https://241c6fb08adb469da1bb82522b25c99f@sentry.quartzinc.space/3",
|
||||||
),
|
),
|
||||||
trace_sample_rate: 1.0,
|
trace_sample_rate: 1.0,
|
||||||
environment: hostname::get()
|
environment: SentryConfiguration::get_hostname()
|
||||||
.unwrap_or_else(|_| OsString::new())
|
.unwrap_or_else(|_| OsString::new())
|
||||||
.to_string_lossy()
|
.to_string_lossy()
|
||||||
.to_string(),
|
.to_string(),
|
||||||
|
|
Loading…
Reference in New Issue