Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace requests to laptop-updates.brave.com with requests to usage-ping.brave.com and feedback.brave.com #25920

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

public class RateFeedbackUtils {
private static final String TAG = "Rate_Brave";
private static final String RATE_URL = "https://laptop-updates.brave.com/1/feedback";
private static final String RATE_URL = "https://feedback.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 @@ -80,8 +81,10 @@ 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);
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
5 changes: 2 additions & 3 deletions browser/brave_stats/brave_stats_updater_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ std::unique_ptr<net::test_server::HttpResponse> HandleRequestForStats(
const net::test_server::HttpRequest& request) {
std::unique_ptr<net::test_server::BasicHttpResponse> http_response(
new net::test_server::BasicHttpResponse());
if (request.relative_url == "/promo/initialize/nonua") {
if (request.relative_url == "//promo/initialize/nonua") {
// We need a download id to make promo initialization happy
http_response->set_code(net::HTTP_OK);
http_response->set_content("{\"download_id\":\"keur123\"}");
Expand Down Expand Up @@ -98,8 +98,7 @@ class BraveStatsUpdaterBrowserTest : public PlatformBrowserTest {
void SetBaseUpdateURLForTest() {
std::unique_ptr<base::Environment> env(base::Environment::Create());
env->SetVar("BRAVE_REFERRALS_SERVER",
embedded_test_server()->host_port_pair().ToString());
env->SetVar("BRAVE_REFERRALS_LOCAL", "1"); // use http for local testing
embedded_test_server()->base_url().spec());
}

GURL GetUpdateURL() const { return update_url_; }
Expand Down
12 changes: 12 additions & 0 deletions browser/brave_stats/buildflags.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 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 = ""
DJAndries marked this conversation as resolved.
Show resolved Hide resolved
}

if (is_official_build) {
assert(brave_stats_updater_url != "")
}
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/"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kylehickinson @Brandon-T we should export BraveServicesDomain to ios

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also hard-coding these url defeats the purpose of not including them in the gn config by default

: "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
Loading