mirror of
https://github.com/umami-software/umami.git
synced 2026-02-20 04:25:39 +01:00
Merge branch 'dev' into feat/um-185-event-data-redirect
This commit is contained in:
commit
53a6a8924d
23 changed files with 3791 additions and 98 deletions
|
|
@ -19,6 +19,9 @@ export interface NextApiRequestCollect extends NextApiRequest {
|
|||
screen: string;
|
||||
language: string;
|
||||
country: string;
|
||||
subdivision1: string;
|
||||
subdivision2: string;
|
||||
city: string;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -31,7 +34,7 @@ export default async (req: NextApiRequestCollect, res: NextApiResponse) => {
|
|||
|
||||
const { type, payload } = getJsonBody(req);
|
||||
|
||||
const { referrer, eventName } = payload;
|
||||
const { referrer, eventName, pageTitle } = payload;
|
||||
let { url } = payload;
|
||||
|
||||
const ignoreIps = process.env.IGNORE_IP;
|
||||
|
|
@ -85,12 +88,13 @@ export default async (req: NextApiRequestCollect, res: NextApiResponse) => {
|
|||
}
|
||||
|
||||
if (type === 'pageview') {
|
||||
await savePageView({ ...session, url, referrer });
|
||||
await savePageView({ ...session, url, referrer, pageTitle });
|
||||
} else if (type === 'event') {
|
||||
await saveEvent({
|
||||
...session,
|
||||
url,
|
||||
referrer,
|
||||
pageTitle,
|
||||
eventName,
|
||||
});
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ export default async (req: NextApiRequest, res: NextApiResponse<ConfigResponse>)
|
|||
updatesDisabled: !!process.env.DISABLE_UPDATES,
|
||||
telemetryDisabled: !!process.env.DISABLE_TELEMETRY,
|
||||
adminDisabled: !!process.env.DISABLE_ADMIN,
|
||||
cloudMode: true, //!!process.env.CLOUD_MODE,
|
||||
cloudMode: process.env.CLOUD_MODE,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ import { canCreateUser, canViewUsers } from 'lib/auth';
|
|||
import { ROLES } from 'lib/constants';
|
||||
import { uuid } from 'lib/crypto';
|
||||
import { useAuth } from 'lib/middleware';
|
||||
import { NextApiRequestQueryBody } from 'lib/types';
|
||||
import { NextApiRequestQueryBody, User } from 'lib/types';
|
||||
import { NextApiResponse } from 'next';
|
||||
import { badRequest, hashPassword, methodNotAllowed, ok, unauthorized } from 'next-basics';
|
||||
import { createUser, getUser, getUsers, User } from 'queries';
|
||||
import { createUser, getUser, getUsers } from 'queries';
|
||||
|
||||
export interface UsersRequestBody {
|
||||
username: string;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import { badRequest, methodNotAllowed, ok, unauthorized } from 'next-basics';
|
|||
import { getPageviewMetrics, getSessionMetrics, getWebsite } from 'queries';
|
||||
|
||||
const sessionColumns = ['browser', 'os', 'device', 'screen', 'country', 'language'];
|
||||
const pageviewColumns = ['url', 'referrer', 'query'];
|
||||
const pageviewColumns = ['url', 'referrer', 'query', 'pageTitle'];
|
||||
|
||||
function getTable(type) {
|
||||
if (type === 'event') {
|
||||
|
|
@ -42,10 +42,14 @@ export interface WebsiteMetricsRequestQuery {
|
|||
endAt: number;
|
||||
url: string;
|
||||
referrer: string;
|
||||
pageTitle: string;
|
||||
os: string;
|
||||
browser: string;
|
||||
device: string;
|
||||
country: string;
|
||||
subdivision1: string;
|
||||
subdivision2: string;
|
||||
city: string;
|
||||
}
|
||||
|
||||
export default async (
|
||||
|
|
@ -62,10 +66,14 @@ export default async (
|
|||
endAt,
|
||||
url,
|
||||
referrer,
|
||||
pageTitle,
|
||||
os,
|
||||
browser,
|
||||
device,
|
||||
country,
|
||||
subdivision1,
|
||||
subdivision2,
|
||||
city,
|
||||
} = req.query;
|
||||
|
||||
if (req.method === 'GET') {
|
||||
|
|
@ -86,6 +94,9 @@ export default async (
|
|||
browser,
|
||||
device,
|
||||
country,
|
||||
subdivision1,
|
||||
subdivision2,
|
||||
city,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -127,10 +138,14 @@ export default async (
|
|||
domain,
|
||||
url: type !== 'url' && table !== 'event' ? url : undefined,
|
||||
referrer: type !== 'referrer' && table !== 'event' ? referrer : FILTER_IGNORED,
|
||||
pageTitle: type !== 'pageTitle' && table !== 'event' ? pageTitle : undefined,
|
||||
os: type !== 'os' ? os : undefined,
|
||||
browser: type !== 'browser' ? browser : undefined,
|
||||
device: type !== 'device' ? device : undefined,
|
||||
country: type !== 'country' ? country : undefined,
|
||||
subdivision1: type !== 'subdivision1' ? subdivision1 : undefined,
|
||||
subdivision2: type !== 'subdivision2' ? subdivision2 : undefined,
|
||||
city: type !== 'city' ? city : undefined,
|
||||
eventUrl: type !== 'url' && table === 'event' ? url : undefined,
|
||||
query: type === 'query' && table !== 'event' ? true : undefined,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -17,10 +17,14 @@ export interface WebsitePageviewRequestQuery {
|
|||
timezone: string;
|
||||
url?: string;
|
||||
referrer?: string;
|
||||
pageTitle?: string;
|
||||
os?: string;
|
||||
browser?: string;
|
||||
device?: string;
|
||||
country?: string;
|
||||
subdivision1?: string;
|
||||
subdivision2?: string;
|
||||
city?: string;
|
||||
}
|
||||
|
||||
export default async (
|
||||
|
|
@ -38,10 +42,14 @@ export default async (
|
|||
timezone,
|
||||
url,
|
||||
referrer,
|
||||
pageTitle,
|
||||
os,
|
||||
browser,
|
||||
device,
|
||||
country,
|
||||
subdivision1,
|
||||
subdivision2,
|
||||
city,
|
||||
} = req.query;
|
||||
|
||||
if (req.method === 'GET') {
|
||||
|
|
@ -66,10 +74,14 @@ export default async (
|
|||
filters: {
|
||||
url,
|
||||
referrer,
|
||||
pageTitle,
|
||||
os,
|
||||
browser,
|
||||
device,
|
||||
country,
|
||||
subdivision1,
|
||||
subdivision2,
|
||||
city,
|
||||
},
|
||||
}),
|
||||
getPageviewStats(websiteId, {
|
||||
|
|
@ -80,10 +92,14 @@ export default async (
|
|||
count: 'distinct website_event.',
|
||||
filters: {
|
||||
url,
|
||||
pageTitle,
|
||||
os,
|
||||
browser,
|
||||
device,
|
||||
country,
|
||||
subdivision1,
|
||||
subdivision2,
|
||||
city,
|
||||
},
|
||||
}),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { WebsiteStats } from 'lib/types';
|
||||
import { NextApiRequestQueryBody } from 'lib/types';
|
||||
import { canViewWebsite } from 'lib/auth';
|
||||
import { useAuth, useCors } from 'lib/middleware';
|
||||
import { NextApiRequestQueryBody, WebsiteStats } from 'lib/types';
|
||||
import { NextApiResponse } from 'next';
|
||||
import { methodNotAllowed, ok, unauthorized } from 'next-basics';
|
||||
import { getWebsiteStats } from 'queries';
|
||||
|
|
@ -13,10 +12,14 @@ export interface WebsiteStatsRequestQuery {
|
|||
endAt: number;
|
||||
url: string;
|
||||
referrer: string;
|
||||
pageTitle: string;
|
||||
os: string;
|
||||
browser: string;
|
||||
device: string;
|
||||
country: string;
|
||||
subdivision1: string;
|
||||
subdivision2: string;
|
||||
city: string;
|
||||
}
|
||||
|
||||
export default async (
|
||||
|
|
@ -26,7 +29,21 @@ export default async (
|
|||
await useCors(req, res);
|
||||
await useAuth(req, res);
|
||||
|
||||
const { id: websiteId, startAt, endAt, url, referrer, os, browser, device, country } = req.query;
|
||||
const {
|
||||
id: websiteId,
|
||||
startAt,
|
||||
endAt,
|
||||
url,
|
||||
referrer,
|
||||
pageTitle,
|
||||
os,
|
||||
browser,
|
||||
device,
|
||||
country,
|
||||
subdivision1,
|
||||
subdivision2,
|
||||
city,
|
||||
} = req.query;
|
||||
|
||||
if (req.method === 'GET') {
|
||||
if (!(await canViewWebsite(req.auth, websiteId))) {
|
||||
|
|
@ -46,10 +63,14 @@ export default async (
|
|||
filters: {
|
||||
url,
|
||||
referrer,
|
||||
pageTitle,
|
||||
os,
|
||||
browser,
|
||||
device,
|
||||
country,
|
||||
subdivision1,
|
||||
subdivision2,
|
||||
city,
|
||||
},
|
||||
});
|
||||
const prevPeriod = await getWebsiteStats(websiteId, {
|
||||
|
|
@ -58,10 +79,14 @@ export default async (
|
|||
filters: {
|
||||
url,
|
||||
referrer,
|
||||
pageTitle,
|
||||
os,
|
||||
browser,
|
||||
device,
|
||||
country,
|
||||
subdivision1,
|
||||
subdivision2,
|
||||
city,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue