2020-09-27 09:51:29 +02:00
|
|
|
import classNames from 'classnames';
|
|
|
|
import Head from 'next/head';
|
|
|
|
import Link from 'next/link';
|
2021-11-21 04:37:13 +01:00
|
|
|
import { useRouter } from 'next/router';
|
2022-01-15 04:10:46 +01:00
|
|
|
import Page from 'components/layout/Page';
|
|
|
|
import PageHeader from 'components/layout/PageHeader';
|
|
|
|
import DropDown from 'components/common/DropDown';
|
|
|
|
import WebsiteChart from 'components/metrics/WebsiteChart';
|
|
|
|
import EventsChart from 'components/metrics/EventsChart';
|
|
|
|
import Button from 'components/common/Button';
|
|
|
|
import useFetch from 'hooks/useFetch';
|
2020-10-09 00:02:48 +02:00
|
|
|
import styles from './TestConsole.module.css';
|
2020-09-27 09:51:29 +02:00
|
|
|
|
2020-09-29 05:23:42 +02:00
|
|
|
export default function TestConsole() {
|
2022-02-23 08:52:31 +01:00
|
|
|
const { data } = useFetch('/websites');
|
2022-08-09 19:27:35 +02:00
|
|
|
const router = useRouter();
|
|
|
|
const {
|
|
|
|
basePath,
|
|
|
|
query: { id },
|
|
|
|
} = router;
|
|
|
|
const websiteId = id?.[0];
|
2020-09-27 09:51:29 +02:00
|
|
|
|
2022-08-09 19:27:35 +02:00
|
|
|
if (!data) {
|
2020-09-27 09:51:29 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2022-10-10 22:42:18 +02:00
|
|
|
const options = data.map(({ name, websiteId }) => ({ label: name, value: websiteId }));
|
|
|
|
const website = data.find(({ websiteId }) => websiteId === +websiteId);
|
|
|
|
const selectedValue = options.find(({ value }) => value === website?.websiteId)?.value;
|
2020-09-27 09:51:29 +02:00
|
|
|
|
|
|
|
function handleSelect(value) {
|
2022-08-09 19:27:35 +02:00
|
|
|
router.push(`/console/${value}`);
|
2020-09-27 09:51:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function handleClick() {
|
2022-08-09 19:27:35 +02:00
|
|
|
window.umami('umami-default');
|
2020-09-27 09:51:29 +02:00
|
|
|
window.umami.trackView('/page-view', 'https://www.google.com');
|
2022-08-09 19:27:35 +02:00
|
|
|
window.umami.trackEvent('track-event-no-data');
|
|
|
|
window.umami.trackEvent('track-event-with-data', { test: 'test-data', time: Date.now() });
|
2020-09-27 09:51:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Page>
|
|
|
|
<Head>
|
|
|
|
{typeof window !== 'undefined' && website && (
|
2022-03-11 05:39:11 +01:00
|
|
|
<script
|
|
|
|
async
|
|
|
|
defer
|
2022-10-10 22:42:18 +02:00
|
|
|
data-website-id={website.websiteUuid}
|
2022-03-11 05:39:11 +01:00
|
|
|
src={`${basePath}/umami.js`}
|
|
|
|
data-cache="true"
|
|
|
|
/>
|
2020-09-27 09:51:29 +02:00
|
|
|
)}
|
|
|
|
</Head>
|
|
|
|
<PageHeader>
|
|
|
|
<div>Test Console</div>
|
|
|
|
<DropDown
|
2022-10-12 06:48:33 +02:00
|
|
|
value={selectedValue || 'Select website'}
|
2020-09-27 09:51:29 +02:00
|
|
|
options={options}
|
|
|
|
onChange={handleSelect}
|
|
|
|
/>
|
|
|
|
</PageHeader>
|
2022-08-09 19:27:35 +02:00
|
|
|
{website && (
|
2020-09-27 09:51:29 +02:00
|
|
|
<>
|
2022-08-09 19:27:35 +02:00
|
|
|
<div className={classNames(styles.test, 'row')}>
|
|
|
|
<div className="col-4">
|
|
|
|
<PageHeader>Page links</PageHeader>
|
|
|
|
<div>
|
|
|
|
<Link href={`/console/${websiteId}?page=1`}>
|
|
|
|
<a>page one</a>
|
|
|
|
</Link>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<Link href={`/console/${websiteId}?page=2`}>
|
|
|
|
<a>page two</a>
|
|
|
|
</Link>
|
2020-09-27 09:51:29 +02:00
|
|
|
</div>
|
2022-08-09 19:27:35 +02:00
|
|
|
<div>
|
|
|
|
<Link href={`https://www.google.com`}>
|
|
|
|
<a className="umami--click--external-link-direct">external link (direct)</a>
|
|
|
|
</Link>
|
2022-01-15 04:10:46 +01:00
|
|
|
</div>
|
2022-08-09 19:27:35 +02:00
|
|
|
<div>
|
|
|
|
<Link href={`https://www.google.com`}>
|
|
|
|
<a className="umami--click--external-link-tab" target="_blank">
|
|
|
|
external link (tab)
|
|
|
|
</a>
|
|
|
|
</Link>
|
2020-09-27 09:51:29 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-08-09 19:27:35 +02:00
|
|
|
<div className="col-4">
|
|
|
|
<PageHeader>CSS events</PageHeader>
|
|
|
|
<Button id="primary-button" className="umami--click--button-click" variant="action">
|
|
|
|
Send event
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
<div className="col-4">
|
|
|
|
<PageHeader>Javascript events</PageHeader>
|
|
|
|
<Button id="manual-button" variant="action" onClick={handleClick}>
|
|
|
|
Run script
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-09-27 09:51:29 +02:00
|
|
|
<div className="row">
|
|
|
|
<div className="col-12">
|
2020-10-21 15:44:43 +02:00
|
|
|
<WebsiteChart
|
2022-10-10 22:42:18 +02:00
|
|
|
websiteId={website.websiteId}
|
2020-10-21 15:44:43 +02:00
|
|
|
title={website.name}
|
|
|
|
domain={website.domain}
|
|
|
|
showLink
|
|
|
|
/>
|
2020-09-27 09:51:29 +02:00
|
|
|
<PageHeader>Events</PageHeader>
|
2022-10-10 22:42:18 +02:00
|
|
|
<EventsChart websiteId={website.websiteId} />
|
2020-09-27 09:51:29 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</Page>
|
|
|
|
);
|
|
|
|
}
|