2023-01-31 06:44:07 +01:00
|
|
|
import { Button, Column, Row, Dropdown, Item } from 'react-basics';
|
2022-12-29 00:43:22 +01:00
|
|
|
import Head from 'next/head';
|
|
|
|
import Link from 'next/link';
|
|
|
|
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 EventsChart from 'components/metrics/EventsChart';
|
2022-12-27 01:57:59 +01:00
|
|
|
import WebsiteChart from 'components/metrics/WebsiteChart';
|
2023-02-15 11:27:18 +01:00
|
|
|
import WebsiteSelect from 'components/input/WebsiteSelect';
|
2022-12-29 00:43:22 +01:00
|
|
|
import useApi from 'hooks/useApi';
|
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-12-29 00:43:22 +01:00
|
|
|
const { get, useQuery } = useApi();
|
2023-02-15 11:27:18 +01:00
|
|
|
const { data, isLoading, error } = useQuery(['websites:me'], () => get('/me/websites'));
|
2022-08-09 19:27:35 +02:00
|
|
|
const router = useRouter();
|
|
|
|
const {
|
|
|
|
basePath,
|
|
|
|
query: { id },
|
|
|
|
} = router;
|
2020-09-27 09:51:29 +02:00
|
|
|
|
2023-01-31 06:44:07 +01:00
|
|
|
function handleChange(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
|
|
|
}
|
|
|
|
|
2023-01-31 06:44:07 +01:00
|
|
|
if (!data) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const websiteId = id?.[0];
|
|
|
|
const website = data.find(({ id }) => websiteId === id);
|
|
|
|
|
2020-09-27 09:51:29 +02:00
|
|
|
return (
|
2023-01-31 06:44:07 +01:00
|
|
|
<Page loading={isLoading} error={error}>
|
2020-09-27 09:51:29 +02:00
|
|
|
<Head>
|
|
|
|
{typeof window !== 'undefined' && website && (
|
2022-03-11 05:39:11 +01:00
|
|
|
<script
|
|
|
|
async
|
|
|
|
defer
|
2022-11-01 07:42:37 +01:00
|
|
|
data-website-id={website.id}
|
2022-03-11 05:39:11 +01:00
|
|
|
src={`${basePath}/umami.js`}
|
|
|
|
data-cache="true"
|
|
|
|
/>
|
2020-09-27 09:51:29 +02:00
|
|
|
)}
|
|
|
|
</Head>
|
2023-01-31 06:44:07 +01:00
|
|
|
<PageHeader title="Test console">
|
2023-02-15 11:27:18 +01:00
|
|
|
<WebsiteSelect websiteId={website?.id} onSelect={handleChange} />
|
2020-09-27 09:51:29 +02:00
|
|
|
</PageHeader>
|
2022-08-09 19:27:35 +02:00
|
|
|
{website && (
|
2020-09-27 09:51:29 +02:00
|
|
|
<>
|
2022-12-09 08:43:43 +01:00
|
|
|
<Row className={styles.test}>
|
|
|
|
<Column xs="4">
|
2023-01-31 06:44:07 +01:00
|
|
|
<div className={styles.header}>Page links</div>
|
2022-08-09 19:27:35 +02:00
|
|
|
<div>
|
2023-03-09 05:23:32 +01:00
|
|
|
<Link href={`/console/${websiteId}?page=1`}>page one</Link>
|
2022-08-09 19:27:35 +02:00
|
|
|
</div>
|
|
|
|
<div>
|
2023-03-09 05:23:32 +01:00
|
|
|
<Link href={`/console/${websiteId}?page=2`}>page two</Link>
|
2020-09-27 09:51:29 +02:00
|
|
|
</div>
|
2022-08-09 19:27:35 +02:00
|
|
|
<div>
|
2023-03-09 05:23:32 +01:00
|
|
|
<a href="https://www.google.com" className="umami--click--external-link-direct">
|
|
|
|
external link (direct)
|
|
|
|
</a>
|
2022-01-15 04:10:46 +01:00
|
|
|
</div>
|
2022-08-09 19:27:35 +02:00
|
|
|
<div>
|
2023-03-09 05:23:32 +01:00
|
|
|
<a
|
|
|
|
href="https://www.google.com"
|
|
|
|
className="umami--click--external-link-tab"
|
|
|
|
target="_blank"
|
|
|
|
rel="noreferrer"
|
|
|
|
>
|
|
|
|
external link (tab)
|
|
|
|
</a>
|
2020-09-27 09:51:29 +02:00
|
|
|
</div>
|
2022-12-09 08:43:43 +01:00
|
|
|
</Column>
|
|
|
|
<Column xs="4">
|
2023-01-31 06:44:07 +01:00
|
|
|
<div className={styles.header}>CSS events</div>
|
2022-08-09 19:27:35 +02:00
|
|
|
<Button id="primary-button" className="umami--click--button-click" variant="action">
|
|
|
|
Send event
|
|
|
|
</Button>
|
2022-12-09 08:43:43 +01:00
|
|
|
</Column>
|
|
|
|
<Column xs="4">
|
2023-01-31 06:44:07 +01:00
|
|
|
<div className={styles.header}>Javascript events</div>
|
2022-08-09 19:27:35 +02:00
|
|
|
<Button id="manual-button" variant="action" onClick={handleClick}>
|
|
|
|
Run script
|
|
|
|
</Button>
|
2022-12-09 08:43:43 +01:00
|
|
|
</Column>
|
|
|
|
</Row>
|
|
|
|
<Row>
|
|
|
|
<Column>
|
2023-01-31 06:44:07 +01:00
|
|
|
<div className={styles.header}>Statistics</div>
|
2020-10-21 15:44:43 +02:00
|
|
|
<WebsiteChart
|
2022-11-01 07:42:37 +01:00
|
|
|
websiteId={website.id}
|
2020-10-21 15:44:43 +02:00
|
|
|
title={website.name}
|
|
|
|
domain={website.domain}
|
|
|
|
showLink
|
|
|
|
/>
|
2023-01-31 06:44:07 +01:00
|
|
|
<div className={styles.header}>Events</div>
|
2022-11-01 07:42:37 +01:00
|
|
|
<EventsChart websiteId={website.id} />
|
2022-12-09 08:43:43 +01:00
|
|
|
</Column>
|
|
|
|
</Row>
|
2020-09-27 09:51:29 +02:00
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</Page>
|
|
|
|
);
|
|
|
|
}
|