-
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.
Merge pull request #16 from complexdatacollective/refactor/event-types
Refactor/event types
- Loading branch information
Showing
43 changed files
with
3,014 additions
and
558 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
115 changes: 80 additions & 35 deletions
115
apps/analytics/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,39 +1,84 @@ | ||
"use client"; | ||
import { DataTableColumnHeader } from "~/components/DataTable/column-header"; | ||
|
||
import { ColumnDef } from "@tanstack/react-table"; | ||
import type { Event } from "~/db/schema"; | ||
import { MetadataDialog } from "./MetadataDialog"; | ||
export const columns: ColumnDef<Event>[] = [ | ||
{ | ||
accessorKey: "type", | ||
header: ({ column }) => ( | ||
<DataTableColumnHeader column={column} title="Event" /> | ||
), | ||
}, | ||
{ | ||
accessorKey: "timestamp", | ||
header: ({ column }) => ( | ||
<DataTableColumnHeader column={column} title="Timestamp" /> | ||
), | ||
}, | ||
{ | ||
accessorKey: "installationid", | ||
header: ({ column }) => ( | ||
<DataTableColumnHeader column={column} title="Installation Id" /> | ||
), | ||
cell: ({ row }) => { | ||
return <div className="break-all">{row.original.installationid}</div>; | ||
}, | ||
}, | ||
{ | ||
accessorKey: "stacktrace", | ||
header: "", | ||
cell: ({ row }) => { | ||
return ( | ||
<div className="min-w-max"> | ||
<MetadataDialog event={row.original} /> | ||
import { type Dispatch, type SetStateAction } from "react"; | ||
import { DataTableColumnHeader } from "~/components/DataTable/column-header"; | ||
import { MetadataDialog } from "~/components/MetadataDialog"; | ||
import type { Event } from "~/db/getEvents"; | ||
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: "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; | ||
}; |
45 changes: 36 additions & 9 deletions
45
apps/analytics/app/_components/analytics/EventsTable/EventsTable.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
13 changes: 13 additions & 0 deletions
13
apps/analytics/app/_components/analytics/EventsTable/StackTraceDialog.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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { DialogButton } from "~/components/DialogButton"; | ||
import { Event } from "~/db/getEvents"; | ||
|
||
export function StackTraceDialog({ error }: { error: Event }) { | ||
return ( | ||
<DialogButton | ||
buttonLabel="Stack Trace" | ||
title="Stack Trace" | ||
description={error.message!} | ||
content={error.stack} | ||
/> | ||
); | ||
} |
84 changes: 84 additions & 0 deletions
84
apps/analytics/app/_components/analytics/EventsTable/TableFilter.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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
"use client"; | ||
|
||
import { useState, type Dispatch, type SetStateAction } from "react"; | ||
import { Button } from "~/components/ui/button"; | ||
import { Checkbox } from "~/components/ui/checkbox"; | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuLabel, | ||
DropdownMenuSeparator, | ||
DropdownMenuTrigger, | ||
} from "~/components/ui/dropdown-menu"; | ||
import { type EventType } from "./EventsTable"; | ||
|
||
type TableFilterProps = { | ||
eventTypes: EventType[]; | ||
setEventTypes: Dispatch<SetStateAction<EventType[]>>; | ||
}; | ||
|
||
const TableFilter = ({ eventTypes, setEventTypes }: TableFilterProps) => { | ||
const [options, setOptions] = useState<EventType[]>(eventTypes); | ||
|
||
const toggleOption = (option: string) => { | ||
setOptions((prevState) => | ||
prevState.map((t) => | ||
t.text === option ? { ...t, isSelected: !t.isSelected } : t | ||
) | ||
); | ||
}; | ||
|
||
const toggleAllOptions = (isSelected: boolean) => { | ||
setOptions((prevState) => prevState.map((t) => ({ ...t, isSelected }))); | ||
}; | ||
|
||
const isAllSelected = options.every((option) => option.isSelected); | ||
|
||
return ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button className="text-sm" size={"sm"} variant="outline"> | ||
Type | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent className="w-52 ml-12"> | ||
<DropdownMenuLabel>Select events</DropdownMenuLabel> | ||
<DropdownMenuSeparator /> | ||
|
||
<div className="space-y-3"> | ||
<label className="text-sm flex items-center gap-3 pl-2 transition-colors hover:bg-muted p-1 rounded-md"> | ||
<Checkbox | ||
checked={isAllSelected} | ||
onCheckedChange={() => toggleAllOptions(!isAllSelected)} | ||
/> | ||
<span>All</span> | ||
</label> | ||
<DropdownMenuSeparator /> | ||
|
||
{options.map((option) => ( | ||
<label | ||
key={option.text} | ||
className="text-sm flex items-center gap-3 pl-2 transition-colors hover:bg-muted p-1 rounded-md" | ||
> | ||
<Checkbox | ||
checked={option.isSelected} | ||
onCheckedChange={() => toggleOption(option.text)} | ||
/> | ||
<span>{option.text}</span> | ||
</label> | ||
))} | ||
|
||
<Button | ||
onClick={() => setEventTypes(options)} | ||
className="float-right" | ||
size={"sm"} | ||
> | ||
Apply | ||
</Button> | ||
</div> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); | ||
}; | ||
|
||
export default TableFilter; |
15 changes: 15 additions & 0 deletions
15
apps/analytics/app/_components/analytics/cards/TotalDataExported.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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { getTotalInterviewsStarted } from "~/utils/getTotalInterviewsStarted"; | ||
import { SummaryCard } from "~/components/SummaryCard"; | ||
|
||
const TotalDataExported = async () => { | ||
const totalInterviewsStarted = await getTotalInterviewsStarted(); | ||
return ( | ||
<SummaryCard | ||
title="Data Exported" | ||
value={totalInterviewsStarted} | ||
description="Total data exported across all instances of Fresco" | ||
/> | ||
); | ||
}; | ||
|
||
export default TotalDataExported; |
15 changes: 15 additions & 0 deletions
15
apps/analytics/app/_components/analytics/cards/TotalErrorsCard.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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { SummaryCard } from "~/components/SummaryCard"; | ||
import { getTotalErrors } from "~/utils/getTotalErrors"; | ||
|
||
const TotalErrorsCard = async () => { | ||
const totalErrors = await getTotalErrors(); | ||
return ( | ||
<SummaryCard | ||
title="Number of Errors" | ||
value={totalErrors} | ||
description="Total number of errors sent from all instances of Fresco" | ||
/> | ||
); | ||
}; | ||
|
||
export default TotalErrorsCard; |
48 changes: 0 additions & 48 deletions
48
apps/analytics/app/_components/errors/ErrorsTable/Columns.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.