Skip to content

Commit d2d4182

Browse files
authored
send a pixel when installed app suggestion clicked (#6980)
Task/Issue URL: https://app.asana.com/1/137249556945/project/1208671518894266/task/1211719139917333?focus=true ### Description Sends a pixel when installed app suggestion clicked. ### Steps to test this PR - [x] Go to Settings -> AI Features and enable Search & Duck.ai. - [x] Go to Feature Flag Inventory and enable `showInputScreenOnSystemSearchLaunch`. - [x] Force close and reopen the app. - [x] Add a widget to the home screen (**not** a search-only widget). - [x] Click on the widget and verify that Input Screen with a Search/Duck.ai toggle opens. - [x] Search for an app installed on your device. - [x] Click on the app name. - [x] Verify that `m_autocomplete_click_installed-app` fires with only `appVersion` as parameter.
1 parent 5378c6b commit d2d4182

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

app/src/main/java/com/duckduckgo/app/autocomplete/api/AutoComplete.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ class AutoCompleteApi constructor(
326326
AutoCompletePixelNames.AUTOCOMPLETE_DUCKAI_PROMPT_LEGACY_SELECTION
327327
}
328328
is AutoCompleteDeviceAppSuggestion -> {
329-
// todo add pixel for device app selection
329+
pixel.fire(AutoCompletePixelNames.AUTOCOMPLETE_INSTALLED_APP_SELECTION)
330330
return
331331
}
332332

app/src/main/java/com/duckduckgo/app/autocomplete/impl/AutoCompletePixelNames.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
package com.duckduckgo.app.autocomplete.impl
1818

1919
import com.duckduckgo.app.statistics.pixels.Pixel
20+
import com.duckduckgo.common.utils.plugins.pixel.PixelParamRemovalPlugin
21+
import com.duckduckgo.common.utils.plugins.pixel.PixelParamRemovalPlugin.PixelParameter
22+
import com.duckduckgo.di.scopes.AppScope
23+
import com.squareup.anvil.annotations.ContributesMultibinding
24+
import javax.inject.Inject
2025

2126
enum class AutoCompletePixelNames(override val pixelName: String) : Pixel.PixelName {
2227

@@ -32,4 +37,14 @@ enum class AutoCompletePixelNames(override val pixelName: String) : Pixel.PixelN
3237

3338
AUTOCOMPLETE_DUCKAI_PROMPT_EXPERIMENTAL_SELECTION("m_autocomplete_click_duckai_experimental"),
3439
AUTOCOMPLETE_DUCKAI_PROMPT_LEGACY_SELECTION("m_autocomplete_click_duckai_legacy"),
40+
AUTOCOMPLETE_INSTALLED_APP_SELECTION("m_autocomplete_click_installed-app"),
41+
}
42+
43+
@ContributesMultibinding(AppScope::class)
44+
class AutocompleteParamRemovalPlugin @Inject constructor() : PixelParamRemovalPlugin {
45+
override fun names(): List<Pair<String, Set<PixelParameter>>> {
46+
return listOf(
47+
AutoCompletePixelNames.AUTOCOMPLETE_INSTALLED_APP_SELECTION.pixelName to PixelParameter.removeAtb(),
48+
)
49+
}
3550
}

app/src/test/java/com/duckduckgo/app/autocomplete/api/AutoCompleteApiTest.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,6 +2012,26 @@ class AutoCompleteApiTest {
20122012
assertEquals(0, deviceAppSuggestions.size)
20132013
}
20142014

2015+
@Test
2016+
fun whenDeviceAppSuggestionSubmittedThenAutoCompleteInstalledAppSelectionPixelSent() = runTest {
2017+
whenever(mockSavedSitesRepository.hasBookmarks()).thenReturn(false)
2018+
whenever(mockSavedSitesRepository.hasFavorites()).thenReturn(false)
2019+
whenever(mockHistory.hasHistory()).thenReturn(false)
2020+
tabsLiveData.value = listOf(TabEntity("1", "https://example.com", position = 0))
2021+
2022+
val suggestion = AutoCompleteDeviceAppSuggestion(
2023+
phrase = "test",
2024+
shortName = "Test App",
2025+
packageName = "com.test.app",
2026+
launchIntent = Intent(),
2027+
)
2028+
val suggestions = listOf(suggestion)
2029+
2030+
testee.fireAutocompletePixel(suggestions, suggestion)
2031+
2032+
verify(mockPixel).fire(AutoCompletePixelNames.AUTOCOMPLETE_INSTALLED_APP_SELECTION)
2033+
}
2034+
20152035
private fun favorite(
20162036
id: String = UUID.randomUUID().toString(),
20172037
title: String = "title",

0 commit comments

Comments
 (0)