Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property default does not exist on type 'PostHog' #1323

Open
bennycode opened this issue Jul 27, 2024 · 1 comment
Open

Property default does not exist on type 'PostHog' #1323

bennycode opened this issue Jul 27, 2024 · 1 comment

Comments

@bennycode
Copy link

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

@Reyno-Skeps
Copy link

Reyno-Skeps commented Aug 16, 2024

Ran into the same issue.

Using import { posthog } from 'posthog-js' fixes the type error while still being able to use posthog.init(...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants