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.

Allow deepview customization + improve domain modal

Steven Tey93d9830ae085
diff --git a/apps/web/app/api/domains/[domain]/route.ts b/apps/web/app/api/domains/[domain]/route.ts
index 6f9b1b1914..5e55cae47f 100644
--- a/apps/web/app/api/domains/[domain]/route.ts
+++ b/apps/web/app/api/domains/[domain]/route.ts
@@ -60,6 +60,7 @@ export const PATCH = withWorkspace(
archived,
assetLinks,
appleAppSiteAssociation,
+ deepviewData,
autoRenew,
} = await extendedUpdateDomainBodySchema.parseAsync(
await parseRequestBody(req),
@@ -71,15 +72,17 @@ export const PATCH = withWorkspace(
expiredUrl ||
notFoundUrl ||
assetLinks ||
- appleAppSiteAssociation
+ appleAppSiteAssociation ||
+ deepviewData
) {
const proFeaturesString = combineWords(
[
logo && "custom QR code logos",
expiredUrl && "default expiration URLs",
notFoundUrl && "not found URLs",
- assetLinks && "asset links",
+ assetLinks && "Asset Links",
appleAppSiteAssociation && "Apple App Site Association",
+ deepviewData && "Deep View",
].filter(Boolean) as string[],
);
@@ -140,6 +143,7 @@ export const PATCH = withWorkspace(
appleAppSiteAssociation: appleAppSiteAssociation
? JSON.parse(appleAppSiteAssociation)
: null,
+ deepviewData: deepviewData ? JSON.parse(deepviewData) : null,
},
include: {
registeredDomain: true,
diff --git a/apps/web/app/api/domains/route.ts b/apps/web/app/api/domains/route.ts
index dfdf085596..210d35a81b 100644
--- a/apps/web/app/api/domains/route.ts
+++ b/apps/web/app/api/domains/route.ts
@@ -97,6 +97,7 @@ export const POST = withWorkspace(
placeholder,
assetLinks,
appleAppSiteAssociation,
+ deepviewData,
} = await createDomainBodySchema.parseAsync(body);
if (workspace.plan === "free") {
@@ -105,15 +106,17 @@ export const POST = withWorkspace(
expiredUrl ||
notFoundUrl ||
assetLinks ||
- appleAppSiteAssociation
+ appleAppSiteAssociation ||
+ deepviewData
) {
const proFeaturesString = combineWords(
[
logo && "custom QR code logos",
expiredUrl && "default expiration URLs",
notFoundUrl && "not found URLs",
- assetLinks && "asset links",
+ assetLinks && "Asset Links",
appleAppSiteAssociation && "Apple App Site Association",
+ deepviewData && "Deep View",
].filter(Boolean) as string[],
);
@@ -180,6 +183,9 @@ export const POST = withWorkspace(
...(appleAppSiteAssociation && {
appleAppSiteAssociation: JSON.parse(appleAppSiteAssociation),
}),
+ ...(deepviewData && {
+ deepviewData: JSON.parse(deepviewData),
+ }),
},
});
},
diff --git a/apps/web/app/app.dub.co/(deeplink)/deeplink/[domain]/[key]/page.tsx b/apps/web/app/app.dub.co/(deeplink)/deeplink/[domain]/[key]/page.tsx
index 037c36e8a5..1afd118851 100644
--- a/apps/web/app/app.dub.co/(deeplink)/deeplink/[domain]/[key]/page.tsx
+++ b/apps/web/app/app.dub.co/(deeplink)/deeplink/[domain]/[key]/page.tsx
@@ -1,3 +1,4 @@
+import { deepViewDataSchema } from "@/lib/zod/schemas/deep-links";
import { prisma } from "@dub/prisma";
import { Grid, Wordmark } from "@dub/ui";
import { ArrowRight, Copy, IOSAppStore, MobilePhone } from "@dub/ui/icons";
@@ -29,6 +30,7 @@ export default async function DeepLinkPreviewPage({
shortDomain: {
select: {
appleAppSiteAssociation: true,
+ deepviewData: true,
},
},
},
@@ -39,9 +41,11 @@ export default async function DeepLinkPreviewPage({
redirect(`https://${domain}`);
}
- // if the link domain doesn't have an AASA file configured,
+ const deepViewData = deepViewDataSchema.parse(link.shortDomain.deepviewData);
+
+ // if the link domain doesn't have an AASA file configured (or deepviewData is null)
// we skip the deep link preview and redirect to the link's URL
- if (!link.shortDomain.appleAppSiteAssociation) {
+ if (!link.shortDomain.appleAppSiteAssociation || !deepViewData) {
redirect(link.ios ?? link.url);
}
diff --git a/apps/web/lib/api/domains/transform-domain.ts b/apps/web/lib/api/domains/transform-domain.ts
index ed21e18292..f54daf31c0 100644
--- a/apps/web/lib/api/domains/transform-domain.ts
+++ b/apps/web/lib/api/domains/transform-domain.ts
@@ -16,5 +16,8 @@ export const transformDomain = (
appleAppSiteAssociation: domain.appleAppSiteAssociation
? JSON.stringify(domain.appleAppSiteAssociation)
: null,
+ deepviewData: domain.deepviewData
+ ? JSON.stringify(domain.deepviewData)
+ : null,
});
};
diff --git a/apps/web/lib/types.ts b/apps/web/lib/types.ts
index 1d395eda21..a06811d0d1 100644
--- a/apps/web/lib/types.ts
+++ b/apps/web/lib/types.ts
@@ -244,6 +244,7 @@ export interface DomainProps {
logo?: string;
appleAppSiteAssociation?: string;
assetLinks?: string;
+ deepviewData?: string;
link?: LinkProps;
registeredDomain?: RegisteredDomainProps;
}
diff --git a/apps/web/lib/zod/schemas/deep-links.ts b/apps/web/lib/zod/schemas/deep-links.ts
new file mode 100644
index 0000000000..1c5beb7a51
--- /dev/null
+++ b/apps/web/lib/zod/schemas/deep-links.ts
@@ -0,0 +1,8 @@
+import z from "@/lib/zod";
+
+export const deepViewDataSchema = z
+ .object({
+ ios: z.any(),
+ android: z.any(),
+ })
+ .nullish();
diff --git a/apps/web/lib/zod/schemas/domains.ts b/apps/web/lib/zod/schemas/domains.ts
index 2e6969636f..1e2fd5a0c6 100644
--- a/apps/web/lib/zod/schemas/domains.ts
+++ b/apps/web/lib/zod/schemas/domains.ts
@@ -5,7 +5,7 @@ import {
getPaginationQuerySchema,
uploadedImageSchema,
} from "./misc";
-import { parseUrlSchemaAllowEmpty } from "./utils";
+import { parseJsonSchema, parseUrlSchemaAllowEmpty } from "./utils";
export const RegisteredDomainSchema = z.object({
id: z.string().describe("The ID of the registered domain record."),
@@ -57,6 +57,7 @@ export const DomainSchema = z.object({
"The URL to redirect to when a link under this domain doesn't exist.",
)
.openapi({ example: "https://acme.com/not-found" }),
+ logo: z.string().nullable().describe("The logo of the domain."),
assetLinks: z
.string()
.nullable()
@@ -71,7 +72,10 @@ export const DomainSchema = z.object({
.describe(
"apple-app-site-association configuration file (for deep link support on iOS).",
),
- logo: z.string().nullable().describe("The logo of the domain."),
+ deepviewData: z
+ .string()
+ .nullish()
+ .describe("The deepview data of the domain."),
createdAt: z.date().describe("The date the domain was created."),
updatedAt: z.date().describe("The date the domain was last updated."),
registeredDomain: RegisteredDomainSchema.nullable().describe(
@@ -150,17 +154,21 @@ export const createDomainBodySchema = z.object({
.openapi({ example: "https://dub.co/help/article/what-is-dub" }),
logo: uploadedImageSchema.nullish().describe("The logo of the domain."),
assetLinks: z
- .string()
+ .preprocess(parseJsonSchema, z.string())
.nullish()
.describe(
"assetLinks.json configuration file (for deep link support on Android).",
),
appleAppSiteAssociation: z
- .string()
+ .preprocess(parseJsonSchema, z.string())
.nullish()
.describe(
"apple-app-site-association configuration file (for deep link support on iOS).",
),
+ deepviewData: z
+ .preprocess(parseJsonSchema, z.string())
+ .nullish()
+ .describe("The deepview data of the domain."),
});
export const updateDomainBodySchema = createDomainBodySchema.partial();
diff --git a/apps/web/lib/zod/schemas/utils.ts b/apps/web/lib/zod/schemas/utils.ts
index f8d783dec5..69f1489484 100644
--- a/apps/web/lib/zod/schemas/utils.ts
+++ b/apps/web/lib/zod/schemas/utils.ts
@@ -1,5 +1,6 @@
import z from "@/lib/zod";
import { getUrlFromString, isValidUrl, parseDateTime } from "@dub/utils";
+import { ZodIssueCode } from "zod";
export const parseUrlSchema = z
.string()
@@ -32,3 +33,18 @@ export const parseDateSchema = z
.string()
.transform((v) => parseDateTime(v))
.refine((v) => !!v, { message: "Invalid date" });
+
+export const parseJsonSchema = (value: any, ctx: z.RefinementCtx) => {
+ if (typeof value === "string") {
+ try {
+ return JSON.parse(value);
+ } catch (e) {
+ ctx.addIssue({
+ code: ZodIssueCode.custom,
+ message: (e as Error).message,
+ });
+ }
+ }
+
+ return value;
+};
diff --git a/apps/web/scripts/migrations/backfill-deepview.ts b/apps/web/scripts/migrations/backfill-deepview.ts
new file mode 100644
index 0000000000..09ea20e5e7
--- /dev/null
+++ b/apps/web/scripts/migrations/backfill-deepview.ts
@@ -0,0 +1,25 @@
+import { prisma } from "@dub/prisma";
+import { Prisma } from "@prisma/client";
+import "dotenv-flow/config";
+
+async function main() {
+ const domains = await prisma.domain.findMany({
+ where: {
+ deepviewData: {
+ equals: Prisma.AnyNull,
+ },
+ },
+ take: 1000,
+ });
+
+ const deepviewData = await prisma.domain.updateMany({
+ where: {
+ id: { in: domains.map((domain) => domain.id) },
+ },
+ data: { deepviewData: {} },
+ });
+
+ console.log(deepviewData);
+}
+
+main();
diff --git a/apps/web/ui/domains/add-edit-domain-form.tsx b/apps/web/ui/domains/add-edit-domain-form.tsx
index a97e2e07f4..49e9a0b34b 100644
--- a/apps/web/ui/domains/add-edit-domain-form.tsx
+++ b/apps/web/ui/domains/add-edit-domain-form.tsx
@@ -14,9 +14,11 @@ import {
FileUpload,
InfoTooltip,
LoadingSpinner,
+ MobilePhone,
ShimmerDots,
SimpleTooltipContent,
Switch,
+ useEnterSubmit,
useMediaQuery,
} from "@dub/ui";
import { cn } from "@dub/utils";
@@ -30,7 +32,7 @@ import {
TextCursorInput,
} from "lucide-react";
import posthog from "posthog-js";
-import { useEffect, useMemo, useState } from "react";
+import { useEffect, useMemo, useRef, useState } from "react";
import { Controller, useForm } from "react-hook-form";
import { toast } from "sonner";
import { useDebouncedCallback } from "use-debounce";
@@ -103,12 +105,10 @@ export function AddEditDomainForm({
props,
onSuccess,
enableDomainConfig = true,
- className,
}: {
props?: DomainProps;
onSuccess?: (data: DomainProps) => void;
enableDomainConfig?: boolean;
- className?: string;
}) {
const { id: workspaceId, plan } = useWorkspace();
const [lockDomain, setLockDomain] = useState(true);
@@ -138,6 +138,9 @@ export function AddEditDomainForm({
? formatJson(props.appleAppSiteAssociation)
: undefined,
assetLinks: props?.assetLinks ? formatJson(props.assetLinks) : undefined,
+ deepviewData: props?.deepviewData
+ ? formatJson(props.deepviewData)
+ : undefined,
},
});
@@ -150,6 +153,13 @@ export function AddEditDomainForm({
assetLinks: !!props?.assetLinks?.trim(),
}));
}
+
+ if (props?.deepviewData) {
+ setShowOptionStates((prev) => ({
+ ...prev,
+ deepviewData: !!props?.deepviewData?.trim(),
+ }));
+ }
}, [props]);
useEffect(() => {
@@ -161,6 +171,7 @@ export function AddEditDomainForm({
expiredUrl: false,
notFoundUrl: false,
placeholder: false,
+ deepviewData: false,
...prev,
}));
}, []);
@@ -205,6 +216,9 @@ export function AddEditDomainForm({
const isDubProvisioned = !!props?.registeredDomain;
+ const formRef = useRef<HTMLFormElement>(null);
+ const { handleKeyDown } = useEnterSubmit(formRef);
+
const onSubmit = async (formData: FormData) => {
try {
const res = await fetch(endpoint.url, {
@@ -223,6 +237,9 @@ export function AddEditDomainForm({
formData.appleAppSiteAssociation,
),
}),
+ ...(formData.deepviewData && {
+ deepviewData: sanitizeJson(formData.deepviewData),
+ }),
}),
});
@@ -259,321 +276,335 @@ export function AddEditDomainForm({
const currentStatusProps = STATUS_CONFIG[domainStatus];
return (
- <form
- onSubmit={handleSubmit(onSubmit)}
- className={cn("flex flex-col gap-y-6 text-left", className)}
- >
- <div>
- <div className="flex items-center justify-between">
- <label htmlFor="domain" className="flex items-center gap-x-2">
- <h2 className="text-sm font-medium text-neutral-700">
- Your domain
- </h2>
- <InfoTooltip
- content={
- <SimpleTooltipContent
- title="Not sure which domain to use?"
- cta="Check out our guide"
- href="https://dub.co/help/article/choosing-a-custom-domain"
- />
- }
- />
- </label>
- {props && lockDomain && !isDubProvisioned && (
- <button
- className="flex items-center gap-x-2 text-sm text-neutral-500 transition-all duration-75 hover:text-black active:scale-95"
- type="button"
- onClick={() => {
- window.confirm(
- "Warning: Changing your workspace's domain will break all existing short links. Are you sure you want to continue?",
- ) && setLockDomain(false);
- }}
- >
- <Lock className="h-3 w-3" />
- <p>Unlock</p>
- </button>
- )}
- </div>
- {props && lockDomain ? (
- <div className="mt-2 cursor-not-allowed rounded-md border border-neutral-300 bg-neutral-100 px-3 py-2 text-sm text-neutral-500 shadow-sm">
- {domain}
+ <form ref={formRef} onSubmit={handleSubmit(onSubmit)}>
+ <div
+ className={cn(
+ "flex flex-col gap-y-6 text-left",
+ enableDomainConfig && "p-8",
+ )}
+ >
+ <div>
+ <div className="flex items-center justify-between">
+ <label htmlFor="domain" className="flex items-center gap-x-2">
+ <h2 className="text-sm font-medium text-neutral-700">
+ Your domain
+ </h2>
+ <InfoTooltip
+ content={
+ <SimpleTooltipContent
+ title="Not sure which domain to use?"
+ cta="Check out our guide"
+ href="https://dub.co/help/article/choosing-a-custom-domain"
+ />
+ }
+ />
+ </label>
+ {props && lockDomain && !isDubProvisioned && (
+ <button
+ className="flex items-center gap-x-2 text-sm text-neutral-500 transition-all duration-75 hover:text-black active:scale-95"
+ type="button"
+ onClick={() => {
+ window.confirm(
+ "Warning: Changing your workspace's domain will break all existing short links. Are you sure you want to continue?",
+ ) && setLockDomain(false);
+ }}
+ >
+ <Lock className="h-3 w-3" />
+ <p>Unlock</p>
+ </button>
+ )}
</div>
- ) : (
- <div className="mt-2">
- <div
- className={cn(
- "-m-1 rounded-[0.625rem] p-1",
- currentStatusProps.className ||
- "bg-neutral-200 text-neutral-500",
- )}
- >
- <div className="flex rounded-md border border-neutral-300 bg-white">
- <input
- {...register("slug", {
- onChange: (e) => {
- setDomainStatus("idle");
- debouncedValidateDomain(e.target.value);
- },
- })}
- className="block w-full rounded-md border-0 text-neutral-900 placeholder-neutral-400 focus:outline-none focus:ring-0 sm:text-sm"
- placeholder="go.acme.com"
- autoFocus={!isMobile}
- />
- </div>
-
- <AnimatedSizeContainer
- height
- transition={{ ease: "easeInOut", duration: 0.1 }}
+ {props && lockDomain ? (
+ <div className="mt-2 cursor-not-allowed rounded-md border border-neutral-300 bg-neutral-100 px-3 py-2 text-sm text-neutral-500 shadow-sm">
+ {domain}
+ </div>
+ ) : (
+ <div className="mt-2">
+ <div
+ className={cn(
+ "-m-1 rounded-[0.625rem] p-1",
+ currentStatusProps.className ||
+ "bg-neutral-200 text-neutral-500",
+ )}
>
- <div className="flex items-center justify-between gap-4 p-2 text-sm">
- <p>
- {domainStatus !== "idle" ? (
- <>
- {currentStatusProps.prefix || "The domain"}{" "}
- {currentStatusProps.useStrong ? (
- <strong className="font-semibold underline underline-offset-2">
- {domain}
- </strong>
- ) : (
- <span className="font-semibold underline underline-offset-2">
- {domain}
- </span>
- )}{" "}
- {currentStatusProps.suffix}
- </>
- ) : (
- currentStatusProps.message
- )}
- </p>
- {currentStatusProps.icon && (
- <currentStatusProps.icon className="size-5 shrink-0" />
- )}
+ <div className="flex rounded-md border border-neutral-300 bg-white">
+ <input
+ {...register("slug", {
+ onChange: (e) => {
+ setDomainStatus("idle");
+ debouncedValidateDomain(e.target.value);
+ },
+ })}
+ className="block w-full rounded-md border-0 text-neutral-900 placeholder-neutral-400 focus:outline-none focus:ring-0 sm:text-sm"
+ placeholder="go.acme.com"
+ autoFocus={!isMobile}
+ />
</div>
- </AnimatedSizeContainer>
+
+ <AnimatedSizeContainer
+ height
+ transition={{ ease: "easeInOut", duration: 0.1 }}
+ >
+ <div className="flex items-center justify-between gap-4 p-2 text-sm">
+ <p>
+ {domainStatus !== "idle" ? (
+ <>
+ {currentStatusProps.prefix || "The domain"}{" "}
+ {currentStatusProps.useStrong ? (
+ <strong className="font-semibold underline underline-offset-2">
+ {domain}
+ </strong>
+ ) : (
+ <span className="font-semibold underline underline-offset-2">
+ {domain}
+ </span>
+ )}{" "}
+ {currentStatusProps.suffix}
+ </>
+ ) : (
+ currentStatusProps.message
+ )}
+ </p>
+ {currentStatusProps.icon && (
+ <currentStatusProps.icon className="size-5 shrink-0" />
+ )}
+ </div>
+ </AnimatedSizeContainer>
+ </div>
</div>
- </div>
- )}
- </div>
+ )}
+ </div>
- {enableDomainConfig && (
- <>
- <div className="h-0.5 w-full bg-neutral-200" />
- <div className="flex flex-col gap-y-6">
- {DOMAIN_OPTIONS.map(
- ({ id, title, description, icon: Icon, proFeature }) => {
- const showOption = showOptionStates[id] || !!watch(id);
-
- return (
- <div key={id}>
- <label className="flex items-center justify-between gap-4">
- <div className="flex items-center gap-3">
- <div className="hidden rounded-lg border border-neutral-200 bg-white p-2 sm:block">
- <Icon className="size-5 text-neutral-500" />
- </div>
- <div>
- <div className="flex items-center gap-2">
- <h2 className="text-sm font-medium text-neutral-900">
- {title}
- </h2>
- {proFeature && plan === "free" && (
- <Badge className="flex items-center space-x-1 bg-white">
- <Crown size={12} />
- <p className="uppercase">Pro</p>
- </Badge>
- )}
+ {enableDomainConfig && (
+ <>
+ <div className="h-0.5 w-full bg-neutral-200" />
+ <div className="flex flex-col gap-y-6">
+ {DOMAIN_OPTIONS.map(
+ ({ id, title, description, icon: Icon, proFeature }) => {
+ const showOption = showOptionStates[id] || !!watch(id);
+
+ return (
+ <div key={id}>
+ <label className="flex items-center justify-between gap-4">
+ <div className="flex items-center gap-3">
+ <div className="hidden rounded-lg border border-neutral-200 bg-white p-2 sm:block">
+ <Icon className="size-5 text-neutral-500" />
+ </div>
+ <div>
+ <div className="flex items-center gap-2">
+ <h2 className="text-sm font-medium text-neutral-900">
+ {title}
+ </h2>
+ {proFeature && plan === "free" && (
+ <Badge className="flex items-center space-x-1 bg-white">
+ <Crown size={12} />
+ <p className="uppercase">Pro</p>
+ </Badge>
+ )}
+ </div>
+ <p className="text-sm text-neutral-500">
+ {description}
+ </p>
</div>
- <p className="text-sm text-neutral-500">
- {description}
- </p>
</div>
- </div>
- <Switch
- checked={showOption}
- fn={(checked) => {
- setShowOptionStates((prev) => ({
- ...prev,
- [id]: checked,
- }));
- if (!checked) {
- setValue(id, "", {
- shouldDirty: true,
- });
- }
- }}
- disabled={isSubmitting}
- />
- </label>
- <motion.div
- animate={{ height: showOption ? "auto" : 0 }}
- transition={{ duration: 0.1 }}
- initial={false}
- className="-m-1 overflow-hidden p-1"
- {...{ inert: showOption ? undefined : "" }}
- >
- <div className="relative mt-2 rounded-md shadow-sm">
- {id === "logo" ? (
- <div className="flex h-24 items-center justify-center overflow-hidden rounded-md border border-neutral-300">
- {!isMobile && (
- <ShimmerDots className="pointer-events-none z-10 opacity-30 [mask-image:radial-gradient(40%_80%,transparent_50%,black)]" />
- )}
- <Controller
- control={control}
- name="logo"
- render={({ field }) => (
- <FileUpload
- accept="images"
- className="h-24 rounded-md"
- iconClassName="size-5 text-neutral-700"
- variant="plain"
- imageSrc={field.value}
- readFile
- onChange={({ src }) => field.onChange(src)}
- maxFileSizeMB={2}
- targetResolution={{
- width: 160,
- height: 160,
- }}
- customPreview={
- <QRCode
- url="https://dub.co"
- fgColor="#000"
- logo={field.value || ""}
- scale={0.6}
- />
- }
- />
+ <Switch
+ checked={showOption}
+ fn={(checked) => {
+ setShowOptionStates((prev) => ({
+ ...prev,
+ [id]: checked,
+ }));
+ if (!checked) {
+ setValue(id, "", {
+ shouldDirty: true,
+ });
+ }
+ }}
+ disabled={isSubmitting}
+ />
+ </label>
+ <motion.div
+ animate={{ height: showOption ? "auto" : 0 }}
+ transition={{ duration: 0.1 }}
+ initial={false}
+ className="-m-1 overflow-hidden p-1"
+ {...{ inert: showOption ? undefined : "" }}
+ >
+ <div className="relative mt-2 rounded-md shadow-sm">
+ {id === "logo" ? (
+ <div className="flex h-24 items-center justify-center overflow-hidden rounded-md border border-neutral-300">
+ {!isMobile && (
+ <ShimmerDots className="pointer-events-none z-10 opacity-30 [mask-image:radial-gradient(40%_80%,transparent_50%,black)]" />
)}
+ <Controller
+ control={control}
+ name="logo"
+ render={({ field }) => (
+ <FileUpload
+ accept="images"
+ className="h-24 rounded-md"
+ iconClassName="size-5 text-neutral-700"
+ variant="plain"
+ imageSrc={field.value}
+ readFile
+ onChange={({ src }) => field.onChange(src)}
+ maxFileSizeMB={2}
+ targetResolution={{
+ width: 160,
+ height: 160,
+ }}
+ customPreview={
+ <QRCode
+ url="https://dub.co"
+ fgColor="#000"
+ logo={field.value || ""}
+ scale={0.6}
+ />
+ }
+ />
+ )}
+ />
+ </div>
+ ) : (
+ <input
+ {...register(id)}
+ className="block w-full rounded-md border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm"
+ placeholder="https://yourwebsite.com"
/>
- </div>
- ) : (
- <input
- {...register(id)}
- className="block w-full rounded-md border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm"
- placeholder="https://yourwebsite.com"
- />
- )}
- </div>
- </motion.div>
- </div>
- );
- },
- )}
- </div>
+ )}
+ </div>
+ </motion.div>
+ </div>
+ );
+ },
+ )}
+ </div>
- <div className="flex flex-col">
- <button
- type="button"
- className="flex w-full items-center gap-2"
- onClick={() => setShowAdvancedOptions(!showAdvancedOptions)}
- >
- <p className="text-sm text-neutral-600">
- {showAdvancedOptions ? "Hide" : "Show"} advanced settings
- </p>
- <motion.div
- animate={{ rotate: showAdvancedOptions ? 180 : 0 }}
- className="text-neutral-600"
+ <div className="flex flex-col">
+ <button
+ type="button"
+ className="flex w-full items-center gap-2"
+ onClick={() => setShowAdvancedOptions(!showAdvancedOptions)}
>
- <ChevronDown className="size-4" />
- </motion.div>
- </button>
-
- <AnimatedSizeContainer height className="flex flex-col">
- {showAdvancedOptions &&
- ADVANCED_OPTIONS.map(
- ({ id, title, description, icon: Icon, proFeature }) => {
- return (
- <div key={id} className="mt-4 flex flex-col space-y-3">
- <div className="flex items-center justify-between">
- <div className="flex items-center gap-3">
- <div className="hidden rounded-lg border border-neutral-200 bg-white p-2 sm:block">
- <Icon className="size-5 text-neutral-500" />
- </div>
- <div>
- <div className="flex items-center gap-2">
- <h2 className="text-sm font-medium text-neutral-900">
- {title}
- </h2>
- {proFeature && plan === "free" && (
- <Badge className="flex items-center space-x-1 bg-white">
- <Crown size={12} />
- <p className="uppercase">Pro</p>
- </Badge>
- )}
+ <p className="text-sm text-neutral-600">
+ {showAdvancedOptions ? "Hide" : "Show"} advanced settings
+ </p>
+ <motion.div
+ animate={{ rotate: showAdvancedOptions ? 180 : 0 }}
+ className="text-neutral-600"
+ >
+ <ChevronDown className="size-4" />
+ </motion.div>
+ </button>
+
+ <AnimatedSizeContainer height className="flex flex-col">
+ {showAdvancedOptions &&
+ ADVANCED_OPTIONS.map(
+ ({ id, title, description, icon: Icon, proFeature }) => {
+ return (
+ <div key={id} className="mt-4 flex flex-col space-y-3">
+ <div className="flex items-center justify-between">
+ <div className="flex items-center gap-3">
+ <div className="hidden rounded-lg border border-neutral-200 bg-white p-2 sm:block">
+ <Icon className="size-5 text-neutral-500" />
+ </div>
+ <div>
+ <div className="flex items-center gap-2">
+ <h2 className="text-sm font-medium text-neutral-900">
+ {title}
+ </h2>
+ {proFeature && plan === "free" && (
+ <Badge className="flex items-center space-x-1 bg-white">
+ <Crown size={12} />
+ <p className="uppercase">Pro</p>
+ </Badge>
+ )}
+ </div>
+ <p className="text-sm text-neutral-500">
+ {description}
+ </p>
</div>
- <p className="text-sm text-neutral-500">
- {description}
- </p>
</div>
- </div>
- <Switch
- checked={showOptionStates[id]}
- fn={(checked: boolean) => {
- setShowOptionStates((prev) => ({
- ...prev,
- [id]: checked,
- }));
- if (!checked) {
- setValue(id, "", {
- shouldDirty: true,
- });
- }
- }}
- disabled={isSubmitting}
- />
- </div>
-
- {showOptionStates[id] && (
- <div className="rounded-md border border-neutral-200 bg-white">
- <textarea
- {...register(id)}
- className="w-full resize-none rounded-md border-0 bg-transparent px-3 py-2 font-mono text-xs text-neutral-700 focus:outline-none focus:ring-0"
- rows={4}
- spellCheck={false}
- onPaste={(e) => {
- if (
- [
- "appleAppSiteAssociation",
- "assetLinks",
- ].includes(id)
- ) {
- e.preventDefault();
- const pastedText =
- e.clipboardData.getData("text");
-
- try {
- const formattedJson = JSON.stringify(
- JSON.parse(pastedText),
- null,
- 2,
- );
- setValue(id, formattedJson, {
- shouldDirty: true,
- });
- } catch (err) {
- setValue(id, pastedText, {
- shouldDirty: true,
- });
- }
+ <Switch
+ checked={showOptionStates[id]}
+ fn={(checked: boolean) => {
+ setShowOptionStates((prev) => ({
+ ...prev,
+ [id]: checked,
+ }));
+ if (!checked) {
+ setValue(id, "", {
+ shouldDirty: true,
+ });
}
}}
+ disabled={isSubmitting}
/>
</div>
- )}
- </div>
- );
- },
- )}
- </AnimatedSizeContainer>
- </div>
- </>
- )}
-
- <Button
- text={props ? "Save changes" : "Add domain"}
- disabled={saveDisabled}
- loading={isSubmitting}
- />
+
+ {showOptionStates[id] && (
+ <div className="rounded-md border border-neutral-200 bg-white">
+ <textarea
+ {...register(id)}
+ className="w-full resize-none rounded-md border-0 bg-transparent px-3 py-2 font-mono text-xs text-neutral-700 focus:outline-none focus:ring-0"
+ rows={4}
+ spellCheck={false}
+ onKeyDown={handleKeyDown}
+ onPaste={(e) => {
+ if (
+ [
+ "appleAppSiteAssociation",
+ "assetLinks",
+ "deepviewData",
+ ].includes(id)
+ ) {
+ e.preventDefault();
+ const pastedText =
+ e.clipboardData.getData("text");
+
+ try {
+ const formattedJson = JSON.stringify(
+ JSON.parse(pastedText),
+ null,
+ 2,
+ );
+ setValue(id, formattedJson, {
+ shouldDirty: true,
+ });
+ } catch (err) {
+ setValue(id, pastedText, {
+ shouldDirty: true,
+ });
+ }
+ }
+ }}
+ />
+ </div>
+ )}
+ </div>
+ );
+ },
+ )}
+ </AnimatedSizeContainer>
+ </div>
+ </>
+ )}
+ </div>
+
+ <div
+ className={cn(
+ "pt-6",
+ enableDomainConfig &&
+ "sticky bottom-0 isolate z-10 border-t border-neutral-200 bg-white px-8 py-4",
+ )}
+ >
+ <Button
+ text={props ? "Save changes" : "Add domain"}
+ disabled={saveDisabled}
+ loading={isSubmitting}
+ />
+ </div>
</form>
);
}
@@ -629,4 +660,11 @@ const ADVANCED_OPTIONS = [
icon: AndroidLogo,
proFeature: true,
},
+ {
+ id: "deepviewData",
+ title: "Deep View",
+ description: "Customize the interstitial pages for your deep links",
+ icon: MobilePhone,
+ proFeature: true,
+ },
] as const;
diff --git a/apps/web/ui/modals/add-edit-domain-modal.tsx b/apps/web/ui/modals/add-edit-domain-modal.tsx
index 2d0e1948ea..dfbe67f46d 100644
--- a/apps/web/ui/modals/add-edit-domain-modal.tsx
+++ b/apps/web/ui/modals/add-edit-domain-modal.tsx
@@ -30,17 +30,16 @@ function AddEditDomainModal({
drawerRootProps={{ repositionInputs: false }}
className="max-h-[90vh] max-w-lg"
>
- <h3 className="border-b border-neutral-200 px-4 py-4 text-lg font-medium sm:px-6">
+ <div className="sticky top-0 z-10 border-b border-neutral-200 bg-white px-4 py-4 text-lg font-medium sm:px-6">
{props ? "Update" : "Add"} Domain
- </h3>
- <div className="flex-1 overflow-auto bg-neutral-50">
+ </div>
+ <div className="bg-neutral-50">
<AddEditDomainForm
props={props}
onSuccess={(domain) => {
setShowAddEditDomainModal(false);
onSuccess?.(domain);
}}
- className="p-8"
/>
</div>
</Modal>
diff --git a/packages/prisma/schema/domain.prisma b/packages/prisma/schema/domain.prisma
index 428f86511d..59998cfa66 100644
--- a/packages/prisma/schema/domain.prisma
+++ b/packages/prisma/schema/domain.prisma
@@ -11,8 +11,9 @@ model Domain {
logo String?
appleAppSiteAssociation Json?
assetLinks Json?
+ deepviewData Json? @default("{}")
+
linkRetentionDays Int? // default is null (links are retained forever)
-
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt