Type 'SentryIntegration' is not assignable to type 'Integration'
Following the instructions from here: https://posthog.com/docs/libraries/sentry#installation
The SentryIntegration class is not type compatible. Force casting throws causing an error from sentry for the same reason.
Type 'SentryIntegration' is not assignable to type 'Integration'.
Types of property 'setupOnce' are incompatible.
Type '(addGlobalEventProcessor: (callback: any) => void, getCurrentHub: () => any) => void' is not assignable to type '() => void'.
Target signature provides too few arguments. Expected 2 or more, but got 0.ts(2322)
Turns out Sentry recently changed the signature: https://github.com/getsentry/sentry-javascript/pull/11238
I am able to get it to work by doing this after Sentry.init:
const postHogIntegration = new posthog.SentryIntegration(
posthog,
'your organization',
project-id,
undefined, // optional: but necessary if you want to set a severity allowlist
['error', 'info'] // optional: here is set to handle captureMessage (info) and captureException (error)
)
postHogIntegration.setupOnce(Sentry.addEventProcessor, () => {})
Essentially passing the handler inside setupOnce to the addEventProcessor.
However, another issue is that the urls being generated are incorrect. The config token here is the API key, but Sentry uses a the project ID (i.e. 80397).
const personUrl = _posthog.requestRouter.endpointFor(
'ui',
`/project/${_posthog.config.token}/person/${_posthog.get_distinct_id()}` // <--- wrong url
)
@benjackwhite Does your PR fix this?
@benjackwhite also wanted to follow up - ty :)
It should, and how you use it is to replace new SentryIntegration... with sentryIntegration() FYI. based on the discussion there the "new" v8 compatible version is a function that is camelCased whereas the "old" v7 version is a class that is "PascalCased"