web & sdk: improved sdk (better failover and batching)
This commit is contained in:
@@ -3,10 +3,11 @@ import { mixan } from '@/analytics';
|
||||
import type { AppProps } from 'next/app';
|
||||
import { useRouter } from 'next/router';
|
||||
|
||||
mixan.init();
|
||||
|
||||
export default function MyApp({ Component, pageProps }: AppProps) {
|
||||
const router = useRouter();
|
||||
useEffect(() => {
|
||||
mixan.init();
|
||||
return router.events.on('routeChangeComplete', () => {
|
||||
mixan.screenView();
|
||||
});
|
||||
|
||||
@@ -1,9 +1,53 @@
|
||||
import { mixan } from '@/analytics';
|
||||
import Link from 'next/link';
|
||||
|
||||
export default function Test() {
|
||||
return (
|
||||
<div>
|
||||
<Link href="/">Home</Link>
|
||||
<button
|
||||
onClick={() => {
|
||||
mixan.setUser({
|
||||
first_name: 'John',
|
||||
});
|
||||
mixan.setUser({
|
||||
last_name: 'Doe',
|
||||
});
|
||||
mixan.setUser({
|
||||
email: 'john.doe@gmail.com',
|
||||
});
|
||||
mixan.setUser({
|
||||
id: '1234',
|
||||
});
|
||||
}}
|
||||
>
|
||||
Set user
|
||||
</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
localStorage.clear();
|
||||
window.location.reload();
|
||||
}}
|
||||
>
|
||||
Clear storage and reload
|
||||
</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
mixan.event('custom_click', {
|
||||
custom_string: 'test',
|
||||
custom_number: 1,
|
||||
});
|
||||
}}
|
||||
>
|
||||
Trigger event
|
||||
</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
mixan.clear();
|
||||
}}
|
||||
>
|
||||
Logout
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user