PostHog / PostHog/posthog-js

Add onError handler for posthog init

Open
#482 6 comments 10 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

AdBlocker enhancement feature/flags feature/surveys
Dominant language
TypeScript
Stars
609
Forks
343
Avg merge
1d 22h
Merged PRs (30d)
312

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no file or test; start by locating the PostHog initialization and retry path in the TypeScript SDK. Trace how initialization failures are surfaced, then add the requested onError behavior and verify that an initialization failure reaches the handler without breaking feature-flag use.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.