Currently themes transpile code in <script type="text/discourse-plugin" version="0.8"> to: Discourse._registerPluginCode('0.8', function (api)
This call often can happen before the application has initialized and thus api.getCurrentUser can be null if this is registered too early (eg in header).
We should change it so registerPluginCode always runs after all objects are injected into the context so the api is fully functional.