Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's the purpose of this pull request?
This PR integrates the VTEX Intelligent Search Analytics API with
@faststore/api
. More specifically, it integrates product queries with search.query event.How it works?
For intelligent search to work properly, some events must be send to their tracking endpoints
https://sp.vtex.com/event-api/v1
. A few of these events (session.ping
andsearch.click
) were already implemented on our starters. However, a missing event wassearch.query
. This event is important for populating indices, likeTop Searches
andSuggestions
. This event was hard to implement because some info was missing on the frontend. To address this issue, an integration on@faststore/api
was proposed.@faststore/api
is a BFF GraphQL layer between the React frontend and the VTEX Intelligent Search API. Every time a search is performed on the frontend, resolvers on@faststore/api
are run and perform a search on Intelligent Search API.This PR integrates IS tracking API with
@faststore/api
right after a search is performed. On the resolvers, we have all necessary info IS tracking API requires.A drawback of this solution is that user ID's are faked, so no session tracking is possible with this approach.
How to test it?
Use one of the deploy previews below and make sure the request to SP returns a 204.
vtex-sites/nextjs.store#2
vtex-sites/gatsby.store#2
References
More info about Search Tracking API
https://www.notion.so/vtexhandbook/Event-API-Documentation-48eee26730cf4d7f80f8fd7262231f84