CommonLibrary/Telemetry/
Configuration.rs1#![allow(non_snake_case)]
2
3pub struct Configuration {
10 pub Key:String,
11 pub Host:String,
12 pub Brand:String,
13 pub Report:bool,
14 pub Capture:bool,
15 pub OTLPEndpoint:String,
16 pub OTLPEnabled:bool,
17}
18
19fn ReadString(Key:&str, Fallback:&str) -> String {
20 std::env::var(Key)
21 .ok()
22 .filter(|V| !V.is_empty())
23 .unwrap_or_else(|| Fallback.to_string())
24}
25
26fn ReadBool(Key:&str, Fallback:bool) -> bool {
27 match std::env::var(Key).ok().map(|V| V.to_lowercase()) {
28 Some(V) => !matches!(V.as_str(), "false" | "0" | "off"),
29 None => Fallback,
30 }
31}
32
33pub fn Fn() -> Configuration {
34 Configuration {
35 Key:ReadString("Authorize", ""),
36 Host:ReadString("Beam", "https://eu.i.posthog.com"),
37 Brand:ReadString("Brand", ""),
38 Report:ReadBool("Report", true),
39 Capture:ReadBool("Capture", true),
40 OTLPEndpoint:ReadString("OTLPEndpoint", "http://127.0.0.1:4318"),
41 OTLPEnabled:ReadBool("OTLPEnabled", true),
42 }
43}