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(preset-algolia): attach algolia credentials on hits #1117

Merged

Conversation

dhayab
Copy link
Member

@dhayab dhayab commented Apr 5, 2023

This PR adds an __autocomplete_algoliaResultsMetadata property on each hit returned from an Algolia source, that includes the credentials of the application it comes from. This will help us send events to the appropriate location at a later stage.

Note
The getAppIdAndApiKey utility is a simplified version of the one that comes from InstantSearch. Support for v3 search clients is not necessary so it has been removed.

FX-2276

@dhayab dhayab requested review from a team, FabienMotte and sarahdayan and removed request for a team April 5, 2023 09:30
@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 5, 2023

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 1296bc9:

Sandbox Source
@algolia/autocomplete-example-github-repositories-custom-plugin Configuration
@algolia/autocomplete-example-instantsearch Configuration
@algolia/autocomplete-example-playground Configuration
@algolia/autocomplete-example-preview-panel-in-modal Configuration
@algolia/autocomplete-example-react-renderer Configuration
@algolia/autocomplete-example-starter-algolia Configuration
@algolia/autocomplete-example-starter Configuration
@algolia/autocomplete-example-reshape Configuration
@algolia/autocomplete-example-vue Configuration

@dhayab dhayab marked this pull request as draft April 5, 2023 12:07
@dhayab dhayab marked this pull request as ready for review April 5, 2023 12:29
Copy link
Contributor

@Haroenv Haroenv left a comment

Choose a reason for hiding this comment

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

this works I think, naming could be edited possibly

Co-authored-by: Haroen Viaene <hello@haroen.me>
@dhayab dhayab requested a review from Haroenv April 6, 2023 08:52
@dhayab dhayab merged commit 972e806 into feat/automatic-events Apr 6, 2023
@dhayab dhayab deleted the feat/automatic-events-algolia-credentials branch April 6, 2023 09:04
Haroenv added a commit that referenced this pull request Apr 7, 2023
Co-authored-by: Haroen Viaene <hello@haroen.me>
Haroenv added a commit that referenced this pull request Apr 7, 2023
Co-authored-by: Haroen Viaene <hello@haroen.me>
Haroenv added a commit that referenced this pull request Apr 7, 2023
Co-authored-by: Haroen Viaene <hello@haroen.me>
dhayab added a commit that referenced this pull request Apr 11, 2023
Co-authored-by: Haroen Viaene <hello@haroen.me>
Haroenv added a commit that referenced this pull request Apr 24, 2023
Co-authored-by: Haroen Viaene <hello@haroen.me>
Haroenv added a commit that referenced this pull request Apr 24, 2023
Co-authored-by: Haroen Viaene <hello@haroen.me>
export function getAppIdAndApiKey(
searchClient: SearchClient
): { appId: string; apiKey: string } {
const { headers, queryParameters } = searchClient.transporter;

Choose a reason for hiding this comment

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

Hi @dhayab, I am not sure if we are using autocomplete incorrectly, but we ran into an issue where the transporter wasn't checked and the JS code was trying to pull headers from undefined. Could you help with this? We have a fix in a place where we are using version 1.8.3 of autocomplete-preset-algolia. We could be using it wrong, I am not sure.

https://github.com/algolia/algoliasearch-shopify/pull/1520

Copy link
Member Author

Choose a reason for hiding this comment

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

Hi Bryan, this is probably because you have the v3 of algoliasearch in your dependencies. Autocomplete relies on the v4, which is what causes the issue right now.

If you're not using the javascript search client directly, you can safely update it to the latest v4 version as InstantSearch and Autocomplete have support for it.

Choose a reason for hiding this comment

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

Ahhh wonderful thank you!

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.

4 participants