From f5462b6dd885d9ad808a619da37243f06c89b2bc Mon Sep 17 00:00:00 2001 From: aecsocket Date: Tue, 12 May 2026 16:23:33 +0100 Subject: [PATCH] Add Modrinth App to app user agent string (#6084) * Add Modrinth App to app user agent string * Simplify UA brand strings --- apps/app/src/api/ads.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/app/src/api/ads.rs b/apps/app/src/api/ads.rs index 463397c65..0a3028e1d 100644 --- a/apps/app/src/api/ads.rs +++ b/apps/app/src/api/ads.rs @@ -17,7 +17,15 @@ pub struct AdsState { const AD_LINK: &str = "https://modrinth.com/wrapper/app-ads-cookie"; #[cfg(not(target_os = "linux"))] -const ADS_USER_AGENT: &str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"; +const APP_VERSION: &str = env!("CARGO_PKG_VERSION"); +#[cfg(not(target_os = "linux"))] +const ADS_USER_AGENT: &str = concat!( + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 ", + "(KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 ", + "ModrinthApp/", + APP_VERSION, + " (Modrinth App)", +); #[cfg(windows)] fn ads_user_agent_override_params() -> String { @@ -28,12 +36,14 @@ fn ads_user_agent_override_params() -> String { "brands": [ { "brand": "Chromium", "version": "128" }, { "brand": "Google Chrome", "version": "128" }, + { "brand": "Modrinth App", "version": APP_VERSION }, { "brand": "Not=A?Brand", "version": "99" }, ], "fullVersion": "128.0.0.0", "fullVersionList": [ { "brand": "Chromium", "version": "128.0.0.0" }, { "brand": "Google Chrome", "version": "128.0.0.0" }, + { "brand": "Modrinth App", "version": APP_VERSION }, { "brand": "Not=A?Brand", "version": "99.0.0.0" }, ], "platform": "Windows",