web & sdk: improved sdk (better failover and batching)

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-01-12 11:31:46 +01:00
parent 8e7558790e
commit 5b5ad23f66
26 changed files with 1266 additions and 377 deletions

View File

@@ -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();
});

View File

@@ -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>
);
}