Getting "apiKey is missing" error when setting up the insightsClient

I’m trying to send click events using the search-insights library. I use vue-instantsearch and it works fine, but when connecting the search-insights library I get this error:
Uncaught Error: apiKey is missing, please provide it so we can authenticate the application
In the head section I have this:

vue-instantsearch version: “^4.3.1”
algoliasearch version: “^3.35.1”

When component is created I use insightsMiddlware:

(setTimeout is a temporary workaround)

I’ve found this solution here:
Didn’t find anything else working for me. Even the examples from documentation.

The ApiKey is set up and is correct:

The search works fine, but the click events are not sent.

Any help will be highly appreciated. Thanks in advance