Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

display JSON properties

Kiran K094aaf0ed131
diff --git a/apps/web/ui/customers/customer-activity-list.tsx b/apps/web/ui/customers/customer-activity-list.tsx
index 58a2e435ff..6af21e897f 100644
--- a/apps/web/ui/customers/customer-activity-list.tsx
+++ b/apps/web/ui/customers/customer-activity-list.tsx
@@ -9,6 +9,7 @@ import { CursorRays, MoneyBill2, UserCheck } from "@dub/ui/icons";
import { formatDateTimeSmart, getApexDomain, getPrettyUrl } from "@dub/utils";
import Link from "next/link";
import { useParams } from "next/navigation";
+import { Fragment } from "react";
const activityData = {
click: {
@@ -131,35 +132,62 @@ const activityData = {
function MetadataViewer({ metadata }: { metadata: Record<string, any> }) {
const [copied, copyToClipboard] = useCopyToClipboard();
+ const displayEntries = Object.entries(metadata).map(([key, value]) => {
+ const displayValue =
+ typeof value === "object" && value !== null
+ ? JSON.stringify(value).slice(0, 20) + "..."
+ : String(value);
+
+ return `${key}: ${displayValue}`;
+ });
+
+ const hasMoreItems = displayEntries.length > 3;
+ const visibleEntries = hasMoreItems
+ ? displayEntries.slice(0, 3)
+ : displayEntries;
+
return (
- <DynamicTooltipWrapper
- tooltipProps={{
- content: (
- <div className="flex flex-col gap-4 overflow-hidden rounded-md border border-neutral-200 bg-white p-4">
- <div className="flex h-[200px] w-[280px] overflow-hidden rounded-md border border-neutral-200 bg-white sm:h-[300px] sm:w-[350px]">
- <div className="w-full overflow-auto">
- <pre className="p-2 text-xs text-neutral-600">
- {JSON.stringify(metadata, null, 1)}
- </pre>
+ <div className="flex items-center gap-2 text-xs text-neutral-600">
+ {visibleEntries.map((entry, i) => (
+ <Fragment key={i}>
+ <span className="rounded-md border border-neutral-200 bg-neutral-100 px-1.5 py-0.5">
+ {entry}
+ </span>
+ </Fragment>
+ ))}
+
+ <DynamicTooltipWrapper
+ tooltipProps={{
+ content: (
+ <div className="flex flex-col gap-4 overflow-hidden rounded-md border border-neutral-200 bg-white p-4">
+ <div className="flex h-[200px] w-[280px] overflow-hidden rounded-md border border-neutral-200 bg-white sm:h-[300px] sm:w-[350px]">
+ <div className="w-full overflow-auto">
+ <pre className="p-2 text-xs text-neutral-600">
+ {JSON.stringify(metadata, null, 2)}
+ </pre>
+ </div>
</div>
+ <Button
+ text={copied ? "Copied!" : "Copy metadata"}
+ onClick={() =>
+ copyToClipboard(JSON.stringify(metadata, null, 2))
+ }
+ />
</div>
-
- <Button
- text={copied ? "Copied!" : "Copy metadata"}
- onClick={() => copyToClipboard(JSON.stringify(metadata, null, 1))}
- />
- </div>
- ),
- align: "start",
- }}
- >
- <button
- type="button"
- className="hidden items-center gap-1 rounded-md border border-neutral-200 px-1.5 py-0.5 text-xs text-neutral-600 transition-colors hover:bg-neutral-50 sm:inline-flex"
+ ),
+ align: "start",
+ }}
>
- View metadata
- </button>
- </DynamicTooltipWrapper>
+ <button
+ type="button"
+ className="rounded-md border border-neutral-200 bg-white px-1.5 py-0.5 hover:bg-neutral-50"
+ >
+ {hasMoreItems
+ ? `+${displayEntries.length - 3} more`
+ : "View metadata"}
+ </button>
+ </DynamicTooltipWrapper>
+ </div>
);
}