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

Support autocompleteSessionId #54

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Conversation

yen-tt
Copy link
Collaborator

@yen-tt yen-tt commented Nov 23, 2021

Update headless state and network calls to support autocompleteSessionId

  • Update QueryState to include SearchAggregation, which includes 'enabled' and 'id' field. This is similar to SessionTrackingState, and would give user better context in what it is use for compare to the backend name of 'autocompleteSessionId'.
  • headless interface exposes two new functions, setSearchAggregationEnabled and setSearchAggregationId. Once searchAggregation is set to true, headless would internally setup new uuid and include it in every group of universal and vertical autocomplete/search calls. A new UUID will automatically be generated after a query is executed. However, in the case of id needing to update manually (i.e. when user type stuff in search bar but click elsewhere without executing search and the searchbar loses focus), then setSearchAggregationId can be used.
  • added new tests

NOTE: product wants to hold off on publishing this in core latest or beta version until backend work is done.

J=SLAP-1723
TEST=auto

use updated core in headless, see that jest tests passed.

Yen Truong and others added 2 commits November 23, 2021 11:02
J=SLAP-1723
TEST=auto

use updated core in headless, see that jest tests passed.
@yen-tt yen-tt added the WIP label Nov 23, 2021
@@ -162,13 +173,18 @@ export default class AnswersHeadless {
this.stateManager.dispatchEvent('searchStatus/setIsLoading', false);
this.stateManager.dispatchEvent('meta/setUUID', response.uuid);
this.stateManager.dispatchEvent('directAnswer/setResult', response.directAnswer);
if (this.state.query.searchAggregation?.enabled) {
this.stateManager.dispatchEvent('query/setSearchAggregationId', uuidv4());
Copy link
Contributor

@oshi97 oshi97 Nov 23, 2021

Choose a reason for hiding this comment

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

could you expand a little on how searches will be grouped together? It looks like here we would generate a new autocompleteSessionId for every single universal search made? Or maybe even a jest automock? I don't have any experience using automock, but it looks like here we're just counting the number of function calls so I think it could work?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

After discussing with product, the usage of autocompleteSessionId is different from the functionality added in this pr. autocompleteSessionId should be used in vertical/universal search only when it's executed for the purpose of visual autocomplete (the search term aggregation and this id doesn't apply for normal autocomplete). My original thought was to update uuid after every final search is triggered, and the visual autocomplete would have another function to execute autocomplete + search endpoints. Updated to always include autocompleteSessionId, and user can set that if they want a uuid to be included in the request

tests/integration/query.ts Outdated Show resolved Hide resolved
@yen-tt yen-tt requested a review from oshi97 November 23, 2021 22:27
src/answers-headless.ts Outdated Show resolved Hide resolved
@@ -48,6 +48,10 @@ export default class AnswersHeadless {
this.stateManager.dispatchEvent('query/setSource', source);
}

setSearchAggregationId(uuid: string): void {
this.stateManager.dispatchEvent('query/setSearchAggregationId', uuid);
Copy link
Contributor

Choose a reason for hiding this comment

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

if somebody wanted to clear the id would they just set it to blank string?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah, do you think undefined/null is better?

Copy link
Contributor

Choose a reason for hiding this comment

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

eh think it's fine!

@oshi97 oshi97 closed this Jan 21, 2022
@yen-tt yen-tt reopened this May 9, 2022
@yen-tt yen-tt requested a review from a team as a code owner September 8, 2022 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants