detsys_ids_client/
lib.rs

1mod builder;
2pub mod checkin;
3mod collator;
4mod compression_set;
5mod configuration_proxy;
6mod ds_correlation;
7mod identity;
8mod json_string;
9mod recorder;
10pub mod storage;
11mod submitter;
12pub mod system_snapshot;
13pub mod transport;
14mod worker;
15
16use std::collections::HashMap;
17
18pub use builder::Builder;
19pub use identity::{AnonymousDistinctId, DeviceId, DistinctId};
20pub use recorder::{IdentifyProperties, Recorder};
21pub use worker::Worker;
22
23pub type Map = serde_json::Map<String, serde_json::Value>;
24pub type Groups = HashMap<String, String>;
25pub type PersonProperties = Map;
26
27#[macro_export]
28macro_rules! builder {
29    () => {{
30        let builder = detsys_ids_client::Builder::new()
31            .fact("cargo_pkg_name", env!("CARGO_PKG_NAME"))
32            .fact("$app_version", env!("CARGO_PKG_VERSION"))
33            .fact("$app_name", env!("CARGO_CRATE_NAME"))
34            .enable_reporting(detsys_ids_client::is_telemetry_enabled())
35            .endpoint(detsys_ids_client::get_ambient_transport_endpoint());
36
37        builder
38    }};
39}
40
41pub fn is_telemetry_enabled() -> bool {
42    let enabled = std::env::var_os("DETSYS_IDS_TELEMETRY").as_deref()
43        != Some(std::ffi::OsStr::new("disabled"));
44
45    if !enabled {
46        eprintln!(
47            "{}",
48            [
49                "[NOTE] Telemetry is disabled, which makes it harder to build great software.",
50                "We don't collect much, so please turn it back on:",
51                "https://dtr.mn/telemetry",
52            ]
53            .join(" ")
54        );
55    }
56
57    enabled
58}
59
60pub fn get_ambient_transport_endpoint() -> Option<String> {
61    std::env::var("DETSYS_IDS_TRANSPORT").ok()
62}