Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Biome #67

Merged
merged 14 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
18 changes: 9 additions & 9 deletions .changeset/config.json
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": []
}
10 changes: 4 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ node_modules
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/
**/.next/
**/out/

# production
/build
**/build

# misc
.DS_Store
Expand All @@ -30,7 +28,7 @@ yarn-error.log*
.env

# vercel
.vercel
**/.vercel

# typescript
*.tsbuildinfo
Expand Down
24 changes: 9 additions & 15 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
{
"eslint.workingDirectories": [
{
"mode": "auto"
}
],
"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"
}
}
43 changes: 19 additions & 24 deletions apps/analytics-web/app/_actions/actions.ts
Original file line number Diff line number Diff line change
@@ -1,36 +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) {
// eslint-disable-next-line no-console
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) {
// eslint-disable-next-line no-console
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 apps/analytics-web/app/_components/analytics/AnalyticsView.tsx
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 apps/analytics-web/app/_components/analytics/EventsTable/Columns.tsx
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;
};
Loading
Loading