Count installations that run: the update check goes through the site
The programs (desktop, Android) ask https://chess.vrubel.xyz/api/update for the latest release instead of GitHub, with a random id of the installation (made once, kept in the settings), the version and the platform; the site passes GitHub's answer on and keeps one row per installation and day (no IP; the country of the address). Without the site the programs ask GitHub, uncounted; with the update check off nothing is sent. /stats shows installations that ran today, in 7 and 30 days, in all and new ones, by platform and version. The texts about the update check and the site's privacy line say so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
04bd7c08a1
commit
1edbbda368
30 changed files with 284 additions and 44 deletions
|
|
@ -167,6 +167,10 @@ impl App {
|
|||
.last_version
|
||||
.clone()
|
||||
.filter(|v| crate::update::parse_version(v) < crate::update::parse_version(current));
|
||||
if settings.install_id.is_empty() {
|
||||
settings.install_id = crate::update::new_install_id();
|
||||
}
|
||||
crate::update::set_install_id(&settings.install_id);
|
||||
if settings.last_version.as_deref() != Some(current) {
|
||||
settings.last_version = Some(current.to_owned());
|
||||
let _ = settings.save();
|
||||
|
|
|
|||
|
|
@ -5661,15 +5661,15 @@ const ROWS: &[[&str; 9]] = &[
|
|||
"Іске қосқанда жаңа нұсқаны тексеру",
|
||||
],
|
||||
[
|
||||
"ChessPenguin asks GitHub which version is the latest; nothing about you is sent",
|
||||
"ChessPenguin спрашивает у GitHub, какая версия последняя; ничего о вас не отправляется",
|
||||
"ChessPenguin demande à GitHub quelle est la dernière version ; rien sur vous n'est envoyé",
|
||||
"ChessPenguin fragt GitHub nach der neuesten Version; nichts über Sie wird gesendet",
|
||||
"ChessPenguin pregunta a GitHub cuál es la última versión; no se envía nada sobre ti",
|
||||
"ChessPenguin chiede a GitHub qual è l'ultima versione; nulla su di te viene inviato",
|
||||
"O ChessPenguin pergunta ao GitHub qual é a versão mais recente; nada sobre você é enviado",
|
||||
"ChessPenguin GitHubdan eng so‘nggi versiyani so‘raydi; siz haqingizda hech narsa yuborilmaydi",
|
||||
"ChessPenguin GitHub-тан қай нұсқа соңғы екенін сұрайды; сіз туралы ештеңе жіберілмейді",
|
||||
"ChessPenguin asks its site which version is the latest; the site counts installations that run: only a random number of this installation, the version and the system are sent",
|
||||
"ChessPenguin спрашивает у своего сайта, какая версия последняя; сайт считает работающие установки: передаются только случайный номер этой установки, версия и система",
|
||||
"ChessPenguin demande à son site quelle est la dernière version ; le site compte les installations actives : seuls un numéro aléatoire de cette installation, la version et le système sont envoyés",
|
||||
"ChessPenguin fragt seine Website nach der neuesten Version; die Website zählt laufende Installationen: Gesendet werden nur eine Zufallsnummer dieser Installation, die Version und das System",
|
||||
"ChessPenguin pregunta a su sitio cuál es la última versión; el sitio cuenta las instalaciones en uso: solo se envían un número aleatorio de esta instalación, la versión y el sistema",
|
||||
"ChessPenguin chiede al suo sito qual è l'ultima versione; il sito conta le installazioni in uso: vengono inviati solo un numero casuale di questa installazione, la versione e il sistema",
|
||||
"O ChessPenguin pergunta ao seu site qual é a versão mais recente; o site conta as instalações em uso: são enviados apenas um número aleatório desta instalação, a versão e o sistema",
|
||||
"ChessPenguin o‘z saytidan eng so‘nggi versiyani so‘raydi; sayt ishlayotgan o‘rnatmalarni sanaydi: faqat shu o‘rnatmaning tasodifiy raqami, versiya va tizim yuboriladi",
|
||||
"ChessPenguin өз сайтынан соңғы нұсқаны сұрайды; сайт жұмыс істеп тұрған орнатуларды санайды: тек осы орнатудың кездейсоқ нөмірі, нұсқа және жүйе жіберіледі",
|
||||
],
|
||||
[
|
||||
"Check now",
|
||||
|
|
|
|||
|
|
@ -128,6 +128,9 @@ pub struct Settings {
|
|||
pub skipped_version: Option<String>,
|
||||
/// The version that ran last (to say "updated to …" once).
|
||||
pub last_version: Option<String>,
|
||||
/// A random id of this installation, sent with the update check (the site counts
|
||||
/// installations that run; nothing else identifies the user).
|
||||
pub install_id: String,
|
||||
/// The database of the reference tab (`None`: the largest one on the shelf).
|
||||
pub reference_db: Option<PathBuf>,
|
||||
}
|
||||
|
|
@ -189,6 +192,7 @@ impl Default for Settings {
|
|||
check_updates: true,
|
||||
skipped_version: None,
|
||||
last_version: None,
|
||||
install_id: String::new(),
|
||||
reference_db: None,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ impl SettingsWindow {
|
|||
changed |= ui
|
||||
.checkbox(&mut s.check_updates, tr("Check for updates at start"))
|
||||
.on_hover_text(tr(
|
||||
"ChessPenguin asks GitHub which version is the latest; nothing about you is sent",
|
||||
"ChessPenguin asks its site which version is the latest; the site counts installations that run: only a random number of this installation, the version and the system are sent",
|
||||
))
|
||||
.changed();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
//! Updates: at start the program asks GitHub for the latest release (once, in the
|
||||
//! background; can be turned off in Settings → About). When it is newer, a button next
|
||||
//! to Settings offers it. What "update" does depends on how ChessPenguin was installed:
|
||||
//! Updates: at start the program asks its site (else GitHub) for the latest release
|
||||
//! (once, in the background; can be turned off in Settings → About; the site counts the
|
||||
//! installation, see `releases::check_latest`). When it is newer, a button next to
|
||||
//! Settings offers it. What "update" does depends on how ChessPenguin was installed:
|
||||
//!
|
||||
//! - the Windows zip, the AppImage and the Linux tarball: the new file is downloaded,
|
||||
//! checked against `SHA256SUMS.txt` and put in place of the running one; the program
|
||||
|
|
@ -206,12 +207,48 @@ fn source_dir() -> Option<PathBuf> {
|
|||
std::env::var_os("CP_UPDATE_SOURCE").map(PathBuf::from)
|
||||
}
|
||||
|
||||
/// Who asks GitHub.
|
||||
/// Who asks the site and GitHub.
|
||||
fn client() -> String {
|
||||
format!("ChessPenguin/{}", env!("CARGO_PKG_VERSION"))
|
||||
}
|
||||
|
||||
/// Asks for the latest release. `Err` with a short reason when there is no answer.
|
||||
static INSTALL_ID: std::sync::OnceLock<String> = std::sync::OnceLock::new();
|
||||
|
||||
/// This installation's id for the update check (`Settings::install_id`).
|
||||
pub fn set_install_id(id: &str) {
|
||||
let _ = INSTALL_ID.set(id.to_owned());
|
||||
}
|
||||
|
||||
/// A new random installation id: 32 hex digits.
|
||||
pub fn new_install_id() -> String {
|
||||
let mut b = [0u8; 16];
|
||||
if getrandom::fill(&mut b).is_err() {
|
||||
// No randomness: no id; the check then goes to GitHub, uncounted.
|
||||
return String::new();
|
||||
}
|
||||
b.iter().map(|x| format!("{x:02x}")).collect()
|
||||
}
|
||||
|
||||
impl Install {
|
||||
/// The platform the site counts this installation under.
|
||||
fn platform(&self) -> &'static str {
|
||||
match self {
|
||||
Install::Windows(_) => "windows",
|
||||
Install::Mac => "macos",
|
||||
Install::AppImage(_) => "appimage",
|
||||
Install::Tarball(_) => "tarball",
|
||||
Install::Deb => "deb",
|
||||
Install::Rpm => "rpm",
|
||||
Install::Arch => "arch",
|
||||
Install::Aur => "aur",
|
||||
Install::Flatpak => "flatpak",
|
||||
Install::Other => "source",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Asks for the latest release (through the site, which counts this installation; see
|
||||
/// `releases::check_latest`). `Err` with a short reason when there is no answer.
|
||||
pub fn latest() -> Result<Release, String> {
|
||||
match source_dir() {
|
||||
Some(dir) => {
|
||||
|
|
@ -220,7 +257,10 @@ pub fn latest() -> Result<Release, String> {
|
|||
let v: Value = serde_json::from_str(&text).map_err(|e| e.to_string())?;
|
||||
releases::parse_release(&v).ok_or_else(|| "unexpected answer".to_owned())
|
||||
}
|
||||
None => releases::fetch_latest(releases::API, &client()),
|
||||
None => match INSTALL_ID.get().filter(|id| !id.is_empty()) {
|
||||
Some(id) => releases::check_latest(id, detect().platform(), &client()),
|
||||
None => releases::fetch_latest(releases::API, &client()),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue