Skip to content

@posthog/nextjs-config withPostHogConfig silently fails if it is not the outermost config wrapper #3572

@jcapogna

Description

@jcapogna

Bug Description

If withPostHogConfig is not the last config wrapper in next.config.js, the PostHog build plugin does not do anything. It does not error, produce logs of any kind (even with log level set to debug), or upload source maps.

Moving withPostHogConfig to be the last wrapper makes it work as expected.

How to reproduce

  1. Wrap your next config with withPostHogConfig per the docs
  2. Wrap that with something like withNextIntl from next-intl
  3. Run your build. See that no source maps get generated or uploaded. With the PostHogConfig having log level set to debug, see there are no logs output from the posthog tool.
  4. Then put withPostHogConfig as the last wrapper and see that it works as expected.

Additional context

Debug info

- [ ] PostHog Cloud, Debug information: [please copy/paste from https://us.posthog.com/settings/project-details#variables or https://eu.posthog.com/settings/project-details#variables]
- [ ] PostHog Hobby self-hosted with `docker compose`, version/commit: [please provide]
- [ ] PostHog self-hosted with Kubernetes (deprecated, see [`Sunsetting Kubernetes support`](https://posthog.com/blog/sunsetting-helm-support-posthog)), version/commit: [please provide]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions