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.

WIP

Tim Wilsonfcf6d446f6fb
diff --git a/apps/web/app/api/docs/guides/[guide]/route.ts b/apps/web/app/api/docs/guides/[guide]/route.ts
index 7441d49817..788ff5aeba 100644
--- a/apps/web/app/api/docs/guides/[guide]/route.ts
+++ b/apps/web/app/api/docs/guides/[guide]/route.ts
@@ -3,8 +3,7 @@ import { getIntegrationGuideMarkdown } from "@/lib/get-integration-guide-markdow
// GET /api/docs/guides/[guide] - get doc guide markdown
export const GET = withSession(async ({ params }) => {
- const { guide: rawGuide } = params;
- const guide = rawGuide.replace(".md", "").toLowerCase();
+ const { guide } = params;
const markdown = await getIntegrationGuideMarkdown(guide);
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/add-hostname-modal.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/add-hostname-modal.tsx
index 51023093db..51741749c9 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/add-hostname-modal.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/add-hostname-modal.tsx
@@ -105,7 +105,6 @@ const AddHostnameForm = ({
variant="primary"
text="Add hostname"
className="h-8 w-fit px-3"
- onClick={addHostname}
disabled={!isValidHostname(hostname)}
loading={processing}
disabledTooltip={permissionsError || undefined}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/base-script-section.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/base-script-section.tsx
index 7703a31c34..8509c47218 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/base-script-section.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/base-script-section.tsx
@@ -9,7 +9,7 @@ const BaseScriptSection = () => {
return (
<div className="flex flex-1 flex-col rounded-lg border border-neutral-200 bg-neutral-50">
- <div className="flex items-center justify-between gap-4 p-5">
+ <div className="flex items-center justify-between gap-4 p-3">
<div className="flex min-w-0 items-center gap-4">
<div className="overflow-hidden">
<label
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/complete-step-button.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/complete-step-button.tsx
index 9d9075ff07..927418e9bc 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/complete-step-button.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/complete-step-button.tsx
@@ -8,11 +8,6 @@ export const CompleteStepButton = ({
loading?: boolean;
}) => {
return (
- <Button
- text="Mark step as complete"
- className=""
- loading={loading}
- onClick={onClick}
- />
+ <Button text="Mark step as complete" loading={loading} onClick={onClick} />
);
};
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/conversion-tracking-section.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/conversion-tracking-section.tsx
index ee261ba7f8..f080a5b418 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/conversion-tracking-section.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/conversion-tracking-section.tsx
@@ -16,7 +16,7 @@ const ConversionTrackingSection = () => {
return (
<div className="flex flex-1 flex-col rounded-lg border border-neutral-200 bg-neutral-50">
- <div className="gap-4m flex items-center justify-between p-5">
+ <div className="flex items-center justify-between gap-4 p-3">
<div className="flex min-w-0 items-center gap-4">
<div className="overflow-hidden">
<label
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/outbound-domain-tracking-section.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/outbound-domain-tracking-section.tsx
index 22249a7a6f..ac744931a4 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/outbound-domain-tracking-section.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/outbound-domain-tracking-section.tsx
@@ -14,7 +14,7 @@ const OutboundDomainTrackingSection = () => {
return (
<div className="flex flex-1 flex-col rounded-lg border border-neutral-200 bg-neutral-50">
- <div className="gap-4m flex items-center justify-between p-5">
+ <div className="gap-4m flex items-center justify-between p-3">
<div className="flex min-w-0 items-center gap-4">
<div className="overflow-hidden">
<label
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/page.tsx
index 95458b4633..9eadfc5798 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/page.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/page.tsx
@@ -145,7 +145,7 @@ export default function WorkspaceAnalytics() {
};
return (
- <div className="flex h-full flex-col gap-8 overflow-hidden">
+ <div className="mx-auto flex h-full w-full max-w-[800px] flex-col gap-8 overflow-hidden">
<div className="flex flex-wrap justify-between gap-6">
<h1 className="text-2xl font-semibold tracking-tight text-black">
Analytics
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/step.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/step.tsx
index 5800943c96..4f62c06693 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/step.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/step.tsx
@@ -2,9 +2,8 @@
import { PropsWithChildren } from "react";
-import { Button, Check2 } from "@dub/ui";
-import { cn } from "@dub/utils";
-import { ChevronDown } from "lucide-react";
+import { Button, Check2, ChevronRight } from "@dub/ui";
+import { cn, isClickOnInteractiveChild } from "@dub/utils";
import { AnimatePresence, motion } from "motion/react";
import { ReactNode } from "react";
@@ -39,8 +38,13 @@ const Step = ({
<div className="flex items-start gap-[22px] rounded-xl border border-neutral-200 bg-white p-5">
<StepNumber number={step} complete={complete} />
- <div className="flex flex-1 flex-col gap-5">
- <div className="flex items-center justify-between gap-2">
+ <div className="flex flex-1 flex-col">
+ <div
+ className="group/step-header flex cursor-pointer items-center justify-between gap-2"
+ onClick={(e) => {
+ if (!isClickOnInteractiveChild(e)) toggleExpanded();
+ }}
+ >
<div>
<div className="text-content-emphasis text-base font-semibold">
{title}
@@ -54,29 +58,35 @@ const Step = ({
<Button
variant="plain"
- className="hover:bg-bg-subtle size-8 w-fit rounded-full border-none px-2"
+ className="hover:bg-bg-subtle group-hover/step-header:bg-bg-subtle group size-8 w-fit rounded-full border-none px-2"
data-state={expanded ? "open" : "closed"}
text={
- <ChevronDown className="text-content-emphasis size-4 transition-transform duration-75 data-[state=open]:rotate-180" />
+ <ChevronRight className="text-content-emphasis size-4 transition-transform duration-75 group-data-[state=open]:rotate-90" />
}
onClick={() => toggleExpanded()}
/>
</div>
- <AnimatePresence initial={false}>
- {expanded && (
- <motion.div
- className={cn(contentClassName, "flex-1 overflow-y-scroll")}
- key="step-content"
- initial={{ opacity: 0, height: 0 }}
- animate={{ opacity: 1, height: "auto" }}
- exit={{ opacity: 0, height: 0 }}
- transition={{ duration: 0.2, ease: "easeInOut" }}
- >
- {children}
- </motion.div>
- )}
- </AnimatePresence>
+ <motion.div
+ initial={false}
+ animate={{ height: expanded ? "auto" : 0 }}
+ className="overflow-hidden"
+ >
+ <AnimatePresence initial={false}>
+ {expanded && (
+ <motion.div
+ className={cn(contentClassName, "pt-5")}
+ key="step-content"
+ initial={{ opacity: 0 }}
+ animate={{ opacity: 1 }}
+ exit={{ opacity: 0 }}
+ transition={{ duration: 0.2, ease: "easeInOut" }}
+ >
+ {children}
+ </motion.div>
+ )}
+ </AnimatePresence>
+ </motion.div>
</div>
</div>
);
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/verify-install.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/verify-install.tsx
index e29791af5a..e0311e32a7 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/verify-install.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/verify-install.tsx
@@ -1,12 +1,13 @@
import { verifyWorkspaceSetup } from "@/lib/actions/verify-workspace-setup";
import useWorkspace from "@/lib/swr/use-workspace";
+import { useWorkspaceStore } from "@/lib/swr/use-workspace-store";
import { Button, Plug2 } from "@dub/ui";
import { cn } from "@dub/utils";
-import { motion } from "motion/react";
import { useAction } from "next-safe-action/hooks";
import Link from "next/link";
import { useMemo } from "react";
import { toast } from "sonner";
+import { CompleteStepButton } from "./complete-step-button";
type VerifyStatus = "pending" | "success" | "error";
@@ -14,13 +15,13 @@ const VerifyInstallIcon = ({ status }: { status: VerifyStatus }) => {
return (
<div
className={cn(
- "flex size-[42px] items-center justify-center rounded-full",
+ "text-content-default flex size-10 items-center justify-center rounded-full",
status === "pending" && "border border-blue-200 bg-white",
- status === "error" && "",
- status === "success" && "",
+ status === "error" && "bg-red-400 text-red-900",
+ status === "success" && "bg-green-400 text-green-800",
)}
>
- <Plug2 className="text-content-default size-[18px]" />
+ <Plug2 className="size-4" />
</div>
);
};
@@ -37,10 +38,10 @@ const VerifyInstall = () => {
const error: any | null = null;
const response: VerificationResponse | null = null;
- // const response: VerificationResponse | null = {
- // verifiedAt: new Date(),
- // verifiedBy: { name: "Ian" },
- // };
+ // const response: VerificationResponse | null = {
+ // verifiedAt: new Date(),
+ // verifiedBy: { name: "Ian" },
+ // };
const { executeAsync, isPending } = useAction(verifyWorkspaceSetup, {
async onSuccess(response) {
@@ -64,30 +65,9 @@ const VerifyInstall = () => {
return "pending";
}, [response, error]);
- const title = useMemo(() => {
- if (error) return "Unable to connect";
- if (response) return "Successfully connected!";
- return "Verify your install";
- }, [response, error]);
-
- const subtitle = useMemo(() => {
- if (error)
- return (
- <>
- Try again. For more help, see our{" "}
- <Link href={"/docs"} className="underline">
- docs
- </Link>{" "}
- or{" "}
- <Link href={"/contact"} className="underline">
- contact support
- </Link>
- .
- </>
- );
- if (response) return "You’re connected and ready to track conversions";
- return "Test your connection to Dub";
- }, [response, error]);
+ const [complete, markComplete, { loading }] = useWorkspaceStore<boolean>(
+ "analyticsSettingsConnectionSetupComplete",
+ );
return (
<div
@@ -113,34 +93,55 @@ const VerifyInstall = () => {
<div className="flex flex-col items-center">
<VerifyInstallIcon status={status} />
- <div className="text-content-emphasis font-semibold">{title}</div>
+ <div className="text-content-emphasis mt-3 font-semibold">
+ {error
+ ? "Unable to connect"
+ : response
+ ? "Successfully connected!"
+ : "Verify your install"}
+ </div>
<p className="text-content-emphasis text-sm font-medium">
- {subtitle}
+ {error ? (
+ <>
+ Try again. For more help, see our{" "}
+ <Link href={"/docs"} className="underline">
+ docs
+ </Link>{" "}
+ or{" "}
+ <Link href={"/contact"} className="underline">
+ contact support
+ </Link>
+ .
+ </>
+ ) : response ? (
+ "You’re connected and ready to track conversions"
+ ) : (
+ "Test your connection to Dub"
+ )}
</p>
</div>
- <Button
- className="mt-8"
- text={isPending ? "Verifying..." : "Verify"}
- type="submit"
- loading={isPending}
- disabled={isPending}
- variant={status === "pending" ? "success" : "primary"}
- />
-
- <motion.div
- animate={{
- height: !!response ? "auto" : 0,
- overflow: "hidden",
- }}
- transition={{
- duration: 0.15,
- }}
- initial={false}
- >
- Last verified by
- </motion.div>
+ <div className="mt-4">
+ {status !== "success" && (
+ <Button
+ text={isPending ? "Verifying..." : "Verify"}
+ type="submit"
+ loading={isPending}
+ disabled={isPending}
+ variant={status === "pending" ? "success" : "primary"}
+ />
+ )}
+
+ {status === "success" && !complete && (
+ <CompleteStepButton
+ onClick={() => {
+ markComplete(true);
+ }}
+ loading={loading}
+ />
+ )}
+ </div>
</div>
</form>
</div>
diff --git a/apps/web/lib/swr/use-guide.ts b/apps/web/lib/swr/use-guide.ts
index 150ed45112..89d4b4c3bf 100644
--- a/apps/web/lib/swr/use-guide.ts
+++ b/apps/web/lib/swr/use-guide.ts
@@ -3,7 +3,7 @@ import useSWR, { SWRConfiguration } from "swr";
export default function useGuide(guideKey: string, swrOpts?: SWRConfiguration) {
const { data: guideMarkdown, error } = useSWR(
- `/api/docs/guides/${guideKey}.md`,
+ `/api/docs/guides/${guideKey}`,
textFetcher,
{
keepPreviousData: true,
diff --git a/apps/web/lib/zod/schemas/workspaces.ts b/apps/web/lib/zod/schemas/workspaces.ts
index 39f24355c9..3b7adf6c47 100644
--- a/apps/web/lib/zod/schemas/workspaces.ts
+++ b/apps/web/lib/zod/schemas/workspaces.ts
@@ -190,7 +190,7 @@ export const workspaceStoreKeys = z.enum([
"analyticsSettingsConversionTrackingEnabled", // boolean
"analyticsSettingsSiteVisitTrackingEnabled", // boolean
"analyticsSettingsOutboundDomainTrackingEnabled", // boolean
- "analyticsSettingsConnectionSeupComplete", // boolean
+ "analyticsSettingsConnectionSetupComplete", // boolean
"analyticsSettingsLeadTrackingSetupComplete", // boolean
"analyticsSettingsSaleTrackingSetupComplete", // boolean
]);