Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 apps/agent/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ require (
github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 // indirect
github.com/AlecAivazis/survey/v2 v2.3.7 // indirect
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/ClickHouse/ch-go v0.65.0 // indirect
github.com/ClickHouse/ch-go v0.64.1 // indirect
github.com/Masterminds/semver/v3 v3.3.0 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/Microsoft/hcsshim v0.12.6 // indirect
Expand Down
4 changes: 2 additions & 2 deletions apps/agent/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/ClickHouse/ch-go v0.65.0 h1:vZAXfTQliuNNefqkPDewX3kgRxN6Q4vUENnnY+ynTRY=
github.com/ClickHouse/ch-go v0.65.0/go.mod h1:tCM0XEH5oWngoi9Iu/8+tjPBo04I/FxNIffpdjtwx3k=
github.com/ClickHouse/ch-go v0.64.1 h1:FWpP+QU4KchgzpEekuv8YoI/fUc4H2r6Bwc5WwrzvcI=
github.com/ClickHouse/ch-go v0.64.1/go.mod h1:RBUynvczWwVzhS6Up9lPKlH1mrk4UAmle6uzCiW4Pkc=
github.com/ClickHouse/clickhouse-go/v2 v2.31.0 h1:9MNHRDYXjFTJizGEJM1DfYAqdra/ohprPoZ+LPiuHXQ=
github.com/ClickHouse/clickhouse-go/v2 v2.31.0/go.mod h1:V1aZaG0ctMbd8KVi+D4loXi97duWYtHiQHMCgipKJcI=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ export function useKeysOverviewLogsQuery({ apiId, limit = 50 }: UseLogsQueryPara
isLoading: isLoadingInitial,
} = trpc.api.keys.query.useInfiniteQuery(queryParams, {
getNextPageParam: (lastPage) => lastPage.nextCursor,
initialCursor: { requestId: null, time: null },
staleTime: Number.POSITIVE_INFINITY,
refetchOnMount: false,
refetchOnWindowFocus: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ export const keysQueryOverviewLogsPayload = z.object({
endTime: z.number().int(),
apiId: z.string(),
since: z.string(),
cursor: z
.object({
requestId: z.string().nullable(),
time: z.number().nullable(),
})
.optional()
.nullable(),
cursor: z.number().nullable().optional().nullable(),
outcomes: z
.array(
z.object({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { toast } from "@/components/ui/toaster";
import { cn } from "@/lib/utils";
import { CircleLock } from "@unkey/icons";
import { useState } from "react";

export const HiddenValueCell = ({
value,
Expand All @@ -12,9 +11,8 @@ export const HiddenValueCell = ({
title: string;
selected: boolean;
}) => {
const [isHovered, setIsHovered] = useState(false);
// Show only first 4 characters, then dots
const displayValue = isHovered ? value : value.padEnd(16, "•");
const displayValue = value.padEnd(16, "•");

const handleClick = (e: React.MouseEvent) => {
e.stopPropagation();
Expand All @@ -37,8 +35,6 @@ export const HiddenValueCell = ({
"rounded-lg border bg-white dark:bg-base-12 border-accent-4 text-grayA-11 w-[150px] px-2 py-1 flex gap-2 items-center cursor-pointer h-[28px] group-hover:border-grayA-3 font-mono",
selected && "border-grayA-3",
)}
onMouseEnter={() => setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}
onClick={(e) => handleClick(e)}
>
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ export function useLogsQuery({
isLoading: isLoadingInitial,
} = trpc.logs.queryLogs.useInfiniteQuery(queryParams, {
getNextPageParam: (lastPage) => lastPage.nextCursor,
initialCursor: { requestId: null, time: null },
staleTime: Number.POSITIVE_INFINITY,
refetchOnMount: false,
refetchOnWindowFocus: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,5 @@ export const queryLogsPayload = z.object({
),
})
.nullable(),
cursor: z
.object({
requestId: z.string().nullable(),
time: z.number().nullable(),
})
.optional()
.nullable(),
cursor: z.number().nullable().optional().nullable(),
});
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ export function useRatelimitOverviewLogsQuery({ namespaceId, limit = 50 }: UseLo
isLoading: isLoadingInitial,
} = trpc.ratelimit.overview.logs.query.useInfiniteQuery(queryParams, {
getNextPageParam: (lastPage) => lastPage.nextCursor,
initialCursor: { requestId: null, time: null },
staleTime: Number.POSITIVE_INFINITY,
refetchOnMount: false,
refetchOnWindowFocus: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,7 @@ export const ratelimitQueryOverviewLogsPayload = z.object({
),
})
.nullable(),
cursor: z
.object({
requestId: z.string().nullable(),
time: z.number().nullable(),
})
.optional()
.nullable(),
cursor: z.number().nullable().optional().nullable(),
sorts: z
.array(
z.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ export function useRatelimitLogsQuery({
isLoading: isLoadingInitial,
} = trpc.ratelimit.logs.query.useInfiniteQuery(queryParams, {
getNextPageParam: (lastPage) => lastPage.nextCursor,
initialCursor: { requestId: null, time: null },
staleTime: Number.POSITIVE_INFINITY,
refetchOnMount: false,
refetchOnWindowFocus: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,7 @@ export const ratelimitQueryLogsPayload = z.object({
),
})
.nullable(),
cursor: z
.object({
requestId: z.string().nullable(),
time: z.number().nullable(),
})
.optional()
.nullable(),
cursor: z.number().nullable().optional().nullable(),
});

export type RatelimitQueryLogsPayload = z.infer<typeof ratelimitQueryLogsPayload>;
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ import { transformKeysFilters } from "./utils";
const KeysOverviewLogsResponse = z.object({
keysOverviewLogs: z.array(keysLogs),
hasMore: z.boolean(),
nextCursor: z
.object({
time: z.number().int(),
requestId: z.string(),
})
.optional(),
nextCursor: z.number().int().optional(),
});

type KeysOverviewLogsResponse = z.infer<typeof KeysOverviewLogsResponse>;
Expand Down Expand Up @@ -46,8 +41,7 @@ export const queryKeysOverviewLogs = t.procedure

const clickhouseResult = await clickhouse.api.keys.logs({
...transformedInputs,
cursorRequestId: input.cursor?.requestId ?? null,
cursorTime: input.cursor?.time ?? null,
cursorTime: input.cursor ?? null,
workspaceId: ctx.workspace.id,
keyspaceId: keyspaceId,
// Only include keyIds filters if explicitly provided in the input
Expand Down Expand Up @@ -99,13 +93,7 @@ export const queryKeysOverviewLogs = t.procedure
const response: KeysOverviewLogsResponse = {
keysOverviewLogs,
hasMore: logs.length === input.limit && keysOverviewLogs.length > 0,
nextCursor:
logs.length === input.limit
? {
time: logs[logs.length - 1].time,
requestId: logs[logs.length - 1].request_id,
}
: undefined,
nextCursor: logs.length === input.limit ? logs[logs.length - 1].time : undefined,
};

return response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ export function transformKeysFilters(
names,
identities,
outcomes,
cursorTime: params.cursor?.time ?? null,
cursorRequestId: params.cursor?.requestId ?? null,
cursorTime: params.cursor ?? null,
sorts,
};
}
18 changes: 3 additions & 15 deletions apps/dashboard/lib/trpc/routers/logs/query-logs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ const LogsResponse = z.object({
logs: z.array(log),
hasMore: z.boolean(),
total: z.number(),
nextCursor: z
.object({
time: z.number().int(),
requestId: z.string(),
})
.optional(),
nextCursor: z.number().int().optional(),
});

type LogsResponse = z.infer<typeof LogsResponse>;
Expand Down Expand Up @@ -52,8 +47,7 @@ export const queryLogs = t.procedure
const transformedInputs = transformFilters(input);
const { logsQuery, totalQuery } = await clickhouse.api.logs({
...transformedInputs,
cursorRequestId: input.cursor?.requestId ?? null,
cursorTime: input.cursor?.time ?? null,
cursorTime: input.cursor ?? null,
workspaceId: workspace.id,
});

Expand All @@ -73,13 +67,7 @@ export const queryLogs = t.procedure
logs,
hasMore: logs.length === input.limit,
total: countResult.val[0].total_count,
nextCursor:
logs.length > 0
? {
time: logs[logs.length - 1].time,
requestId: logs[logs.length - 1].request_id,
}
: undefined,
nextCursor: logs.length > 0 ? logs[logs.length - 1].time : undefined,
};

return response;
Expand Down
2 changes: 0 additions & 2 deletions apps/dashboard/lib/trpc/routers/logs/query-logs/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ describe("transformFilters", () => {
statusCodes: [],
requestIds: [],
cursorTime: null,
cursorRequestId: null,
});
});

Expand Down Expand Up @@ -96,6 +95,5 @@ describe("transformFilters", () => {
const result = transformFilters(payload);

expect(result.cursorTime).toBe(1706024400000);
expect(result.cursorRequestId).toBe("req123");
});
});
3 changes: 1 addition & 2 deletions apps/dashboard/lib/trpc/routers/logs/query-logs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export function transformFilters(
methods,
paths,
statusCodes,
cursorTime: params.cursor?.time ?? null,
cursorRequestId: params.cursor?.requestId ?? null,
cursorTime: params.cursor ?? null,
};
}
18 changes: 3 additions & 15 deletions apps/dashboard/lib/trpc/routers/ratelimit/query-logs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ const RatelimitLogsResponse = z.object({
ratelimitLogs: z.array(ratelimitLogs),
hasMore: z.boolean(),
total: z.number(),
nextCursor: z
.object({
time: z.number().int(),
requestId: z.string(),
})
.optional(),
nextCursor: z.number().int().optional(),
});

type RatelimitLogsResponse = z.infer<typeof RatelimitLogsResponse>;
Expand Down Expand Up @@ -61,8 +56,7 @@ export const queryRatelimitLogs = t.procedure
const transformedInputs = transformFilters(input);
const { countQuery, logsQuery } = await clickhouse.ratelimits.logs({
...transformedInputs,
cursorRequestId: input.cursor?.requestId ?? null,
cursorTime: input.cursor?.time ?? null,
cursorTime: input.cursor ?? null,
workspaceId: ctx.workspace.id,
namespaceId: ratelimitNamespaces[0].id,
});
Expand All @@ -81,13 +75,7 @@ export const queryRatelimitLogs = t.procedure
ratelimitLogs: logs,
total: countResult.val[0].total_count,
hasMore: logs.length === input.limit,
nextCursor:
logs.length > 0
? {
time: logs[logs.length - 1].time,
requestId: logs[logs.length - 1].request_id,
}
: undefined,
nextCursor: logs.length > 0 ? logs[logs.length - 1].time : undefined,
};

return response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export function transformFilters(
identifiers,
requestIds: params.requestIds?.filters.map((f) => f.value) || [],
status,
cursorTime: params.cursor?.time ?? null,
cursorRequestId: params.cursor?.requestId ?? null,
cursorTime: params.cursor ?? null,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ const RatelimitOverviewLogsResponse = z.object({
ratelimitOverviewLogs: z.array(ratelimitOverviewLogs),
hasMore: z.boolean(),
total: z.number(),
nextCursor: z
.object({
time: z.number().int(),
requestId: z.string(),
})
.optional(),
nextCursor: z.number().int().optional(),
});

type RatelimitOverviewLogsResponse = z.infer<typeof RatelimitOverviewLogsResponse>;
Expand Down Expand Up @@ -61,8 +56,7 @@ export const queryRatelimitOverviewLogs = t.procedure
const transformedInputs = transformFilters(input);
const { countQuery, logsQuery } = await clickhouse.ratelimits.overview.logs({
...transformedInputs,
cursorRequestId: input.cursor?.requestId ?? null,
cursorTime: input.cursor?.time ?? null,
cursorTime: input.cursor ?? null,
workspaceId: ctx.workspace.id,
namespaceId: ratelimitNamespaces[0].id,
});
Expand All @@ -84,10 +78,7 @@ export const queryRatelimitOverviewLogs = t.procedure
hasMore: logsWithOverrides.length === input.limit,
nextCursor:
logsWithOverrides.length === input.limit
? {
time: logsWithOverrides[logsWithOverrides.length - 1].time,
requestId: logsWithOverrides[logsWithOverrides.length - 1].request_id,
}
? logsWithOverrides[logsWithOverrides.length - 1].time
: undefined,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ export function transformFilters(
startTime,
endTime,
identifiers,
cursorTime: params.cursor?.time ?? null,
cursorTime: params.cursor ?? null,
status,
cursorRequestId: params.cursor?.requestId ?? null,
sorts, // Add sorts to the returned params
};
}
Loading
Loading