diff --git a/WordPress/src/main/java/org/wordpress/android/ui/WebViewActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/WebViewActivity.java index eceaf5b2876e..b50315129ea7 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/WebViewActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/WebViewActivity.java @@ -14,8 +14,10 @@ import org.wordpress.android.R; import org.wordpress.android.WordPress; +import org.wordpress.android.analytics.AnalyticsTracker; import org.wordpress.android.util.extensions.CompatExtensionsKt; +import java.util.HashMap; import java.util.Map; /** @@ -90,13 +92,18 @@ protected void loadContent() { protected void onSaveInstanceState(@NonNull Bundle outState) { mWebView.saveState(outState); - // If the WebView state is too large, remove it from the bundle. This workaround is + // If the WebView state is too large, remove it from the bundle and track the error. This workaround is // necessary since the Android system cannot handle large states without a crash. // Note that Chromium `WebViewBrowserFragment` uses a similar workaround for this issue: // https://source.chromium.org/chromium/chromium/src/+/27a9bbd3dcd7005ac9f3862dc2e356b557023de9 byte[] webViewState = outState.getByteArray(WEBVIEW_CHROMIUM_STATE); if (webViewState != null && webViewState.length > WEBVIEW_CHROMIUM_STATE_THRESHOLD) { outState.remove(WEBVIEW_CHROMIUM_STATE); + + // Track the error to better understand the root of the issue + Map properties = new HashMap<>(); + properties.put(URL, mWebView.getUrl()); + AnalyticsTracker.track(AnalyticsTracker.Stat.WEBVIEW_TOO_LARGE_PAYLOAD_ERROR, properties); } super.onSaveInstanceState(outState); } diff --git a/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTracker.java b/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTracker.java index 82b8a3b126f2..5a4e730ef599 100644 --- a/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTracker.java +++ b/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTracker.java @@ -1106,7 +1106,8 @@ public enum Stat { SITE_MONITORING_SCREEN_SHOWN, OPENED_SITE_MONITORING, SITE_MONITORING_TAB_SHOWN, - SITE_MONITORING_TAB_LOADING_ERROR + SITE_MONITORING_TAB_LOADING_ERROR, + WEBVIEW_TOO_LARGE_PAYLOAD_ERROR, } private static final List TRACKERS = new ArrayList<>(); diff --git a/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTrackerNosara.java b/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTrackerNosara.java index fcd096393664..08a9c022394b 100644 --- a/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTrackerNosara.java +++ b/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTrackerNosara.java @@ -2707,6 +2707,8 @@ public static String getEventNameForStat(AnalyticsTracker.Stat stat) { return "site_monitoring_tab_shown"; case SITE_MONITORING_TAB_LOADING_ERROR: return "site_monitoring_tab_loading_error"; + case WEBVIEW_TOO_LARGE_PAYLOAD_ERROR: + return "webview_too_large_payload_error"; } return null; }