Skip to content
Merged
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 @@ -22,6 +22,7 @@
import androidx.annotation.Nullable;

import butterknife.BindView;
import me.ghui.v2er.BuildConfig;
import me.ghui.v2er.R;
import me.ghui.v2er.module.base.BaseActivity;
import me.ghui.v2er.module.base.BaseContract;
Expand Down Expand Up @@ -103,13 +104,14 @@ protected void init() {

setupWebView();

// Compute URL with theme parameter based on current app theme
String url = VSHARE_BASE_URL;
if (DarkModelUtils.isDarkMode()) {
url += "?theme=dark";
} else {
url += "?theme=light";
}
// Compute URL with theme and source parameters for analytics tracking
String themeParam = DarkModelUtils.isDarkMode() ? "dark" : "light";
String url = Uri.parse(VSHARE_BASE_URL)
.buildUpon()
.appendQueryParameter("theme", themeParam)
.appendQueryParameter("source", "v2er-android")
.build()
.toString();
mWebView.loadUrl(url);
}

Expand Down Expand Up @@ -143,6 +145,12 @@ private void setupWebView() {

WebSettings settings = mWebView.getSettings();

// Set custom User-Agent for analytics tracking
String defaultUserAgent = settings.getUserAgentString();
String appVersion = getAppVersion();
String customUserAgent = defaultUserAgent + " V2er-Android/" + appVersion;
settings.setUserAgentString(customUserAgent);
Comment on lines +148 to +152
Copy link

Copilot AI Oct 18, 2025

Choose a reason for hiding this comment

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

New User-Agent augmentation logic lacks automated test coverage (e.g., instrumentation test asserting WebView#getSettings().getUserAgentString() ends with the expected suffix). Adding a focused test would protect analytics integrity across refactors.

Copilot generated this review using guidance from repository custom instructions.

// Enable JavaScript
settings.setJavaScriptEnabled(true);

Expand Down Expand Up @@ -273,6 +281,13 @@ private int getStatusBarHeight() {
return result;
}

/**
* Get app version name for User-Agent tracking
*/
private String getAppVersion() {
return BuildConfig.VERSION_NAME != null ? BuildConfig.VERSION_NAME : "unknown";
}

/**
* Handle URL loading for WebView
* Returns true if the URL was handled externally, false if WebView should load it
Expand Down
Loading