alephium / alephium-frontend

A monorepo containing all things frontend on Alephium.
Other
14 stars 13 forks source link

Add Sentry #917

Open mvaivre opened 1 month ago

mvaivre commented 1 month ago

https://docs.sentry.io/platforms/javascript/guides/electron/

nop33 commented 1 month ago

I followed the guide as well as the recommended @sentry/wizard which created the sentry.properties file. This was the output of the command:

Successfully created sentry.properties

Add these lines in to your main process code to setup Sentry:

    // ESM
    import * as Sentry from '@sentry/electron/main';
    // CommonJs
    const Sentry = require('@sentry/electron/main');

    Sentry.init({
      dsn: 'I_REMOVED_IT_TO_PASTE_HERE',
    });

Add these lines in to your renderer processes code to setup Sentry:

    // ESM
    import * as Sentry from '@sentry/electron/renderer';
    // CommonJs
    const Sentry = require('@sentry/electron/renderer');

    Sentry.init({});

Inside the sentry.properties file there was the auth.token property. That felt like it shouldn't be committed, although the wizard did not add the sentry.properties file to .gitignore. I can't find any info about env vars on their docs, only something related to Sentry CLI and sourcemaps. On SO a person recommends to treat this file as .env, so it should be ignored.

With the auth.token inside sentry.properties (default wizard output) I managed to send test errors to Sentry.io from all these 3 places:

Then I tried removing the auth.token from the sentry.properties, exporting it in my terminal through the SENTRY_AUTH_TOKEN env var, moving the dsn URL in the env var SENTRY_DSN inside .env and tested again. This time only these test errors reached Sentry.io:

Finally, I set up these 2 env vars on GitHub:

and made them available to the electron-build commend in the GH action: https://github.com/alephium/alephium-frontend/commit/02ef3ed8a45291a5d23be3b4fe1ad9259a680906

I hardcoded an exception outside the App component and triggered an RC build.

I downloaded it and installed it in my system, the app crashed, but the error was not reported on Sentry.io

What am I missing?

The examples don't include electron-builder: https://github.com/getsentry/sentry-electron/tree/master/examples

I discovered this GH action but I don't think it's what we are looking for: https://github.com/marketplace/actions/sentry-release

Related branch: https://github.com/alephium/alephium-frontend/tree/sentry-dw