To send events with InstantSearch, you must first add the search-insights library to your application. You can read more about installing the search-insights library here - https://www.algolia.com/doc/guides/building-search-ui/going-further/send-insights-events/js/#installing-the-search-insights-library.
You can load the search-insights library either as a static file on your server or use a CDN such as jsDelivr CDN (please note jsDelivr is a third-party CDN. Algolia can’t provide support for this service).
Using a static file hosted on your server, you must update theALGOLIA_INSIGHTS_SRC variable to point to the file URL.
If instantsearch.middlewares is undefined, since jspm does not include middlewares, you would need to manually add an entry to grab middlewares from jsdelivr:
Pin "instantsearch.js/es/middlewares", to "https://cdn.jsdelivr.net/npm/instantsearch.js@4.49.1/es/middlewares/index.js"
Then, import the middleware within your source code:
import { createInsightsMiddleware } from 'instantsearch.js/es/middlewares';