Open tomzweb opened 1 year ago
@tomzweb Even though the search-insights
middleware has a generic name, it turns out that it is only useful to send analytics events to Algolia. To send analytics to a third party service, you want to use the approach outlined here: https://www.algolia.com/doc/guides/building-search-ui/going-further/integrate-google-analytics/js/
@tomzweb I recently encountered this issue myself when developing a Search page for a client. It turns out that the reason for this, in my case, was that I was attempting to remove empty queries from Search Analytics using the old React InstantSearch method.
Check out the documentation here: https://www.algolia.com/doc/guides/getting-analytics/search-analytics/out-of-the-box-analytics/how-to/how-to-remove-empty-search-from-analytics/?client=React+Hooks
Specifically, look at the React Hooks example and note that the searchClient
constant now has ...algoliaClient
as part of it. This cleared up the issue and it's now working for me.
Hopefully this helps!
@accalton Thanks that does fix the error I was seeing, thank you!
Description
When using the
createInsightsMiddleware
with the typesense-instantsearch-adapter search client, theuseInstantSearch
from 'react-instantsearch-hooks' throws the following error:Uncaught Error: [insights middleware]: could not extract Algolia credentials from searchClient
This appears to be because of a missing appId and appKey. Attempts to add this via search-insights have not been successful:
What I'm trying to achieve is to use insights to send events to a third-party analytics service.
Steps to reproduce
Create an insights middleware component:
Provide the InsightsMiddleware to the InstantSearch component:
Expected Behavior
The ability to use insights middleware to send events to third-party APIs.
Actual Behavior
Uncaught Error: [insights middleware]: could not extract Algolia credentials from searchClient