Closed antoinerousseau closed 2 months ago
This lib really isn't designed for the use case in mind. Next-js router API is running server side and as such is basically a node-js environment and so should use the built posthog-node
target instead as that way it includes concepts such as graceful shutdown and the correct fetch implementation for your node environment.
Bug description
SSR support was supported in https://github.com/PostHog/posthog-js-lite/pull/57), but as mentioned here, the web version gets loaded instead of the Node.js version, and it tries to access the
window
object, throwing aReferenceError: window is not defined
from here, here or here.How to reproduce
ReferenceError: window is not defined
Related sub-libraries
Additional context
Related: https://github.com/PostHog/posthog-js-lite/issues/67#issuecomment-1488735973