Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Add a global React wrapper component from plugins? #1211

Open
joaquimrocha opened this issue Jul 5, 2023 · 0 comments
Open

RFC: Add a global React wrapper component from plugins? #1211

joaquimrocha opened this issue Jul 5, 2023 · 0 comments
Labels

Comments

@joaquimrocha
Copy link
Collaborator

Some distributors of Headlamp want to be able to easily access app insights about the users' usage, so errors and patterns are reported more transparently.

With some solutions, like Microsoft's App Insights, the recommended way for tracking React applications is by wrapping the app using the Insights' own component.

Issues

Supporting this in Headlamp from plugins (i.e. plugins register an HOC for wrapping the whole app) is a bit tricky:

  1. Plugins get loaded dynamically and thus the app's rendering may start before plugins are loaded; so the whole application rendering may get delayed if we have to re-render with the HOC.
  2. If the HOC plugins register fails, then the whole app fails. Meaning we may have to use an error boundary and skip that HOC after it fails more than X times?

Interesting Issues (Misfeature?)

It would have interesting side effects as well. E.g. plugins could conditionally render the whole app, or even provide a completely different React app in itself.

Alternatives

As an alternative we could:

  1. Add error boundaries to the whole app and call a function registered by plugins whenever an error happens. This would allow plugins to use whatever service they want to report errors. However, we'd lose other things like click tracking, page views, etc. that may be otherwise set up transparently in an HOC approach.
  2. Add Microsoft App Insights as part of Headlamp (i.e. wrap the app in the original code) itself, but only do it if a plugin has provided a config file related to it. This has the downside of 1. the extra space added to Headlamp for something that may be completely optional; 2. with the aggravation of having to support other similar options out there (imagine having X modules related to insights/tracking, wasting extra space, just so plugins can eventually use one of them).
  3. Have a way to make it easier to load these HOCs from an file that may or may not be present (untracked in git) on frontend build time. I.e. it'd not be a plugin but an easy way to rebuild the frontend without having to modify it...

Any comments?
Any other solitions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant