-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
724 changed files
with
8,475 additions
and
45,806 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
{ | ||
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json", | ||
"changelog": "@changesets/cli/changelog", | ||
"commit": false, | ||
"fixed": [], | ||
"linked": [], | ||
"access": "public", | ||
"baseBranch": "main", | ||
"updateInternalDependencies": "patch", | ||
"ignore": [] | ||
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json", | ||
"changelog": "@changesets/cli/changelog", | ||
"commit": false, | ||
"fixed": [], | ||
"linked": [], | ||
"access": "public", | ||
"baseBranch": "main", | ||
"updateInternalDependencies": "patch", | ||
"ignore": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
{ | ||
"typescript.tsdk": "./node_modules/typescript/lib", | ||
"typescript.enablePromptUseWorkspaceTsdk": true, | ||
"cSpell.enableFiletypes": [ | ||
"mdx" | ||
], | ||
"cSpell.words": [ | ||
"netcanvas", | ||
"Tipbox" | ||
] | ||
} | ||
"typescript.tsdk": "./node_modules/typescript/lib", | ||
"typescript.enablePromptUseWorkspaceTsdk": true, | ||
"cSpell.enableFiletypes": ["mdx"], | ||
"cSpell.words": ["netcanvas", "Tipbox"], | ||
"editor.defaultFormatter": "biomejs.biome", | ||
"[typescriptreact]": { | ||
"editor.defaultFormatter": "biomejs.biome" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,31 @@ | ||
'use server'; | ||
"use server"; | ||
|
||
import { type EventInsertType, db } from '~/db/db'; | ||
import { eventsTable } from '~/db/schema'; | ||
import { type EventInsertType, db } from "~/db/db"; | ||
import { eventsTable } from "~/db/schema"; | ||
|
||
export async function getEvents() { | ||
try { | ||
const events = await db.query.eventsTable.findMany({ | ||
orderBy: (events, { desc }) => [desc(events.timestamp)], | ||
}); | ||
try { | ||
const events = await db.query.eventsTable.findMany({ | ||
orderBy: (events, { desc }) => [desc(events.timestamp)], | ||
}); | ||
|
||
return events; | ||
} catch (error) { | ||
console.error('Error getting events', error); | ||
return []; | ||
} | ||
return events; | ||
} catch (error) { | ||
console.error("Error getting events", error); | ||
return []; | ||
} | ||
} | ||
|
||
type Events = Awaited<ReturnType<typeof getEvents>>; | ||
export type Event = Events[0]; | ||
|
||
export async function insertEvent(event: EventInsertType) { | ||
try { | ||
const insertedEvent = await db | ||
.insert(eventsTable) | ||
.values(event) | ||
.returning(); | ||
try { | ||
const insertedEvent = await db.insert(eventsTable).values(event).returning(); | ||
|
||
return { data: insertedEvent, error: null }; | ||
} catch (error) { | ||
console.error('Error inserting events', error); | ||
return { data: null, error: 'Error inserting events' }; | ||
} | ||
return { data: insertedEvent, error: null }; | ||
} catch (error) { | ||
console.error("Error inserting events", error); | ||
return { data: null, error: "Error inserting events" }; | ||
} | ||
} |
68 changes: 34 additions & 34 deletions
68
apps/analytics-web/app/_components/analytics/AnalyticsView.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
import { getEvents } from '~/app/_actions/actions'; | ||
import { Card, CardContent, CardHeader } from '~/components/ui/card'; | ||
import EventsTable from './EventsTable/EventsTable'; | ||
import RegionsTable from './RegionsTable/RegionsTable'; | ||
import TotalAppsCard from './cards/TotalAppsCard'; | ||
import TotalDataExported from './cards/TotalDataExported'; | ||
import TotalErrorsCard from './cards/TotalErrorsCard'; | ||
import TotalInterviewsCompletedCard from './cards/TotalInterviewsCompletedCard'; | ||
import TotalInterviewsStartedCard from './cards/TotalInterviewsStartedCard'; | ||
import TotalProtocolsInstalledCard from './cards/TotalProtocolsInstalledCard'; | ||
import { getEvents } from "~/app/_actions/actions"; | ||
import { Card, CardContent, CardHeader } from "~/components/ui/card"; | ||
import EventsTable from "./EventsTable/EventsTable"; | ||
import RegionsTable from "./RegionsTable/RegionsTable"; | ||
import TotalAppsCard from "./cards/TotalAppsCard"; | ||
import TotalDataExported from "./cards/TotalDataExported"; | ||
import TotalErrorsCard from "./cards/TotalErrorsCard"; | ||
import TotalInterviewsCompletedCard from "./cards/TotalInterviewsCompletedCard"; | ||
import TotalInterviewsStartedCard from "./cards/TotalInterviewsStartedCard"; | ||
import TotalProtocolsInstalledCard from "./cards/TotalProtocolsInstalledCard"; | ||
|
||
export default async function AnalyticsView() { | ||
const events = await getEvents(); | ||
const events = await getEvents(); | ||
|
||
return ( | ||
<div className="space-y-4"> | ||
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4"> | ||
<TotalAppsCard events={events} /> | ||
<TotalProtocolsInstalledCard events={events} /> | ||
<TotalInterviewsStartedCard events={events} /> | ||
<TotalInterviewsCompletedCard events={events} /> | ||
<TotalDataExported events={events} /> | ||
<TotalErrorsCard events={events} /> | ||
</div> | ||
<div className="grid gap-4 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3"> | ||
<div className="lg:col-span-2"> | ||
<EventsTable /> | ||
</div> | ||
<Card className="h-fit"> | ||
<CardHeader>Regions</CardHeader> | ||
<CardContent> | ||
<RegionsTable events={events} /> | ||
</CardContent> | ||
</Card> | ||
</div> | ||
</div> | ||
); | ||
return ( | ||
<div className="space-y-4"> | ||
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4"> | ||
<TotalAppsCard events={events} /> | ||
<TotalProtocolsInstalledCard events={events} /> | ||
<TotalInterviewsStartedCard events={events} /> | ||
<TotalInterviewsCompletedCard events={events} /> | ||
<TotalDataExported events={events} /> | ||
<TotalErrorsCard events={events} /> | ||
</div> | ||
<div className="grid gap-4 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3"> | ||
<div className="lg:col-span-2"> | ||
<EventsTable /> | ||
</div> | ||
<Card className="h-fit"> | ||
<CardHeader>Regions</CardHeader> | ||
<CardContent> | ||
<RegionsTable events={events} /> | ||
</CardContent> | ||
</Card> | ||
</div> | ||
</div> | ||
); | ||
} |
155 changes: 69 additions & 86 deletions
155
apps/analytics-web/app/_components/analytics/EventsTable/Columns.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,73 @@ | ||
'use client'; | ||
"use client"; | ||
|
||
import { type ColumnDef } from '@tanstack/react-table'; | ||
import { type Dispatch, type SetStateAction } from 'react'; | ||
import { DataTableColumnHeader } from '~/components/DataTable/column-header'; | ||
import { MetadataDialog } from '~/components/MetadataDialog'; | ||
import { type EventType } from './EventsTable'; | ||
import { StackTraceDialog } from './StackTraceDialog'; | ||
import TableFilter from './TableFilter'; | ||
import { type Event } from '~/app/_actions/actions'; | ||
import type { ColumnDef } from "@tanstack/react-table"; | ||
import type { Dispatch, SetStateAction } from "react"; | ||
import type { Event } from "~/app/_actions/actions"; | ||
import { DataTableColumnHeader } from "~/components/DataTable/column-header"; | ||
import { MetadataDialog } from "~/components/MetadataDialog"; | ||
import type { EventType } from "./EventsTable"; | ||
import { StackTraceDialog } from "./StackTraceDialog"; | ||
import TableFilter from "./TableFilter"; | ||
|
||
export const getColumns = ( | ||
eventTypes: EventType[], | ||
setEventTypes: Dispatch<SetStateAction<EventType[]>>, | ||
) => { | ||
const columns: ColumnDef<Event>[] = [ | ||
{ | ||
accessorKey: 'type', | ||
header: ({ column }) => ( | ||
<div className="flex space-x-4"> | ||
<TableFilter eventTypes={eventTypes} setEventTypes={setEventTypes} /> | ||
<DataTableColumnHeader column={column} /> | ||
</div> | ||
), | ||
}, | ||
{ | ||
accessorKey: 'timestamp', | ||
header: ({ column }) => ( | ||
<DataTableColumnHeader column={column} title="Timestamp" /> | ||
), | ||
cell: ({ row }) => { | ||
return ( | ||
<div className="break-all"> | ||
{row.original.timestamp.toUTCString()} | ||
</div> | ||
); | ||
}, | ||
}, | ||
{ | ||
accessorKey: 'installationId', | ||
header: ({ column }) => ( | ||
<DataTableColumnHeader column={column} title="Installation Id" /> | ||
), | ||
cell: ({ row }) => { | ||
return <div className="break-all">{row.original.installationId}</div>; | ||
}, | ||
}, | ||
{ | ||
accessorKey: 'name', | ||
header: ({ column }) => ( | ||
<DataTableColumnHeader column={column} title="Name" /> | ||
), | ||
}, | ||
{ | ||
accessorKey: 'message', | ||
header: ({ column }) => ( | ||
<DataTableColumnHeader column={column} title="Message" /> | ||
), | ||
}, | ||
{ | ||
accessorKey: 'cause', | ||
header: ({ column }) => ( | ||
<DataTableColumnHeader column={column} title="Cause" /> | ||
), | ||
}, | ||
{ | ||
accessorKey: 'stack', | ||
header: '', | ||
cell: ({ row }) => | ||
row.original.stack && ( | ||
<div className="min-w-max"> | ||
<StackTraceDialog error={row.original} /> | ||
</div> | ||
), | ||
}, | ||
{ | ||
accessorKey: 'metadata', | ||
header: '', | ||
cell: ({ row }) => { | ||
return ( | ||
<div className="min-w-max"> | ||
<MetadataDialog event={row.original} /> | ||
</div> | ||
); | ||
}, | ||
}, | ||
]; | ||
export const getColumns = (eventTypes: EventType[], setEventTypes: Dispatch<SetStateAction<EventType[]>>) => { | ||
const columns: ColumnDef<Event>[] = [ | ||
{ | ||
accessorKey: "type", | ||
header: ({ column }) => ( | ||
<div className="flex space-x-4"> | ||
<TableFilter eventTypes={eventTypes} setEventTypes={setEventTypes} /> | ||
<DataTableColumnHeader column={column} /> | ||
</div> | ||
), | ||
}, | ||
{ | ||
accessorKey: "timestamp", | ||
header: ({ column }) => <DataTableColumnHeader column={column} title="Timestamp" />, | ||
cell: ({ row }) => { | ||
return <div className="break-all">{row.original.timestamp.toUTCString()}</div>; | ||
}, | ||
}, | ||
{ | ||
accessorKey: "installationId", | ||
header: ({ column }) => <DataTableColumnHeader column={column} title="Installation Id" />, | ||
cell: ({ row }) => { | ||
return <div className="break-all">{row.original.installationId}</div>; | ||
}, | ||
}, | ||
{ | ||
accessorKey: "name", | ||
header: ({ column }) => <DataTableColumnHeader column={column} title="Name" />, | ||
}, | ||
{ | ||
accessorKey: "message", | ||
header: ({ column }) => <DataTableColumnHeader column={column} title="Message" />, | ||
}, | ||
{ | ||
accessorKey: "cause", | ||
header: ({ column }) => <DataTableColumnHeader column={column} title="Cause" />, | ||
}, | ||
{ | ||
accessorKey: "stack", | ||
header: "", | ||
cell: ({ row }) => | ||
row.original.stack && ( | ||
<div className="min-w-max"> | ||
<StackTraceDialog error={row.original} /> | ||
</div> | ||
), | ||
}, | ||
{ | ||
accessorKey: "metadata", | ||
header: "", | ||
cell: ({ row }) => { | ||
return ( | ||
<div className="min-w-max"> | ||
<MetadataDialog event={row.original} /> | ||
</div> | ||
); | ||
}, | ||
}, | ||
]; | ||
|
||
return columns; | ||
return columns; | ||
}; |
Oops, something went wrong.