insights
createInsightsMiddleware({ insightsClient: null | InsightsClient, insightsInitParams?: object, onEvent?: (event: InsightsEvent, aa: null | InsightsClient) => void, });
1
import { createInsightsMiddleware } from 'instantsearch.js/es/middlewares';
About this widget # A
Starting from v4.55.0, you can use the insights
option instead of setting up the Insights middleware yourself.
The createInsightsMiddleware
creates an insights middleware to help you achieve the following:
- Set the
userToken
for insights purposes (Click Analytics, Personalization, etc.) - Automatically send events from built-in widgets (you can disable it)
- Lets you send events from your own custom widgets
Requirements#
- Use
search-insights
v1.6.2 or later. - Use InstantSearch.js v4.8.3 or later.
Examples # A
1
2
3
4
5
6
7
const insightsMiddleware = createInsightsMiddleware({
insightsClient,
insightsInitParams,
onEvent,
});
search.use(insightsMiddleware);
Options # A
Parameter | Description | ||
---|---|---|---|
insightsClient
# |
type: InsightsClient | null
Optional
The Insights client is used to send events. It synchronizes the user token between search and analytics calls. To disable |
||
Copy
|
|||
insightsInitParams
# |
since: v4.11.0
type: object
Optional
Insights parameters to forward to the Insights client’s With With |
||
Copy
|
|||
onEvent
# |
type: (event: InsightsEvent, aa: null | InsightsClient) => void
default: undefined
Optional
By default, the middleware sends events to Algolia using the provided If you want to use The
|
||
Copy
|
Custom events # A
Parameter | Description | ||
---|---|---|---|
Connectors
# |
Many of the InstantSearch connectors expose the Here’s a list of connectors that expose
|
||
Copy
|
|||
Hits
# |
The The
|
||
Copy
|