Compare commits

..

No commits in common. "504c45909072dbb2e6d0c0bdd93160b0f14f0d6e" and "f073fb1996a637815d4296c8cd8bf8bb6d5e3839" have entirely different histories.

3 changed files with 8 additions and 13 deletions

View file

@ -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 }> }) {
const schema = z.object({
name: z.string().optional(),
url: z.string().optional(),
slug: z.string().min(8).optional(),
name: z.string(),
url: z.string(),
slug: z.string(),
});
const { auth, body, error } = await parseRequest(request, schema);

View file

@ -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 }> }) {
const schema = z.object({
name: z.string().optional(),
slug: z.string().min(8).optional(),
name: z.string(),
slug: z.string().min(8),
});
const { auth, body, error } = await parseRequest(request, schema);

View file

@ -82,8 +82,6 @@ export async function POST(request: Request) {
id,
} = payload;
const sourceId = websiteId || pixelId || linkId;
// Cache check
let cache: Cache | null = null;
@ -130,13 +128,13 @@ export async function POST(request: Request) {
const sessionSalt = hash(startOfMonth(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
if (!clickhouse.enabled && !cache?.sessionId) {
await createSession({
id: sessionId,
websiteId: sourceId,
websiteId,
browser,
os,
device,
@ -208,7 +206,7 @@ export async function POST(request: Request) {
: EVENT_TYPE.pageView;
await saveEvent({
websiteId: sourceId,
websiteId: websiteId || linkId || pixelId,
sessionId,
visitId,
eventType,
@ -272,9 +270,6 @@ export async function POST(request: Request) {
} catch (e) {
const error = serializeError(e);
// eslint-disable-next-line no-console
console.log(error);
return serverError({ errorObject: error });
}
}