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 site visit tracking

Tim Wilson6ead2358548a
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/hostname-section.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/hostname-section.tsx
index 97e2fa569a..28f9760b0b 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/hostname-section.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/hostname-section.tsx
@@ -40,7 +40,7 @@ export const HostnameSection = ({ className }: { className?: string }) => {
<>
<div className={cn("flex flex-col gap-2 p-3", className)}>
<div className="flex items-center justify-between">
- <div className="flex items-center gap-0.5">
+ <div className="flex items-center gap-1">
<h2 className="text-content-emphasis flex-1 text-sm font-semibold">
Allowed hostnames
</h2>
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 cc06d4e453..bd93d57af2 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
@@ -2,6 +2,7 @@
import Link from "next/link";
+import useWorkspace from "@/lib/swr/use-workspace";
import { useWorkspaceStore } from "@/lib/swr/use-workspace-store";
import { useLocalStorage, useRouterStuff } from "@dub/ui";
import { cn } from "@dub/utils";
@@ -10,6 +11,7 @@ import { CompleteStepButton } from "./complete-step-button";
import ConnectionInstructions from "./connection-instructions";
import ConversionTrackingSection from "./conversion-tracking-section";
import OutboundDomainTrackingSection from "./outbound-domain-tracking-section";
+import { SiteVisitTrackingSection } from "./site-visit-tracking-section";
import Step, { BaseStepProps } from "./step";
import TrackLeadsGuidesSection from "./track-lead-guides-section";
import TrackSalesGuidesSection from "./track-sales-guides-section";
@@ -19,6 +21,8 @@ const ConnectStep = ({
toggleExpanded,
onComplete,
}: BaseStepProps & { onComplete: () => void }) => {
+ const { flags } = useWorkspace();
+
const { searchParams } = useRouterStuff();
const guide = searchParams.get("guide");
@@ -48,7 +52,9 @@ const ConnectStep = ({
<ConversionTrackingSection />
- {/* TODO: Site visit tracking */}
+ {flags?.analyticsSettingsSiteVisitTracking && (
+ <SiteVisitTrackingSection />
+ )}
<OutboundDomainTrackingSection />
</div>
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/publishable-key-form.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/publishable-key-form.tsx
index 9bf0d5593c..277494ff08 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/publishable-key-form.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/publishable-key-form.tsx
@@ -91,7 +91,7 @@ export const PublishableKeyForm = ({ className }: { className?: string }) => {
return (
<div className={cn("flex flex-col gap-2 p-3", className)}>
<div className="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
- <div className="flex items-center gap-0.5">
+ <div className="flex items-center gap-1">
<h2 className="text-content-emphasis flex-1 text-sm font-semibold">
Publishable key
</h2>
@@ -101,7 +101,7 @@ export const PublishableKeyForm = ({ className }: { className?: string }) => {
{!publishableKey && (
<Button
text="Generate"
- className="w-fit rounded-lg px-2.5 py-1 text-sm font-medium h-7"
+ className="h-7 w-fit rounded-lg px-2.5 py-1 text-sm font-medium"
onClick={() => setShowGenerateModal(true)}
loading={processing}
disabledTooltip={permissionsError || undefined}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/site-visit-tracking-section.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/site-visit-tracking-section.tsx
new file mode 100644
index 0000000000..a982cab50d
--- /dev/null
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/analytics/site-visit-tracking-section.tsx
@@ -0,0 +1,107 @@
+"use client";
+
+import { useWorkspaceStore } from "@/lib/swr/use-workspace-store";
+import { Button, InfoTooltip, Sitemap, Switch } from "@dub/ui";
+import { formatDate } from "@dub/utils";
+import { motion } from "motion/react";
+import { useId } from "react";
+import { toast } from "sonner";
+
+export const SiteVisitTrackingSection = () => {
+ const id = useId();
+
+ const [enabled, setEnabled, { loading }] = useWorkspaceStore<boolean>(
+ "analyticsSettingsSiteVisitTrackingEnabled",
+ {
+ mutateOnSet: true,
+ },
+ );
+
+ const sitemaps = [
+ {
+ url: "dub.co/sitemap.xml",
+ lastUpdated: new Date(),
+ },
+ ];
+
+ 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-3">
+ <div className="flex min-w-0 items-center gap-4">
+ <div className="overflow-hidden">
+ <label
+ htmlFor={`${id}-switch`}
+ className="text-content-emphasis block text-sm font-semibold"
+ >
+ Site visit tracking
+ </label>
+ <p className="text-content-subtle text-sm font-medium">
+ For tracking site visits (organic visits from Google/SEO/AEO).
+ </p>
+ </div>
+ </div>
+
+ <Switch
+ disabled={loading}
+ checked={enabled || false}
+ trackDimensions="radix-state-checked:bg-black focus-visible:ring-black/20 w-7 h-4"
+ thumbDimensions="size-3"
+ thumbTranslate="translate-x-3"
+ fn={setEnabled}
+ />
+ </div>
+
+ <motion.div
+ animate={{
+ height: enabled ? "auto" : 0,
+ overflow: "hidden",
+ }}
+ transition={{
+ duration: 0.15,
+ }}
+ initial={false}
+ >
+ <div className="flex flex-col gap-2 border-t border-neutral-200 p-3">
+ <div className="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
+ <div className="flex items-center gap-1">
+ <h2 className="text-content-emphasis text-sm font-semibold">
+ Sitemaps
+ </h2>
+ <InfoTooltip content="Required for conversion tracking." />
+ </div>
+ <Button
+ text="Add sitemap"
+ className="h-7 w-fit rounded-lg px-2.5 py-1 text-sm font-medium"
+ onClick={() => toast.info("Coming soon")}
+ />
+ </div>
+
+ <div className="flex flex-col gap-2">
+ {sitemaps.map((sitemap) => (
+ <div
+ key={sitemap.url}
+ className="border-border-subtle flex items-center justify-between gap-4 rounded-xl border bg-white p-3"
+ >
+ <div className="flex min-w-0 items-center gap-2">
+ <div className="flex size-[28px] items-center justify-center rounded-md bg-neutral-100">
+ <Sitemap className="size-4 text-neutral-800" />
+ </div>
+ <span className="text-content-emphasis min-w-0 truncate text-sm font-semibold">
+ {sitemap.url}
+ </span>
+ </div>
+ <div className="flex items-center gap-2">
+ {sitemap.lastUpdated && (
+ <span className="text-content-subtle text-xs font-medium">
+ Updated {formatDate(sitemap.lastUpdated)}
+ </span>
+ )}
+ </div>
+ </div>
+ ))}
+ </div>
+ </div>
+ </motion.div>
+ </div>
+ );
+};
diff --git a/apps/web/lib/edge-config/get-feature-flags.ts b/apps/web/lib/edge-config/get-feature-flags.ts
index ebed700597..e9db9db136 100644
--- a/apps/web/lib/edge-config/get-feature-flags.ts
+++ b/apps/web/lib/edge-config/get-feature-flags.ts
@@ -18,6 +18,7 @@ export const getFeatureFlags = async ({
const workspaceFeatures: Record<BetaFeatures, boolean> = {
noDubLink: false,
abTesting: false,
+ analyticsSettingsSiteVisitTracking: false,
};
if (!process.env.NEXT_PUBLIC_IS_DUB || !process.env.EDGE_CONFIG) {
diff --git a/apps/web/lib/types.ts b/apps/web/lib/types.ts
index 22de65e830..203d22f548 100644
--- a/apps/web/lib/types.ts
+++ b/apps/web/lib/types.ts
@@ -126,7 +126,6 @@ import {
workflowConditionSchema,
} from "./zod/schemas/workflows";
import { workspacePreferencesSchema } from "./zod/schemas/workspace-preferences";
-import { workspaceStoreKeys } from "./zod/schemas/workspaces";
export type LinkProps = Link;
@@ -194,7 +193,10 @@ export type PlanProps = (typeof plans)[number];
export type RoleProps = (typeof roles)[number];
-export type BetaFeatures = "noDubLink" | "abTesting";
+export type BetaFeatures =
+ | "noDubLink"
+ | "abTesting"
+ | "analyticsSettingsSiteVisitTracking";
export interface WorkspaceProps extends Project {
logo: string | null;
diff --git a/packages/ui/src/icons/nucleo/index.ts b/packages/ui/src/icons/nucleo/index.ts
index de59db3a00..6f464108ff 100644
--- a/packages/ui/src/icons/nucleo/index.ts
+++ b/packages/ui/src/icons/nucleo/index.ts
@@ -194,6 +194,7 @@ export * from "./shield-keyhole";
export * from "./shield-slash";
export * from "./shield-user";
export * from "./shuffle";
+export * from "./sitemap";
export * from "./sliders";
export * from "./sparkle3";
export * from "./square-chart";
diff --git a/packages/ui/src/icons/nucleo/sitemap.tsx b/packages/ui/src/icons/nucleo/sitemap.tsx
new file mode 100644
index 0000000000..f5466546e8
--- /dev/null
+++ b/packages/ui/src/icons/nucleo/sitemap.tsx
@@ -0,0 +1,75 @@
+import { SVGProps } from "react";
+
+export function Sitemap(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="M14.75,12.25v-1.5c0-1.105-.895-2-2-2H5.25c-1.105,0-2,.895-2,2v1.5"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <line
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ x1="9"
+ x2="9"
+ y1="5.25"
+ y2="12.25"
+ />
+ <circle
+ cx="3.25"
+ cy="14"
+ fill="none"
+ r="1.75"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <circle
+ cx="14.75"
+ cy="14"
+ fill="none"
+ r="1.75"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <circle
+ cx="9"
+ cy="14"
+ fill="none"
+ r="1.75"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ <circle
+ cx="9"
+ cy="3.5"
+ fill="none"
+ r="1.75"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.5"
+ />
+ </g>
+ </svg>
+ );
+}