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.

improve architecture

Kiran K5690009b155b
diff --git a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/constants.ts b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/constants.ts
new file mode 100644
index 0000000000..21257b3715
--- /dev/null
+++ b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/constants.ts
@@ -0,0 +1,35 @@
+import { Shopify } from "@/ui/layout/sidebar/conversions/icons/shopify";
+import { Code, Framer, Globe } from "lucide-react";
+import { IntegrationGuide } from "./types";
+
+export const guides: IntegrationGuide[] = [
+ {
+ type: "no-code",
+ key: "framer",
+ title: "Framer",
+ description: "Dub Analytics",
+ icon: Framer,
+ recommended: true,
+ },
+ {
+ type: "no-code",
+ key: "shopify",
+ title: "Shopify",
+ description: "Dub Analytics",
+ icon: Shopify,
+ },
+ {
+ type: "no-code",
+ key: "webflow",
+ title: "Webflow",
+ description: "Dub Analytics",
+ icon: Globe,
+ },
+ {
+ type: "code",
+ key: "wordpress",
+ title: "WordPress",
+ description: "Dub Analytics",
+ icon: Code,
+ },
+];
diff --git a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/guide-list.tsx b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/guide-list.tsx
index a415008eac..08b02abe1f 100644
--- a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/guide-list.tsx
+++ b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/guide-list.tsx
@@ -2,48 +2,16 @@
import { onboardProgramAction } from "@/lib/actions/partners/onboard-program";
import useWorkspace from "@/lib/swr/use-workspace";
-import { Shopify } from "@/ui/layout/sidebar/conversions/icons/shopify";
-import { Stripe } from "@/ui/layout/sidebar/conversions/icons/stripe";
import { Button, ToggleGroup } from "@dub/ui";
import { useAction } from "next-safe-action/hooks";
+import Link from "next/link";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { toast } from "sonner";
-import { IntegrationGuide, IntegrationType } from "./types";
+import { guides } from "./constants";
+import { IntegrationType } from "./types";
-interface GuidesListProps {
- onGuideSelect: (guide: IntegrationGuide) => void;
-}
-
-export const guides: IntegrationGuide[] = [
- {
- type: "no-code",
- title: "Framer",
- description: "Dub Analytics",
- icon: Shopify,
- recommended: true,
- },
- {
- type: "no-code",
- title: "Shopify",
- description: "Dub Analytics",
- icon: Shopify,
- },
- {
- type: "no-code",
- title: "Webflow",
- description: "Dub Analytics",
- icon: Stripe,
- },
- {
- type: "code",
- title: "WordPress",
- description: "Dub Analytics",
- icon: Shopify,
- },
-];
-
-export function GuidesList({ onGuideSelect }: GuidesListProps) {
+export function GuideList() {
const router = useRouter();
const [hasSubmitted, setHasSubmitted] = useState(false);
const { id: workspaceId, slug: workspaceSlug, mutate } = useWorkspace();
@@ -93,10 +61,10 @@ export function GuidesList({ onGuideSelect }: GuidesListProps) {
{guides
.filter((g) => g.type === integrationType)
.map((guide) => (
- <button
+ <Link
+ href={`/${workspaceSlug}/program/new/connect?guide=${guide.key}`}
key={guide.title}
className="group relative flex h-40 cursor-pointer flex-col justify-center rounded-lg bg-neutral-200/40 transition-colors duration-100 hover:bg-neutral-200/60"
- onClick={() => onGuideSelect(guide)}
>
{guide.recommended && (
<span className="absolute -top-2 left-1/2 z-10 -translate-x-1/2 rounded-md bg-blue-100 px-2 py-0.5 text-xs font-medium text-blue-600">
@@ -116,7 +84,7 @@ export function GuidesList({ onGuideSelect }: GuidesListProps) {
{guide.description}
</div>
</div>
- </button>
+ </Link>
))}
</div>
diff --git a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/guide.tsx b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/guide.tsx
index 17c43d9daa..3504f693c8 100644
--- a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/guide.tsx
+++ b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/guide.tsx
@@ -2,6 +2,7 @@
import { onboardProgramAction } from "@/lib/actions/partners/onboard-program";
import useWorkspace from "@/lib/swr/use-workspace";
+import { Markdown } from "@/ui/shared/markdown";
import { Button } from "@dub/ui";
import { useAction } from "next-safe-action/hooks";
import { useRouter } from "next/navigation";
@@ -9,13 +10,12 @@ import { useState } from "react";
import { toast } from "sonner";
import { IntegrationGuide } from "./types";
-export function Guide({
- guide,
- clearSelectedGuide,
-}: {
- guide: IntegrationGuide;
- clearSelectedGuide: () => void;
-}) {
+interface GuideProps {
+ selectedGuide: IntegrationGuide;
+ guideContent: string | null;
+}
+
+export function Guide({ selectedGuide, guideContent }: GuideProps) {
const router = useRouter();
const [hasSubmitted, setHasSubmitted] = useState(false);
const { id: workspaceId, slug: workspaceSlug, mutate } = useWorkspace();
@@ -43,7 +43,7 @@ export function Guide({
});
};
- const Icon = guide.icon;
+ const Icon = selectedGuide.icon;
return (
<>
@@ -56,19 +56,19 @@ export function Guide({
variant="secondary"
className="h-8 w-fit rounded-lg px-2"
type="button"
- onClick={clearSelectedGuide}
+ onClick={() => router.push(`/${workspaceSlug}/program/new/connect`)}
/>
</div>
<h2 className="py-2 text-xl font-semibold leading-7 text-neutral-900">
- Instructions for {guide.title}
+ Instructions for {selectedGuide.title}
</h2>
<div className="rounded-2xl bg-white p-0 py-6 shadow-none">
{/* Step 1 */}
<div className="mb-4">
<div className="mb-1 text-base font-bold">
- Step 1: Install the Dub {guide.title} App
+ Step 1: Install the Dub {selectedGuide.title} App
</div>
<div className="mb-6 text-neutral-600">
Ensure your program is connected to your website, so you can track
@@ -76,11 +76,10 @@ export function Guide({
</div>
</div>
- {/* Help Article Section */}
- <div className="mb-8 flex min-h-[260px] items-center justify-center rounded-2xl bg-neutral-100">
- <span className="text-center text-neutral-500">
- Rest of the help article content
- </span>
+ <div className="mb-8 rounded-2xl bg-neutral-100">
+ {guideContent && (
+ <Markdown className="p-6">{guideContent}</Markdown>
+ )}
</div>
<div className="flex flex-col gap-2">
diff --git a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/page-client.tsx b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/page-client.tsx
index 09789966bc..01aca07803 100644
--- a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/page-client.tsx
+++ b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/page-client.tsx
@@ -1,15 +1,39 @@
"use client";
-import { useState } from "react";
+import { useSearchParams } from "next/navigation";
+import { useEffect, useState } from "react";
+import { guides } from "./constants";
import { Guide } from "./guide";
-import { GuidesList } from "./guide-list";
+import { GuideList } from "./guide-list";
import { IntegrationGuide } from "./types";
-export function PageClient() {
+interface PageClientProps {
+ guideContent: string | null;
+}
+
+export function PageClient({ guideContent }: PageClientProps) {
+ const searchParams = useSearchParams();
const [selectedGuide, setSelectedGuide] = useState<IntegrationGuide | null>(
null,
);
+ useEffect(() => {
+ const guide = searchParams.get("guide");
+
+ if (!guide) {
+ setSelectedGuide(null);
+ return;
+ }
+
+ const integrationGuide = guides.find(
+ (g) => g.title.toLowerCase() === guide.toLowerCase(),
+ );
+
+ if (integrationGuide) {
+ setSelectedGuide(integrationGuide);
+ }
+ }, [searchParams]);
+
return (
<div>
<p className="mb-6 text-sm text-neutral-600">
@@ -19,12 +43,9 @@ export function PageClient() {
<div>
{selectedGuide ? (
- <Guide
- guide={selectedGuide}
- clearSelectedGuide={() => setSelectedGuide(null)}
- />
+ <Guide selectedGuide={selectedGuide} guideContent={guideContent} />
) : (
- <GuidesList onGuideSelect={setSelectedGuide} />
+ <GuideList />
)}
</div>
</div>
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.tsx
index 432ef00371..43f42c48d8 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,50 @@
+import { readFileSync } from "fs";
+import { notFound } from "next/navigation";
+import { join } from "path";
import { StepPage } from "../step-page";
+import { guides } from "./constants";
import { PageClient } from "./page-client";
+import { IntegrationGuide } from "./types";
+
+function getGuideContent(guideKey: string): string | null {
+ const markdownPath = join(process.cwd(), "markdown", `${guideKey}.md`);
+
+ try {
+ return readFileSync(markdownPath, "utf-8");
+ } catch (error) {
+ console.warn(`Guide content not found for: ${guideKey}`);
+ return null;
+ }
+}
+
+export default async function Page({
+ searchParams,
+}: {
+ searchParams: {
+ guide: string;
+ };
+}) {
+ let { guide } = searchParams;
+ let selectedGuide: IntegrationGuide | null = null;
+ let content: string | null = null;
+
+ if (guide) {
+ selectedGuide = guides.find((g) => g.key === guide.toLowerCase()) ?? null;
+
+ if (!selectedGuide) {
+ notFound();
+ }
+
+ content = getGuideContent(selectedGuide.key);
+
+ if (!content) {
+ notFound();
+ }
+ }
-export default async function Page() {
return (
<StepPage title="Connecting Dub">
- <PageClient />
+ <PageClient guideContent={content} />
</StepPage>
);
}
diff --git a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/types.ts b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/types.ts
index 42826c0aa8..be8e67e692 100644
--- a/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/types.ts
+++ b/apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/program/new/connect/types.ts
@@ -2,8 +2,10 @@ export type IntegrationType = "no-code" | "code";
export type IntegrationGuide = {
type: IntegrationType;
+ key: string;
title: string;
description?: string;
icon: any;
recommended?: boolean;
+ content?: string;
};
diff --git a/apps/web/markdown/webflow.md b/apps/web/markdown/webflow.md
new file mode 100644
index 0000000000..1ff0532f38
--- /dev/null
+++ b/apps/web/markdown/webflow.md
@@ -0,0 +1,29 @@
+# Webflow
+
+> How to add @dub/analytics to your Webflow site
+
+With `@dub/analytics`, you can track lead and sale conversions on your Webflow site, enabling you to measure the effectiveness of your marketing campaigns.
+
+You can add the `@dub/analytics` script to your Webflow website same way you would add Google Analytics script or any other JavaScript code.
+
+Follow these steps to add the script to your site:
+
+* On your project's page, click on the **Webflow logo** in the left-hand side menu and choose **Project Settings**.
+* Choose **[Custom Code](https://university.webflow.com/lesson/custom-code-in-the-head-and-body-tags?topics=site-settings)** from the menu and paste the Dub analytics script in the **Head Code** section.
+* Click on the **Save Changes** button and then **Publish** your changes.
+
+```html
+<script src="https://www.dubcdn.com/analytics/script.js" defer></script>
+```
+
+If you're using [Dub Partners](/partners/quickstart) for affiliate management, you will also need to set up the `data-domains` property to enable [client-side click-tracking](/sdks/client-side/features/client-side-click-tracking).
+
+```html
+<script
+ src="https://www.dubcdn.com/analytics/script.js"
+ defer
+ data-domains='{"refer":"yourcompany.link"}'
+></script>
+```
+
+Read the [client-side click-tracking guide](/sdks/client-side/features/client-side-click-tracking) for more information.