sdk improvement and get profile with events

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-02-11 23:26:30 +01:00
parent 85e4922dc3
commit 6f2aeffdff
8 changed files with 86 additions and 24 deletions

View File

@@ -20,6 +20,7 @@ export function EventListItem({
createdAt,
name,
properties,
path,
}: EventListItemProps) {
const params = useAppParams();
@@ -46,16 +47,15 @@ export function EventListItem({
switch (name) {
case 'screen_view': {
const route = (properties?.route || properties?.path)!;
if (route) {
bullets.push(route);
if (path) {
bullets.push(path);
}
break;
}
}
return bullets;
}, [name, createdAt, profile, properties, params]);
}, [name, createdAt, profile, properties, params, path]);
return (
<ExpandableListItem

View File

@@ -12,6 +12,12 @@ const handler = (req: Request) =>
session: auth(),
};
},
onError(opts) {
const { error, type, path, input, ctx, req } = opts;
console.error('---- TRPC ERROR');
console.error('Error:', error);
console.error();
},
});
export { handler as GET, handler as POST };

View File

@@ -27,8 +27,8 @@ export function ExpandableListItem({
<div className="flex flex-col flex-1 gap-1 min-w-0">
<span className="text-lg font-medium leading-none mb-1">{title}</span>
<div className="flex flex-col sm:flex-row sm:items-center gap-1 sm:gap-4 text-sm text-muted-foreground">
{bullets.map((bullet) => (
<span key={bullet}>{bullet}</span>
{bullets.map((bullet, index) => (
<span key={index}>{bullet}</span>
))}
</div>
</div>

View File

@@ -3,7 +3,7 @@ import { transformEvent } from '@/server/services/event.service';
import { z } from 'zod';
import type { IDBEvent } from '@mixan/db';
import { chQuery, createSqlBuilder } from '@mixan/db';
import { chQuery, createSqlBuilder, getEvents } from '@mixan/db';
export const eventRouter = createTRPCRouter({
list: protectedProcedure
@@ -31,6 +31,8 @@ export const eventRouter = createTRPCRouter({
sb.orderBy.created_at = 'created_at DESC';
return (await chQuery<IDBEvent>(getSql())).map(transformEvent);
const res = await getEvents(getSql(), { profile: true });
return res;
}),
});