| 98 | } |
| 99 | |
| 100 | fn sanitize_browser_version(browser_version: &str) -> String { |
| 101 | let version = browser_version.trim().to_ascii_lowercase(); |
| 102 | if version.is_empty() { |
| 103 | return String::new(); |
| 104 | } |
| 105 | if VALID_VERSION_LABELS.contains(&version.as_str()) { |
| 106 | return version; |
| 107 | } |
| 108 | // Report only the numeric major component, never a full version or free text. |
| 109 | // Electron accepts pins with a leading "v" (e.g. v36.2.1) |
| 110 | let numeric = version.strip_prefix('v').unwrap_or(&version); |
| 111 | let major = numeric.split('.').next().unwrap_or_default(); |
| 112 | if !major.is_empty() && major.bytes().all(|b| b.is_ascii_digit()) { |
| 113 | major.to_string() |
| 114 | } else { |
| 115 | STATS_OTHER.to_string() |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | #[tokio::main] |
| 120 | pub async fn send_stats_to_plausible(http_client: Client, props: Props, sender: Sender<String>) { |