Skip to content

fix: load posthog-js via a consumer-injected loader#9

Merged
SvenAlHamad merged 1 commit into
v3from
fix/posthog-consumer-loader
Jun 5, 2026
Merged

fix: load posthog-js via a consumer-injected loader#9
SvenAlHamad merged 1 commit into
v3from
fix/posthog-consumer-loader

Conversation

@SvenAlHamad

Copy link
Copy Markdown
Contributor

WTS no longer imports posthog-js itself. The web client previously did a bare import("posthog-js") guarded with webpackIgnore so consumers that don't record (e.g. the Webiny admin app, which doesn't install posthog-js) could still build. But webpackIgnore left a bare module specifier the browser can't resolve at runtime, so session recording silently failed in bundled apps (no traffic to s.webiny.com).

Add SessionRecordingConfig.loadPostHog, a loader the consumer supplies as () => import('posthog-js'). The import resolves inside the consumer's bundle (where posthog-js is installed), and the library contains no posthog-js reference at all — so non-recording consumers build cleanly without webpackIgnore. Recording is skipped with a warning if no loader is given.

WTS no longer imports posthog-js itself. The web client previously did a bare
`import("posthog-js")` guarded with `webpackIgnore` so consumers that don't
record (e.g. the Webiny admin app, which doesn't install posthog-js) could
still build. But webpackIgnore left a bare module specifier the browser can't
resolve at runtime, so session recording silently failed in bundled apps (no
traffic to s.webiny.com).

Add `SessionRecordingConfig.loadPostHog`, a loader the consumer supplies as
`() => import('posthog-js')`. The import resolves inside the consumer's bundle
(where posthog-js is installed), and the library contains no posthog-js
reference at all — so non-recording consumers build cleanly without
webpackIgnore. Recording is skipped with a warning if no loader is given.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@SvenAlHamad SvenAlHamad merged commit 45fcdf8 into v3 Jun 5, 2026
4 checks passed
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 3.1.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant