Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
fc8fec6
fix: style issues
ogzhanolguncu Jan 15, 2025
01ceecc
fix: focus issues of filters
ogzhanolguncu Jan 15, 2025
df73530
fix: search focus issue
ogzhanolguncu Jan 15, 2025
bebcf77
feat: add focus to control cloud
ogzhanolguncu Jan 15, 2025
150987a
feat: adjust rows for dynamic selection
ogzhanolguncu Jan 15, 2025
b59a1c7
feat: add accessbility to display
ogzhanolguncu Jan 15, 2025
c7f877d
fix: show xx instead of direct status
ogzhanolguncu Jan 15, 2025
9744826
fix: duplicate filter when querying openai
ogzhanolguncu Jan 15, 2025
bf54d05
feat: add optional bottom content for table
ogzhanolguncu Jan 16, 2025
9d637bf
feat: add initial paginated data fetching
ogzhanolguncu Jan 16, 2025
57083fa
fix: no need to send all the status variations its already handled on…
ogzhanolguncu Jan 17, 2025
542711c
feat: add different variants for searching path
ogzhanolguncu Jan 17, 2025
58bc61a
refactor: improve ai query
ogzhanolguncu Jan 17, 2025
4efd937
Merge branch 'main' of github.com:unkeyed/unkey into feat/logs-v2-dat…
ogzhanolguncu Jan 17, 2025
e8f1976
chore: run formatter
ogzhanolguncu Jan 17, 2025
cbf91c0
feat: add ability to return datetimes from ai
ogzhanolguncu Jan 20, 2025
a58b8fc
fix: overflow issue of log details
ogzhanolguncu Jan 20, 2025
fcda52f
fix: update prompt and allow multiple requestID and host pass
ogzhanolguncu Jan 20, 2025
50fcb07
tests: add for filters
ogzhanolguncu Jan 20, 2025
3fb6835
feat: fetch paths for logs page
ogzhanolguncu Jan 20, 2025
37bb636
chore: get rid of old logs page
ogzhanolguncu Jan 20, 2025
78d80cd
refactor: move datetime components to audit for temporarily
ogzhanolguncu Jan 20, 2025
1b2ab57
refactor: add components to audit
ogzhanolguncu Jan 20, 2025
ce22698
feat: add realtime data fetching
ogzhanolguncu Jan 21, 2025
ebcfc1c
feat: add new param for relative time search
ogzhanolguncu Jan 21, 2025
a11b5c7
fix: filter reset
ogzhanolguncu Jan 22, 2025
ef39643
feat: fix rendering issues when live enabled
ogzhanolguncu Jan 22, 2025
716f09a
refacor: use maps to prevent array merges
ogzhanolguncu Jan 22, 2025
f9d779b
refactor: only allow refresh if relative time is around
ogzhanolguncu Jan 22, 2025
02d022a
refactor: move since logic to trpc
ogzhanolguncu Jan 22, 2025
cff009f
[autofix.ci] apply automated fixes
autofix-ci[bot] Jan 22, 2025
ea6ce68
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Jan 22, 2025
d0c31d7
[autofix.ci] apply automated fixes (attempt 3/3)
autofix-ci[bot] Jan 22, 2025
c045256
refactor: allow llm to return relative times
ogzhanolguncu Jan 22, 2025
b048018
Merge branch 'feat/logs-v2-data-fetching' of github.com:unkeyed/unkey…
ogzhanolguncu Jan 22, 2025
041c786
Merge branch 'main' into feat/logs-v2-data-fetching
ogzhanolguncu Jan 22, 2025
b4fb5ba
[autofix.ci] apply automated fixes
autofix-ci[bot] Jan 22, 2025
186dd56
Merge branch 'main' of github.com:unkeyed/unkey into feat/logs-v2-dat…
ogzhanolguncu Jan 22, 2025
198671e
Merge branch 'feat/logs-v2-data-fetching' of github.com:unkeyed/unkey…
ogzhanolguncu Jan 22, 2025
36adadf
feat: introduce new params for timeseries fetch
ogzhanolguncu Jan 23, 2025
a3344a0
feat: add proper data fetching
ogzhanolguncu Jan 23, 2025
6d80b1a
test: add tests for hooks
ogzhanolguncu Jan 23, 2025
97ff534
feat: add timestamp explainer for control pills
ogzhanolguncu Jan 23, 2025
7ff3f49
fix: detail dock issue
ogzhanolguncu Jan 23, 2025
d1025dd
feat: add a hook to track applied filters
ogzhanolguncu Jan 23, 2025
cdd36f7
fix: visual bugs
ogzhanolguncu Jan 24, 2025
50a82de
fix: ui issues
ogzhanolguncu Jan 24, 2025
8d9d293
fix: audit style issues after logs page refactor
ogzhanolguncu Jan 24, 2025
3649939
chore: enable logs page flag
ogzhanolguncu Jan 24, 2025
9efb202
fix: use same window for reseting and initial fetch
ogzhanolguncu Jan 24, 2025
fbdeead
working filter
Jan 24, 2025
13f476a
gh comment changes
Jan 24, 2025
2700833
style changes
Jan 27, 2025
1352deb
refactor: improve search prompt
ogzhanolguncu Jan 28, 2025
4d7a7cf
Merge branch 'feat/logs-v2-data-fetching' into datetime-into-logs-v2
MichaelUnkey Jan 28, 2025
5f89271
[autofix.ci] apply automated fixes
autofix-ci[bot] Jan 28, 2025
7373818
styles and icon
Jan 28, 2025
86bba82
fix: calendar range selection
ogzhanolguncu Jan 30, 2025
f39d241
fix: bunch of fixes
ogzhanolguncu Jan 30, 2025
2586a43
refactor: change how we show since filter
ogzhanolguncu Jan 30, 2025
a937c86
refactor: if
ogzhanolguncu Jan 30, 2025
2fc1fc5
fix: wrap function call
ogzhanolguncu Jan 30, 2025
1d93c9c
fix: datetime input alignment
chronark Jan 30, 2025
9271b71
Merge pull request #2836 from unkeyed/datetime-into-logs-v2
ogzhanolguncu Jan 30, 2025
583f46f
Merge branch 'main' of github.com:unkeyed/unkey into feat/logs-v2-dat…
ogzhanolguncu Jan 30, 2025
5401d32
rename logs
ogzhanolguncu Jan 30, 2025
d4aaab2
[autofix.ci] apply automated fixes
autofix-ci[bot] Jan 30, 2025
2684a29
Merge branch 'main' into feat/logs-v2-data-fetching
chronark Jan 30, 2025
0c9d5a2
fix: empty content
chronark Jan 30, 2025
4424656
fix: import paths
ogzhanolguncu Jan 30, 2025
0f35bc3
Merge branch 'feat/logs-v2-data-fetching' of github.com:unkeyed/unkey…
ogzhanolguncu Jan 30, 2025
0654dea
[autofix.ci] apply automated fixes
autofix-ci[bot] Jan 30, 2025
cb19e5f
fix: broken tests
ogzhanolguncu Jan 30, 2025
36ee64a
Merge branch 'feat/logs-v2-data-fetching' of github.com:unkeyed/unkey…
ogzhanolguncu Jan 30, 2025
023aa6b
fix: minor grammar issues
ogzhanolguncu Jan 30, 2025
62e635a
fix: table spacing issues
ogzhanolguncu Jan 31, 2025
adbc345
feat: add outcomes to table
ogzhanolguncu Jan 31, 2025
118b79b
fix: spacing
ogzhanolguncu Jan 31, 2025
07d530e
Merge branch 'main' into feat/logs-v2-data-fetching
ogzhanolguncu Jan 31, 2025
ea6e34b
fix: wrap issue for outcome
ogzhanolguncu Jan 31, 2025
d05a0c4
Merge branch 'feat/logs-v2-data-fetching' of github.com:unkeyed/unkey…
ogzhanolguncu Jan 31, 2025
0a76284
fix: styling issues
ogzhanolguncu Jan 31, 2025
b60f3a9
fix: setState issue
ogzhanolguncu Jan 31, 2025
24b8b53
fix: type issues
ogzhanolguncu Jan 31, 2025
d22690d
Merge branch 'main' of github.com:unkeyed/unkey into feat/logs-v2-dat…
ogzhanolguncu Jan 31, 2025
0a6e42d
chore: format
ogzhanolguncu Jan 31, 2025
33bb5c8
fix: audit logs panel
ogzhanolguncu Feb 3, 2025
105ef9b
fix: minor style issues
ogzhanolguncu Feb 3, 2025
1e5193c
Merge branch 'main' into feat/logs-v2-data-fetching
ogzhanolguncu Feb 3, 2025
96c7328
fix: typo
ogzhanolguncu Feb 3, 2025
c1c690a
Merge branch 'feat/logs-v2-data-fetching' of github.com:unkeyed/unkey…
ogzhanolguncu Feb 3, 2025
215dca2
chore: remove beta flag
ogzhanolguncu Feb 3, 2025
f03eab7
fix: add empty instead of undefined meta field
ogzhanolguncu Feb 3, 2025
b69baba
ci: build correct path
chronark Feb 3, 2025
a2a5079
chore: revert beta tag
ogzhanolguncu Feb 3, 2025
67f20a6
Merge branch 'feat/logs-v2-data-fetching' of github.com:unkeyed/unkey…
ogzhanolguncu Feb 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/job_test_go_api_local.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test GO API Local
name: Test Go API Local
on:
workflow_call:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type Data = {
export type AuditData = {
user:
| {
username?: string | null;
Expand Down
23 changes: 23 additions & 0 deletions apps/dashboard/app/(app)/audit/components/logs-client.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"use client";

import { useState } from "react";
import type { AuditData } from "../audit.type";
import { AuditLogsTable } from "./table/audit-logs-table";
import { AuditLogDetails } from "./table/log-details";

// INFO: Hacky way to create distance from top. This will be fixed when this page gets a refactor.
const DISTANCE_TO_TOP = 9;
export const LogsClient = () => {
const [selectedLog, setSelectedLog] = useState<AuditData | null>(null);

return (
<>
<AuditLogsTable selectedLog={selectedLog} setSelectedLog={setSelectedLog} />
<AuditLogDetails
distanceToTop={DISTANCE_TO_TOP}
selectedLog={selectedLog}
setSelectedLog={setSelectedLog}
/>
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@ import { VirtualTable } from "@/components/virtual-table";
import { trpc } from "@/lib/trpc/client";
import { Empty } from "@unkey/ui";
import { cn } from "@unkey/ui/src/lib/utils";
import { useState } from "react";
import type { AuditData } from "../../audit.type";
import { useAuditLogParams } from "../../query-state";
import { columns } from "./columns";
import { DEFAULT_FETCH_COUNT } from "./constants";
import { LogDetails } from "./table-details";
import type { Data } from "./types";
import { getEventType } from "./utils";

const STATUS_STYLES: Record<
"create" | "update" | "delete" | "other",
{ base: string; hover: string; selected: string }
> = {
create: {
base: "text-accent-11 ",
base: "text-accent-11",
hover: "hover:bg-accent-3",
selected: "bg-accent-3",
},
Expand All @@ -38,8 +36,12 @@ const STATUS_STYLES: Record<
},
};

export const AuditLogTableClient = () => {
const [selectedLog, setSelectedLog] = useState<Data | null>(null);
type Props = {
selectedLog: AuditData | null;
setSelectedLog: (log: AuditData | null) => void;
};

export const AuditLogsTable = ({ selectedLog, setSelectedLog }: Props) => {
const { setCursor, searchParams } = useAuditLogParams();

const { data, fetchNextPage, hasNextPage, isFetchingNextPage, isLoading, isError } =
Expand Down Expand Up @@ -75,23 +77,22 @@ export const AuditLogTableClient = () => {
}
};

const getRowClassName = (item: Data) => {
const getRowClassName = (item: AuditData) => {
const eventType = getEventType(item.auditLog.event);
const style = STATUS_STYLES[eventType];

return cn(
style.base,
style.hover,
"group rounded-md",
"focus:outline-none focus:ring-1 focus:ring-opacity-40 px-1",
selectedLog && {
"opacity-50 z-0": selectedLog.auditLog.id !== item.auditLog.id,
"opacity-100 z-10": selectedLog.auditLog.id === item.auditLog.id,
},
);
};

const getSelectedClassName = (item: Data, isSelected: boolean) => {
const getSelectedClassName = (item: AuditData, isSelected: boolean) => {
if (!isSelected) {
return "";
}
Expand Down Expand Up @@ -123,9 +124,6 @@ export const AuditLogTableClient = () => {
onRowClick={setSelectedLog}
selectedClassName={getSelectedClassName}
keyExtractor={(log) => log.auditLog.id}
renderDetails={(log, onClose, distanceToTop) => (
<LogDetails log={log} onClose={onClose} distanceToTop={distanceToTop} />
)}
config={{
loadingRows: DEFAULT_FETCH_COUNT,
}}
Expand Down
10 changes: 2 additions & 8 deletions apps/dashboard/app/(app)/audit/components/table/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ import { Badge } from "@/components/ui/badge";
import type { Column } from "@/components/virtual-table/types";
import { cn } from "@unkey/ui/src/lib/utils";
import { FunctionSquare, KeySquare } from "lucide-react";
import type { Data } from "./types";
import type { AuditData } from "../../audit.type";
import { getEventType } from "./utils";

export const columns: Column<Data>[] = [
export const columns: Column<AuditData>[] = [
{
key: "time",
header: "Time",
width: "150px",
headerClassName: "pl-3",
noTruncate: true,
render: (log) => (
<div className="flex items-center gap-3">
<TimestampInfo
Expand All @@ -26,8 +24,6 @@ export const columns: Column<Data>[] = [
key: "actor",
header: "Actor",
width: "15%",
headerClassName: "pl-3",
noTruncate: true,
render: (log) => (
<div className="flex items-center gap-3 truncate">
{log.auditLog.actor.type === "user" && log.user ? (
Expand All @@ -54,8 +50,6 @@ export const columns: Column<Data>[] = [
key: "action",
header: "Action",
width: "15%",
headerClassName: "pl-3",
noTruncate: true,
render: (log) => {
const eventType = getEventType(log.auditLog.event);
const badgeClassName = cn("font-mono capitalize", {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"use client";

import type { AuditData } from "@/app/(app)/audit/audit.type";
import { RequestResponseDetails } from "@/app/(app)/logs/components/table/log-details/components/request-response-details";
import { TimestampInfo } from "@/components/timestamp-info";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import { FunctionSquare, KeySquare } from "lucide-react";
import type { Data } from "./types";

type Props = {
log: Data;
log: AuditData;
};

export const LogFooter = ({ log }: Props) => {
Expand Down Expand Up @@ -65,7 +65,7 @@ export const LogFooter = ({ log }: Props) => {
{
label: "User Agent",
description: (content) => (
<span className="text-[13px] font-mono w-[100px] truncate">{content}</span>
<span className="text-[13px] font-mono text-right">{content}</span>
),
content: log.auditLog.userAgent,
tooltipContent: "Copy User Agent",
Expand All @@ -80,9 +80,7 @@ export const LogFooter = ({ log }: Props) => {
},
{
label: "Description",
description: (content) => (
<span className="text-[13px] font-mono flex text-end">{content}</span>
),
description: (content) => <span className="text-[13px] font-mono">{content}</span>,
content: log.auditLog.description,
tooltipContent: "Copy Description",
tooltipSuccessMessage: "Description copied to clipboard",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { AuditData } from "@/app/(app)/audit/audit.type";
import { Badge } from "@/components/ui/badge";
import { XMark } from "@unkey/icons";
import { Button } from "@unkey/ui";
import type { Data } from "./types";

type Props = {
log: Data;
log: AuditData;
onClose: () => void;
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { Card, CardContent } from "@/components/ui/card";
import { toast } from "@/components/ui/toaster";
import { Button } from "@unkey/ui";
import { Copy } from "lucide-react";

export const LogSection = ({
details,
title,
}: {
details: string | string[];
title: string;
}) => {
const handleClick = () => {
navigator.clipboard
.writeText(getFormattedContent(details))
.then(() => {
toast.success(`${title} copied to clipboard`);
})
.catch((error) => {
console.error("Failed to copy to clipboard:", error);
toast.error("Failed to copy to clipboard");
});
};

return (
<div className="flex flex-col gap-1 mt-[16px]">
<div className="flex justify-between items-center">
<span className="text-[13px] text-accent-9 font-sans">{title}</span>
</div>
<Card className="bg-gray-2 border-gray-4 rounded-lg">
<CardContent className="py-2 px-3 text-xs relative group ">
<pre className="flex flex-col gap-1 whitespace-pre-wrap leading-relaxed">
{Array.isArray(details)
? details.map((header) => {
const [key, ...valueParts] = header.split(":");
const value = valueParts.join(":").trim();
return (
<div className="group flex items-center w-full p-[3px]" key={key}>
<span className="w-28 text-left truncate text-accent-9">{key}:</span>
<span className="ml-2 text-xs text-accent-12 ">{value}</span>
</div>
);
})
: details}
</pre>
<Button
shape="square"
onClick={handleClick}
className="absolute bottom-2 right-3 opacity-0 group-hover:opacity-100 transition-opacity"
aria-label="Copy content"
>
<Copy size={14} />
</Button>
</CardContent>
</Card>
</div>
);
};

const getFormattedContent = (details: string | string[]) => {
if (Array.isArray(details)) {
return details
.map((header) => {
const [key, ...valueParts] = header.split(":");
const value = valueParts.join(":").trim();
return `${key}: ${value}`;
})
.join("\n");
}
return details;
};
Original file line number Diff line number Diff line change
@@ -1,49 +1,51 @@
"use client";

import { LogSection } from "@/app/(app)/logs/components/table/log-details/components/log-section";
import { ResizablePanel } from "@/app/(app)/logs/components/table/log-details/resizable-panel";
import { useMemo } from "react";
import { LogFooter } from "./log-footer";
import { LogHeader } from "./log-header";
import type { Data } from "./types";

type Props = {
log: Data | null;
onClose: () => void;
distanceToTop: number;
};

const PANEL_MAX_WIDTH = 600;
const PANEL_MIN_WIDTH = 400;
import type { AuditData } from "../../../audit.type";
import { DEFAULT_DRAGGABLE_WIDTH, PANEL_MAX_WIDTH, PANEL_MIN_WIDTH } from "../../../constants";
import { LogFooter } from "./components/log-footer";
import { LogHeader } from "./components/log-header";
import { LogSection } from "./components/log-section";
import { ResizablePanel } from "./resizable-panel";

const createPanelStyle = (distanceToTop: number) => ({
top: `${distanceToTop}px`,
width: "500px",
width: `${DEFAULT_DRAGGABLE_WIDTH}px`,
height: `calc(100vh - ${distanceToTop}px)`,
paddingBottom: "1rem",
});

export const LogDetails = ({ log, onClose, distanceToTop }: Props) => {
type Props = {
distanceToTop: number;
selectedLog: AuditData | null;
setSelectedLog: (log: AuditData | null) => void;
};

export const AuditLogDetails = ({ distanceToTop, selectedLog, setSelectedLog }: Props) => {
const panelStyle = useMemo(() => createPanelStyle(distanceToTop), [distanceToTop]);

if (!log) {
if (!selectedLog) {
return null;
}

const handleClose = () => {
setSelectedLog(null);
};

return (
<ResizablePanel
minW={PANEL_MIN_WIDTH}
maxW={PANEL_MAX_WIDTH}
onClose={onClose}
onClose={handleClose}
className="absolute right-0 bg-gray-1 dark:bg-black font-mono drop-shadow-2xl overflow-y-auto z-20 p-4"
style={panelStyle}
>
<LogHeader log={log} onClose={onClose} />
<LogHeader log={selectedLog} onClose={handleClose} />
<div className="space-y-3 py-4">
<div className="mt-[-24px]" />

<LogFooter log={log} />
{log.auditLog.targets.map((target) => {
<LogFooter log={selectedLog} />
{selectedLog.auditLog.targets.map((target) => {
const title = String(target.type).charAt(0).toUpperCase() + String(target.type).slice(1);

return (
Expand Down
Loading
Loading