Why am I getting the Cannot read properties of undefined (reading 'pushEvent') error?

Hi.

I didn’t follow through all the logic in your code but it is most likely you have a race condition e.g… trying to subscribe or unsubscribe to specific events before the objects are ready, or trying to access objects before they are ready.

as I side note. Don’t use direct general dom operations in your code. This will most likely cause side effects in your plugin and in Grafana itself and there are some (optional) security options in Grafana that will prevent your plugin from accessing elements outside of your panel rendering scope.