Allow filtering on session fields.

This commit is contained in:
Mike Cao 2022-04-10 03:51:43 -07:00
parent edd1645bab
commit fb2dc9f5ab
19 changed files with 275 additions and 211 deletions

View file

@ -14,7 +14,8 @@ export default async (req, res) => {
return unauthorized(res);
}
const { id, start_at, end_at, unit, tz, url, referrer } = req.query;
const { id, start_at, end_at, unit, tz, url, referrer, os, browser, device, country } =
req.query;
const websiteId = +id;
const startDate = new Date(+start_at);
@ -25,10 +26,20 @@ export default async (req, res) => {
}
const [pageviews, sessions] = await Promise.all([
getPageviewStats(websiteId, startDate, endDate, tz, unit, '*', { url, referrer }),
getPageviewStats(websiteId, startDate, endDate, tz, unit, 'distinct session_id', {
getPageviewStats(websiteId, startDate, endDate, tz, unit, '*', {
url,
referrer,
os,
browser,
device,
country,
}),
getPageviewStats(websiteId, startDate, endDate, tz, unit, 'distinct pageview.session_id', {
url,
os,
browser,
device,
country,
}),
]);