elbwalker/walkerOS

Usage with Next.js app router (nextjs 13,14,15)

Opened this issue · 1 comments

Describe the bug
We are having a hard time getting walker.js running with next.js 15 and the app router. We created a client component and trying to start walker like that:

export const ElbWalker: React.FC<WalkerOSProps> = ({ customerId }) => {
  const location = usePathname();
  useEffect(() => {
    setupAnalytics(customerId);
  }, [location]);

  return undefined;
};

but it seems like the pathname update gets already triggered even when the page has not been loaded completely, which results in the triggering of the same event multiple times... we are trying to debug that, but currently can't really explain the behaviour.

Let's say I have an e-commerce item page. When I first load the page, the view_item event gets triggered and it is fine. When I make a local page transition to the /cart page, I see another time the view_item event being triggered, but not the view_cart event. When loading the cart page, I get the view_cart event being triggered just one time.

We are using the most recent version of the walker.js.

Are there any configuration settings for Next.js that we can follow?

the main issue with next.js and the app router is, that the router events got removed: vercel/next.js#41934
that problem is now, that the navigation hook is already triggered, even though the page is not loaded yet, leading to wrong or no triggered events from elbwalker. This is something that needs to be solved.