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.

code improvements

Pedro Ladeira680543ca6fb4
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/configure-tracking-section.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/configure-tracking-section.tsx
index bbafc8ea7f..3f4b3573d7 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/configure-tracking-section.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/configure-tracking-section.tsx
@@ -4,19 +4,40 @@ import { clientAccessCheck } from "@/lib/client-access-check";
import useWorkspace from "@/lib/swr/use-workspace";
import { useWorkspaceStore } from "@/lib/swr/use-workspace-store";
import { guides, stackItems } from "@/ui/guides/integrations";
-import { Button } from "@dub/ui";
+import { Button, Switch } from "@dub/ui";
import { useEffect, useMemo } from "react";
import { Controller, useForm } from "react-hook-form";
import { toast } from "sonner";
import { HostnameField } from "./hostname-field";
-import { OutboundDomainTrackingField } from "./outbound-domain-tracking-field";
import { PublishableKeyField } from "./publishable-key-field";
import { SectionCard } from "./section-card";
-import { SiteVisitTrackingField } from "./site-visit-tracking-field";
+import {
+ SiteVisitTrackingField,
+ TrackedSitemapDraft,
+} from "./site-visit-tracking-field";
import { StackPicker, StackSelectionStatus } from "./stack-picker";
-import { emptyTrackingFormValues, TrackingFormData } from "./tracking-form";
import { TrackingSettingsRow } from "./tracking-settings-row";
+type TrackingFormData = {
+ stack: string[];
+ allowedHostnames: string[];
+ publishableKey: string | null;
+ siteVisitTrackingEnabled: boolean;
+ siteDomainSlug: string;
+ trackedSitemaps: TrackedSitemapDraft[];
+ outboundDomainTrackingEnabled: boolean;
+};
+
+const emptyTrackingFormValues: TrackingFormData = {
+ stack: [],
+ allowedHostnames: [],
+ publishableKey: null,
+ siteVisitTrackingEnabled: false,
+ siteDomainSlug: "",
+ trackedSitemaps: [],
+ outboundDomainTrackingEnabled: false,
+};
+
const STACK_DESCRIPTION =
"Select all items that apply to your stack. [Learn more](https://dub.co/docs/conversions/quickstart)";
const HOSTNAMES_DESCRIPTION =
@@ -329,16 +350,21 @@ export function ConfigureTrackingSection() {
description={OUTBOUND_DESCRIPTION}
align="center"
>
- <OutboundDomainTrackingField
- enabled={watch("outboundDomainTrackingEnabled")}
- onEnabledChange={(enabled) =>
- setValue("outboundDomainTrackingEnabled", enabled, {
- shouldDirty: true,
- })
- }
- disabled={disabled}
- disabledTooltip={disabledTooltip}
- />
+ <label className="flex w-fit cursor-pointer items-center gap-2">
+ <Switch
+ checked={watch("outboundDomainTrackingEnabled")}
+ fn={(enabled) =>
+ setValue("outboundDomainTrackingEnabled", enabled, {
+ shouldDirty: true,
+ })
+ }
+ disabled={disabled}
+ disabledTooltip={disabledTooltip}
+ />
+ <span className="text-content-default text-sm font-medium">
+ Enable
+ </span>
+ </label>
</TrackingSettingsRow>
</div>
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/empty-tracking-card.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/empty-tracking-card.tsx
index 78f6500439..0954007702 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/empty-tracking-card.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/empty-tracking-card.tsx
@@ -1,4 +1,3 @@
-import { cn } from "@dub/utils";
import { ReactNode } from "react";
export const emptyTrackingActionClassName =
@@ -33,11 +32,7 @@ export function EmptyTrackingCard({
<div className="flex h-16 w-full items-center justify-between gap-4 rounded-xl bg-neutral-50 py-4 pl-6 pr-4">
<div className="flex min-w-0 items-center gap-2">
{icon}
- <span
- className={cn(
- "text-content-subtle truncate text-center text-sm font-medium leading-5 tracking-[-0.02em]",
- )}
- >
+ <span className="text-content-subtle truncate text-center text-sm font-medium leading-5 tracking-[-0.02em]">
{text}
</span>
</div>
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/enable-switch.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/enable-switch.tsx
deleted file mode 100644
index 04fc79b9a6..0000000000
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/enable-switch.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-"use client";
-
-import { Switch } from "@dub/ui";
-
-export function EnableSwitch({
- checked,
- onChange,
- disabled,
- disabledTooltip,
-}: {
- checked: boolean;
- onChange: (checked: boolean) => void;
- disabled?: boolean;
- disabledTooltip?: string;
-}) {
- return (
- <label className="flex w-fit cursor-pointer items-center gap-2">
- <Switch
- checked={checked}
- fn={onChange}
- disabled={disabled}
- disabledTooltip={disabledTooltip}
- />
- <span className="text-content-default text-sm font-medium">Enable</span>
- </label>
- );
-}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/guide.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/guide.tsx
deleted file mode 100644
index 8be76ba814..0000000000
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/guide.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-"use client";
-
-import { GuidesMarkdown } from "@/ui/guides/markdown";
-import { use } from "react";
-
-export default function GuideMarkdown({
- guideMarkdown,
-}: {
- guideMarkdown: Promise<string | null>;
-}) {
- const guide = use(guideMarkdown);
-
- if (!guide) {
- return null;
- }
-
- return <GuidesMarkdown>{guide}</GuidesMarkdown>;
-}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/hostname-field.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/hostname-field.tsx
index 2be905b18c..9492bff288 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/hostname-field.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/hostname-field.tsx
@@ -8,7 +8,7 @@ import {
EmptyTrackingCard,
emptyTrackingActionClassName,
} from "./empty-tracking-card";
-import HostnameMenu from "./hostname-menu";
+import { HostnameMenu } from "./hostname-menu";
export function HostnameField({
hostnames,
@@ -109,12 +109,7 @@ function HostnameRow({
{hostname}
</span>
</div>
- {!disabled && (
- <HostnameMenu
- onDelete={() => setShowConfirmModal(true)}
- loading={false}
- />
- )}
+ {!disabled && <HostnameMenu onDelete={() => setShowConfirmModal(true)} />}
{confirmModal}
</div>
);
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/hostname-menu.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/hostname-menu.tsx
index a3126c6c39..6d72a68298 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/hostname-menu.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/hostname-menu.tsx
@@ -1,16 +1,9 @@
import { ThreeDots } from "@/ui/shared/icons";
-import { Button, LoadingSpinner, Popover } from "@dub/ui";
+import { Button, Popover } from "@dub/ui";
import { Delete } from "lucide-react";
import { useState } from "react";
-function HostnameMenu({
- onDelete,
- loading,
-}: {
- onDelete: () => void;
- loading: boolean;
- permissionsError?: string;
-}) {
+export function HostnameMenu({ onDelete }: { onDelete: () => void }) {
const [openPopover, setOpenPopover] = useState(false);
return (
@@ -38,13 +31,7 @@ function HostnameMenu({
<Button
variant="outline"
className="size-7 shrink-0 border-transparent p-0 outline-none transition-all duration-200 data-[state=open]:border-neutral-500"
- icon={
- loading ? (
- <LoadingSpinner className="size-3 shrink-0" />
- ) : (
- <ThreeDots className="size-4 shrink-0 rotate-90" />
- )
- }
+ icon={<ThreeDots className="size-4 shrink-0 rotate-90" />}
onClick={() => {
setOpenPopover(!openPopover);
}}
@@ -52,5 +39,3 @@ function HostnameMenu({
</Popover>
);
}
-
-export default HostnameMenu;
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/installation-section.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/installation-section.tsx
index 1ff9c46d1e..953e4ddee2 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/installation-section.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/installation-section.tsx
@@ -5,11 +5,7 @@ import { useWorkspaceStore } from "@/lib/swr/use-workspace-store";
import { buildTrackingSetup } from "@/lib/tracking/build-tracking-setup";
import { useEffect, useMemo, useRef } from "react";
import { SectionCard } from "./section-card";
-import {
- DeveloperGuides,
- isSetupInstructionsReady,
- SetupInstructions,
-} from "./setup-instructions";
+import { DeveloperGuides, SetupInstructions } from "./setup-instructions";
import { TrackingSettingsRow } from "./tracking-settings-row";
import { VerifyInstall } from "./verify-install";
@@ -32,7 +28,7 @@ export function InstallationSection() {
const stack = savedStack ?? [];
const hostnames = allowedHostnames ?? [];
- const ready = isSetupInstructionsReady(stack, hostnames.length > 0);
+ const ready = stack.length > 0 && hostnames.length > 0;
const seedingRef = useRef(false);
useEffect(() => {
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/outbound-domain-tracking-field.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/outbound-domain-tracking-field.tsx
deleted file mode 100644
index b82ca53581..0000000000
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/outbound-domain-tracking-field.tsx
+++ /dev/null
@@ -1,24 +0,0 @@
-"use client";
-
-import { EnableSwitch } from "./enable-switch";
-
-export function OutboundDomainTrackingField({
- enabled,
- onEnabledChange,
- disabled,
- disabledTooltip,
-}: {
- enabled: boolean;
- onEnabledChange: (enabled: boolean) => void;
- disabled?: boolean;
- disabledTooltip?: string;
-}) {
- return (
- <EnableSwitch
- checked={enabled}
- onChange={onEnabledChange}
- disabled={disabled}
- disabledTooltip={disabledTooltip}
- />
- );
-}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/page-client.tsx
deleted file mode 100644
index 8329218da8..0000000000
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/page-client.tsx
+++ /dev/null
@@ -1,13 +0,0 @@
-"use client";
-
-import { ConfigureTrackingSection } from "./configure-tracking-section";
-import { InstallationSection } from "./installation-section";
-
-export function WorkspaceTrackingSettingsPageClient() {
- return (
- <div className="flex flex-1 flex-col gap-8 overflow-hidden">
- <ConfigureTrackingSection />
- <InstallationSection />
- </div>
- );
-}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/page.tsx
index 30c2a52d8d..e8eb48aa8f 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/page.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/page.tsx
@@ -1,8 +1,9 @@
import { PageContent } from "@/ui/layout/page-content";
import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";
import { Suspense } from "react";
+import { ConfigureTrackingSection } from "./configure-tracking-section";
import { ConversionTrackingToggle } from "./conversion-tracking-toggle";
-import { WorkspaceTrackingSettingsPageClient } from "./page-client";
+import { InstallationSection } from "./installation-section";
export default function WorkspaceTrackingSettingsPage() {
return (
@@ -17,7 +18,10 @@ export default function WorkspaceTrackingSettingsPage() {
>
<PageWidthWrapper className="pb-20">
<Suspense>
- <WorkspaceTrackingSettingsPageClient />
+ <div className="flex flex-1 flex-col gap-8 overflow-hidden">
+ <ConfigureTrackingSection />
+ <InstallationSection />
+ </div>
</Suspense>
</PageWidthWrapper>
</PageContent>
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/publishable-key-field.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/publishable-key-field.tsx
index 8e5e52add1..0045ab17d6 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/publishable-key-field.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/publishable-key-field.tsx
@@ -7,7 +7,7 @@ import {
EmptyTrackingCard,
emptyTrackingActionClassName,
} from "./empty-tracking-card";
-import PublishableKeyMenu from "./publishable-key-menu";
+import { PublishableKeyMenu } from "./publishable-key-menu";
export function PublishableKeyField({
publishableKey,
@@ -69,10 +69,7 @@ export function PublishableKeyField({
className="h-7 w-fit shrink-0 px-2.5"
textWrapperClassName="overflow-visible"
/>
- <PublishableKeyMenu
- onRevoke={() => setShowRevokeModal(true)}
- loading={false}
- />
+ <PublishableKeyMenu onRevoke={() => setShowRevokeModal(true)} />
</div>
</div>
) : (
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/publishable-key-menu.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/publishable-key-menu.tsx
index aee9f14598..3a1e0ee049 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/publishable-key-menu.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/publishable-key-menu.tsx
@@ -3,14 +3,7 @@ import { Button, Popover } from "@dub/ui";
import { Delete } from "lucide-react";
import { useState } from "react";
-function PublishableKeyMenu({
- onRevoke,
- loading,
-}: {
- onRevoke: () => void;
- loading: boolean;
- permissionsError?: string;
-}) {
+export function PublishableKeyMenu({ onRevoke }: { onRevoke: () => void }) {
const [openPopover, setOpenPopover] = useState(false);
return (
@@ -27,7 +20,6 @@ function PublishableKeyMenu({
}}
icon={<Delete className="h-4 w-4" />}
className="h-9 justify-start px-2 font-medium"
- loading={loading}
/>
</div>
</div>
@@ -47,5 +39,3 @@ function PublishableKeyMenu({
</Popover>
);
}
-
-export default PublishableKeyMenu;
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/setup-instructions.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/setup-instructions.tsx
index 5a4ba6bd5f..b06ce1e45b 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/setup-instructions.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/setup-instructions.tsx
@@ -16,21 +16,6 @@ import {
import { cn } from "@dub/utils";
import Link from "next/link";
-const FALLBACK_DEVELOPER_GUIDES = [
- {
- title: "Client-side SDK install guide",
- href: "https://dub.co/docs/sdks/client-side",
- },
- {
- title: "Tracking lead events",
- href: "https://dub.co/docs/conversions/leads/introduction",
- },
- {
- title: "Tracking sale events",
- href: "https://dub.co/docs/conversions/sales/introduction",
- },
-];
-
const OPEN_IN_APPS = [
{
id: "claude",
@@ -117,21 +102,11 @@ function StepIcon({ step }: { step: TrackingSetupStep }) {
return <Icon className="size-5 shrink-0" />;
}
-export function isSetupInstructionsReady(
- stack: string[],
- hasHostname: boolean,
-) {
- return stack.length > 0 && hasHostname;
-}
-
-export function DeveloperGuides({ steps }: { steps?: TrackingSetupStep[] }) {
- const guides =
- steps && steps.length > 0
- ? steps.map((step) => ({
- title: step.label,
- href: step.url,
- }))
- : FALLBACK_DEVELOPER_GUIDES;
+export function DeveloperGuides({ steps }: { steps: TrackingSetupStep[] }) {
+ const guides = steps.map((step) => ({
+ title: step.label,
+ href: step.url,
+ }));
return (
<div className="flex flex-col gap-1.5">
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/site-visit-tracking-field.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/site-visit-tracking-field.tsx
index 4d210cb47d..117c1819ed 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/site-visit-tracking-field.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/site-visit-tracking-field.tsx
@@ -10,6 +10,7 @@ import {
LoadingSpinner,
Popover,
Sitemap,
+ Switch,
} from "@dub/ui";
import { Trash } from "@dub/ui/icons";
import { cn, formatDate } from "@dub/utils";
@@ -19,8 +20,12 @@ import { useState } from "react";
import { toast } from "sonner";
import { useAddSitemapModal } from "./add-sitemap-modal";
import { EmptyTrackingCard } from "./empty-tracking-card";
-import { EnableSwitch } from "./enable-switch";
-import { TrackedSitemapDraft } from "./tracking-form";
+
+export type TrackedSitemapDraft = {
+ url: string;
+ lastCrawledAt?: string;
+ lastUrlCount?: number;
+};
export function SiteVisitTrackingField({
enabled,
@@ -135,15 +140,20 @@ export function SiteVisitTrackingField({
return (
<>
<div className="flex flex-col">
- <EnableSwitch
- checked={enabled}
- onChange={(next) => {
- setShouldAnimateHeight(true);
- onEnabledChange(next);
- }}
- disabled={disabled}
- disabledTooltip={disabledTooltip}
- />
+ <label className="flex w-fit cursor-pointer items-center gap-2">
+ <Switch
+ checked={enabled}
+ fn={(next) => {
+ setShouldAnimateHeight(true);
+ onEnabledChange(next);
+ }}
+ disabled={disabled}
+ disabledTooltip={disabledTooltip}
+ />
+ <span className="text-content-default text-sm font-medium">
+ Enable
+ </span>
+ </label>
<AnimatedSizeContainer
height
@@ -180,9 +190,7 @@ export function SiteVisitTrackingField({
{sitemaps.length === 0 ? (
<EmptyTrackingCard
variant="stack"
- icon={
- <Sitemap className="size-[18px] text-neutral-500" />
- }
+ icon={<Sitemap className="size-[18px] text-neutral-500" />}
text="No site maps added"
action={
<Button
@@ -190,9 +198,7 @@ export function SiteVisitTrackingField({
variant="secondary"
className="h-8 w-fit px-2.5 active:scale-[0.97]"
onClick={() => setShowAddSitemapModal(true)}
- disabled={
- disabled || Boolean(addSitemapDisabledReason)
- }
+ disabled={disabled || Boolean(addSitemapDisabledReason)}
disabledTooltip={addSitemapDisabledReason}
/>
}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/stack-picker.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/stack-picker.tsx
index ac4e1bd8a8..de41f373a3 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/stack-picker.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/stack-picker.tsx
@@ -94,7 +94,7 @@ export function StackPicker({
onClick={() => toggleItem(item.id)}
className={cn(
"relative flex h-[42px] items-center gap-2.5 rounded-lg border p-2 text-left transition-[border-color,background-color,transform] duration-150 ease-out",
- "focus-visible:ring-2 focus-visible:ring-black/50 focus-visible:outline-none",
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-black/50",
"active:scale-[0.98]",
selected
? "border-neutral-600 bg-neutral-50"
@@ -104,7 +104,10 @@ export function StackPicker({
disabled && "cursor-not-allowed opacity-50",
)}
>
- <StackItemIcon icon={item.icon} fullSize={item.iconProps?.fullSize} />
+ <StackItemIcon
+ icon={item.icon}
+ fullSize={item.iconProps?.fullSize}
+ />
<StackItemTitle title={item.title} />
</button>
);
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/tracking-form.ts b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/tracking-form.ts
deleted file mode 100644
index cbdd0982ef..0000000000
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/tracking-form.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-export type TrackedSitemapDraft = {
- url: string;
- lastCrawledAt?: string;
- lastUrlCount?: number;
-};
-
-export type TrackingFormData = {
- stack: string[];
- allowedHostnames: string[];
- publishableKey: string | null;
- siteVisitTrackingEnabled: boolean;
- siteDomainSlug: string;
- trackedSitemaps: TrackedSitemapDraft[];
- outboundDomainTrackingEnabled: boolean;
-};
-
-export const emptyTrackingFormValues: TrackingFormData = {
- stack: [],
- allowedHostnames: [],
- publishableKey: null,
- siteVisitTrackingEnabled: false,
- siteDomainSlug: "",
- trackedSitemaps: [],
- outboundDomainTrackingEnabled: false,
-};
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/tracking-settings-row.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/tracking-settings-row.tsx
index 8a81ba2028..28e795ca75 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/tracking-settings-row.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/tracking-settings-row.tsx
@@ -9,28 +9,25 @@ export function TrackingSettingsRow({
leftExtraAlign = "start",
align = "start",
children,
- className,
}: PropsWithChildren<{
heading: string;
description: string;
leftExtra?: ReactNode;
leftExtraAlign?: "start" | "end";
align?: "start" | "center";
- className?: string;
}>) {
return (
<div
className={cn(
"grid grid-cols-1 gap-10 p-6 sm:grid-cols-2",
align === "center" && "sm:items-center",
- className,
)}
>
<div className="flex h-full min-w-0 flex-col gap-1">
<h3 className="text-content-emphasis text-base font-semibold leading-6 tracking-[-0.02em]">
{heading}
</h3>
- <MarkdownDescription className="text-content-subtle text-sm font-normal leading-5 tracking-[-0.02em] [&_a]:text-content-subtle [&_a]:decoration-solid [&_a]:underline-offset-auto">
+ <MarkdownDescription className="text-content-subtle [&_a]:text-content-subtle text-sm font-normal leading-5 tracking-[-0.02em] [&_a]:decoration-solid [&_a]:underline-offset-auto">
{description}
</MarkdownDescription>
{leftExtra && (
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/use-dynamic-guide.ts b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/use-dynamic-guide.ts
deleted file mode 100644
index 4ea15a1719..0000000000
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/use-dynamic-guide.ts
+++ /dev/null
@@ -1,167 +0,0 @@
-import useGuide from "@/lib/swr/use-guide";
-import useProgram from "@/lib/swr/use-program";
-import useWorkspace from "@/lib/swr/use-workspace";
-import { useWorkspaceStore } from "@/lib/swr/use-workspace-store";
-import { useMemo } from "react";
-import { SWRConfiguration } from "swr";
-
-export function useDynamicGuide(
- { guide }: { guide: string },
- swrOpts?: SWRConfiguration,
-) {
- const { guideMarkdown: guideMarkdownRaw, error } = useGuide(guide, swrOpts);
-
- const { publishableKey } = useWorkspace();
- const { program } = useProgram();
-
- const [siteVisitTrackingEnabled] = useWorkspaceStore<boolean>(
- "analyticsSettingsSiteVisitTrackingEnabled",
- );
- const [domainTrackingEnabled] = useWorkspaceStore<boolean>(
- "analyticsSettingsOutboundDomainTrackingEnabled",
- );
- const [conversionTrackingEnabled] = useWorkspaceStore<boolean>(
- "analyticsSettingsConversionTrackingEnabled",
- );
-
- const guideMarkdown = useMemo(() => {
- let result = guideMarkdownRaw;
-
- if (program?.domain)
- result = result?.replaceAll(/yourcompany\.link/g, program.domain);
-
- const scriptComponents = [
- siteVisitTrackingEnabled ? "site-visit" : null,
- domainTrackingEnabled ? "outbound-domains" : null,
- conversionTrackingEnabled ? "conversion-tracking" : null,
- ]
- .filter(Boolean)
- .join(".");
-
- if (scriptComponents.length)
- result = result?.replaceAll(
- /https\:\/\/www.dubcdn.com\/analytics\/script.js/g,
- `https://www.dubcdn.com/analytics/script.${scriptComponents}.js`,
- );
-
- if (result) {
- // Store original result for context checks
- const originalResult = result;
-
- result = result
- // for manual installations - add data-publishable-key after src attribute
- .replaceAll(
- /(<script[\s\S]*?)(src="https:\/\/www\.dubcdn\.com\/analytics\/script[^"]+")([\s\S]*?)(>)/g,
- (match, beforeSrc, srcAttr, afterSrc, closingTag) => {
- if (match.includes("data-publishable-key")) return match;
-
- // Find src line in original to get indentation
- const originalLines = originalResult.split("\n");
- const srcLine =
- originalLines.find((line) => line.includes(srcAttr)) || "";
- const indent = srcLine.match(/^(\s*)/)?.[1] || " ";
-
- // Clean up other attributes
- const otherAttrs = afterSrc.replace(/>$/, "").trim();
-
- const domainsConfigParts = [
- ...(program ? [`"refer": "${program.domain}"`] : []),
- ...(domainTrackingEnabled
- ? [`"outbound": ["example.com", "example.sh"]`]
- : []),
- ].join(`, `);
- const parts = [
- ...(publishableKey
- ? [`data-publishable-key="${publishableKey}"`]
- : []),
- ...(domainsConfigParts
- ? [`data-domains='{${domainsConfigParts}}'`]
- : []),
- ].join(`\n${indent}`);
-
- // Return: before src, src, publishable-key, other attrs, closing tag
- return `${beforeSrc}${srcAttr}${parts ? `\n${indent}${parts}` : ""}${otherAttrs ? `\n${indent}${otherAttrs}` : ""}\n${closingTag}`;
- },
- )
- // for React applications - add publishableKey prop after <DubAnalytics
- .replaceAll(
- /^(\s+)(<DubAnalytics)(\s*\/?>|\s+[^\n>]*\/?>|)$/gm,
- (match, indent, tag, rest) => {
- if (match.includes("publishableKey")) return match;
- // Check context for multiline case
- if (rest === "") {
- const idx = originalResult.indexOf(match);
- if (idx >= 0) {
- const context = originalResult.substring(idx, idx + 300);
- if (context.includes("publishableKey")) return match;
- }
- }
-
- const domainsConfigParts = [
- ...(program ? [`refer: "${program.domain}"`] : []),
- ...(domainTrackingEnabled
- ? [`outbound: ["example.com", "example.sh"]`]
- : []),
- ].join(`,\n${indent} `);
- const parts = [
- ...(publishableKey ? [`publishableKey="${publishableKey}"`] : []),
- ...(domainsConfigParts
- ? [
- `domainsConfig={{\n${indent} ${domainsConfigParts}\n${indent} }}`,
- ]
- : []),
- ].join(`\n ${indent}`);
-
- return `${indent}${tag}${parts ? `\n${indent} ${parts}` : ""}${rest}`;
- },
- )
- // for GTM installations - add data-publishable-key after script.src
- .replaceAll(
- /^(\s+)(s\.src\s*=\s*"https:\/\/www\.dubcdn\.com\/analytics\/script[^"]+";)$/gm,
- (match, indent, srcLine) => {
- const idx = originalResult.indexOf(match);
- if (idx >= 0) {
- const context = originalResult.substring(idx, idx + 200);
- if (context.includes("data-publishable-key")) return match;
- }
-
- const domainsConfigParts = [
- ...(program ? [`"refer": "${program.domain}"`] : []),
- ...(domainTrackingEnabled
- ? [`"outbound": ["example.com", "example.sh"]`]
- : []),
- ].join(`, `);
- const parts = [
- ...(publishableKey
- ? [
- `s.setAttribute("data-publishable-key", "${publishableKey}");`,
- ]
- : []),
- ...(domainsConfigParts
- ? [
- `s.dataset.domains = JSON.stringify({${domainsConfigParts}});`,
- ]
- : []),
- ].join(`\n${indent}`);
-
- return `${indent}${srcLine}${parts ? `\n${indent}${parts}` : ""}`;
- },
- );
- }
-
- return result;
- }, [
- guideMarkdownRaw,
- program,
- siteVisitTrackingEnabled,
- domainTrackingEnabled,
- conversionTrackingEnabled,
- publishableKey,
- ]);
-
- return {
- guideMarkdown,
- error,
- loading: !guideMarkdown && !error,
- };
-}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/verify-install.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/verify-install.tsx
index e59d261f1c..5ebd406654 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/verify-install.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/tracking/verify-install.tsx
@@ -44,9 +44,7 @@ export function VerifyInstall({ hostnames }: { hostnames: string[] }) {
() =>
hostnames.map((hostname) => ({
value: hostname,
- label: hostname.startsWith("*.")
- ? hostname
- : toVerifySiteUrl(hostname),
+ label: hostname.startsWith("*.") ? hostname : toVerifySiteUrl(hostname),
icon: <Globe className="size-4 text-neutral-600" />,
})),
[hostnames],
@@ -169,7 +167,9 @@ export function VerifyInstall({ hostnames }: { hostnames: string[] }) {
}}
className="size-4 border-neutral-200"
/>
- <span className="font-medium">{persistedForHostname.user.name}</span>
+ <span className="font-medium">
+ {persistedForHostname.user.name}
+ </span>
{timeAgo(new Date(persistedForHostname.verifiedAt), {
withAgo: true,
})}
@@ -180,7 +180,7 @@ export function VerifyInstall({ hostnames }: { hostnames: string[] }) {
{showButton && (
<Button
text="Verify installation"
- className="h-7 w-fit bg-bg-inverted px-2.5 text-sm font-medium tracking-[-0.02em] active:scale-[0.97]"
+ className="bg-bg-inverted h-7 w-fit px-2.5 text-sm font-medium tracking-[-0.02em] active:scale-[0.97]"
loading={isPending}
disabled={!workspaceId}
onClick={() => {
diff --git a/apps/web/lib/analytics/verify-installation.ts b/apps/web/lib/analytics/verify-installation.ts
index 2d6020be31..efe7352ecd 100644
--- a/apps/web/lib/analytics/verify-installation.ts
+++ b/apps/web/lib/analytics/verify-installation.ts
@@ -1,4 +1,4 @@
-export const VERIFY_ERROR_CODES = [
+const VERIFY_ERROR_CODES = [
"not_installed",
"missing_attributes",
"duplicate",
@@ -35,9 +35,7 @@ const ERROR_HEADLINE: Record<VerifyErrorCode | "unreachable", string> = {
export const VERIFY_DOCS_HREF = "https://dub.co/docs/sdks/client-side";
export const VERIFY_SUPPORT_HREF = "https://dub.co/support";
-export function getVerifyErrorHeadline(
- error: VerifyErrorCode | "unreachable",
-) {
+export function getVerifyErrorHeadline(error: VerifyErrorCode | "unreachable") {
return ERROR_HEADLINE[error];
}
diff --git a/apps/web/lib/tracking/build-tracking-setup.ts b/apps/web/lib/tracking/build-tracking-setup.ts
index a9e0c08b12..a5fe62574f 100644
--- a/apps/web/lib/tracking/build-tracking-setup.ts
+++ b/apps/web/lib/tracking/build-tracking-setup.ts
@@ -46,7 +46,7 @@ export type TrackingSetupStep = {
iconProps?: StackItem["iconProps"];
};
-export type BuildTrackingSetupInput = {
+type BuildTrackingSetupInput = {
stack: string[];
hostnames: string[];
publishableKey: string | null;
@@ -90,9 +90,7 @@ function toStep(
};
}
-export function resolveTrackingSetupSteps(
- stack: string[],
-): TrackingSetupStep[] {
+function resolveTrackingSetupSteps(stack: string[]): TrackingSetupStep[] {
const selected = getSelectedStackItems(stack);
const steps: TrackingSetupStep[] = [];
@@ -130,13 +128,13 @@ export function resolveTrackingSetupSteps(
return steps;
}
-export function isReactOnlyClientStep(steps: TrackingSetupStep[]) {
+function isReactOnlyClientStep(steps: TrackingSetupStep[]) {
const clientSteps = steps.filter((step) => step.type === "client-sdk");
return clientSteps.length === 1 && clientSteps[0]?.guideKey === "react";
}
-export function getAnalyticsScriptUrl({
+function getAnalyticsScriptUrl({
siteVisitEnabled,
outboundEnabled,
publishableKey,
@@ -157,7 +155,7 @@ export function getAnalyticsScriptUrl({
return `https://www.dubcdn.com/analytics/script.${segments.join(".")}.js`;
}
-export function composeTrackingSetupPrompt({
+function composeTrackingSetupPrompt({
steps,
hostnames,
publishableKey,