From d493a4cce8b4959e52e395afc21f6e9fdb90a6e8 Mon Sep 17 00:00:00 2001 From: Michael Herrmann Date: Wed, 9 Mar 2022 17:04:09 +0100 Subject: [PATCH] Disable Brave stats pings to /installerEvent --- omaha/common/brave_stats_updater.cc | 91 ----------------------------- omaha/common/brave_stats_updater.h | 18 ------ omaha/common/build.scons | 1 - omaha/goopdate/download_manager.cc | 4 -- omaha/goopdate/install_manager.cc | 4 -- omaha/mi_exe_stub/mi.cc | 6 -- 6 files changed, 124 deletions(-) delete mode 100644 omaha/common/brave_stats_updater.cc delete mode 100644 omaha/common/brave_stats_updater.h diff --git a/omaha/common/brave_stats_updater.cc b/omaha/common/brave_stats_updater.cc deleted file mode 100644 index c97fbb47..00000000 --- a/omaha/common/brave_stats_updater.cc +++ /dev/null @@ -1,91 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "omaha/common/brave_stats_updater.h" - -#include "omaha/base/safe_format.h" -#include "omaha/base/utils.h" -#include "omaha/net/network_config.h" -#include "omaha/net/network_request.h" -#include "omaha/net/simple_request.h" - -namespace omaha { - -namespace { - -CString GetChannelName(const CString& app_guid) { - if (app_guid == _T("{AFE6A462-C574-4B8A-AF43-4CC60DF4563B}")) - return _T("release"); - else if (app_guid == _T("{103BD053-949B-43A8-9120-2E424887DE11}")) - return _T("beta"); - else if (app_guid == _T("{CB2150F2-595F-4633-891A-E39720CE0531}")) - return _T("dev"); - else if (app_guid == _T("{C6CB981E-DB30-4876-8639-109F8933582C}")) - return _T("nightly"); - else - return _T(""); -} - -CString GetBraveVersion(const CString& version) { - // Strip first segment from version number. - int pos = version.Find(_T('.')); - if (pos != -1) - return version.Right(version.GetLength() - pos - 1); - return _T("0.0.0"); -} - -} // namespace - -HRESULT BraveSendStatsPing(const CString& event, const CString& app_guid, - const CString& referral_code, - const CString& version) { - // Retrieve the update server name. - CString update_server = - omaha::GetEnvironmentVariableAsString(_T("BRAVE_UPDATE_SERVER")); - if (update_server.IsEmpty()) - update_server = _T("laptop-updates.brave.com"); - - _SYSTEM_INFO system_info = {}; - ::GetNativeSystemInfo(&system_info); - - // Ensure that channel is valid/supported. - CString channel_name = GetChannelName(app_guid); - if (channel_name.IsEmpty()) { - CORE_LOG(LE, (_T("[Channel name is empty][%s]"), app_guid)); - return E_INVALIDARG; - } - - // Build the update url. - CString url; - omaha::SafeCStringAppendFormat( - &url, - _T("https://%s/1/") - _T("installerEvent?platform=%s&version=%s&channel=%s&ref=%s&event=%s"), - update_server, - system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL - ? _T("winia32-bc") - : _T("winx64-bc"), - GetBraveVersion(version), channel_name, referral_code, event); - - omaha::NetworkConfig* network_config = NULL; - omaha::NetworkConfigManager& network_manager = - omaha::NetworkConfigManager::Instance(); - HRESULT hr = network_manager.GetUserNetworkConfig(&network_config); - if (FAILED(hr)) - return hr; - - omaha::NetworkRequest network_request(network_config->session()); - - network_request.set_num_retries(1); - network_request.AddHttpRequest(new omaha::SimpleRequest); - - std::vector response_buffer; - hr = network_request.Get(url, &response_buffer); - if (FAILED(hr)) - return hr; - - return S_OK; -} - -} // namespace omaha diff --git a/omaha/common/brave_stats_updater.h b/omaha/common/brave_stats_updater.h deleted file mode 100644 index 5bcae621..00000000 --- a/omaha/common/brave_stats_updater.h +++ /dev/null @@ -1,18 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef OMAHA_COMMON_BRAVE_STATS_UPDATER_H__ -#define OMAHA_COMMON_BRAVE_STATS_UPDATER_H__ - -#include - -namespace omaha { - -HRESULT BraveSendStatsPing(const CString& event, const CString& app_guid, - const CString& referral_code, - const CString& version); - -} // namespace omaha - -#endif // OMAHA_COMMON_BRAVE_STATS_UPDATER_H__ diff --git a/omaha/common/build.scons b/omaha/common/build.scons index 4aab1c5f..f46d35fe 100644 --- a/omaha/common/build.scons +++ b/omaha/common/build.scons @@ -21,7 +21,6 @@ def BuildCommonLib(env): inputs = [ 'app_registry_utils.cc', 'brave_referral_code_utils.cc', - 'brave_stats_updater.cc', 'command_line.cc', 'command_line_builder.cc', 'config_manager.cc', diff --git a/omaha/goopdate/download_manager.cc b/omaha/goopdate/download_manager.cc index 83ea8fbb..01325dff 100644 --- a/omaha/goopdate/download_manager.cc +++ b/omaha/goopdate/download_manager.cc @@ -39,7 +39,6 @@ #include "omaha/base/synchronized.h" #include "omaha/base/user_rights.h" #include "omaha/base/utils.h" -#include "omaha/common/brave_stats_updater.h" #include "omaha/common/config_manager.h" #include "omaha/common/const_goopdate.h" #include "omaha/common/google_signaturevalidator.h" @@ -279,9 +278,6 @@ HRESULT DownloadManager::DownloadApp(App* app) { } if (SUCCEEDED(hr)) { - omaha::BraveSendStatsPing(_T("download-complete"), app->app_guid_string(), - app->referral_id(), - app_version->app()->next_version()->version()); app->DownloadComplete(); app->MarkReadyToInstall(); } else { diff --git a/omaha/goopdate/install_manager.cc b/omaha/goopdate/install_manager.cc index 844869f8..b29abd1a 100644 --- a/omaha/goopdate/install_manager.cc +++ b/omaha/goopdate/install_manager.cc @@ -23,7 +23,6 @@ #include "omaha/base/scope_guard.h" #include "omaha/base/synchronized.h" #include "omaha/base/utils.h" -#include "omaha/common/brave_stats_updater.h" #include "omaha/common/config_manager.h" #include "omaha/common/const_cmd_line.h" #include "omaha/common/install_manifest.h" @@ -120,9 +119,6 @@ void InstallManager::InstallApp(App* app, const CString& dir) { HANDLE primary_token(app->app_bundle()->primary_token()); - omaha::BraveSendStatsPing(_T("installer-run"), app->app_guid_string(), - app->referral_id(), next_version->version()); - HRESULT hr = InstallApp(is_machine_, primary_token, current_version_string, diff --git a/omaha/mi_exe_stub/mi.cc b/omaha/mi_exe_stub/mi.cc index 429d157f..e5e95e5d 100644 --- a/omaha/mi_exe_stub/mi.cc +++ b/omaha/mi_exe_stub/mi.cc @@ -58,7 +58,6 @@ #include "omaha/base/system_info.h" #include "omaha/base/utils.h" #include "omaha/common/brave_referral_code_utils.h" -#include "omaha/common/brave_stats_updater.h" #include "omaha/common/const_cmd_line.h" #include "omaha/mi_exe_stub/process.h" #include "omaha/mi_exe_stub/mi.grh" @@ -765,11 +764,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpCmdLine, int) { omaha::StorePathToRegForPromoCode(lpCmdLine); const CString referral_code = omaha::GetReferralCodeFromModuleFileName(); - if (CString(lpCmdLine).IsEmpty()) { - const CString app_guid = omaha::ReadAppGuidFromTag(hInstance); - hr = omaha::BraveSendStatsPing(_T("startup"), app_guid, referral_code, - _T("")); - } omaha::MetaInstaller mi(hInstance, lpCmdLine, referral_code); int result = mi.ExtractAndRun();