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 with either the jsDelivr CDN or your static file server (jsDelivr is a third-party CDN. Algolia can’t provide support for this service). If you choose the latter, you must update theALGOLIA_INSIGHTS_SRC
variable to point to the file URL on your file server.
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:
import { createInsightsMiddleware } from 'instantsearch.js/es/middlewares';