Skip to content

Commit a699693

Browse files
committed
fix(outpost): handle SDK validation errors and improve event fetching logic
1 parent 5f2fd98 commit a699693

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

examples/demos/dashboard-integration/src/components/dashboard/RecentActivity.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ export default function RecentActivity({ events }: RecentActivityProps) {
2828
</CardHeader>
2929
<CardContent>
3030
<div className="space-y-4">
31-
{events.slice(0, 5).map((event) => (
32-
<div key={event.id} className="flex items-center justify-between">
31+
{events.slice(0, 5).map((event, index) => (
32+
<div
33+
key={`${event.id}-${(event as any).destination_id || index}`}
34+
className="flex items-center justify-between"
35+
>
3336
<div className="flex-1">
3437
<div className="flex items-center space-x-2">
3538
<span className="text-sm font-medium">{event.topic}</span>
@@ -38,15 +41,15 @@ export default function RecentActivity({ events }: RecentActivityProps) {
3841
event.status === "delivered"
3942
? "success"
4043
: event.status === "failed"
41-
? "error"
42-
: "default"
44+
? "error"
45+
: "default"
4346
}
4447
>
4548
{event.status}
4649
</Badge>
4750
</div>
4851
<p className="text-xs text-gray-500 mt-1">
49-
{formatDateTime(event.createdAt)}
52+
{formatDateTime((event as any).time || event.createdAt)}
5053
</p>
5154
</div>
5255
</div>

examples/demos/dashboard-integration/src/lib/outpost.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export async function createTenant(tenantId: string): Promise<void> {
4242

4343
export async function getPortalUrl(
4444
tenantId: string,
45-
theme?: string,
45+
theme?: string
4646
): Promise<string> {
4747
try {
4848
const outpost = getOutpostClient();
@@ -102,7 +102,27 @@ export async function getTenantOverview(tenantId: string) {
102102
}
103103
logger.debug(`Events found`, { tenantId, totalEvents });
104104
} catch (error) {
105-
logger.warn("Could not fetch events", { error, tenantId });
105+
// Handle SDK validation error - the API response is valid but SDK expects different format
106+
if (error && typeof error === "object" && "rawValue" in error) {
107+
const rawResponse = (error as any).rawValue;
108+
if (
109+
rawResponse &&
110+
typeof rawResponse === "object" &&
111+
"data" in rawResponse &&
112+
Array.isArray(rawResponse.data)
113+
) {
114+
recentEvents = rawResponse.data.slice(0, 10);
115+
totalEvents = rawResponse.count || rawResponse.data.length;
116+
logger.debug(`Events extracted from validation error`, {
117+
tenantId,
118+
totalEvents,
119+
});
120+
} else {
121+
logger.warn("Could not fetch events", { error, tenantId });
122+
}
123+
} else {
124+
logger.warn("Could not fetch events", { error, tenantId });
125+
}
106126
}
107127

108128
const overview = {

0 commit comments

Comments
 (0)