Collection API.

This commit is contained in:
Mike Cao 2020-07-17 19:15:29 -07:00
parent f7f0c05e12
commit 11f1afe5c3
9 changed files with 400 additions and 64 deletions

View file

@ -4,7 +4,7 @@ import { savePageView } from '../../lib/db';
export default async (req, res) => {
const values = parseCollectRequest(req);
if (values) {
if (values.valid) {
const { type, session_id, url, referrer } = values;
if (type === 'pageview') {
@ -12,5 +12,5 @@ export default async (req, res) => {
}
}
res.status(200).json({ status: 'ok' });
res.status(200).json({ status: values.valid });
};

View file

@ -5,6 +5,10 @@ export default function Home() {
return (
<Layout>
Hello.
<br />
<a href="/?q=abc">abc</a>
<br />
<a href="/?q=123">123</a>
</Layout>
);
}