mirror of
https://github.com/umami-software/umami.git
synced 2026-02-24 06:25:43 +01:00
Compare commits
No commits in common. "504c45909072dbb2e6d0c0bdd93160b0f14f0d6e" and "f073fb1996a637815d4296c8cd8bf8bb6d5e3839" have entirely different histories.
504c459090
...
f073fb1996
3 changed files with 8 additions and 13 deletions
|
|
@ -24,9 +24,9 @@ export async function GET(request: Request, { params }: { params: Promise<{ link
|
||||||
|
|
||||||
export async function POST(request: Request, { params }: { params: Promise<{ linkId: string }> }) {
|
export async function POST(request: Request, { params }: { params: Promise<{ linkId: string }> }) {
|
||||||
const schema = z.object({
|
const schema = z.object({
|
||||||
name: z.string().optional(),
|
name: z.string(),
|
||||||
url: z.string().optional(),
|
url: z.string(),
|
||||||
slug: z.string().min(8).optional(),
|
slug: z.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const { auth, body, error } = await parseRequest(request, schema);
|
const { auth, body, error } = await parseRequest(request, schema);
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@ export async function GET(request: Request, { params }: { params: Promise<{ pixe
|
||||||
|
|
||||||
export async function POST(request: Request, { params }: { params: Promise<{ pixelId: string }> }) {
|
export async function POST(request: Request, { params }: { params: Promise<{ pixelId: string }> }) {
|
||||||
const schema = z.object({
|
const schema = z.object({
|
||||||
name: z.string().optional(),
|
name: z.string(),
|
||||||
slug: z.string().min(8).optional(),
|
slug: z.string().min(8),
|
||||||
});
|
});
|
||||||
|
|
||||||
const { auth, body, error } = await parseRequest(request, schema);
|
const { auth, body, error } = await parseRequest(request, schema);
|
||||||
|
|
|
||||||
|
|
@ -82,8 +82,6 @@ export async function POST(request: Request) {
|
||||||
id,
|
id,
|
||||||
} = payload;
|
} = payload;
|
||||||
|
|
||||||
const sourceId = websiteId || pixelId || linkId;
|
|
||||||
|
|
||||||
// Cache check
|
// Cache check
|
||||||
let cache: Cache | null = null;
|
let cache: Cache | null = null;
|
||||||
|
|
||||||
|
|
@ -130,13 +128,13 @@ export async function POST(request: Request) {
|
||||||
const sessionSalt = hash(startOfMonth(createdAt).toUTCString());
|
const sessionSalt = hash(startOfMonth(createdAt).toUTCString());
|
||||||
const visitSalt = hash(startOfHour(createdAt).toUTCString());
|
const visitSalt = hash(startOfHour(createdAt).toUTCString());
|
||||||
|
|
||||||
const sessionId = id ? uuid(sourceId, id) : uuid(sourceId, ip, userAgent, sessionSalt);
|
const sessionId = id ? uuid(websiteId, id) : uuid(websiteId, ip, userAgent, sessionSalt);
|
||||||
|
|
||||||
// Create a session if not found
|
// Create a session if not found
|
||||||
if (!clickhouse.enabled && !cache?.sessionId) {
|
if (!clickhouse.enabled && !cache?.sessionId) {
|
||||||
await createSession({
|
await createSession({
|
||||||
id: sessionId,
|
id: sessionId,
|
||||||
websiteId: sourceId,
|
websiteId,
|
||||||
browser,
|
browser,
|
||||||
os,
|
os,
|
||||||
device,
|
device,
|
||||||
|
|
@ -208,7 +206,7 @@ export async function POST(request: Request) {
|
||||||
: EVENT_TYPE.pageView;
|
: EVENT_TYPE.pageView;
|
||||||
|
|
||||||
await saveEvent({
|
await saveEvent({
|
||||||
websiteId: sourceId,
|
websiteId: websiteId || linkId || pixelId,
|
||||||
sessionId,
|
sessionId,
|
||||||
visitId,
|
visitId,
|
||||||
eventType,
|
eventType,
|
||||||
|
|
@ -272,9 +270,6 @@ export async function POST(request: Request) {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const error = serializeError(e);
|
const error = serializeError(e);
|
||||||
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.log(error);
|
|
||||||
|
|
||||||
return serverError({ errorObject: error });
|
return serverError({ errorObject: error });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue