Setup algolia click analytics on searchbox widget

Hey team
I want to set up a click, no-click, and no-conversion rate analytics in my code.

I am having search box widget on my website.
code :

const search = instantsearch({
      indexName: algolia_config.indexes.search.relevance,
      searchClient
      },
    });

search.use(insightsMiddleware);
search.start()

custom search box

 search.addWidget(
      customHit({
        container: document.querySelector("#search_bar__hits"),
        clickAnalytics: true,
      })
    );

so whatever we search on the search box, I display their hits using on this container (search suggestion flyout box)

custom search box render hits logic

 const renderHits = (renderOptions, isFirstRender, url) => {
      const { hits, widgetParams, sendEvent, bindEvent } = renderOptions;

 }
     

in my hits, I tried using

  window.aa("convertedObjectIDsAfterSearch", window.appData.hits);

it gave an error, error = " needs query ID"

 sendEvent("click", window.appData.hits[index], "search clicked");
 (using onclick)

    AND

  ${bindEvent("click", item, "Search click")}
  (directly in element)

in both cases, I don’t get any error but the event doesn’t get registered.

Any help would be appreciated.

@staff @admin_algolia