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