mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
Compare commits
2 commits
592f7c0ae7
...
14f5babea7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
14f5babea7 | ||
|
|
14f3db550b |
2 changed files with 40 additions and 36 deletions
|
|
@ -146,6 +146,7 @@ export async function POST(request: Request) {
|
||||||
region,
|
region,
|
||||||
city,
|
city,
|
||||||
distinctId: id,
|
distinctId: id,
|
||||||
|
createdAt,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,44 @@
|
||||||
import { Prisma } from '@/generated/prisma/client';
|
import { Prisma } from '@/generated/prisma/client';
|
||||||
import prisma from '@/lib/prisma';
|
import prisma from '@/lib/prisma';
|
||||||
|
|
||||||
export async function createSession(data: Prisma.SessionCreateInput) {
|
const FUNCTION_NAME = 'createSession';
|
||||||
const {
|
|
||||||
id,
|
|
||||||
websiteId,
|
|
||||||
browser,
|
|
||||||
os,
|
|
||||||
device,
|
|
||||||
screen,
|
|
||||||
language,
|
|
||||||
country,
|
|
||||||
region,
|
|
||||||
city,
|
|
||||||
distinctId,
|
|
||||||
} = data;
|
|
||||||
|
|
||||||
try {
|
export async function createSession(data: Prisma.SessionCreateInput) {
|
||||||
return await prisma.client.session.create({
|
const { rawQuery } = prisma;
|
||||||
data: {
|
|
||||||
id,
|
await rawQuery(
|
||||||
websiteId,
|
`
|
||||||
browser,
|
insert into session (
|
||||||
os,
|
session_id,
|
||||||
device,
|
website_id,
|
||||||
screen,
|
browser,
|
||||||
language,
|
os,
|
||||||
country,
|
device,
|
||||||
region,
|
screen,
|
||||||
city,
|
language,
|
||||||
distinctId,
|
country,
|
||||||
},
|
region,
|
||||||
});
|
city,
|
||||||
} catch (e: any) {
|
distinct_id,
|
||||||
if (e.message.toLowerCase().includes('unique constraint')) {
|
created_at
|
||||||
return null;
|
)
|
||||||
}
|
values (
|
||||||
throw e;
|
{{id}},
|
||||||
}
|
{{websiteId}},
|
||||||
|
{{browser}},
|
||||||
|
{{os}},
|
||||||
|
{{device}},
|
||||||
|
{{screen}},
|
||||||
|
{{language}},
|
||||||
|
{{country}},
|
||||||
|
{{region}},
|
||||||
|
{{city}},
|
||||||
|
{{distinctId}},
|
||||||
|
{{createdAt}}
|
||||||
|
)
|
||||||
|
on conflict (session_id) do nothing
|
||||||
|
`,
|
||||||
|
data,
|
||||||
|
FUNCTION_NAME,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue