mirror of
https://github.com/kremalicious/umami.git
synced 2024-06-30 05:31:50 +02:00
update pageview, event save
This commit is contained in:
parent
cfa36d1802
commit
7596f42545
|
@ -8,8 +8,8 @@ import cache from 'lib/cache';
|
||||||
export async function saveEvent(args: {
|
export async function saveEvent(args: {
|
||||||
id: string;
|
id: string;
|
||||||
websiteId: string;
|
websiteId: string;
|
||||||
url: string;
|
urlPath: string;
|
||||||
referrer?: string;
|
urlQuery?: string;
|
||||||
pageTitle?: string;
|
pageTitle?: string;
|
||||||
eventName?: string;
|
eventName?: string;
|
||||||
hostname?: string;
|
hostname?: string;
|
||||||
|
@ -32,20 +32,20 @@ export async function saveEvent(args: {
|
||||||
async function relationalQuery(data: {
|
async function relationalQuery(data: {
|
||||||
id: string;
|
id: string;
|
||||||
websiteId: string;
|
websiteId: string;
|
||||||
url: string;
|
urlPath: string;
|
||||||
referrer?: string;
|
urlQuery?: string;
|
||||||
pageTitle?: string;
|
pageTitle?: string;
|
||||||
eventName?: string;
|
eventName?: string;
|
||||||
}) {
|
}) {
|
||||||
const { websiteId, id: sessionId, url, eventName, referrer, pageTitle } = data;
|
const { websiteId, id: sessionId, urlPath, urlQuery, eventName, pageTitle } = data;
|
||||||
|
|
||||||
return prisma.client.websiteEvent.create({
|
return prisma.client.websiteEvent.create({
|
||||||
data: {
|
data: {
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
websiteId,
|
websiteId,
|
||||||
sessionId,
|
sessionId,
|
||||||
url: url?.substring(0, URL_LENGTH),
|
urlPath: urlPath?.substring(0, URL_LENGTH),
|
||||||
referrer: referrer?.substring(0, URL_LENGTH),
|
urlQuery: urlQuery?.substring(0, URL_LENGTH),
|
||||||
pageTitle: pageTitle,
|
pageTitle: pageTitle,
|
||||||
eventType: EVENT_TYPE.customEvent,
|
eventType: EVENT_TYPE.customEvent,
|
||||||
eventName: eventName?.substring(0, EVENT_NAME_LENGTH),
|
eventName: eventName?.substring(0, EVENT_NAME_LENGTH),
|
||||||
|
@ -56,8 +56,8 @@ async function relationalQuery(data: {
|
||||||
async function clickhouseQuery(data: {
|
async function clickhouseQuery(data: {
|
||||||
id: string;
|
id: string;
|
||||||
websiteId: string;
|
websiteId: string;
|
||||||
url: string;
|
urlPath: string;
|
||||||
referrer?: string;
|
urlQuery?: string;
|
||||||
pageTitle?: string;
|
pageTitle?: string;
|
||||||
eventName?: string;
|
eventName?: string;
|
||||||
hostname?: string;
|
hostname?: string;
|
||||||
|
@ -74,7 +74,8 @@ async function clickhouseQuery(data: {
|
||||||
const {
|
const {
|
||||||
websiteId,
|
websiteId,
|
||||||
id: sessionId,
|
id: sessionId,
|
||||||
url,
|
urlPath,
|
||||||
|
urlQuery,
|
||||||
pageTitle,
|
pageTitle,
|
||||||
eventName,
|
eventName,
|
||||||
country,
|
country,
|
||||||
|
@ -94,7 +95,8 @@ async function clickhouseQuery(data: {
|
||||||
subdivision1: subdivision1 ? subdivision1 : null,
|
subdivision1: subdivision1 ? subdivision1 : null,
|
||||||
subdivision2: subdivision2 ? subdivision2 : null,
|
subdivision2: subdivision2 ? subdivision2 : null,
|
||||||
city: city ? city : null,
|
city: city ? city : null,
|
||||||
url: url?.substring(0, URL_LENGTH),
|
urlPath: urlPath?.substring(0, URL_LENGTH),
|
||||||
|
urlQuery: urlQuery?.substring(0, URL_LENGTH),
|
||||||
page_title: pageTitle,
|
page_title: pageTitle,
|
||||||
event_type: EVENT_TYPE.customEvent,
|
event_type: EVENT_TYPE.customEvent,
|
||||||
event_name: eventName?.substring(0, EVENT_NAME_LENGTH),
|
event_name: eventName?.substring(0, EVENT_NAME_LENGTH),
|
||||||
|
|
|
@ -8,8 +8,11 @@ import { uuid } from 'lib/crypto';
|
||||||
export async function savePageView(args: {
|
export async function savePageView(args: {
|
||||||
id: string;
|
id: string;
|
||||||
websiteId: string;
|
websiteId: string;
|
||||||
url: string;
|
urlPath: string;
|
||||||
referrer?: string;
|
urlQuery?: string;
|
||||||
|
referrerPath?: string;
|
||||||
|
referrerQuery?: string;
|
||||||
|
referrerDomain?: string;
|
||||||
pageTitle?: string;
|
pageTitle?: string;
|
||||||
hostname?: string;
|
hostname?: string;
|
||||||
browser?: string;
|
browser?: string;
|
||||||
|
@ -31,19 +34,34 @@ export async function savePageView(args: {
|
||||||
async function relationalQuery(data: {
|
async function relationalQuery(data: {
|
||||||
id: string;
|
id: string;
|
||||||
websiteId: string;
|
websiteId: string;
|
||||||
url: string;
|
urlPath: string;
|
||||||
referrer?: string;
|
urlQuery?: string;
|
||||||
|
referrerPath?: string;
|
||||||
|
referrerQuery?: string;
|
||||||
|
referrerDomain?: string;
|
||||||
pageTitle?: string;
|
pageTitle?: string;
|
||||||
}) {
|
}) {
|
||||||
const { websiteId, id: sessionId, url, referrer, pageTitle } = data;
|
const {
|
||||||
|
websiteId,
|
||||||
|
id: sessionId,
|
||||||
|
urlPath,
|
||||||
|
urlQuery,
|
||||||
|
referrerPath,
|
||||||
|
referrerQuery,
|
||||||
|
referrerDomain,
|
||||||
|
pageTitle,
|
||||||
|
} = data;
|
||||||
|
|
||||||
return prisma.client.websiteEvent.create({
|
return prisma.client.websiteEvent.create({
|
||||||
data: {
|
data: {
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
websiteId,
|
websiteId,
|
||||||
sessionId,
|
sessionId,
|
||||||
url: url?.substring(0, URL_LENGTH),
|
urlPath: urlPath?.substring(0, URL_LENGTH),
|
||||||
referrer: referrer?.substring(0, URL_LENGTH),
|
urlQuery: urlQuery?.substring(0, URL_LENGTH),
|
||||||
|
referrerPath: referrerPath?.substring(0, URL_LENGTH),
|
||||||
|
referrerQuery: referrerQuery?.substring(0, URL_LENGTH),
|
||||||
|
referrerDomain: referrerDomain?.substring(0, URL_LENGTH),
|
||||||
pageTitle: pageTitle,
|
pageTitle: pageTitle,
|
||||||
eventType: EVENT_TYPE.pageView,
|
eventType: EVENT_TYPE.pageView,
|
||||||
},
|
},
|
||||||
|
@ -53,8 +71,11 @@ async function relationalQuery(data: {
|
||||||
async function clickhouseQuery(data: {
|
async function clickhouseQuery(data: {
|
||||||
id: string;
|
id: string;
|
||||||
websiteId: string;
|
websiteId: string;
|
||||||
url: string;
|
urlPath: string;
|
||||||
referrer?: string;
|
urlQuery?: string;
|
||||||
|
referrerPath?: string;
|
||||||
|
referrerQuery?: string;
|
||||||
|
referrerDomain?: string;
|
||||||
pageTitle?: string;
|
pageTitle?: string;
|
||||||
hostname?: string;
|
hostname?: string;
|
||||||
browser?: string;
|
browser?: string;
|
||||||
|
@ -70,8 +91,11 @@ async function clickhouseQuery(data: {
|
||||||
const {
|
const {
|
||||||
websiteId,
|
websiteId,
|
||||||
id: sessionId,
|
id: sessionId,
|
||||||
url,
|
urlPath,
|
||||||
referrer,
|
urlQuery,
|
||||||
|
referrerPath,
|
||||||
|
referrerQuery,
|
||||||
|
referrerDomain,
|
||||||
pageTitle,
|
pageTitle,
|
||||||
country,
|
country,
|
||||||
subdivision1,
|
subdivision1,
|
||||||
|
@ -90,8 +114,11 @@ async function clickhouseQuery(data: {
|
||||||
subdivision1: subdivision1 ? subdivision1 : null,
|
subdivision1: subdivision1 ? subdivision1 : null,
|
||||||
subdivision2: subdivision2 ? subdivision2 : null,
|
subdivision2: subdivision2 ? subdivision2 : null,
|
||||||
city: city ? city : null,
|
city: city ? city : null,
|
||||||
url: url?.substring(0, URL_LENGTH),
|
urlPath: urlPath?.substring(0, URL_LENGTH),
|
||||||
referrer: referrer?.substring(0, URL_LENGTH),
|
urlQuery: urlQuery?.substring(0, URL_LENGTH),
|
||||||
|
referrerPath: referrerPath?.substring(0, URL_LENGTH),
|
||||||
|
referrerQuery: referrerQuery?.substring(0, URL_LENGTH),
|
||||||
|
referrerDomain: referrerDomain?.substring(0, URL_LENGTH),
|
||||||
page_title: pageTitle,
|
page_title: pageTitle,
|
||||||
event_type: EVENT_TYPE.pageView,
|
event_type: EVENT_TYPE.pageView,
|
||||||
created_at: getDateFormat(new Date()),
|
created_at: getDateFormat(new Date()),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user