mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
Add event collection.
This commit is contained in:
parent
1ca72cbd9c
commit
9f3acd1583
6 changed files with 87 additions and 3 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { parseCollectRequest } from 'lib/utils';
|
||||
import { savePageView } from 'lib/db';
|
||||
import { savePageView, saveEvent } from 'lib/db';
|
||||
import { allowPost } from 'lib/middleware';
|
||||
|
||||
export default async (req, res) => {
|
||||
|
|
@ -8,12 +8,16 @@ export default async (req, res) => {
|
|||
const values = parseCollectRequest(req);
|
||||
|
||||
if (values.success) {
|
||||
const { type, website_id, session_id, url, referrer } = values;
|
||||
const { type, website_id, session_id, url, referrer, eventType, eventValue } = values;
|
||||
|
||||
if (type === 'pageview') {
|
||||
await savePageView(website_id, session_id, url, referrer).catch(() => {
|
||||
values.success = 0;
|
||||
});
|
||||
} else if (type === 'event') {
|
||||
await saveEvent(website_id, session_id, url, eventType, eventValue).catch(() => {
|
||||
values.success = 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue