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

feat: Add search event API #1241

Merged
merged 1 commit into from
Apr 25, 2022
Merged

feat: Add search event API #1241

merged 1 commit into from
Apr 25, 2022

Conversation

tlgimenes
Copy link
Contributor

@tlgimenes tlgimenes commented Apr 25, 2022

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 and search.click) were already implemented on our starters. However, a missing event was search.query. This event is important for populating indices, like Top Searches and Suggestions. 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

@tlgimenes tlgimenes requested a review from a team as a code owner April 25, 2022 17:27
@vercel
Copy link

vercel bot commented Apr 25, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
faststore ✅ Ready (Inspect) Visit Preview Apr 25, 2022 at 5:27PM (UTC)

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 2c7460b:

Sandbox Source
Store UI Typescript Configuration

Copy link
Contributor

@chrsmutti chrsmutti left a comment

Choose a reason for hiding this comment

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

LGTM

@tlgimenes tlgimenes merged commit 6895d28 into master Apr 25, 2022
@tlgimenes tlgimenes deleted the feat/search-event branch April 25, 2022 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants