The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Fix root domain link stats error, added ToS, Privacy Policy
Steven Tey927b9904bf13
diff --git a/app/dub.sh/layout.tsx b/app/dub.sh/layout.tsxindex 38a5f67095..aac408bc51 100644--- a/app/dub.sh/layout.tsx+++ b/app/dub.sh/layout.tsx@@ -3,7 +3,7 @@ import Footer from "#/ui/home/footer";export default function MarketingLayout(props) {return (- <div className="flex min-h-screen flex-col justify-between">+ <div className="flex min-h-screen flex-col">{/* Only show stats modal if not on the /stats page */}{props.children.props.childProp.segment !== "stats" && props.modal}<Nav />diff --git a/app/dub.sh/privacy/page.tsx b/app/dub.sh/privacy/page.tsxnew file mode 100644index 0000000000..9d2834d747--- /dev/null+++ b/app/dub.sh/privacy/page.tsx@@ -0,0 +1,13 @@+import { Metadata } from "next";+import { constructMetadata } from "@/lib/utils";+import LegalPage from "#/ui/blog/legal";+import { allLegalPosts } from "contentlayer/generated";++export const metadata: Metadata = constructMetadata({+ title: "Privacy Policy - Dub",+});++export default function Privacy() {+ const post = allLegalPosts.find((post) => post.slug === "privacy")!;+ return <LegalPage post={post} />;+}diff --git a/app/dub.sh/terms/page.tsx b/app/dub.sh/terms/page.tsxnew file mode 100644index 0000000000..e80ae1a51c--- /dev/null+++ b/app/dub.sh/terms/page.tsx@@ -0,0 +1,13 @@+import { Metadata } from "next";+import { constructMetadata } from "@/lib/utils";+import LegalPage from "#/ui/blog/legal";+import { allLegalPosts } from "contentlayer/generated";++export const metadata: Metadata = constructMetadata({+ title: "Terms of Service - Dub",+});++export default function Terms() {+ const post = allLegalPosts.find((post) => post.slug === "terms")!;+ return <LegalPage post={post} />;+}diff --git a/app/ui/blog/legal.tsx b/app/ui/blog/legal.tsxnew file mode 100644index 0000000000..9bdd66d050--- /dev/null+++ b/app/ui/blog/legal.tsx@@ -0,0 +1,23 @@+import { LegalPost } from "contentlayer/generated";+import { MDX } from "#/ui/blog/mdx";+import { formatDate } from "@/lib/utils";++export default function LegalPage({ post }: { post: LegalPost }) {+ return (+ <div className="bg-gray-50">+ <div className="bg-white py-20 sm:py-40">+ <h1 className="mt-5 text-center font-display text-4xl font-extrabold leading-[1.15] text-black sm:text-6xl sm:leading-[1.15]">+ {post.title}+ </h1>+ </div>+ <div className="flex flex-col items-center pb-10 pt-20">+ <MDX code={post.body.code} />+ <div className="mt-10 w-full max-w-screen-md border-t border-gray-200 pt-10 text-center">+ <p className="text-gray-500">+ Last updated: {formatDate(post.updatedAt)}+ </p>+ </div>+ </div>+ </div>+ );+}diff --git a/app/ui/home/footer.tsx b/app/ui/home/footer.tsxindex 5dac2f9c7f..ae0e10f7ea 100644--- a/app/ui/home/footer.tsx+++ b/app/ui/home/footer.tsx@@ -1,36 +1,149 @@"use client";import Link from "next/link";-import { Github, Logo, Twitter } from "@/components/shared/icons";+import { Github, LinkedIn, Logo, Twitter } from "@/components/shared/icons";import { useParams } from "next/navigation";+import MaxWidthWrapper from "@/components/shared/max-width-wrapper";++const navigation = {+ tools: [{ name: "Metatags API", href: "/metatags" }],+ company: [{ name: "Changelog", href: "/changelog" }],+ legal: [+ { name: "Privacy", href: "/privacy" },+ { name: "Terms", href: "/terms" },+ ],+};export default function Footer() {const { domain = "dub.sh" } = useParams() as { domain: string };+ const createHref = (href: string) =>+ domain === "dub.sh"+ ? href+ : `https://dub.sh${href}?utm_source=${domain}&utm_medium=referral&utm_campaign=custom-domain`;+return (- <div className="z-10 flex h-20 items-center justify-center space-x-12 border-t border-gray-200">- <a href="https://twitter.com/dubdotsh" target="_blank" rel="noreferrer">- <span className="sr-only">Twitter</span>- <Twitter className="h-6 w-6 text-gray-600" />- </a>- <Link- href={- domain === "dub.sh"- ? "/"- : `https://dub.sh?utm_source=${domain}&utm_medium=referral&utm_campaign=custom-domain`- }- >- <span className="sr-only">Dub.sh Logo</span>- <Logo className="h-7 w-7 text-gray-600" />- </Link>- <a- href="https://github.com/steven-tey/dub"- target="_blank"- rel="noreferrer"- >- <span className="sr-only">Github</span>- <Github className="h-6 w-6 text-gray-600" />- </a>- </div>+ <footer className="z-10 border-t border-gray-200 bg-white/50 py-8 backdrop-blur-lg">+ <MaxWidthWrapper className="pt-10">+ <div className="xl:grid xl:grid-cols-3 xl:gap-8">+ <div className="space-y-8">+ <Link href={createHref("/")}>+ <span className="sr-only">Dub.sh Logo</span>+ <Logo className="h-7 w-7 text-gray-600" />+ </Link>+ <p className="text-sm leading-6 text-gray-500">+ Giving modern marketing teams superpowers with short links that+ stand out.+ </p>+ <div className="flex items-center space-x-2">+ <a+ href="https://twitter.com/dubdotsh"+ target="_blank"+ rel="noreferrer"+ className="rounded-md p-2 transition-colors hover:bg-gray-100 active:bg-gray-200"+ >+ <span className="sr-only">Twitter</span>+ <Twitter className="h-5 w-5 text-gray-600" />+ </a>+ <div className="h-8 border-l border-gray-200" />+ <a+ href="https://github.com/steven-tey/dub"+ target="_blank"+ rel="noreferrer"+ className="rounded-md p-2 transition-colors hover:bg-gray-100 active:bg-gray-200"+ >+ <span className="sr-only">Github</span>+ <Github className="h-5 w-5 text-gray-600" />+ </a>+ <div className="h-8 border-l border-gray-200" />+ <a+ href="https://www.linkedin.com/company/dubhq/"+ target="_blank"+ rel="noreferrer"+ className="rounded-md p-2 transition-colors hover:bg-gray-100 active:bg-gray-200"+ >+ <span className="sr-only">LinkedIn</span>+ <LinkedIn className="h-5 w-5" fill="#52525B" />+ </a>+ </div>+ </div>+ <div className="mt-16 grid grid-cols-2 gap-8 xl:col-span-2 xl:mt-0">+ <div className="md:grid md:grid-cols-2 md:gap-8">+ {/*+ <div>+ <h3 className="text-sm font-semibold leading-6 text-gray-900">+ Features+ </h3>+ <ul role="list" className="mt-6 space-y-4">+ {navigation.features.map((item) => (+ <li key={item.name}>+ <Link+ href={createHref(item.href)}+ className="text-sm text-gray-500 hover:text-gray-900"+ >+ {item.name}+ </Link>+ </li>+ ))}+ </ul>+ </div> */}+ <div className="hidden sm:block" />+ <div>+ <h3 className="text-sm font-semibold text-gray-600">Tools</h3>+ <ul role="list" className="mt-6 space-y-4">+ {navigation.tools.map((item) => (+ <li key={item.name}>+ <Link+ href={createHref(item.href)}+ className="text-sm text-gray-500 hover:text-gray-900"+ >+ {item.name}+ </Link>+ </li>+ ))}+ </ul>+ </div>+ </div>+ <div className="md:grid md:grid-cols-2 md:gap-8">+ <div>+ <h3 className="text-sm font-semibold text-gray-600">Company</h3>+ <ul role="list" className="mt-6 space-y-4">+ {navigation.company.map((item) => (+ <li key={item.name}>+ <Link+ href={createHref(item.href)}+ className="text-sm text-gray-500 hover:text-gray-900"+ >+ {item.name}+ </Link>+ </li>+ ))}+ </ul>+ </div>+ <div className="mt-10 md:mt-0">+ <h3 className="text-sm font-semibold text-gray-600">Legal</h3>+ <ul role="list" className="mt-6 space-y-4">+ {navigation.legal.map((item) => (+ <li key={item.name}>+ <Link+ href={createHref(item.href)}+ className="text-sm text-gray-500 hover:text-gray-900"+ >+ {item.name}+ </Link>+ </li>+ ))}+ </ul>+ </div>+ </div>+ </div>+ </div>+ <div className="mt-16 border-t border-gray-900/10 pt-8 sm:mt-20 lg:mt-24">+ <p className="text-sm leading-5 text-gray-500">+ © {new Date().getFullYear()} Dub.sh+ </p>+ </div>+ </MaxWidthWrapper>+ </footer>);}diff --git a/app/ui/home/nav.tsx b/app/ui/home/nav.tsxindex 56a99344e3..33c125f35d 100644--- a/app/ui/home/nav.tsx+++ b/app/ui/home/nav.tsx@@ -5,6 +5,7 @@ import Image from "next/image";import { useParams, useSelectedLayoutSegment } from "next/navigation";import useScroll from "#/lib/hooks/use-scroll";import clsx from "clsx";+import MaxWidthWrapper from "@/components/shared/max-width-wrapper";const transparentHeaderSegments = new Set(["metatags"]);@@ -22,7 +23,7 @@ export default function Nav() {segment && !transparentHeaderSegments.has(segment),})}>- <div className="mx-auto w-full max-w-screen-xl px-5 md:px-20">+ <MaxWidthWrapper><div className="flex h-14 items-center justify-between"><Linkhref={@@ -75,7 +76,7 @@ export default function Nav() {</Link></div></div>- </div>+ </MaxWidthWrapper></div>);}diff --git a/components/app/modals/tag-link-modal.tsx b/components/app/modals/tag-link-modal.tsxindex 043af4db13..ed06d76d4f 100644--- a/components/app/modals/tag-link-modal.tsx+++ b/components/app/modals/tag-link-modal.tsx@@ -153,17 +153,7 @@ function TagLinkModal({height={20}/><h3 className="text-lg font-medium">{type.title}</h3>- <p className="text-sm text-gray-500">- {type.description} <br className="mt-1" />- <a- className="underline underline-offset-4 transition-colors hover:text-black"- href="https://dub.sh/tags"- target="_blank"- rel="noopener noreferrer"- >- Read the announcement.- </a>- </p>+ <p className="text-sm text-gray-500">{type.description}</p></div><formdiff --git a/components/stats/index.tsx b/components/stats/index.tsxindex 0deeac5276..208821fd79 100644--- a/components/stats/index.tsx+++ b/components/stats/index.tsx@@ -78,7 +78,7 @@ export default function Stats({domain: staticDomain,endpoint: `/api/edge/links/${encodeURIComponent(key)}/stats`,};- }, [slug, key, router.asPath]);+ }, [slug, domainSlug, key, router.asPath]);return (<StatsContext.Providerdiff --git a/contentlayer.config.ts b/contentlayer.config.tsindex 80513d5bd6..b52150962e 100644--- a/contentlayer.config.ts+++ b/contentlayer.config.ts@@ -35,7 +35,25 @@ export const ChangelogPost = defineDocumentType(() => ({computedFields: computedFields("changelog"),}));-const computedFields = (type: "changelog" | "blog") => ({+export const LegalPost = defineDocumentType(() => ({+ name: "LegalPost",+ filePathPattern: `**/legal/*.mdx`,+ contentType: "mdx",+ fields: {+ title: {+ type: "string",+ required: true,+ },+ updatedAt: {+ type: "string",+ required: true,+ },+ },+ // @ts-ignore+ computedFields: computedFields("legal"),+}));++const computedFields = (type: "changelog" | "legal") => ({slug: {type: "string",resolve: (doc) => doc._raw.flattenedPath.replace(`${type}/`, ""),@@ -87,7 +105,7 @@ const computedFields = (type: "changelog" | "blog") => ({export default makeSource({contentDirPath: "posts",- documentTypes: [ChangelogPost],+ documentTypes: [ChangelogPost, LegalPost],mdx: {remarkPlugins: [remarkGfm],rehypePlugins: [diff --git a/lib/auth.ts b/lib/auth.tsindex f2d7b882ee..56578a3772 100644--- a/lib/auth.ts+++ b/lib/auth.ts@@ -301,28 +301,27 @@ const withLinksAuth =}}- // if key is defined, check if the current user is the owner of the link+ // if key is defined, check if the current user is the owner of the link (only for dub.sh links)const { key } = req.query;- if (key && !skipKeyCheck) {+ if (key && domain === "dub.sh" && !skipKeyCheck) {if (typeof key !== "string") {return res.status(400).end("Missing or misconfigured link key.");- } else {- link =- (await prisma.link.findUnique({- where: {- domain_key: {- domain: domain || "dub.sh",- key,- },+ }+ link =+ (await prisma.link.findUnique({+ where: {+ domain_key: {+ domain: domain || "dub.sh",+ key,},- })) || undefined;- if (!link) {- return res.status(404).end("Link not found.");+ },+ })) || undefined;+ if (!link) {+ return res.status(404).end("Link not found.");- // for dub.sh links, check if the user is the owner of the link- } else if (!slug && link.userId !== session.user.id) {- return res.status(403).end("Unauthorized: Not link owner.");- }+ // for dub.sh links, check if the user is the owner of the link+ } else if (!slug && link.userId !== session.user.id) {+ return res.status(403).end("Unauthorized: Not link owner.");}}diff --git a/posts/legal/privacy.mdx b/posts/legal/privacy.mdxnew file mode 100644index 0000000000..258f0962d1--- /dev/null+++ b/posts/legal/privacy.mdx@@ -0,0 +1,28 @@+---+title: Privacy Policy+updatedAt: 2023-05-29+---++Welcome to [Dub.sh](/) (the "Site"), hosted by Dub ("Dub", "we", "us", and/or "our"). Dub provides a platform for creating and managing short links (the "Services")1. We value your privacy and are dedicated to protecting your personal data. This Privacy Policy covers how we collect, handle, and disclose personal data on our Platform.++If you have any questions, comments, or concerns regarding this Privacy Policy, our data practices, or would like to exercise your rights, do not hesitate to contact us.++## To Whom Does This Policy Apply++This Privacy Policy applies to customers and site visitors. Each customer is responsible for posting its own terms, conditions, and privacy policies, and ensuring compliance with all applicable laws and regulations.++## Changes To This Privacy Policy++This Privacy Policy may change from time to time, as our Platform and our business may change. Your continued use of the Platform after any changes to this Privacy Policy indicates your agreement with the terms of the revised Privacy Policy.++## What Information Do We Collect++We collect information directly from you when you provide it to us explicitly on our Site. We do not use third-party cookies on our Site.++## What We Use Your Information For++We use your information to provide our Services, to improve our Platform, to understand how you use our Platform, and to communicate with you.++## How To Contact Us++For privacy-related questions, please contact us at [email protected].diff --git a/posts/legal/terms.mdx b/posts/legal/terms.mdxnew file mode 100644index 0000000000..95154e15d9--- /dev/null+++ b/posts/legal/terms.mdx@@ -0,0 +1,56 @@+---+title: Terms of Service+updatedAt: 2023-05-29+---++Subject to these Terms of Service (this "Agreement"), [Dub.sh](/) ("Dub", "we", "us" and/or "our") provides access to Dub's cloud platform as a service (collectively, the "Services"). By using or accessing the Services, you acknowledge that you have read, understand, and agree to be bound by this Agreement.++If you are entering into this Agreement on behalf of a company, business or other legal entity, you represent that you have the authority to bind such entity to this Agreement, in which case the term "you" shall refer to such entity. If you do not have such authority, or if you do not agree with this Agreement, you must not accept this Agreement and may not use the Services.++## 1. Acceptance of Terms++By signing up and using the services provided by Dub (referred to as the "Service"), you are agreeing to be bound by the following terms and conditions ("Terms of Service"). The Service is owned and operated by Dub ("Us", "We", or "Our").++## 2. Description of Service++Dub provides an open-source link management tool for modern marketing teams to create, share, and track short links ("the Product"). The Product is accessible at dub.sh and other domains and subdomains controlled by Us (collectively, "the Website").++## 3. Fair Use++You are responsible for your use of the Service and for any content that you post or transmit through the Service. You may not use the Service for any purpose that is illegal or infringes upon the rights of others.++We reserve the right to suspend or terminate your access to the Service if we determine, in our sole discretion, that you have violated these Terms of Service, including but not limited to, adding phishing links, spam links, scam links, or other inappropriate or illegal content.++## 4. Intellectual Property Rights++You acknowledge and agree that the Service and its entire contents, features, and functionality, including but not limited to all information, software, code, text, displays, graphics, photographs, video, audio, design, presentation, selection, and arrangement, are owned by Us, our licensors, or other providers of such material and are protected by United States and international copyright, trademark, patent, trade secret, and other intellectual property or proprietary rights laws.++## 5. Shortlink Ownership++If you're using a default dub.sh link, we reserve the right to reclaim the shortlink if needed, particularly if it is necessary for brand compliance, to prevent confusion among users, or to maintain the integrity and reputation of our Service.++## 6. Changes to these Terms++We reserve the right to revise and update these Terms of Service from time to time in our sole discretion. All changes are effective immediately when we post them, and apply to all access to and use of the Website thereafter. Your continued use of the Website following the posting of revised Terms of Service means that you accept and agree to the changes.++## 7. Contact Information++Questions or comments about the Website or these Terms of Service may be directed to our support team at [email protected].++## 8. Disclaimer of Warranties++THE SERVICE AND ITS CONTENT ARE PROVIDED ON AN "AS IS" AND "AS AVAILABLE" BASIS WITHOUT ANY WARRANTIES OF ANY KIND. WE DISCLAIM ALL WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE WARRANTY OF TITLE, MERCHANTABILITY, NON-INFRINGEMENT OF THIRD PARTIES’ RIGHTS, AND FITNESS FOR PARTICULAR PURPOSE.++## 9. Limitation of Liability++IN NO EVENT WILL WE, OUR AFFILIATES OR THEIR LICENSORS, SERVICE PROVIDERS, EMPLOYEES, AGENTS, OFFICERS OR DIRECTORS BE LIABLE FOR DAMAGES OF ANY KIND, UNDER ANY LEGAL THEORY, ARISING OUT OF OR IN CONNECTION WITH YOUR USE, OR INABILITY TO USE, THE WEBSITE, THE SERVICE, ANY WEBSITES LINKED TO IT, ANY CONTENT ON THE WEBSITE OR SUCH OTHER WEBSITES, INCLUDING ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES.++## 10. Governing Law and Jurisdiction++These Terms of Service and any dispute or claim arising out of or related to them, their subject matter or their formation (in each case, including non-contractual disputes or claims) shall be governed by and construed in accordance with the internal laws of the State of California without giving effect to any choice or conflict of law provision or rule. Any legal suit, action, or proceeding arising out of, or related to, these Terms of Service or the Website shall be instituted exclusively in the federal courts of the United States or the courts of the State of California.++---++By using Dub, you acknowledge that you have read these Terms of Service, understood them, and agree to be bound by them. If you do not agree to these Terms of Service, you are not authorized to use the Service. We reserve the right to change these Terms of Service at any time, so please review them frequently.++Thank you for using Dub!