Open MarkLyck opened 1 year ago
Any news? I want to set a default value for my feature flags if an error occurs but I didn't find any solution
Sending events to PostHog from your own domain should be a workaround of the issue with an ad blocker interceptor. But we definitely need an onError
handler.
@EugeneBalabai for your use-case, you can check if posthog.getFeatureFlag
returns undefined instead of a value, which implies an error and you can use that to set the default
@neilkakkar yep, but I also want to show the loader to a customer until I get the values from Posthog to prevent flickering
I'm facing the same or a similar problem here.
For me the problem is with the surveys module which uses a setInterval
with no break conditions. Every second it tries to load the surveys and check if there is an active matching survey. If an ad blocker is enabled, the call to the surveys endpoint will fail and then retry indefinitely every second. The error logs completely take over the browser console and the network tab, which is really annoying.
I had to add a workaround where I manually check if posthog server is reachable before initializing posthog client.
It would be very nice if posthog could expose an api to do some health checks before the initialisation method is called or perfom the checks on the init method and bail out in case the server can't be reached.
One major problem with Posthog is that ad blockers are blocking it. Which I'm fine with for analytics. But because I also use posthog for feature flags that is core functionality, that a user would likely want to work.
However right now, if you have an adblocker like the default one in Brave Browser, posthog init will just fail and keep retrying. But there's no way to catch the error and prompt the user that they might want to disable their adblocker.
Please add an onError handler to catch the error when it fails to init for whatever reason.