Skip to content

[CDX-471] Support passing itemID in trackAutocompleteSelect#168

Merged
HHHindawy merged 2 commits into
masterfrom
cdx-471-android-sdk-support-passing-itemid-in
Jun 24, 2026
Merged

[CDX-471] Support passing itemID in trackAutocompleteSelect#168
HHHindawy merged 2 commits into
masterfrom
cdx-471-android-sdk-support-passing-itemid-in

Conversation

@HHHindawy

Copy link
Copy Markdown
Contributor

Support passing an itemID parameter to the existing trackAutocompleteSelect function.

1 test added ✅

@HHHindawy HHHindawy requested review from a team and Copilot June 24, 2026 12:33
@HHHindawy HHHindawy requested a review from a team as a code owner June 24, 2026 12:33
constructor-claude-bedrock[bot]

This comment was marked as outdated.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the SDK’s autocomplete select tracking API to optionally send an itemID (item_id query param), allowing consumers to attribute a selection to a specific item when available.

Changes:

  • Added optional itemID parameter to trackAutocompleteSelect (and internal implementation) and plumbed it into the request query params.
  • Added a unit test asserting item_id is included in the autocomplete select tracking request.
  • Updated README with an example showing how to pass itemID.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
README.md Adds documentation example for passing itemID to autocomplete select tracking.
library/src/main/java/io/constructor/core/ConstructorIo.kt Adds optional itemID to the public/internal autocomplete select tracking API and includes it in encoded params.
library/src/test/java/io/constructor/core/ConstructorIoTrackingTest.kt Adds coverage for item_id being emitted in the tracking URL.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1453 to +1454
fun trackAutocompleteSelect(searchTerm: String, originalQuery: String, sectionName: String, resultGroup: ResultGroup? = null, resultID: String? = null, itemID: String? = null) {
var completable = trackAutocompleteSelectInternal(searchTerm, originalQuery, sectionName, resultGroup, resultID, itemID)
Comment thread README.md
Comment on lines 530 to 531
// Track when the user submits a search (searchTerm, originalQuery)
ConstructorIo.trackSearchSubmit("toothpicks", "tooth")

@Alexey-Pavlov Alexey-Pavlov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Thank you!

@constructor-claude-bedrock constructor-claude-bedrock Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This PR adds an itemID parameter to trackAutocompleteSelect, wiring it through to the existing getEncodedParams machinery — a clean, minimal change that follows established patterns. The implementation is correct and consistent with the rest of the codebase.

Inline comments: 3 discussions added

Overall Assessment: ⚠️ Needs Work

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) {
var completable = trackAutocompleteSelectInternal(searchTerm, originalQuery, sectionName, resultGroup, resultID, itemID)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: The completable variable is assigned once and never reassigned, so it should be val rather than var. The same pattern exists on the previous line of the original code (var completable = ...), but since this PR touches this function it's worth fixing here.

val completable = trackAutocompleteSelectInternal(searchTerm, originalQuery, sectionName, resultGroup, resultID, itemID)

fun trackAutocompleteSelectWithItemID() {
val mockResponse = MockResponse().setResponseCode(204)
mockServer.enqueue(mockResponse)
val observer = ConstructorIo.trackAutocompleteSelectInternal("titanic", "tit", "Products", null, null, "TIT-REP-1997").test()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: Passing null, null as positional arguments for resultGroup and resultID is hard to read and fragile — if the parameter order changes, this silently breaks. The existing codebase already uses named arguments (e.g. in getEncodedParams calls), and the trackAutocompleteSelectInternal signature supports them too. Prefer:

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()

Comment thread README.md
// 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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: The comment documents all six parameters including resultGroup and resultID, but neither appears in the example call below. This makes the comment misleading. Since the call only uses itemID as a named argument, the comment could simply reflect the params that matter:

// 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")

@HHHindawy HHHindawy merged commit d1d0fcc into master Jun 24, 2026
1 check passed
@HHHindawy HHHindawy deleted the cdx-471-android-sdk-support-passing-itemid-in branch June 24, 2026 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants