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

Passing a framework specific init into the electron renderer init does not work

Open nnguyen01 opened this issue 1 year ago • 2 comments

Is there an existing issue for this?

  • [x] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
  • [x] I have reviewed the documentation https://docs.sentry.io/
  • [x] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases

How do you use Sentry?

Sentry Saas (sentry.io)

Electron SDK Version

5.2.0

Electron Version

27.3.11

What platform are you using?

Windows

Link to Sentry event

No response

Steps to Reproduce

  1. Install
"@sentry/electron": "^5.2.0",
"@sentry/integrations": "^7.114.0",
"@sentry/react": "^8.16.0",
  1. Call the init method in the electron renderer process.
import * as SentryReact from '@sentry/react';
import * as SentryElectronRenderer from '@sentry/electron/renderer';


SentryElectronRenderer.init(
  {
    ...
  },
  SentryReact.init,
);

Expected Result

SentryReact.init doesn't have a typescript error.

Actual Result

Argument of type '(options: BrowserOptions) => Client<ClientOptions<BaseTransportOptions>> | undefined' is not assignable to parameter of type '(if_you_get_a_typescript_error_ensure_sdks_use_version_v8_16_0: ElectronRendererOptions) => void'.
  Types of parameters 'options' and 'if_you_get_a_typescript_error_ensure_sdks_use_version_v8_16_0' are incompatible.
    Type 'ElectronRendererOptions' is not assignable to type 'BrowserOptions'.
      Type 'ElectronRendererOptions' is not assignable to type 'Options<BrowserTransportOptions>'.
        Types of property 'defaultIntegrations' are incompatible.
          Type 'false | import("c:/.../node_modules/@sentry/types/build/types/integration").Integration[] | undefined' is not assignable to type 'false | import("c:/.../node_modules/@sentry/react/node_modules/@sentry/types/build/types/integration").Integration[] | undefined'.
            Type 'Integration[]' is not assignable to type 'false | Integration[] | undefined'.
              Type 'import("c:/.../node_modules/@sentry/types/build/types/integration").Integration[]' is not assignable to type 'import("c:/.../node_modules/@sentry/react/node_modules/@sentry/types/build/types/integration").Integration[]'.
                Type 'import("c:/.../node_modules/@sentry/types/build/types/integration").Integration' is not assignable to type 'import("c:/.../node_modules/@sentry/react/node_modules/@sentry/types/build/types/integration").Integration'.
                  Types of property 'setup' are incompatible.
                    Type '((client: import("c:/.../node_modules/@sentry/types/build/types/client").Client<import("c:/.../node_modules/@sentry/types/build/types/options").ClientOptions<import("c:/.../node_modules/@sentry/types/build/types/transport").BaseTransportOptio...' is not assignable to type '((client: import("c:/.../node_modules/@sentry/react/node_modules/@sentry/types/build/types/client").Client<import("c:/.../node_modules/@sentry/react/node_modules/@sentry/types/build/types/options").ClientOptions<import("c:/.../node_modules/@s...'.
                      Type '(client: import("c:/.../node_modules/@sentry/types/build/types/client").Client<import("c:/.../node_modules/@sentry/types/build/types/options").ClientOptions<import("c:/.../node_modules/@sentry/types/build/types/transport").BaseTransportOption...' is not assignable to type '(client: import("c:/.../node_modules/@sentry/react/node_modules/@sentry/types/build/types/client").Client<import("c:/.../node_modules/@sentry/react/node_modules/@sentry/types/build/types/options").ClientOptions<import("c:/.../node_modules/@se...'.
                        Types of parameters 'client' and 'client' are incompatible.
                          Type 'import("c:/.../node_modules/@sentry/react/node_modules/@sentry/types/build/types/client").Client<import("c:/.../node_modules/@sentry/react/node_modules/@sentry/types/build/types/options").ClientOptions<import("c:/.../node_modules/@sentry/reac...' is not assignable to type 'import("c:/.../node_modules/@sentry/types/build/types/client").Client<import("c:/.../node_modules/@sentry/types/build/types/options").ClientOptions<import("c:/.../node_modules/@sentry/types/build/types/transport").BaseTransportOptions>>'.
                            Types of property 'captureException' are incompatible.
                              Type '(exception: any, hint?: import("c:/.../node_modules/@sentry/react/node_modules/@sentry/types/build/types/event").EventHint | undefined, currentScope?: import("c:/.../node_modules/@sentry/react/node_modules/@sentry/types/build/types/scope").Scope | undefined) => string' is not assignable to type '(exception: any, hint?: import("c:/.../node_modules/@sentry/types/build/types/event").EventHint | undefined, currentScope?: import("c:/.../node_modules/@sentry/types/build/types/scope").Scope | undefined) => string'.
                                Types of parameters 'currentScope' and 'currentScope' are incompatible.
                                  Type 'import("c:/.../node_modules/@sentry/types/build/types/scope").Scope | undefined' is not assignable to type 'import("c:/.../node_modules/@sentry/react/node_modules/@sentry/types/build/types/scope").Scope | undefined'.
                                    Type 'import("c:/.../node_modules/@sentry/types/build/types/scope").Scope' is not assignable to type 'import("c:/.../node_modules/@sentry/react/node_modules/@sentry/types/build/types/scope").Scope'.
                                      The types returned by 'getClient()' are incompatible between these types.
                                        Type 'Client<ClientOptions<BaseTransportOptions>> | undefined' is not assignable to type 'C | undefined'.
                                          Type 'Client<ClientOptions<BaseTransportOptions>>' is not assignable to type 'C'.
                                            'C' could be instantiated with an arbitrary type which could be unrelated to 'Client<ClientOptions<BaseTransportOptions>>'

I have also tried upgrading to sentry/react 8.20.0 to no avail.

nnguyen01 avatar Jul 29 '24 00:07 nnguyen01