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

Duck Player custom error #5698

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

mgurgel
Copy link
Collaborator

@mgurgel mgurgel commented Feb 26, 2025

Task/Issue URL: https://app.asana.com/0/72649045549333/1209459625347014

Description

Shows a custom error screen when Duck Player detects an error message in the YouTube embed

Steps to test this PR

  1. In the debug menu, override privacy config to https://www.jsonblob.com/api/jsonBlob/1344674224849215488
  2. Follow the steps here: https://app.asana.com/0/1142021229838617/1209392401656236

UI changes

Before After

@mgurgel mgurgel self-assigned this Feb 26, 2025
@mgurgel mgurgel force-pushed the feature/mgurgel/duckplayer-custom-error branch from fa757fd to 6a43c68 Compare March 3, 2025 10:34
@mgurgel mgurgel force-pushed the feature/mgurgel/duckplayer-custom-error branch from 13f1ebd to 9d36ba9 Compare March 3, 2025 14:26
@mgurgel mgurgel marked this pull request as ready for review March 3, 2025 15:04
@mgurgel mgurgel requested a review from CrisBarreiro March 3, 2025 15:13
@@ -247,6 +271,24 @@ class DuckPlayerJSHelper @Inject constructor(
else -> null
}
}
"reportYouTubeError" -> {
val impressionPixelName: DuckPlayerPixelName = when (data?.getString("error")) {
"age-restricted" -> DUCK_PLAYER_YOUTUBE_ERROR_AGE_RESTRICTED_IMPRESSION
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Extract to constants

@@ -127,6 +137,9 @@ class DuckPlayerJSHelper @Inject constructor(
jsonObject.put("platform", JSONObject("""{ name: "android" }"""))
jsonObject.put("locale", java.util.Locale.getDefault().language)
jsonObject.put("env", if (appBuildConfig.isDebug) "development" else "production")

// Custom Error Settings
jsonObject.getJSONObject("settings").put("customError", getCustomErrorSettings())
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't pass this from native when CSS already has access to the RC JSON. See DuckPlayerContentScopeConfigPlugin

*
* @return True if should show a custom error view, false otherwise.
*/
fun shouldShowCustomError(): Boolean
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to what I said above, we shouldn't expose this on the public API, but rather rely on CSS to get this values internally from the RC JSON

@@ -33,4 +33,12 @@ enum class DuckPlayerPixelName(override val pixelName: String) : Pixel.PixelName
DUCK_PLAYER_SETTINGS_PRESSED("duckplayer_setting_pressed"),
DUCK_PLAYER_NEWTAB_SETTING_ON("duckplayer_newtab_setting-on"),
DUCK_PLAYER_NEWTAB_SETTING_OFF("duckplayer_newtab_setting-off"),
DUCK_PLAYER_YOUTUBE_ERROR_SIGN_IN_REQUIRED_IMPRESSION("duckplayer_youtube-signin-error_impression"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Since these pixels are fired from the app module, they should be moved to AppPixelName. Other modules should never access the impl directly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants