mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-27 12:55:45 +01:00
b484286523
* Add session_data / session redis to CH. * Add mysql migration.
46 lines
827 B
TypeScript
46 lines
827 B
TypeScript
import { Prisma } from '@prisma/client';
|
|
import cache from 'lib/cache';
|
|
import prisma from 'lib/prisma';
|
|
|
|
export async function createSession(data: Prisma.SessionCreateInput) {
|
|
const {
|
|
id,
|
|
websiteId,
|
|
hostname,
|
|
browser,
|
|
os,
|
|
device,
|
|
screen,
|
|
language,
|
|
country,
|
|
subdivision1,
|
|
subdivision2,
|
|
city,
|
|
} = data;
|
|
|
|
return prisma.client.session
|
|
.create({
|
|
data: {
|
|
id,
|
|
websiteId,
|
|
hostname,
|
|
browser,
|
|
os,
|
|
device,
|
|
screen,
|
|
language,
|
|
country,
|
|
subdivision1: country && subdivision1 ? `${country}-${subdivision1}` : null,
|
|
subdivision2,
|
|
city,
|
|
},
|
|
})
|
|
.then(async data => {
|
|
if (cache.enabled) {
|
|
await cache.storeSession(data);
|
|
}
|
|
|
|
return data;
|
|
});
|
|
}
|