sentry-capacitor icon indicating copy to clipboard operation
sentry-capacitor copied to clipboard

Implement electron platform

Open muuvmuuv opened this issue 3 years ago • 6 comments

There is a package available to use Electron platform together with Capacitor, unfortunately it will log a lot of "Native client not available" errors. Would it be possible or in range of this package to add the electron platform?

Here is an instruction on how to add electron as a platform for capacitor: https://capacitor-community.github.io/electron/docs/creatingplugins

muuvmuuv avatar May 17 '22 13:05 muuvmuuv

What would that support look like? @sentry/electron bundles the JS SDK just like we do here already. So I assume we'd need to pull some of the code written for electron in https://github.com/getsentry/sentry-electron and share it here? cc @AbhiPrasad @timfish

bruno-garcia avatar May 17 '22 18:05 bruno-garcia

I guess, at least for Sentry here, it's just like wrapping it, so the capacitor electron platform can use it properly.

Here is an example from SQLite: https://github.com/capacitor-community/sqlite

muuvmuuv avatar May 17 '22 18:05 muuvmuuv

Reading the docs for @capacitor-community/electron, once you install it you'll get a *yourAppDir*/electron/src/index.ts file added to your project. I haven't had a proper look yet but I'm guessing this is the Electron startup code where you would just start the Electron SDK.

You'll also need to start the Electron SDK in the browser front end and this code will vary from the other platforms. ~~Is there a way for the build to select different JavaScript entry points for each platform?~~ Oooohhh, reading the docs and see this is possible via plugin config.

timfish avatar May 17 '22 18:05 timfish

Would this need to live in a separate repo? Also there will be complexities in versioning, especially because electron and capacitor can (and will usually) depend on different versions on the base JS SDK.

AbhiPrasad avatar May 17 '22 18:05 AbhiPrasad

Versioning pain aside, I'm guessing we could:

  • Add @sentry/electron as an optional peer dep
  • Add some code that inits the Electron SDK browser code when targeting that platform
  • Add electron to the capacitor key in package.json pointing to above entry code
  • Override release and environment with whatever the default is for Capacitor because it's likely to differ from Electron

Because Electron has multiple processes we'd need to get users to init the SDK in the main process too.

So instructions for users would go:

  • Install @sentry/electron
  • Init the Electron SDK in *yourAppDir*/electron/src/index.ts
  • Everything worky

But yeah, versioning would be super painful 🤔

timfish avatar May 17 '22 19:05 timfish

A version painless solution would be to just use the web SDK in electron, but I couldn't get that to work (though I thought it would already fall back to web if nothing else declared).

muuvmuuv avatar May 17 '22 19:05 muuvmuuv

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

github-actions[bot] avatar May 30 '23 00:05 github-actions[bot]