mirror of
https://github.com/umami-software/umami.git
synced 2026-02-05 13:17:19 +01:00
Allow populating event's createdAt on the send endpoint
This commit is contained in:
parent
9a87442870
commit
30b28793cf
2 changed files with 16 additions and 7 deletions
|
|
@ -29,6 +29,7 @@ export async function saveEvent(args: {
|
|||
subdivision2?: string;
|
||||
city?: string;
|
||||
tag?: string;
|
||||
createdAt?: Date;
|
||||
}) {
|
||||
return runQuery({
|
||||
[PRISMA]: () => relationalQuery(args),
|
||||
|
|
@ -49,6 +50,7 @@ async function relationalQuery(data: {
|
|||
eventName?: string;
|
||||
eventData?: any;
|
||||
tag?: string;
|
||||
createdAt?: Date;
|
||||
}) {
|
||||
const {
|
||||
websiteId,
|
||||
|
|
@ -63,6 +65,7 @@ async function relationalQuery(data: {
|
|||
eventData,
|
||||
pageTitle,
|
||||
tag,
|
||||
createdAt,
|
||||
} = data;
|
||||
const websiteEventId = uuid();
|
||||
|
||||
|
|
@ -80,6 +83,7 @@ async function relationalQuery(data: {
|
|||
pageTitle: pageTitle?.substring(0, PAGE_TITLE_LENGTH),
|
||||
eventType: eventName ? EVENT_TYPE.customEvent : EVENT_TYPE.pageView,
|
||||
eventName: eventName ? eventName?.substring(0, EVENT_NAME_LENGTH) : null,
|
||||
createdAt,
|
||||
tag,
|
||||
},
|
||||
});
|
||||
|
|
@ -121,6 +125,7 @@ async function clickhouseQuery(data: {
|
|||
subdivision2?: string;
|
||||
city?: string;
|
||||
tag?: string;
|
||||
createdAt?: Date;
|
||||
}) {
|
||||
const {
|
||||
websiteId,
|
||||
|
|
@ -139,12 +144,13 @@ async function clickhouseQuery(data: {
|
|||
subdivision2,
|
||||
city,
|
||||
tag,
|
||||
createdAt,
|
||||
...args
|
||||
} = data;
|
||||
const { insert, getUTCString } = clickhouse;
|
||||
const { sendMessage } = kafka;
|
||||
const eventId = uuid();
|
||||
const createdAt = getUTCString();
|
||||
const createdAtUTC = getUTCString(createdAt);
|
||||
|
||||
const message = {
|
||||
...args,
|
||||
|
|
@ -170,7 +176,7 @@ async function clickhouseQuery(data: {
|
|||
event_type: eventName ? EVENT_TYPE.customEvent : EVENT_TYPE.pageView,
|
||||
event_name: eventName ? eventName?.substring(0, EVENT_NAME_LENGTH) : null,
|
||||
tag: tag,
|
||||
created_at: createdAt,
|
||||
created_at: createdAtUTC,
|
||||
};
|
||||
|
||||
if (kafka.enabled) {
|
||||
|
|
@ -187,7 +193,7 @@ async function clickhouseQuery(data: {
|
|||
urlPath: urlPath?.substring(0, URL_LENGTH),
|
||||
eventName: eventName?.substring(0, EVENT_NAME_LENGTH),
|
||||
eventData,
|
||||
createdAt,
|
||||
createdAt: createdAtUTC,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue