Skip to content

Commit f5c4f25

Browse files
committed
add WEBHOOK_REQUEST_ACTORS
1 parent 36d4b0f commit f5c4f25

4 files changed

Lines changed: 41 additions & 30 deletions

File tree

apps/web/lib/api-logs/constants.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,3 @@ export const METHOD_BADGE_VARIANTS: Record<string, string> = {
9090
DELETE: "error",
9191
GET: "success",
9292
} as const;
93-
94-
export const WEBHOOK_DISPLAY_NAMES: Record<string, string> = {
95-
"/appsflyer/webhook": "AppsFlyer",
96-
"/stripe/integration/webhook": "Stripe",
97-
"/shopify/integration/webhook": "Shopify",
98-
};

apps/web/lib/api-logs/enrich-api-logs.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,30 @@
11
import { prisma } from "@dub/prisma";
22
import { ApiLogTB, EnrichedApiLog } from "../types";
33

4+
const WEBHOOK_REQUEST_ACTORS: Record<
5+
string,
6+
{ id: string; name: string; image: string }
7+
> = {
8+
"/appsflyer/webhook": {
9+
id: "appsflyer",
10+
name: "AppsFlyer",
11+
image:
12+
"https://dubassets.com/integrations/int_1KN8JP7ET3VQQRF7ZQEVNFPJ5_2Geprc8",
13+
},
14+
"/stripe/integration/webhook": {
15+
id: "stripe",
16+
name: "Stripe",
17+
image:
18+
"https://dubassets.com/integrations/clzra1ya60001wnj4a89zcg9h_jtyaGa7",
19+
},
20+
"/shopify/integration/webhook": {
21+
id: "shopify",
22+
name: "Shopify",
23+
image:
24+
"https://dubassets.com/integrations/int_iWOtrZgmcyU6XDwKr4AYYqLN_jUmF77W",
25+
},
26+
};
27+
428
export async function enrichApiLogs(
529
logs: ApiLogTB | ApiLogTB[],
630
): Promise<EnrichedApiLog | EnrichedApiLog[]> {
@@ -52,7 +76,14 @@ export async function enrichApiLogs(
5276
const enriched = logsArray.map((log) => ({
5377
...log,
5478
token: log.token_id ? tokenMap.get(log.token_id) ?? null : null,
55-
user: log.user_id ? userMap.get(log.user_id) ?? null : null,
79+
user: WEBHOOK_REQUEST_ACTORS[log.path]
80+
? {
81+
...WEBHOOK_REQUEST_ACTORS[log.path],
82+
email: null,
83+
}
84+
: log.user_id
85+
? userMap.get(log.user_id) ?? null
86+
: null,
5687
}));
5788

5889
return isSingle ? enriched[0] : enriched;

apps/web/ui/logs/logs-table.tsx

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import {
44
API_LOGS_MAX_PAGE_SIZE,
55
METHOD_BADGE_VARIANTS,
6-
WEBHOOK_DISPLAY_NAMES,
76
} from "@/lib/api-logs/constants";
87
import { useApiLogsCount } from "@/lib/swr/use-api-logs-count";
98
import useWorkspace from "@/lib/swr/use-workspace";
@@ -43,7 +42,6 @@ export function LogsTable() {
4342
onRemove,
4443
onRemoveAll,
4544
searchQuery,
46-
setSearch,
4745
setSelectedFilter,
4846
} = useLogFilters();
4947

@@ -77,18 +75,14 @@ export function LogsTable() {
7775
{
7876
id: "path",
7977
header: "Endpoint",
80-
cell: ({ row }: { row: Row<EnrichedApiLog> }) => {
81-
const displayName = WEBHOOK_DISPLAY_NAMES[row.original.path];
82-
83-
return (
84-
<span
85-
className="truncate"
86-
title={row.original.route_pattern || undefined}
87-
>
88-
{displayName || row.original.path}
89-
</span>
90-
);
91-
},
78+
cell: ({ row }: { row: Row<EnrichedApiLog> }) => (
79+
<span
80+
className="truncate"
81+
title={row.original.route_pattern || undefined}
82+
>
83+
{row.original.path}
84+
</span>
85+
),
9286
meta: {
9387
filterParams: ({ row }: { row: Row<EnrichedApiLog> }) => ({
9488
routePattern: row.original.route_pattern,
@@ -246,7 +240,6 @@ export function LogsTable() {
246240
onSelect={onSelect}
247241
onRemove={onRemove}
248242
onRemoveAll={onRemoveAll}
249-
setSearch={setSearch}
250243
setSelectedFilter={setSelectedFilter}
251244
/>
252245
{logs?.length !== 0 ? (
@@ -277,15 +270,13 @@ function LogsFilters({
277270
onSelect,
278271
onRemove,
279272
onRemoveAll,
280-
setSearch,
281273
setSelectedFilter,
282274
}: {
283275
filters: any[];
284276
activeFilters: any[];
285277
onSelect: (key: string, value: any) => void;
286278
onRemove: (key: string) => void;
287279
onRemoveAll: () => void;
288-
setSearch: (s: string) => void;
289280
setSelectedFilter: (f: string | null) => void;
290281
}) {
291282
return (
@@ -297,7 +288,6 @@ function LogsFilters({
297288
activeFilters={activeFilters}
298289
onSelect={onSelect}
299290
onRemove={onRemove}
300-
onSearchChange={setSearch}
301291
onSelectedFilterChange={setSelectedFilter}
302292
/>
303293
<SearchBoxPersisted

apps/web/ui/logs/use-log-filters.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
HTTP_METHODS,
55
HTTP_STATUS_CODES,
66
REQUEST_TYPES,
7-
WEBHOOK_DISPLAY_NAMES,
87
} from "@/lib/api-logs/constants";
98
import { useApiLogsCount } from "@/lib/swr/use-api-logs-count";
109
import useWorkspace from "@/lib/swr/use-workspace";
@@ -24,8 +23,6 @@ import useSWR from "swr";
2423
export function useLogFilters() {
2524
const { searchParamsObj, queryParams } = useRouterStuff();
2625
const { id: workspaceId } = useWorkspace();
27-
28-
const [search, setSearch] = useState("");
2926
const [selectedFilter, setSelectedFilter] = useState<string | null>(null);
3027

3128
const { data: tokens } = useSWR<TokenProps[]>(
@@ -83,7 +80,7 @@ export function useLogFilters() {
8380
label: "Endpoint",
8481
options: routePatterns?.map(({ routePattern, count }) => ({
8582
value: routePattern,
86-
label: WEBHOOK_DISPLAY_NAMES[routePattern] ?? routePattern,
83+
label: routePattern,
8784
right: nFormatter(count, { full: true }),
8885
})),
8986
},
@@ -165,7 +162,6 @@ export function useLogFilters() {
165162
onRemove,
166163
onRemoveAll,
167164
searchQuery,
168-
setSearch,
169165
setSelectedFilter,
170166
};
171167
}

0 commit comments

Comments
 (0)