Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at python-updates 143 lines 5.9 kB view raw
1diff --git a/src-tauri/src/qf_client/modules/analytics.rs b/src-tauri/src/qf_client/modules/analytics.rs 2index 3b31cfa..562e0b4 100644 3--- a/src-tauri/src/qf_client/modules/analytics.rs 4+++ b/src-tauri/src/qf_client/modules/analytics.rs 5@@ -37,7 +37,7 @@ impl AnalyticsModule { 6 current_page: "home".to_string(), 7 component: "Analytics".to_string(), 8 is_init: false, 9- send_metrics: true, 10+ send_metrics: false, 11 last_user_activity: Arc::new(Mutex::new(Instant::now())), 12 metricAndLabelPairsScheduledToSend: vec![], 13 } 14@@ -96,69 +96,6 @@ impl AnalyticsModule { 15 // Create Timer for sending metrics 16 let mut last_metric_time = Instant::now(); 17 18- if is_first_install { 19- logger::info( 20- &&qf.analytics().get_component("init"), 21- "Detected first install", 22- LoggerOptions::default(), 23- ); 24- match qf 25- .analytics() 26- .try_send_analytics("install", 3, json!({})) 27- .await 28- { 29- Ok(_) => {} 30- Err(e) => { 31- error::create_log_file("analytics.log", &e); 32- } 33- }; 34- } 35- loop { 36- let send_metrics = qf.analytics().send_metrics; 37- if !send_metrics { 38- tokio::time::sleep(std::time::Duration::from_secs(60)).await; 39- continue; 40- } 41- if last_metric_time.elapsed() > Duration::from_secs(15) 42- || qf.analytics().is_user_active() 43- { 44- if last_metric_time.elapsed() > Duration::from_secs(60) 45- && qf.analytics().is_user_active() 46- { 47- continue; 48- } 49- 50- last_metric_time = Instant::now(); 51- // logger::info_con( 52- // &qf.analytics().get_component("TrySendAnalytics"), 53- // "Sending user activity", 54- // ); 55- match qf 56- .analytics() 57- .try_send_analytics( 58- "metrics/periodic", 59- 3, 60- json!(qf.analytics().metricAndLabelPairsScheduledToSend), 61- ) 62- .await 63- { 64- Ok(_) => { 65- qf.analytics().clear_metrics(); 66- } 67- Err(e) => { 68- if e.cause().contains("Unauthorized") 69- || e.cause().contains("Banned") 70- || e.cause().contains("WFMBanned") 71- { 72- error::create_log_file("analytics.log", &e); 73- break; 74- } 75- error::create_log_file("analytics.log", &e); 76- } 77- }; 78- } 79- tokio::time::sleep(std::time::Duration::from_secs(5)).await; 80- } 81 qf.analytics().is_init = false; 82 } 83 }); 84@@ -174,45 +111,6 @@ impl AnalyticsModule { 85 mut retry_count: i64, 86 data: Value, 87 ) -> Result<(), AppError> { 88- let mut parameters: Vec<String> = vec![]; 89- if self.is_user_active() { 90- parameters.push(format!("Active_Page={}", self.current_page)); 91- } 92- 93- while retry_count >= 0 { 94- let err = match self 95- .client 96- .post::<Value>( 97- format!("analytics/{}?{}", url, parameters.join("&")).as_str(), 98- data.clone(), 99- ) 100- .await 101- { 102- Ok(ApiResult::Success(_, _)) => { 103- return Ok(()); 104- } 105- Ok(ApiResult::Error(e, _headers)) => AppError::new_api( 106- &self.get_component("TrySendAnalytics"), 107- e, 108- eyre!("Failed to send analytics"), 109- LogLevel::Error, 110- ), 111- Err(e) => e, 112- }; 113- if retry_count == 0 { 114- return Err(err); 115- } 116- retry_count -= 1; 117- logger::warning( 118- &self.get_component("TrySendAnalytics"), 119- &format!( 120- "Failed to send analytics, retrying in 5 seconds, retries left: {}", 121- retry_count 122- ), 123- LoggerOptions::default(), 124- ); 125- tokio::time::sleep(std::time::Duration::from_secs(5)).await; 126- } 127- Ok(()) 128+ return Ok(()) 129 } 130 } 131diff --git a/src/contexts/app.context.tsx b/src/contexts/app.context.tsx 132index 8b3ced9..5da811f 100644 133--- a/src/contexts/app.context.tsx 134+++ b/src/contexts/app.context.tsx 135@@ -160,7 +160,7 @@ export function AppContextProvider({ children }: AppContextProviderProps) { 136 const id = context.substring(start, end); 137 138 console.log("OpenTos", settings?.tos_uuid, id); 139- if (id == settings?.tos_uuid) return; 140+ if (true) return; 141 modals.open({ 142 title: useTranslateModals("tos.title"), 143 size: "100%",