File size: 863 Bytes
d8435ba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use std::time::Duration;

pub struct ErrorReporter;

impl ErrorReporter {
    fn get_url() -> String {
        if cfg!(debug_assertions) {
            "https://staging-telemetry.qdrant.io".to_string()
        } else {
            "https://telemetry.qdrant.io".to_string()
        }
    }

    pub fn report(error: &str, reporting_id: &str, backtrace: Option<&str>) {
        let client = reqwest::blocking::Client::new();

        let report = serde_json::json!({
            "id": reporting_id,
            "error": error,
            "backtrace": backtrace.unwrap_or(""),
        });

        let data = serde_json::to_string(&report).unwrap();
        let _resp = client
            .post(Self::get_url())
            .body(data)
            .header("Content-Type", "application/json")
            .timeout(Duration::from_secs(1))
            .send();
    }
}