posthog-js
posthog-js copied to clipboard
Property default does not exist on type 'PostHog'
I tried to integrate PostHog in my Astro website the following way:
---
import posthog from 'posthog-js';
---
{
posthog.init('xxx', {
api_host: 'https://eu.i.posthog.com',
persistence: 'memory',
person_profiles: 'always',
})
}
It crashed my website with the following error:
TypeError: vite_ssr_import_1.default.init is not a function
I changed the code to:
---
import posthog from 'posthog-js';
---
{
posthog.default.init('xxx', {
api_host: 'https://eu.i.posthog.com',
persistence: 'memory',
person_profiles: 'always',
})
}
This works now in a live environment but shows me an error in my IDE:
Property 'default' does not exist on type 'PostHog'.
I guess there is something wrong with the default typing?
Best, Benny