The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
use path name
Kiran K3e0ff683f94b
diff --git a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/page.tsx b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/page.tsxindex c53b85fb90..7e5d420c90 100644--- a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/page.tsx+++ b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/page.tsx@@ -1,10 +1,11 @@+import { Guide } from "@/ui/guides/guide";+import { GuideList } from "@/ui/guides/guide-list";import { guides, IntegrationGuide } from "@/ui/guides/integrations";import { readFileSync } from "fs";import { notFound } from "next/navigation";import { join } from "path";import { Suspense } from "react";import { StepPage } from "../step-page";-import { PageClient } from "./page-client";export default async function Page({searchParams,@@ -34,7 +35,21 @@ export default async function Page({return (<StepPage title="Connecting Dub"><Suspense fallback={<div>Loading...</div>}>- <PageClient markdown={markdown} />+ <div>+ <p className="mb-6 text-sm text-neutral-600">+ Ensure Dub is connected to your app, so you can track your clicks,+ leads, and sales on your program. A developer might be required to+ complete.+ </p>++ <div>+ {selectedGuide ? (+ <Guide markdown={markdown} />+ ) : (+ <GuideList showConnectLaterButton={false} />+ )}+ </div>+ </div></Suspense></StepPage>);diff --git a/apps/web/app/(ee)/app.dub.co/[slug]/(guide)/tracking-guide/page.tsx b/apps/web/app/(ee)/app.dub.co/[slug]/(guide)/tracking-guide/page.tsxindex 92891935ba..09f28db871 100644--- a/apps/web/app/(ee)/app.dub.co/[slug]/(guide)/tracking-guide/page.tsx+++ b/apps/web/app/(ee)/app.dub.co/[slug]/(guide)/tracking-guide/page.tsx@@ -1,9 +1,10 @@+import { Guide } from "@/ui/guides/guide";+import { GuideList } from "@/ui/guides/guide-list";import { guides, IntegrationGuide } from "@/ui/guides/integrations";import { readFileSync } from "fs";import { notFound } from "next/navigation";import { join } from "path";import { Suspense } from "react";-import { PageClient } from "./page-client";export default async function Page({searchParams,@@ -32,7 +33,21 @@ export default async function Page({return (<Suspense fallback={<div>Loading...</div>}>- <PageClient markdown={markdown} />+ <div>+ <p className="mb-6 text-sm text-neutral-600">+ Ensure Dub is connected to your app, so you can track your clicks,+ leads, and sales on your program. A developer might be required to+ complete.+ </p>++ <div>+ {selectedGuide ? (+ <Guide markdown={markdown} />+ ) : (+ <GuideList showConnectLaterButton={false} />+ )}+ </div>+ </div></Suspense>);}diff --git a/apps/web/ui/guides/guide-list.tsx b/apps/web/ui/guides/guide-list.tsxindex 6a1aa2ea8a..18460acd34 100644--- a/apps/web/ui/guides/guide-list.tsx+++ b/apps/web/ui/guides/guide-list.tsx@@ -12,46 +12,18 @@ import { Button, Copy, useCopyToClipboard } from "@dub/ui";import { cn } from "@dub/utils";import { Check } from "lucide-react";import Link from "next/link";+import { usePathname } from "next/navigation";import { useState } from "react";import { toast } from "sonner";import { guides, IntegrationGuide, IntegrationType } from "./integrations";--const sections: {- type: IntegrationType;- title: string;- description: string;-}[] = [- {- type: "client-sdk",- title: "Set up client-side script",- description:- "The step allows Dub to track clicks, automatically fetch the partner and discount data for a given link. Select the guide for instructions.",- },- {- type: "server-sdk",- title: "Set up server-side SDK",- description:- "Install the server-side SDK of your choice and select the guide for instructions.",- },- {- type: "track-leads",- title: "Track lead events",- description:- "The step allows your app to send lead events to Dub. Select the guide for instructions.",- },- {- type: "track-sales",- title: "Track sale events",- description:- "The step allows your app to send sale events to Dub. Select the guide for instructions.",- },-];+import { sections } from "./sections";interface GuideListProps {showConnectLaterButton?: boolean;}export function GuideList({ showConnectLaterButton = true }: GuideListProps) {+ const pathname = usePathname();const { slug: workspaceSlug } = useWorkspace();const [copied, copyToClipboard] = useCopyToClipboard();@@ -141,7 +113,7 @@ export function GuideList({ showConnectLaterButton = true }: GuideListProps) {{(guidesByType[section.type] || []).map((guide) => (<Linkprefetch={true}- href={`/${workspaceSlug}/program/new/connect?guide=${guide.key}`}+ href={`${pathname}?guide=${guide.key}`}key={guide.title}className="group relative flex h-[140px] cursor-pointer flex-col items-center justify-center gap-3 rounded-lg bg-neutral-100 px-2 py-4 text-center">diff --git a/apps/web/ui/guides/guide.tsx b/apps/web/ui/guides/guide.tsxindex 44ad352a43..ed1216d9a7 100644--- a/apps/web/ui/guides/guide.tsx+++ b/apps/web/ui/guides/guide.tsx@@ -1,13 +1,13 @@"use client";-import useWorkspace from "@/lib/swr/use-workspace";-import { Button } from "@dub/ui";-import { useRouter } from "next/navigation";-import { IntegrationGuide, IntegrationType } from "./integrations";+import { buttonVariants } from "@dub/ui";+import { cn } from "@dub/utils";+import Link from "next/link";+import { notFound, usePathname, useSearchParams } from "next/navigation";+import { guides, IntegrationType } from "./integrations";import { Markdown } from "./markdown";interface GuideProps {- selectedGuide: IntegrationGuide;markdown: string | null;}@@ -18,12 +18,27 @@ const integrationTypeToTitle: Record<IntegrationType, string> = {"track-sales": "tracking sale events",};-export function Guide({ selectedGuide, markdown }: GuideProps) {- const router = useRouter();- const { slug: workspaceSlug } = useWorkspace();+export function Guide({ markdown }: GuideProps) {+ const pathname = usePathname();+ const searchParams = useSearchParams();++ const guide = searchParams.get("guide");++ if (!guide) {+ console.error("Guide not found");+ notFound();+ }++ const selectedGuide = guides.find((g) => g.key === guide);++ if (!selectedGuide) {+ console.error(`Guide not found: ${guide}`);+ notFound();+ }if (!markdown) {- return null;+ console.error(`Markdown not found: ${guide}`);+ notFound();}const Icon = selectedGuide.icon;@@ -34,13 +49,18 @@ export function Guide({ selectedGuide, markdown }: GuideProps) {<div className="mx-auto max-w-2xl space-y-6"><div className="flex items-center justify-between"><Icon className="size-8" />- <Button- text="Select another method"- variant="secondary"- className="h-8 w-fit rounded-lg px-3"- type="button"- onClick={() => router.push(`/${workspaceSlug}/program/new/connect`)}- />++ <Link+ href={pathname}+ className={cn(+ buttonVariants({+ variant: "secondary",+ }),+ "flex h-8 w-fit items-center justify-center rounded-lg border border-neutral-200 px-3 text-sm",+ )}+ >+ Select another method+ </Link></div><div className="flex flex-col">@@ -55,12 +75,17 @@ export function Guide({ selectedGuide, markdown }: GuideProps) {<div className="space-y-6 rounded-2xl bg-white p-0 shadow-none"><Markdown>{markdown}</Markdown>- <Button- text="I've completed this"- className="w-full"- type="button"- onClick={() => router.back()}- />+ <Link+ href={pathname}+ className={cn(+ buttonVariants({+ variant: "primary",+ }),+ "flex h-10 w-full items-center justify-center rounded-lg border border-neutral-200 px-4 text-sm",+ )}+ >+ I've completed this+ </Link></div></div></>diff --git a/apps/web/ui/guides/sections.ts b/apps/web/ui/guides/sections.tsnew file mode 100644index 0000000000..3c6fe60574--- /dev/null+++ b/apps/web/ui/guides/sections.ts@@ -0,0 +1,32 @@+import { IntegrationType } from "./integrations";++export const sections: {+ type: IntegrationType;+ title: string;+ description: string;+}[] = [+ {+ type: "client-sdk",+ title: "Set up client-side script",+ description:+ "The step allows Dub to track clicks, automatically fetch the partner and discount data for a given link. Select the guide for instructions.",+ },+ {+ type: "server-sdk",+ title: "Set up server-side SDK",+ description:+ "Install the server-side SDK of your choice and select the guide for instructions.",+ },+ {+ type: "track-leads",+ title: "Track lead events",+ description:+ "The step allows your app to send lead events to Dub. Select the guide for instructions.",+ },+ {+ type: "track-sales",+ title: "Track sale events",+ description:+ "The step allows your app to send sale events to Dub. Select the guide for instructions.",+ },+];