Skip to content

Commit aa0f7f8

Browse files
committed
Add support for reportMetric
1 parent d5df32a commit aa0f7f8

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

app/src/main/java/com/duckduckgo/app/browser/duckplayer/DuckPlayerJSHelper.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import com.duckduckgo.app.browser.commands.Command.SendResponseToJs
2727
import com.duckduckgo.app.browser.commands.Command.SendSubscriptions
2828
import com.duckduckgo.app.browser.commands.NavigationCommand.Navigate
2929
import com.duckduckgo.app.pixels.AppPixelName
30+
import com.duckduckgo.app.pixels.AppPixelName.DUCK_PLAYER_JS_ERROR
3031
import com.duckduckgo.app.pixels.AppPixelName.DUCK_PLAYER_SETTING_ALWAYS_DUCK_PLAYER
3132
import com.duckduckgo.app.pixels.AppPixelName.DUCK_PLAYER_SETTING_ALWAYS_OVERLAY_YOUTUBE
3233
import com.duckduckgo.app.pixels.AppPixelName.DUCK_PLAYER_SETTING_ALWAYS_SERP
@@ -291,6 +292,19 @@ class DuckPlayerJSHelper @Inject constructor(
291292
pixel.fire(impressionPixelName)
292293
pixel.fire(dailyPixelName, emptyMap(), emptyMap(), Daily())
293294
}
295+
"reportMetric" -> {
296+
try {
297+
val params = data?.getJSONObject("params") ?: return null
298+
val message = params.getString("message") ?: return null
299+
val kind = params.getString("kind") ?: return null
300+
pixel.fire(
301+
DUCK_PLAYER_JS_ERROR,
302+
mapOf("message" to message, "kind" to kind, "origin" to featureName),
303+
)
304+
} catch (e: Exception) {
305+
logcat { "Error reporting metric: $e" }
306+
}
307+
}
294308
else -> {
295309
return null
296310
}

app/src/main/java/com/duckduckgo/app/pixels/AppPixelName.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ enum class AppPixelName(override val pixelName: String) : Pixel.PixelName {
408408
DUCK_PLAYER_YOUTUBE_ERROR_AGE_RESTRICTED_DAILY_UNIQUE("duckplayer_youtube-age-restricted-error_daily-unique"),
409409
DUCK_PLAYER_YOUTUBE_ERROR_NO_EMBED_DAILY_UNIQUE("duckplayer_youtube-no-embed-error_daily-unique"),
410410
DUCK_PLAYER_YOUTUBE_ERROR_UNKNOWN_DAILY_UNIQUE("duckplayer_youtube-unknown-error_daily-unique"),
411+
DUCK_PLAYER_JS_ERROR("duckplayer_js-error"),
411412

412413
MALICIOUS_SITE_PROTECTION_SETTING_TOGGLED("m_malicious-site-protection_feature-toggled"),
413414
MALICIOUS_SITE_PROTECTION_VISIT_SITE("m_malicious-site-protection_visit-site"),

duckplayer/duckplayer-impl/src/main/java/com/duckduckgo/duckplayer/impl/DuckPlayerScriptsJsMessaging.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ class DuckPlayerScriptsJsMessaging @Inject constructor(
129129
"openSettings",
130130
"openInfo",
131131
"setUserValues",
132+
"reportMetric",
132133
"reportPageException",
133134
"reportInitException",
134135
"reportYouTubeError",

0 commit comments

Comments
 (0)