import { Button } from '@umami/react-zen'; import Link from 'next/link'; import Script from 'next/script'; import { WebsiteSelect } from '@/components/input/WebsiteSelect'; import { Page } from '@/components/layout/Page'; import { PageHeader } from '@/components/layout/PageHeader'; import { EventsChart } from '@/components/metrics/EventsChart'; import { WebsiteChart } from '../websites/[websiteId]/WebsiteChart'; import { useApi, useNavigation } from '@/components/hooks'; import styles from './TestConsole.module.css'; export function TestConsole({ websiteId }: { websiteId: string }) { const { get, useQuery } = useApi(); const { data, isLoading, error } = useQuery({ queryKey: ['websites:me'], queryFn: () => get('/me/websites'), }); const { router } = useNavigation(); function handleChange(value: string) { router.push(`/console/${value}`); } function handleRunScript() { window['umami'].track(props => ({ ...props, url: '/page-view', referrer: 'https://www.google.com', })); window['umami'].track('track-event-no-data'); window['umami'].track('track-event-with-data', { test: 'test-data', boolean: true, booleanError: 'true', time: new Date(), user: `user${Math.round(Math.random() * 10)}`, number: 1, number2: Math.random() * 100, time2: new Date().toISOString(), nested: { test: 'test-data', number: 1, object: { test: 'test-data', }, }, array: [1, 2, 3], }); } function handleRunRevenue() { window['umami'].track(props => ({ ...props, url: '/checkout-cart', referrer: 'https://www.google.com', })); window['umami'].track('checkout-cart', { revenue: parseFloat((Math.random() * 1000).toFixed(2)), currency: 'USD', }); window['umami'].track('affiliate-link', { revenue: parseFloat((Math.random() * 1000).toFixed(2)), currency: 'USD', }); window['umami'].track('promotion-link', { revenue: parseFloat((Math.random() * 1000).toFixed(2)), currency: 'USD', }); window['umami'].track('checkout-cart', { revenue: parseFloat((Math.random() * 1000).toFixed(2)), currency: 'EUR', }); window['umami'].track('promotion-link', { revenue: parseFloat((Math.random() * 1000).toFixed(2)), currency: 'EUR', }); window['umami'].track('affiliate-link', { item1: { productIdentity: 'ABC424', revenue: parseFloat((Math.random() * 10000).toFixed(2)), currency: 'JPY', }, item2: { productIdentity: 'ZYW684', revenue: parseFloat((Math.random() * 10000).toFixed(2)), currency: 'JPY', }, }); } function handleRunIdentify() { window['umami'].identify({ userId: 123, name: 'brian', number: Math.random() * 100, test: 'test-data', boolean: true, booleanError: 'true', time: new Date(), time2: new Date().toISOString(), nested: { test: 'test-data', number: 1, object: { test: 'test-data', }, }, array: [1, 2, 3], }); } if (!data) { return null; } const website = data?.data.find(({ id }) => websiteId === id); return ( {website && (