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 10, 2024
1 parent f289ba6 commit 3bd8f97
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 30 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 @@ -68,9 +68,13 @@ protected void onPostExecute(Void result) {
}

private static void sendRateFeedback(String userSelection, String userFeedback) {
assert BraveConfig.FEEDBACK_REPORT_ENDPOINT != null
&& !BraveConfig.FEEDBACK_REPORT_ENDPOINT.isEmpty();

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 +83,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 != "")
}
4 changes: 2 additions & 2 deletions browser/net/brave_network_audit_allowed_lists.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ inline constexpr const char* kAllowedUrlPrefixes[] = {
"https://updates.bravesoftware.com/",

// stats/referrals
"https://laptop-updates.brave.com/",
"https://laptop-updates-staging.brave.com/",
"https://usage-ping.brave.com/",
"https://feedback.brave.com/",

// needed for DoH on Mac build machines
"https://dns.google/dns-query",
Expand Down
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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* You can obtain one at https://mozilla.org/MPL/2.0/. */
static const char* kBraveCTExcludedHosts[] = {
// Critical endpoints that shouldn't require SCTs so they always work
"laptop-updates.brave.com",
"usage-ping.brave.com",
"updates.bravesoftware.com",
"updates-cdn.bravesoftware.com",
// Test host for manual testing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ constexpr std::string_view kBravePinsJson = R"brave_pins_json({
// Brave
{ "name": "adblock-data.s3.brave.com", "pins": "brave"},
{ "name": "ai-chat.bsg.brave.com", "pins": "brave"},
{ "name": "feedback.brave.com", "pins": "brave"},
{ "name": "brave-core-ext.s3.brave.com", "pins": "brave"},
{ "name": "brave-today-cdn.brave.com", "pins": "brave"},
{ "name": "clients4.brave.com", "pins": "brave"},
Expand All @@ -48,6 +47,7 @@ constexpr std::string_view kBravePinsJson = R"brave_pins_json({
{ "name": "devtools.brave.com", "pins": "brave"},
{ "name": "dict.brave.com", "pins": "brave"},
{ "name": "extensionupdater.brave.com", "pins": "brave"},
{ "name": "feedback.brave.com", "pins": "brave"},
{ "name": "gaia.brave.com", "pins": "brave"},
{ "name": "go-updater.brave.com", "pins": "brave"},
{ "name": "mobile-data.s3.brave.com", "pins": "brave"},
Expand Down Expand Up @@ -137,7 +137,7 @@ constexpr std::string_view kBraveHstsJson = R"brave_hsts_json({
// Critical endpoints that should remain unpinned so that they
// always work.
{
"name": "laptop-updates.brave.com",
"name": "usage-ping.brave.com",
"mode": "force-https",
"policy": "custom"
},
Expand All @@ -163,11 +163,6 @@ constexpr std::string_view kBraveHstsJson = R"brave_hsts_json({
"mode": "force-https",
"policy": "custom"
},
{
"name": "feedback.brave.com",
"mode": "force-https",
"policy": "custom"
},
{
"name": "brave-core-ext.s3.brave.com",
"mode": "force-https",
Expand Down Expand Up @@ -208,6 +203,11 @@ constexpr std::string_view kBraveHstsJson = R"brave_hsts_json({
"mode": "force-https",
"policy": "custom"
},
{
"name": "feedback.brave.com",
"mode": "force-https",
"policy": "custom"
},
{
"name": "gaia.brave.com",
"mode": "force-https",
Expand Down
9 changes: 9 additions & 0 deletions components/brave_referrals/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# 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/components/brave_referrals/browser/buildflags.gni")
import("//build/buildflag_header.gni")

if (is_android) {
import("//build/config/android/rules.gni")
import("//third_party/jni_zero/jni_zero.gni")
Expand All @@ -20,6 +23,7 @@ static_library("browser") {

deps = [
"//base",
"//brave/components/brave_referrals/browser:buildflags",
"//brave/components/brave_stats/browser",
"//brave/components/constants",
"//brave/vendor/brave_base",
Expand Down Expand Up @@ -71,3 +75,8 @@ source_set("unit_tests") {
]
}
}

buildflag_header("buildflags") {
header = "buildflags.h"
flags = [ "BRAVE_REFERRALS_SERVER=\"$brave_referrals_server\"" ]
}
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/components/brave_referrals/browser/buildflags.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 @@ -132,7 +133,7 @@ std::string BuildReferralEndpoint(const std::string& path) {
std::string proto = "https";
env->GetVar("BRAVE_REFERRALS_SERVER", &referral_server);
if (referral_server.empty())
referral_server = kBraveReferralsServer;
referral_server = BUILDFLAG(BRAVE_REFERRALS_SERVER);
if (env->HasVar("BRAVE_REFERRALS_LOCAL"))
proto = "http";

Expand Down
12 changes: 12 additions & 0 deletions components/brave_referrals/browser/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_referrals_server = ""
}

if (is_official_build) {
assert(brave_referrals_server != "")
}
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 3bd8f97

Please sign in to comment.