Skip to content

Commit

Permalink
Replace requests to laptop-updates.brave.com with requests to `usag…
Browse files Browse the repository at this point in the history
…e-ping.brave.com` and `feedback.brave.com`
  • Loading branch information
DJAndries committed Oct 16, 2024
1 parent c7cec2f commit 1e14eff
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 26 deletions.
2 changes: 2 additions & 0 deletions android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at https://mozilla.org/MPL/2.0/.

import("//brave/browser/brave_stats/buildflags.gni")
import("//brave/components/ai_chat/core/common/buildflags/buildflags.gni")
import("//brave/components/p3a/buildflags.gni")
import("//brave/components/webcompat_reporter/buildflags/buildflags.gni")
Expand All @@ -26,5 +27,6 @@ java_cpp_template("brave_config_java") {
"BRAVE_ANDROID_P3A_ENABLED=$brave_p3a_enabled",
"BRAVE_ANDROID_WEBCOMPAT_REPORT_ENDPOINT=\"$webcompat_report_api_endpoint\"",
"BRAVE_ANDROID_AI_CHAT_ENABLED=$enable_ai_chat",
"BRAVE_ANDROID_FEEDBACK_REPORT_ENDPOINT=\"$android_feedback_report_api_endpoint\"",
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.chromium.base.Log;
import org.chromium.base.ThreadUtils;
import org.chromium.base.task.AsyncTask;
import org.chromium.chrome.browser.BraveConfig;
import org.chromium.chrome.browser.about_settings.AboutChromeSettings;
import org.chromium.chrome.browser.about_settings.AboutSettingsBridge;
import org.chromium.chrome.browser.ntp_background_images.NTPBackgroundImagesBridge;
Expand All @@ -35,7 +36,6 @@

public class RateFeedbackUtils {
private static final String TAG = "Rate_Brave";
private static final String RATE_URL = "https://laptop-updates.brave.com/1/feedback";

public interface RateFeedbackCallback {
void rateFeedbackSubmitted();
Expand Down Expand Up @@ -69,8 +69,9 @@ protected void onPostExecute(Void result) {

private static void sendRateFeedback(String userSelection, String userFeedback) {
Context context = ContextUtils.getApplicationContext();
String appVersion = AboutChromeSettings.getApplicationVersion(
context, AboutSettingsBridge.getApplicationVersion());
String appVersion =
AboutChromeSettings.getApplicationVersion(
context, AboutSettingsBridge.getApplicationVersion());
StringBuilder sb = new StringBuilder();

Profile mProfile = ProfileManager.getLastUsedRegularProfile();
Expand All @@ -79,9 +80,11 @@ private static void sendRateFeedback(String userSelection, String userFeedback)

HttpURLConnection urlConnection = null;
try {
URL url = new URL(RATE_URL);
urlConnection = (HttpURLConnection) ChromiumNetworkAdapter.openConnection(
url, NetworkTrafficAnnotationTag.MISSING_TRAFFIC_ANNOTATION);
URL url = new URL(BraveConfig.FEEDBACK_REPORT_ENDPOINT);
urlConnection =
(HttpURLConnection)
ChromiumNetworkAdapter.openConnection(
url, NetworkTrafficAnnotationTag.MISSING_TRAFFIC_ANNOTATION);
urlConnection.setDoOutput(true);
urlConnection.setRequestMethod("POST");
urlConnection.setUseCaches(false);
Expand Down
9 changes: 1 addition & 8 deletions browser/brave_stats/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,9 @@
# 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/. */

import("//brave/browser/brave_stats/buildflags.gni")
import("//build/buildflag_header.gni")

declare_args() {
brave_stats_updater_url = ""
}

if (is_official_build) {
assert(brave_stats_updater_url != "")
}

buildflag_header("buildflags") {
header = "buildflags.h"
flags = [ "BRAVE_USAGE_SERVER=\"$brave_stats_updater_url\"" ]
Expand Down
14 changes: 14 additions & 0 deletions browser/brave_stats/buildflags.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright (c) 2024 The Brave Authors. All rights reserved.
# 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 https://mozilla.org/MPL/2.0/.

declare_args() {
brave_stats_updater_url = ""
android_feedback_report_api_endpoint = ""
}

if (is_official_build) {
assert(brave_stats_updater_url != "")
assert(android_feedback_report_api_endpoint != "")
}
1 change: 1 addition & 0 deletions build/android/java/templates/BraveConfig.template
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ public class BraveConfig {
public static final boolean P3A_ENABLED = BRAVE_ANDROID_P3A_ENABLED;
public static final boolean AI_CHAT_ENABLED = BRAVE_ANDROID_AI_CHAT_ENABLED;
public static final String WEBCOMPAT_REPORT_ENDPOINT = BRAVE_ANDROID_WEBCOMPAT_REPORT_ENDPOINT;
public static final String FEEDBACK_REPORT_ENDPOINT = BRAVE_ANDROID_FEEDBACK_REPORT_ENDPOINT;
}
3 changes: 3 additions & 0 deletions build/commands/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ const Config = function () {
this.realRewrapperDir = process.env.RBE_DIR || path.join(this.srcDir, 'buildtools', 'reclient')
this.braveStatsApiKey = getEnvConfig(['brave_stats_api_key']) || ''
this.braveStatsUpdaterUrl = getEnvConfig(['brave_stats_updater_url']) || ''
this.androidFeedbackReportAPIEndpoint = getEnvConfig(['android_feedback_report_api_endpoint']) || ''
this.ignore_compile_failure = false
this.enable_hangout_services_extension = false
this.enable_pseudolocales = false
Expand Down Expand Up @@ -411,6 +412,7 @@ Config.prototype.buildArgs = function () {
rewards_grant_prod_endpoint: this.rewardsGrantProdEndpoint,
brave_stats_api_key: this.braveStatsApiKey,
brave_stats_updater_url: this.braveStatsUpdaterUrl,
android_feedback_report_api_endpoint: this.androidFeedbackReportAPIEndpoint,
enable_hangout_services_extension: this.enable_hangout_services_extension,
enable_cdm_host_verification: this.enableCDMHostVerification(),
enable_pseudolocales: this.enable_pseudolocales,
Expand Down Expand Up @@ -710,6 +712,7 @@ Config.prototype.buildArgs = function () {
delete args.brave_google_api_endpoint
delete args.brave_google_api_key
delete args.brave_stats_updater_url
delete args.android_feedback_report_api_endpoint
delete args.bitflyer_production_client_id
delete args.bitflyer_production_client_secret
delete args.bitflyer_production_fee_address
Expand Down
1 change: 1 addition & 0 deletions components/brave_referrals/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ static_library("browser") {

deps = [
"//base",
"//brave/brave_domains",
"//brave/components/brave_stats/browser",
"//brave/components/constants",
"//brave/vendor/brave_base",
Expand Down
14 changes: 7 additions & 7 deletions components/brave_referrals/browser/brave_referrals_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "base/strings/stringprintf.h"
#include "base/task/thread_pool.h"
#include "base/values.h"
#include "brave/brave_domains/service_domains.h"
#include "brave/components/brave_referrals/common/pref_names.h"
#include "brave/components/constants/network_constants.h"
#include "brave/components/constants/pref_names.h"
Expand Down Expand Up @@ -129,15 +130,14 @@ std::string ReadPromoCode(const base::FilePath& promo_code_file) {
std::string BuildReferralEndpoint(const std::string& path) {
std::unique_ptr<base::Environment> env(base::Environment::Create());
std::string referral_server;
std::string proto = "https";
env->GetVar("BRAVE_REFERRALS_SERVER", &referral_server);
if (referral_server.empty())
referral_server = kBraveReferralsServer;
if (env->HasVar("BRAVE_REFERRALS_LOCAL"))
proto = "http";
if (referral_server.empty()) {
auto referral_domain = brave_domains::GetServicesDomain("usage-ping");
referral_server = base::StrCat(
{url::kHttpsScheme, url::kStandardSchemeSeparator, referral_domain});
}

return base::StringPrintf("%s://%s%s", proto.c_str(), referral_server.c_str(),
path.c_str());
return referral_server + path;
}

} // namespace
Expand Down
1 change: 0 additions & 1 deletion components/constants/network_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ inline constexpr char kBraveSoftwareProxyPattern[] =

inline constexpr char kBraveUsageStandardPath[] = "/1/usage/brave-core";

inline constexpr char kBraveReferralsServer[] = "laptop-updates.brave.com";
inline constexpr char kBraveReferralsInitPath[] = "/promo/initialize/nonua";
inline constexpr char kBraveReferralsActivityPath[] = "/promo/activity";

Expand Down
4 changes: 2 additions & 2 deletions ios/brave-ios/Sources/Growth/DAU.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public class DAU {
// TODO: Handle via brave-stats-updater-server switch and get URL from brave_stats_updater_url
let domain =
AppConstants.isOfficialBuild
? "https://laptop-updates.brave.com/"
: "https://laptop-updates.bravesoftware.com/"
? "https://usage-ping.brave.com/"
: "https://usage-ping.bravesoftware.com/"

return "\(domain)\(apiVersion)/usage/ios?platform=ios"
}
Expand Down
4 changes: 2 additions & 2 deletions ios/brave-ios/Sources/Growth/URP/UserReferralProgram.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public class UserReferralProgram {
public static let shared = UserReferralProgram()

struct HostUrl {
static let staging = "https://laptop-updates.bravesoftware.com"
static let prod = "https://laptop-updates.brave.com"
static let staging = "https://usage-ping.bravesoftware.com"
static let prod = "https://usage-ping.brave.com"
}

let adServicesURLString = "https://api-adservices.apple.com/api/v1/"
Expand Down

0 comments on commit 1e14eff

Please sign in to comment.