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.

add docs, empty states

Steven Tey3f0df19f33b8
diff --git a/apps/docs/api-reference/introduction.mdx b/apps/docs/api-reference/introduction.mdx
index ef4ec4cb12..622cba003d 100644
--- a/apps/docs/api-reference/introduction.mdx
+++ b/apps/docs/api-reference/introduction.mdx
@@ -23,31 +23,13 @@ https://api.dub.co
## Authentication
-Authentication to Dub.co's API is performed via the Authorization header with a Bearer token. To authenticate, you need to include the Authorization header with the word `Bearer` followed by your token in your API requests like so:
+Authentication to Dub.co's API is performed via the Authorization header with a Bearer token. To authenticate, you need to include the Authorization header with the word `Bearer` followed by your API key in your requests like so:
```bash Terminal
Authorization: Bearer <Your-Token>
```
-You can create a new token/API key under your [Dub.co Account Settings](https://app.dub.co/settings/tokens).
-
-<Frame>
- <img src="/images/dub-api-key.png" alt="Dub API Key" />
-</Frame>
-
-## Workspace ID
-
-Dub.co's API is organized around workspaces. Each workspace has its own set of resources and permissions. To access a workspace's resources, you need to include the `workspaceId` query parameter in your API requests like so:
-
-```bash Terminal
-https://api.dub.co/links?workspaceId=<Your-Workspace-ID>
-```
-
-You can get your workspace ID under your Dub.co Workspace Settings.
-
-<Frame>
- <img src="/images/dub-workspace-id.png" alt="Workspace ID" />
-</Frame>
+Learn more about [how to get your API key](/docs/api-reference/tokens).
## Response Codes
diff --git a/apps/docs/api-reference/rate-limits.mdx b/apps/docs/api-reference/rate-limits.mdx
index f681b487e6..de2c8b7c86 100644
--- a/apps/docs/api-reference/rate-limits.mdx
+++ b/apps/docs/api-reference/rate-limits.mdx
@@ -19,3 +19,5 @@ Dub's API is capped at **600 requests per minute** per user.
This is implemented to ensure a fair usage policy so that excessive use by a single user does not adversely affect the performance and usage of the API by others.
You'll receive a `429 Too Many Requests` response code if the rate limit is exceeded.
+
+## Rate limits by plan
diff --git a/apps/docs/api-reference/tokens.mdx b/apps/docs/api-reference/tokens.mdx
new file mode 100644
index 0000000000..2668d1c586
--- /dev/null
+++ b/apps/docs/api-reference/tokens.mdx
@@ -0,0 +1,8 @@
+---
+title: "API Keys"
+"og:title": "How to get my Dub.co API key?"
+description: "Learn how to get your Dub.co API key."
+icon: key
+---
+
+Dub.co's API is organized around workspaces.
diff --git a/apps/docs/mint.json b/apps/docs/mint.json
index b7358fd419..f4bfe43ff0 100644
--- a/apps/docs/mint.json
+++ b/apps/docs/mint.json
@@ -100,6 +100,7 @@
"group": "API Reference",
"pages": [
"api-reference/introduction",
+ "api-reference/tokens",
"api-reference/rate-limits",
"api-reference/errors"
]
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/tokens/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/tokens/page-client.tsx
index 86c75c451b..1c5405f067 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/tokens/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/tokens/page-client.tsx
@@ -5,10 +5,12 @@ import { TokenProps } from "@/lib/types";
import { useAddEditTokenModal } from "@/ui/modals/add-edit-token-modal";
import { useDeleteTokenModal } from "@/ui/modals/delete-token-modal";
import { useTokenCreatedModal } from "@/ui/modals/token-created-modal";
+import EmptyState from "@/ui/shared/empty-state";
import { Delete } from "@/ui/shared/icons";
import { Button, LoadingSpinner, Popover, TokenAvatar } from "@dub/ui";
+import { Key } from "@dub/ui/src/icons";
import { fetcher, timeAgo } from "@dub/utils";
-import { Edit3, FolderOpen, MoreVertical } from "lucide-react";
+import { Edit3, MoreVertical } from "lucide-react";
import { useState } from "react";
import useSWR from "swr";
@@ -38,18 +40,23 @@ export default function TokensPageClient() {
<TokenCreatedModal />
<AddEditTokenModal />
<div className="rounded-lg border border-gray-200 bg-white">
- <div className="flex flex-col items-center justify-between gap-2 space-y-3 p-5 sm:flex-row sm:space-y-0 sm:p-10">
- <div className="flex flex-col space-y-3">
- <h2 className="text-xl font-medium">API Keys</h2>
+ <div className="flex flex-col items-center justify-between gap-4 space-y-3 border-b border-gray-200 p-5 sm:flex-row sm:space-y-0 sm:p-10">
+ <div className="flex max-w-screen-sm flex-col space-y-3">
+ <h2 className="text-xl font-medium">Workspace API Keys</h2>
<p className="text-sm text-gray-500">
These API keys allow other apps to access your workspace. Use it
- with caution – do not share your API key with others, or expose it
- in the browser or other client-side code
+ with caution – do not share your API key with others, or expose it
+ in the browser or other client-side code.{" "}
+ <a
+ href="https://dub.co/docs/api-reference/tokens"
+ target="_blank"
+ className="font-medium underline underline-offset-4 hover:text-black"
+ >
+ Learn more.
+ </a>
</p>
</div>
- <div className="flex">
- <AddTokenButton />
- </div>
+ <AddTokenButton />
</div>
{isLoading || !tokens ? (
<div className="flex flex-col items-center justify-center space-y-4 pb-20 pt-10">
@@ -70,11 +77,12 @@ export default function TokensPageClient() {
</div>
</div>
) : (
- <div className="flex flex-col items-center justify-center space-y-4 pb-20 pt-10">
- <FolderOpen className="h-6 w-6 text-gray-500" />
- <p className="text-sm text-gray-500">
- No API keys found for this workspace.
- </p>
+ <div className="flex flex-col items-center justify-center gap-y-4 py-20">
+ <EmptyState
+ icon={Key}
+ title="No API keys found for this workspace"
+ />
+ <AddTokenButton />
</div>
)}
</div>
diff --git a/apps/web/app/app.dub.co/(dashboard)/settings/tokens/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/settings/tokens/page-client.tsx
index 0cd373b4d0..26cee71445 100644
--- a/apps/web/app/app.dub.co/(dashboard)/settings/tokens/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/settings/tokens/page-client.tsx
@@ -29,10 +29,17 @@ export default function TokensPageClient() {
<AlertTitle>
User API Keys have been replaced by Workspace API Keys.
</AlertTitle>
- <AlertDescription>
- We recommend creating a new Workspace API Key for more granular
- control over your resources such as Links, Tags, Domains, Analytics,
- etc.
+ <AlertDescription className="text-gray-500">
+ We recommend creating a new{" "}
+ <a
+ href="https://dub.co/docs/api-reference/tokens"
+ target="_blank"
+ className="font-medium underline underline-offset-4 hover:text-black"
+ >
+ Workspace API Key
+ </a>{" "}
+ for more granular control over your resources such as Links, Tags,
+ Domains, Analytics, etc.
</AlertDescription>
</Alert>
diff --git a/apps/web/ui/analytics/events/empty-state.tsx b/apps/web/ui/analytics/events/empty-state.tsx
index 0afee8290d..b1948e1230 100644
--- a/apps/web/ui/analytics/events/empty-state.tsx
+++ b/apps/web/ui/analytics/events/empty-state.tsx
@@ -1,35 +1,14 @@
-import { buttonVariants } from "@dub/ui";
+import EmptyState from "@/ui/shared/empty-state";
import { InvoiceDollar } from "@dub/ui/src/icons";
-import { cn } from "@dub/utils";
-import Link from "next/link";
-export default function EmptyState() {
+export default function EventEmptyState() {
return (
- <div className="flex flex-col items-center justify-center">
- <div className="flex h-16 w-16 items-center justify-center rounded-2xl border border-gray-200 bg-gray-50">
- <InvoiceDollar className="h-8 w-8 text-black" strokeWidth={0.75} />
- </div>
- <p className="mt-8 text-center font-medium text-gray-950">
- Lead and sales analytics
- </p>
- <p className="mt-4 max-w-md text-center text-gray-500">
- Collect insights on lead generation and sales with metrics. Learn about
- top-converting leads and best-selling products.
- </p>
- <div className="mt-8">
- <Link
- href="https://dub.co/docs"
- target="_blank"
- className={cn(
- buttonVariants({ variant: "secondary" }),
- "flex h-8 items-center justify-center gap-2 rounded-md border px-4 text-sm transition-all",
- )}
- >
- <span className="bg-gradient-to-r from-violet-600 to-pink-600 bg-clip-text text-transparent">
- Enable Sales Analytics
- </span>
- </Link>
- </div>
- </div>
+ <EmptyState
+ icon={InvoiceDollar}
+ title="Lead and sales analytics"
+ description="Collect insights on lead generation and sales with metrics. Learn about top-converting leads and best-selling products."
+ buttonText="Enable Sales Analytics"
+ buttonLink="https://dub.co/docs"
+ />
);
}
diff --git a/apps/web/ui/modals/add-edit-token-modal.tsx b/apps/web/ui/modals/add-edit-token-modal.tsx
index 85ef5ef59c..a3511d9537 100644
--- a/apps/web/ui/modals/add-edit-token-modal.tsx
+++ b/apps/web/ui/modals/add-edit-token-modal.tsx
@@ -306,9 +306,8 @@ function AddTokenButton({
return (
<div>
<Button
- text="New API Key"
+ text="Create"
onClick={() => setShowAddEditTokenModal(true)}
- className="w-36"
{...buttonProps}
/>
</div>
diff --git a/apps/web/ui/shared/empty-state.tsx b/apps/web/ui/shared/empty-state.tsx
new file mode 100644
index 0000000000..a19a73b8b7
--- /dev/null
+++ b/apps/web/ui/shared/empty-state.tsx
@@ -0,0 +1,45 @@
+import { buttonVariants } from "@dub/ui";
+import { cn } from "@dub/utils";
+import Link from "next/link";
+
+export default function EmptyState({
+ icon: Icon,
+ title,
+ description,
+ buttonText,
+ buttonLink,
+}: {
+ icon: React.ElementType;
+ title: string;
+ description?: string;
+ buttonText?: string;
+ buttonLink?: string;
+}) {
+ return (
+ <div className="flex flex-col items-center justify-center gap-y-4">
+ <div className="flex h-16 w-16 items-center justify-center rounded-2xl border border-gray-200 bg-gray-50">
+ <Icon className="h-8 w-8 text-black" strokeWidth={0.75} />
+ </div>
+ <p className="text-center text-base font-medium text-gray-950">{title}</p>
+ {description && (
+ <p className="max-w-md text-center text-sm text-gray-500">
+ {description}
+ </p>
+ )}
+ {buttonText && buttonLink && (
+ <Link
+ href={buttonLink}
+ target="_blank"
+ className={cn(
+ buttonVariants({ variant: "secondary" }),
+ "flex h-8 items-center justify-center gap-2 rounded-md border px-4 text-sm transition-all",
+ )}
+ >
+ <span className="bg-gradient-to-r from-violet-600 to-pink-600 bg-clip-text text-transparent">
+ {buttonText}
+ </span>
+ </Link>
+ )}
+ </div>
+ );
+}
diff --git a/packages/ui/src/icons/nucleo/index.ts b/packages/ui/src/icons/nucleo/index.ts
index f2b71e0a84..2cd4f05d13 100644
--- a/packages/ui/src/icons/nucleo/index.ts
+++ b/packages/ui/src/icons/nucleo/index.ts
@@ -10,6 +10,7 @@ export * from "./gear";
export * from "./globe";
export * from "./hyperlink";
export * from "./invoice-dollar";
+export * from "./key";
export * from "./mobile-phone";
export * from "./office-building";
export * from "./qrcode";
diff --git a/packages/ui/src/icons/nucleo/key.tsx b/packages/ui/src/icons/nucleo/key.tsx
new file mode 100644
index 0000000000..5065eb9cd1
--- /dev/null
+++ b/packages/ui/src/icons/nucleo/key.tsx
@@ -0,0 +1,25 @@
+import { SVGProps } from "react";
+
+export function Key(props: SVGProps<SVGSVGElement>) {
+ return (
+ <svg
+ height="18"
+ width="18"
+ viewBox="0 0 18 18"
+ xmlns="http://www.w3.org/2000/svg"
+ {...props}
+ >
+ <g fill="currentColor">
+ <path
+ d="M15.747,2.076l-2.847,.177-5.891,5.891c-.324-.084-.658-.144-1.009-.144-2.209,0-4,1.791-4,4s1.791,4,4,4,4-1.791,4-4c0-.362-.064-.707-.154-1.041l1.904-1.959v-2.25h2.25l1.753-1.645-.006-3.029Z"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <circle cx="5.5" cy="12.5" fill="currentColor" r="1" stroke="none" />
+ </g>
+ </svg>
+ );
+}