-
Notifications
You must be signed in to change notification settings - Fork 3
[CDX-471] Support passing itemID in trackAutocompleteSelect #168
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -524,6 +524,9 @@ ConstructorIo.trackInputFocus("") | |
| // Track when the user selects an autocomplete suggestion (searchTerm, originalQuery, sectionName) | ||
| ConstructorIo.trackAutocompleteSelect("toothpicks", "tooth", "Search Suggestions") | ||
|
|
||
| // Track when the user selects an autocomplete suggestion with an item ID (searchTerm, originalQuery, sectionName, resultGroup, resultID, itemID) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: The comment documents all six parameters including // Track when the user selects an autocomplete suggestion with an item ID (searchTerm, originalQuery, sectionName, itemID)
ConstructorIo.trackAutocompleteSelect("Fashionable Toothpicks", "tooth", "Products", itemID = "1234567-AB") |
||
| ConstructorIo.trackAutocompleteSelect("Fashionable Toothpicks", "tooth", "Products", itemID = "1234567-AB") | ||
|
|
||
| // Track when the user submits a search (searchTerm, originalQuery) | ||
| ConstructorIo.trackSearchSubmit("toothpicks", "tooth") | ||
|
Comment on lines
530
to
531
|
||
| ``` | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1448,18 +1448,19 @@ object ConstructorIo { | |
| * @param sectionName the section the selection came from, i.e. "Search Suggestions" | ||
| * @param resultGroup the group to search within if a user selected to search in a group, i.e. "Pumpkin in Canned Goods" | ||
| * @param resultID the result ID of the autocomplete response that the selection came from | ||
| * @param itemID the item ID of the selection, i.e. "ITEM-123" | ||
| */ | ||
| fun trackAutocompleteSelect(searchTerm: String, originalQuery: String, sectionName: String, resultGroup: ResultGroup? = null, resultID: String? = null) { | ||
| var completable = trackAutocompleteSelectInternal(searchTerm, originalQuery, sectionName, resultGroup, resultID) | ||
| fun trackAutocompleteSelect(searchTerm: String, originalQuery: String, sectionName: String, resultGroup: ResultGroup? = null, resultID: String? = null, itemID: String? = null) { | ||
|
constructor-claude-bedrock[bot] marked this conversation as resolved.
|
||
| var completable = trackAutocompleteSelectInternal(searchTerm, originalQuery, sectionName, resultGroup, resultID, itemID) | ||
|
constructor-claude-bedrock[bot] marked this conversation as resolved.
Comment on lines
+1453
to
+1454
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: The val completable = trackAutocompleteSelectInternal(searchTerm, originalQuery, sectionName, resultGroup, resultID, itemID) |
||
| disposable.add(completable.subscribeOn(Schedulers.io()).subscribe({ | ||
| context.broadcastIntent(Constants.EVENT_QUERY_SENT, Constants.EXTRA_TERM to searchTerm) | ||
| }, { | ||
| t -> e("Autocomplete Select error: ${t.message}") | ||
| })) | ||
| } | ||
| internal fun trackAutocompleteSelectInternal(searchTerm: String, originalQuery: String, sectionName: String, resultGroup: ResultGroup? = null, resultID: String? = null): Completable { | ||
| internal fun trackAutocompleteSelectInternal(searchTerm: String, originalQuery: String, sectionName: String, resultGroup: ResultGroup? = null, resultID: String? = null, itemID: String? = null): Completable { | ||
| preferenceHelper.getSessionId(sessionIncrementHandler) | ||
| val encodedParams: ArrayList<Pair<String, String>> = getEncodedParams(groupId = resultGroup?.groupId, groupDisplayName = resultGroup?.displayName, resultId = resultID) | ||
| val encodedParams: ArrayList<Pair<String, String>> = getEncodedParams(groupId = resultGroup?.groupId, groupDisplayName = resultGroup?.displayName, resultId = resultID, itemId = itemID) | ||
|
|
||
| return dataManager.trackAutocompleteSelect(searchTerm, arrayOf( | ||
| Constants.QueryConstants.SECTION to sectionName, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -299,6 +299,17 @@ class ConstructorIoTrackingTest { | |
| assert(request.path!!.startsWith(path)) | ||
| } | ||
|
|
||
| @Test | ||
| fun trackAutocompleteSelectWithItemID() { | ||
| val mockResponse = MockResponse().setResponseCode(204) | ||
| mockServer.enqueue(mockResponse) | ||
| val observer = ConstructorIo.trackAutocompleteSelectInternal("titanic", "tit", "Products", null, null, "TIT-REP-1997").test() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Passing val observer = ConstructorIo.trackAutocompleteSelectInternal(
"titanic", "tit", "Products",
resultGroup = null, resultID = null, itemID = "TIT-REP-1997"
).test()Or, since the parameters have defaults, simply omit the nulls: val observer = ConstructorIo.trackAutocompleteSelectInternal(
"titanic", "tit", "Products", itemID = "TIT-REP-1997"
).test() |
||
| observer.assertComplete() | ||
| val request = mockServer.takeRequest() | ||
| val path = "/autocomplete/titanic/select?section=Products&original_query=tit&tr=click&item_id=TIT-REP-1997&key=copper-key&i=wacko-the-guid&ui=player-three&s=67&c=cioand-2.41.0&_dt=" | ||
| assert(request.path!!.startsWith(path)) | ||
| } | ||
|
|
||
| @Test | ||
| fun trackAutocompleteSelectWithServerError() { | ||
| val mockResponse = MockResponse().setResponseCode(500).setBody("Internal server error") | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.