144 lines
5.7 KiB
Diff
144 lines
5.7 KiB
Diff
diff --git a/src-tauri/src/qf_client/modules/analytics.rs b/src-tauri/src/qf_client/modules/analytics.rs
|
|
index 3b31cfa..562e0b4 100644
|
|
--- a/src-tauri/src/qf_client/modules/analytics.rs
|
|
+++ b/src-tauri/src/qf_client/modules/analytics.rs
|
|
@@ -37,7 +37,7 @@ impl AnalyticsModule {
|
|
current_page: "home".to_string(),
|
|
component: "Analytics".to_string(),
|
|
is_init: false,
|
|
- send_metrics: true,
|
|
+ send_metrics: false,
|
|
last_user_activity: Arc::new(Mutex::new(Instant::now())),
|
|
metricAndLabelPairsScheduledToSend: vec![],
|
|
}
|
|
@@ -96,69 +96,6 @@ impl AnalyticsModule {
|
|
// Create Timer for sending metrics
|
|
let mut last_metric_time = Instant::now();
|
|
|
|
- if is_first_install {
|
|
- logger::info(
|
|
- &&qf.analytics().get_component("init"),
|
|
- "Detected first install",
|
|
- LoggerOptions::default(),
|
|
- );
|
|
- match qf
|
|
- .analytics()
|
|
- .try_send_analytics("install", 3, json!({}))
|
|
- .await
|
|
- {
|
|
- Ok(_) => {}
|
|
- Err(e) => {
|
|
- error::create_log_file("analytics.log", &e);
|
|
- }
|
|
- };
|
|
- }
|
|
- loop {
|
|
- let send_metrics = qf.analytics().send_metrics;
|
|
- if !send_metrics {
|
|
- tokio::time::sleep(std::time::Duration::from_secs(60)).await;
|
|
- continue;
|
|
- }
|
|
- if last_metric_time.elapsed() > Duration::from_secs(15)
|
|
- || qf.analytics().is_user_active()
|
|
- {
|
|
- if last_metric_time.elapsed() > Duration::from_secs(60)
|
|
- && qf.analytics().is_user_active()
|
|
- {
|
|
- continue;
|
|
- }
|
|
-
|
|
- last_metric_time = Instant::now();
|
|
- // logger::info_con(
|
|
- // &qf.analytics().get_component("TrySendAnalytics"),
|
|
- // "Sending user activity",
|
|
- // );
|
|
- match qf
|
|
- .analytics()
|
|
- .try_send_analytics(
|
|
- "metrics/periodic",
|
|
- 3,
|
|
- json!(qf.analytics().metricAndLabelPairsScheduledToSend),
|
|
- )
|
|
- .await
|
|
- {
|
|
- Ok(_) => {
|
|
- qf.analytics().clear_metrics();
|
|
- }
|
|
- Err(e) => {
|
|
- if e.cause().contains("Unauthorized")
|
|
- || e.cause().contains("Banned")
|
|
- || e.cause().contains("WFMBanned")
|
|
- {
|
|
- error::create_log_file("analytics.log", &e);
|
|
- break;
|
|
- }
|
|
- error::create_log_file("analytics.log", &e);
|
|
- }
|
|
- };
|
|
- }
|
|
- tokio::time::sleep(std::time::Duration::from_secs(5)).await;
|
|
- }
|
|
qf.analytics().is_init = false;
|
|
}
|
|
});
|
|
@@ -174,45 +111,6 @@ impl AnalyticsModule {
|
|
mut retry_count: i64,
|
|
data: Value,
|
|
) -> Result<(), AppError> {
|
|
- let mut parameters: Vec<String> = vec![];
|
|
- if self.is_user_active() {
|
|
- parameters.push(format!("Active_Page={}", self.current_page));
|
|
- }
|
|
-
|
|
- while retry_count >= 0 {
|
|
- let err = match self
|
|
- .client
|
|
- .post::<Value>(
|
|
- format!("analytics/{}?{}", url, parameters.join("&")).as_str(),
|
|
- data.clone(),
|
|
- )
|
|
- .await
|
|
- {
|
|
- Ok(ApiResult::Success(_, _)) => {
|
|
- return Ok(());
|
|
- }
|
|
- Ok(ApiResult::Error(e, _headers)) => AppError::new_api(
|
|
- &self.get_component("TrySendAnalytics"),
|
|
- e,
|
|
- eyre!("Failed to send analytics"),
|
|
- LogLevel::Error,
|
|
- ),
|
|
- Err(e) => e,
|
|
- };
|
|
- if retry_count == 0 {
|
|
- return Err(err);
|
|
- }
|
|
- retry_count -= 1;
|
|
- logger::warning(
|
|
- &self.get_component("TrySendAnalytics"),
|
|
- &format!(
|
|
- "Failed to send analytics, retrying in 5 seconds, retries left: {}",
|
|
- retry_count
|
|
- ),
|
|
- LoggerOptions::default(),
|
|
- );
|
|
- tokio::time::sleep(std::time::Duration::from_secs(5)).await;
|
|
- }
|
|
- Ok(())
|
|
+ return Ok(())
|
|
}
|
|
}
|
|
diff --git a/src/contexts/app.context.tsx b/src/contexts/app.context.tsx
|
|
index 8b3ced9..5da811f 100644
|
|
--- a/src/contexts/app.context.tsx
|
|
+++ b/src/contexts/app.context.tsx
|
|
@@ -160,7 +160,7 @@ export function AppContextProvider({ children }: AppContextProviderProps) {
|
|
const id = context.substring(start, end);
|
|
|
|
console.log("OpenTos", settings?.tos_uuid, id);
|
|
- if (id == settings?.tos_uuid) return;
|
|
+ if (true) return;
|
|
modals.open({
|
|
title: useTranslateModals("tos.title"),
|
|
size: "100%",
|