Updated pixel/link endpoints. Added name to rawQuery.

This commit is contained in:
Mike Cao 2025-09-30 16:11:21 -07:00
parent b9fbbc6453
commit 8a977b0164
18 changed files with 913 additions and 810 deletions

View file

@ -4,6 +4,8 @@ import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
import prisma from '@/lib/prisma';
import { QueryFilters } from '@/lib/types';
const FUNCTION_NAME = 'getEventMetrics';
export interface EventMetricParameters {
type: string;
limit?: string;
@ -58,6 +60,7 @@ async function relationalQuery(
offset ${offset}
`,
{ ...queryParams, ...parameters },
FUNCTION_NAME,
);
}
@ -89,5 +92,6 @@ async function clickhouseQuery(
offset ${offset}
`,
{ ...queryParams, ...parameters },
FUNCTION_NAME,
);
}

View file

@ -1,5 +1,5 @@
import { uuid } from '@/lib/crypto';
import { EVENT_NAME_LENGTH, URL_LENGTH, EVENT_TYPE, PAGE_TITLE_LENGTH } from '@/lib/constants';
import { EVENT_NAME_LENGTH, URL_LENGTH, PAGE_TITLE_LENGTH } from '@/lib/constants';
import { CLICKHOUSE, PRISMA, runQuery } from '@/lib/db';
import clickhouse from '@/lib/clickhouse';
import kafka from '@/lib/kafka';
@ -66,10 +66,9 @@ async function relationalQuery({
websiteId,
sessionId,
visitId,
createdAt,
eventType,
createdAt,
pageTitle,
tag,
hostname,
urlPath,
urlQuery,
@ -78,6 +77,7 @@ async function relationalQuery({
referrerDomain,
eventName,
eventData,
tag,
utmSource,
utmMedium,
utmCampaign,
@ -154,9 +154,16 @@ async function clickhouseQuery({
websiteId,
sessionId,
visitId,
distinctId,
eventType,
createdAt,
pageTitle,
hostname,
urlPath,
urlQuery,
referrerPath,
referrerQuery,
referrerDomain,
distinctId,
browser,
os,
device,
@ -165,15 +172,9 @@ async function clickhouseQuery({
country,
region,
city,
tag,
hostname,
urlPath,
urlQuery,
referrerPath,
referrerQuery,
referrerDomain,
eventName,
eventData,
tag,
utmSource,
utmMedium,
utmCampaign,
@ -215,7 +216,7 @@ async function clickhouseQuery({
ttclid: ttclid,
li_fat_id: lifatid,
twclid: twclid,
event_type: eventName ? EVENT_TYPE.customEvent : EVENT_TYPE.pageView,
event_type: eventType,
event_name: eventName ? eventName?.substring(0, EVENT_NAME_LENGTH) : null,
tag: tag,
distinct_id: distinctId,