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

using the API before posthog.init() is called #1121

Open
aroman opened this issue Apr 9, 2024 · 1 comment
Open

using the API before posthog.init() is called #1121

aroman opened this issue Apr 9, 2024 · 1 comment

Comments

@aroman
Copy link

aroman commented Apr 9, 2024

is it safe to call posthog methods (e.g. posthog.capture) before posthog.init() has been called? will they be queued and flushed when (and if) the posthog client is eventually initialized?

I ask because we are considering moving to an architecture where we lazily initialize posthog once some async initial data is fetched (e.g. an initial distinctID for providing to posthog.initialize({bootstrap: distinctId})

@aroman
Copy link
Author

aroman commented Apr 9, 2024

from a quick skim of the source, it looks like the answer to my question is "no, don't do that"

however, I'd love for someone on the posthog team to chime in here as to the recommended best practice when a user's distinct ID is not known immediately

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

1 participant