79359420

Date: 2025-01-15 19:16:36
Score: 1
Natty:
Report link

https://docusaurus.io/docs/swizzling#wrapper-your-site-with-root

import React from 'react';
import mixpanel from 'mixpanel-browser';

// Default implementation, that you can customize
export default function Root({children}) {
  React.useEffect(() => {
    if (typeof window !== 'undefined') {
      // Initialize Mixpanel with the token
      mixpanel.init(TOKEN, {
        track_pageview: true,
        debug: process.env.NODE_ENV === 'development'
      });
    }
  }, []);

  return <>{children}</>;
}
Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Linghua Jin