React SDK
The React SDK provides hooks and components for easy integration.
Installation
Section titled “Installation”npm install @analyze.swiss/reactimport { AnalyzeProvider } from '@analyze.swiss/react';
function App() { return ( <AnalyzeProvider apiKey="YOUR_API_KEY"> <YourApp /> </AnalyzeProvider> );}useAnalyze
Section titled “useAnalyze”import { useAnalyze } from '@analyze.swiss/react';
function SignupButton() { const { track } = useAnalyze();
return ( <button onClick={() => track('signup_clicked')}> Sign Up </button> );}useIdentify
Section titled “useIdentify”import { useIdentify } from '@analyze.swiss/react';
function UserProfile({ user }) { const identify = useIdentify();
useEffect(() => { identify(user.id, { email: user.email, name: user.name }); }, [user]);}