mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-22 18:00:17 +01:00
Merge branch 'dev' into analytics
This commit is contained in:
commit
df4b57fc51
@ -130,11 +130,3 @@ export async function getClientInfo(req: NextApiRequestCollect, { screen }) {
|
|||||||
|
|
||||||
return { userAgent, browser, os, ip, country, subdivision1, subdivision2, city, device };
|
return { userAgent, browser, os, ip, country, subdivision1, subdivision2, city, device };
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getJsonBody<T>(req): T {
|
|
||||||
if ((req.headers['content-type'] || '').indexOf('text/plain') !== -1) {
|
|
||||||
return JSON.parse(req.body);
|
|
||||||
}
|
|
||||||
|
|
||||||
return req.body;
|
|
||||||
}
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { isUuid, secret, uuid } from 'lib/crypto';
|
import { isUuid, secret, uuid } from 'lib/crypto';
|
||||||
import { getClientInfo, getJsonBody } from 'lib/detect';
|
import { getClientInfo } from 'lib/detect';
|
||||||
import { parseToken } from 'next-basics';
|
import { parseToken } from 'next-basics';
|
||||||
import { CollectRequestBody, NextApiRequestCollect } from 'pages/api/send';
|
import { NextApiRequestCollect } from 'pages/api/send';
|
||||||
import { createSession } from 'queries';
|
import { createSession } from 'queries';
|
||||||
import cache from './cache';
|
import cache from './cache';
|
||||||
import clickhouse from './clickhouse';
|
import clickhouse from './clickhouse';
|
||||||
@ -22,7 +22,7 @@ export async function findSession(req: NextApiRequestCollect): Promise<{
|
|||||||
city: any;
|
city: any;
|
||||||
ownerId: string;
|
ownerId: string;
|
||||||
}> {
|
}> {
|
||||||
const { payload } = getJsonBody<CollectRequestBody>(req);
|
const { payload } = req.body;
|
||||||
|
|
||||||
if (!payload) {
|
if (!payload) {
|
||||||
throw new Error('Invalid payload.');
|
throw new Error('Invalid payload.');
|
||||||
|
@ -3,7 +3,7 @@ import ipaddr from 'ipaddr.js';
|
|||||||
import isbot from 'isbot';
|
import isbot from 'isbot';
|
||||||
import { COLLECTION_TYPE, HOSTNAME_REGEX } from 'lib/constants';
|
import { COLLECTION_TYPE, HOSTNAME_REGEX } from 'lib/constants';
|
||||||
import { secret } from 'lib/crypto';
|
import { secret } from 'lib/crypto';
|
||||||
import { getIpAddress, getJsonBody } from 'lib/detect';
|
import { getIpAddress } from 'lib/detect';
|
||||||
import { useCors, useSession, useValidate } from 'lib/middleware';
|
import { useCors, useSession, useValidate } from 'lib/middleware';
|
||||||
import { CollectionType, YupRequest } from 'lib/types';
|
import { CollectionType, YupRequest } from 'lib/types';
|
||||||
import { NextApiRequest, NextApiResponse } from 'next';
|
import { NextApiRequest, NextApiResponse } from 'next';
|
||||||
@ -77,7 +77,7 @@ export default async (req: NextApiRequestCollect, res: NextApiResponse) => {
|
|||||||
return ok(res);
|
return ok(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { type, payload } = getJsonBody<CollectRequestBody>(req);
|
const { type, payload } = req.body;
|
||||||
|
|
||||||
if (!type || !payload) {
|
if (!type || !payload) {
|
||||||
return badRequest(res);
|
return badRequest(res);
|
||||||
|
Loading…
Reference in New Issue
Block a user