The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
started on analytics
Steven Teye7290619d2b0
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/analytics/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/analytics/page.tsxindex 0b98f2d640..a5ecc56614 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/analytics/page.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/analytics/page.tsx@@ -1,3 +1,39 @@-export default function Page() {- return <div></div>;+import { getProject } from "#/lib/fetchers";+import LayoutLoader from "#/ui/layout/layout-loader";+import ProjectExceededUsage from "#/ui/layout/project-exceeded-usage";+import ProjectNotFound from "#/ui/layout/project-not-found";+import { Suspense } from "react";++export default function ProjectAnalytics({+ params,+}: {+ params: { slug: string };+}) {+ return (+ <Suspense fallback={<LayoutLoader />}>+ <AnalyticsAuth slug={params.slug}>+ <div></div>+ </AnalyticsAuth>+ </Suspense>+ );+}++async function AnalyticsAuth({+ slug,+ children,+}: {+ slug: string;+ children: React.ReactNode;+}) {+ const project = await getProject({ slug });++ if (!project) {+ return <ProjectNotFound />;+ }++ if (project.usage > project.usageLimit) {+ return <ProjectExceededUsage />;+ }++ return children as JSX.Element;}diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/layout.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/layout.tsxindex f0fc432d20..0fac0899c0 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/layout.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/layout.tsx@@ -1,9 +1,7 @@import { ReactNode, Suspense } from "react";import { getProject } from "#/lib/fetchers";-import { BlurImage } from "#/ui/shared/blur-image";-import { LoadingSpinner, MaxWidthWrapper } from "@dub/ui";-import { FileX2 } from "lucide-react";-import Link from "next/link";+import LayoutLoader from "#/ui/layout/layout-loader";+import ProjectNotFound from "#/ui/layout/project-not-found";export default function ProjectLayout({params,@@ -15,7 +13,7 @@ export default function ProjectLayout({children: ReactNode;}) {return (- <Suspense fallback={<ProjectAuthLoader />}>+ <Suspense fallback={<LayoutLoader />}><ProjectAuth slug={params.slug}>{children}</ProjectAuth></Suspense>);@@ -31,43 +29,8 @@ async function ProjectAuth({const project = await getProject({ slug });if (!project) {- return (- <MaxWidthWrapper>- <div className="my-10 flex flex-col items-center justify-center rounded-md border border-gray-200 bg-white py-12">- <div className="rounded-full bg-gray-100 p-3">- <FileX2 className="h-6 w-6 text-gray-600" />- </div>- <h1 className="my-3 text-xl font-semibold text-gray-700">- Project Not Found- </h1>- <p className="z-10 max-w-sm text-center text-sm text-gray-600">- Bummer! The project you are looking for does not exist. You either- typed in the wrong URL or don't have access to this project.- </p>- <BlurImage- src="/_static/illustrations/coffee-call.svg"- alt="No links yet"- width={400}- height={400}- />- <Link- href="/"- className="z-10 rounded-md border border-black bg-black px-10 py-2 text-sm font-medium text-white transition-all duration-75 hover:bg-white hover:text-black"- >- Back to my projects- </Link>- </div>- </MaxWidthWrapper>- );+ return <ProjectNotFound />;}return children as JSX.Element;}--function ProjectAuthLoader() {- return (- <div className="flex h-[calc(100vh-16px)] items-center justify-center">- <LoadingSpinner />- </div>- );-}diff --git a/apps/web/app/ui/layout/layout-loader.tsx b/apps/web/app/ui/layout/layout-loader.tsxnew file mode 100644index 0000000000..3f8fee2219--- /dev/null+++ b/apps/web/app/ui/layout/layout-loader.tsx@@ -0,0 +1,9 @@+import { LoadingSpinner } from "@dub/ui";++export default function LayoutLoader() {+ return (+ <div className="flex h-[calc(100vh-16px)] items-center justify-center">+ <LoadingSpinner />+ </div>+ );+}diff --git a/apps/web/app/ui/layout/project-exceeded-usage.tsx b/apps/web/app/ui/layout/project-exceeded-usage.tsxnew file mode 100644index 0000000000..ca9b29d78f--- /dev/null+++ b/apps/web/app/ui/layout/project-exceeded-usage.tsx@@ -0,0 +1,41 @@+"use client";++import { BlurImage } from "#/ui/shared/blur-image";+import { MaxWidthWrapper } from "@dub/ui";+import { Lock } from "lucide-react";+import { useContext } from "react";+import { ModalContext } from "../modals/provider";++export default function ProjectExceededUsage() {+ const { setShowUpgradePlanModal } = useContext(ModalContext);++ return (+ <MaxWidthWrapper>+ <div className="my-10 flex flex-col items-center justify-center rounded-md border border-gray-200 bg-white py-12">+ <div className="rounded-full bg-gray-100 p-3">+ <Lock className="h-6 w-6 text-gray-600" />+ </div>+ <h1 className="my-3 text-xl font-semibold text-gray-700">+ Stats Locked+ </h1>+ <p className="z-10 max-w-sm text-center text-sm text-gray-600">+ Your project has exceeded your usage limits. We're still collecting+ data on your link, but you need to upgrade to view them.+ </p>+ <BlurImage+ src="/_static/illustrations/video-park.svg"+ alt="No links yet"+ width={400}+ height={400}+ className="-my-8"+ />+ <button+ onClick={() => setShowUpgradePlanModal(true)}+ className="z-10 rounded-md border border-black bg-black px-10 py-2 text-sm font-medium text-white transition-all duration-75 hover:bg-white hover:text-black"+ >+ Upgrade now+ </button>+ </div>+ </MaxWidthWrapper>+ );+}diff --git a/apps/web/app/ui/layout/project-not-found.tsx b/apps/web/app/ui/layout/project-not-found.tsxnew file mode 100644index 0000000000..6569c449c5--- /dev/null+++ b/apps/web/app/ui/layout/project-not-found.tsx@@ -0,0 +1,35 @@+import { BlurImage } from "#/ui/shared/blur-image";+import { MaxWidthWrapper } from "@dub/ui";+import { FileX2 } from "lucide-react";+import Link from "next/link";++export default function ProjectNotFound() {+ return (+ <MaxWidthWrapper>+ <div className="my-10 flex flex-col items-center justify-center rounded-md border border-gray-200 bg-white py-12">+ <div className="rounded-full bg-gray-100 p-3">+ <FileX2 className="h-6 w-6 text-gray-600" />+ </div>+ <h1 className="my-3 text-xl font-semibold text-gray-700">+ Project Not Found+ </h1>+ <p className="z-10 max-w-sm text-center text-sm text-gray-600">+ Bummer! The project you are looking for does not exist. You either+ typed in the wrong URL or don't have access to this project.+ </p>+ <BlurImage+ src="/_static/illustrations/coffee-call.svg"+ alt="No links yet"+ width={400}+ height={400}+ />+ <Link+ href="/"+ className="z-10 rounded-md border border-black bg-black px-10 py-2 text-sm font-medium text-white transition-all duration-75 hover:bg-white hover:text-black"+ >+ Back to my projects+ </Link>+ </div>+ </MaxWidthWrapper>+ );+}diff --git a/apps/web/app/ui/layout/settings-layout.tsx b/apps/web/app/ui/layout/settings-layout.tsxindex 5dedefb27c..902b7d741a 100644--- a/apps/web/app/ui/layout/settings-layout.tsx+++ b/apps/web/app/ui/layout/settings-layout.tsx@@ -13,7 +13,7 @@ export default function SettingsLayout({children: ReactNode;}) {return (- <div className="h-screen bg-white">+ <div className="h-[calc(100vh-16px)] bg-white"><div className="flex h-36 items-center border-b border-gray-200"><MaxWidthWrapper><div className="flex items-center justify-between">diff --git a/apps/web/package.json b/apps/web/package.jsonindex 0e8140b898..5c7d84af47 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -51,7 +51,7 @@"js-cookie": "^3.0.5","lucide-react": "^0.269.0","nanoid": "^5.0.1",- "next": "13.5.5-canary.4",+ "next": "13.5.5-canary.16","next-auth": "^4.23.1","node-html-parser": "^6.1.4","nodemailer": "^6.9.3",diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex e2feaccf9f..fc5949975d 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -155,11 +155,11 @@ importers:specifier: ^5.0.1version: 5.0.1next:- specifier: 13.5.5-canary.4- version: 13.5.5-canary.4(@babel/[email protected])(@opentelemetry/[email protected])([email protected])([email protected])+ specifier: 13.5.5-canary.16+ version: 13.5.5-canary.16(@babel/[email protected])(@opentelemetry/[email protected])([email protected])([email protected])next-auth:specifier: ^4.23.1node-html-parser:specifier: ^6.1.4version: 6.1.4@@ -3193,7 +3193,7 @@ packages:next-auth: ^4dependencies:'@prisma/client': 5.2.0([email protected])dev: false/@next/[email protected]:@@ -3204,8 +3204,8 @@ packages:resolution: {integrity: sha512-LGegJkMvRNw90WWphGJ3RMHMVplYcOfRWf2Be3td3sUa+1AaxmsYyANsA+znrGCBjXJNi4XAQlSoEfUxs/4kIQ==}dev: true- /@next/[email protected]:- resolution: {integrity: sha512-tx4KDZqpizfNEC9w/VLOHvROR8xCajx1Gw5d/lIzdIS68x+vcERWWmmaV8GoDwfF2H+TB7hfMqdOgZ4pnurRzw==}+ /@next/[email protected]:+ resolution: {integrity: sha512-BeZFr5UqpumatRFjWfkbv/JT51ysG6jpfynIKlRrNUMEyT9I0Dau3nTV59bmsWtXlnepLkR28R4VsgsfUN+i2g==}dev: false/@next/[email protected]:@@ -3244,8 +3244,8 @@ packages:dev: trueoptional: true- /@next/[email protected]:- resolution: {integrity: sha512-BqAx4wV55DmkEYHKijnYv1bt3mPQDAFBwws1E7KiMN0tEJiyhipeBVZTOkpZP5axxLBLV+bhJTOSikVvC2DKrw==}+ /@next/[email protected]:+ resolution: {integrity: sha512-1TEZgQc5mLTqMrr4c6XrKrlENcqb3csyxcclVPaXv1TTaEXARDkHKAid7h7Y1bddbL2xOAp9H0Nc4H1f85hExg==}engines: {node: '>= 10'}cpu: [arm64]os: [darwin]@@ -3271,8 +3271,8 @@ packages:dev: trueoptional: true- /@next/[email protected]:- resolution: {integrity: sha512-Lxp+7rSYO+pyWcldy2S2Vh30bgg4w/bS7JoYnnDwTFMwf1IaDaVHsseNedlE56tkkQwZRBy/Q7GS3yE5i6GdmA==}+ /@next/[email protected]:+ resolution: {integrity: sha512-MovGbN2Ym3oAKrIVf2SxpF1SiMH5yJe7SesVHkxOQyjYHIRrImWsmBSi67KjOsEiUowEbin/H+0Z9HIDR3yrSA==}engines: {node: '>= 10'}cpu: [x64]os: [darwin]@@ -3316,8 +3316,8 @@ packages:dev: trueoptional: true- /@next/[email protected]:- resolution: {integrity: sha512-Lm6Uqm/V4J8sJ82YCtq4xOHGXBj54zZ3ldsTNVO8LHqqWsPWX9vYds7CqFrBaKXdsz0bH9f2XkHbjKS0TaO5DQ==}+ /@next/[email protected]:+ resolution: {integrity: sha512-eGM+TNcllmqC48wiUqzeCOXDMat907IQHmOwf61YwzHqZZPVdbrKgW0Iwy6rJg5Cusbs1mMhVlUG6NZq5P56KA==}engines: {node: '>= 10'}cpu: [arm64]os: [linux]@@ -3343,8 +3343,8 @@ packages:dev: trueoptional: true- /@next/[email protected]:- resolution: {integrity: sha512-YQGNStscoM0NEoCZtB4B3PLpJFMGgGiiYwGmd0UTh83KbhrPdPzaQruXvG1WdxAcXHGsMar/lYIrI9H1otGdgw==}+ /@next/[email protected]:+ resolution: {integrity: sha512-psAkCo7VTv06/3pw+UhORvUU7SxUQRlGLpcDKb/2plHTQFJlDb2n8Mmy2kqGkh27H9J7oTWZ5P4WsJ5LHdWnjA==}engines: {node: '>= 10'}cpu: [arm64]os: [linux]@@ -3370,8 +3370,8 @@ packages:dev: trueoptional: true- /@next/[email protected]:- resolution: {integrity: sha512-VIno27rSb7WsTgYmlyaH58BroPbLqgeSsSbs0Re2aogb/lb7eJvGP21wIXKt0+LsrTKCbqPvl3raGPdTpjFXQA==}+ /@next/[email protected]:+ resolution: {integrity: sha512-E9l4ALB9QZ/wao20M4PGg0ogQZEBg0bPMXSQbve2DV7rH3jleLeWHO6P9hzMdszknEp03RIkeWEURYk7bjF/ZA==}engines: {node: '>= 10'}cpu: [x64]os: [linux]@@ -3397,8 +3397,8 @@ packages:dev: trueoptional: true- /@next/[email protected]:- resolution: {integrity: sha512-G8vTuU8r5jeEkjyOTnmLkjXHcN57swr+woe117JKaN2Y7r1xxVEguRNYeE9zmnE2McLq2j27geb3z2uuMY+WRg==}+ /@next/[email protected]:+ resolution: {integrity: sha512-5xmrJy73iPPjUC5qOd9pit4hjpoTSftLneBb+DNGyDRDkP1lpH241zsgIw8XuDmZ111qzH73oy3nUVVSQvzdFw==}engines: {node: '>= 10'}cpu: [x64]os: [linux]@@ -3424,8 +3424,8 @@ packages:dev: trueoptional: true- /@next/[email protected]:- resolution: {integrity: sha512-Zxl0365GKr902smRGZEfewLhCg4n23/DLYMfrCPoctMSZl4yn0wOXqxD5+cTIkIGphPeqtUIKXfHdeOwgFJRkw==}+ /@next/[email protected]:+ resolution: {integrity: sha512-pFVZz7kEZ58L/iYJlxvnmWgwsu3U3okfjTxb4iPgMgx2OOEj6Z5zJXcwHyhXu6oFHjw+gSK3mCpUFt5aleTtag==}engines: {node: '>= 10'}cpu: [arm64]os: [win32]@@ -3451,8 +3451,8 @@ packages:dev: trueoptional: true- /@next/[email protected]:- resolution: {integrity: sha512-HCysudS8C79Oo05TWAjBpkB0NrYPGSQxvzFURdrOwJQVirF8RpmHpCu6dPOQZdXyubG/8AovMR5JCtQVHPRquQ==}+ /@next/[email protected]:+ resolution: {integrity: sha512-5xYcLX6htXELWlrtxImqw8vfwxLyWUTcdWAAy+E3i/wcjyx7syYZelLqB+9uCeQdknBEa/ziQS4gBYrCe97KDQ==}engines: {node: '>= 10'}cpu: [ia32]os: [win32]@@ -3478,8 +3478,8 @@ packages:dev: trueoptional: true- /@next/[email protected]:- resolution: {integrity: sha512-7bSBhwUtQp/qyScGfyFc89SDIK7C8OPzDoy0ooOj0K8kt26GCFtWfKnyxLkZVw22uHYoBAegDe+D3iPU2rDieg==}+ /@next/[email protected]:+ resolution: {integrity: sha512-K7wPCDEwTjrWGJoWAf4Wh8khBxAGkw9FJ58JiyHuLXh4rh+eZUliWHtvdzfu7u/bfSavSQiIGRALQy9lbE9Kcw==}engines: {node: '>= 10'}cpu: [x64]os: [win32]@@ -10834,7 +10834,7 @@ packages:resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==}dev: falseresolution: {integrity: sha512-mL083z8KgRtlrIV6CDca2H1kduWJuK/3pTS0Fe2og15KOm4v2kkLGdSDfc2g+019aEBrJUT0pPW2Xx42ImN1WA==}peerDependencies:next: ^12.2.5 || ^13@@ -10849,7 +10849,7 @@ packages:'@panva/hkdf': 1.1.1cookie: 0.5.0jose: 4.15.2- next: 13.5.5-canary.4(@babel/[email protected])(@opentelemetry/[email protected])([email protected])([email protected])+ next: 13.5.5-canary.16(@babel/[email protected])(@opentelemetry/[email protected])([email protected])([email protected])nodemailer: 6.9.3oauth: 0.9.15openid-client: 5.6.0@@ -10943,8 +10943,8 @@ packages:- babel-plugin-macrosdev: true- /[email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected])([email protected]):- resolution: {integrity: sha512-a07Akh5WtCXRY/indnpTU21ccXPqEAVrzVueHpcgOq55gRnmYWle7dF/qrBzAlvrldoLG7bzQKNt0AaG2inNWg==}+ /[email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected])([email protected]):+ resolution: {integrity: sha512-ke4kVUTM33bZKWqPy7RJXmdiAn/HhMjEZmiikKQeo/6cMYocTvx9Mog13VAudsLZIY23mnHbIOymlftAMbYMoA==}engines: {node: '>=16.14.0'}hasBin: truepeerDependencies:@@ -10958,7 +10958,7 @@ packages:sass:optional: truedependencies:- '@next/env': 13.5.5-canary.4+ '@next/env': 13.5.5-canary.16'@opentelemetry/api': 1.4.1'@swc/helpers': 0.5.2busboy: 1.6.0@@ -10969,15 +10969,15 @@ packages:styled-jsx: 5.1.1(@babel/[email protected])([email protected])watchpack: 2.4.0optionalDependencies:- '@next/swc-darwin-arm64': 13.5.5-canary.4- '@next/swc-darwin-x64': 13.5.5-canary.4- '@next/swc-linux-arm64-gnu': 13.5.5-canary.4- '@next/swc-linux-arm64-musl': 13.5.5-canary.4- '@next/swc-linux-x64-gnu': 13.5.5-canary.4- '@next/swc-linux-x64-musl': 13.5.5-canary.4- '@next/swc-win32-arm64-msvc': 13.5.5-canary.4- '@next/swc-win32-ia32-msvc': 13.5.5-canary.4- '@next/swc-win32-x64-msvc': 13.5.5-canary.4+ '@next/swc-darwin-arm64': 13.5.5-canary.16+ '@next/swc-darwin-x64': 13.5.5-canary.16+ '@next/swc-linux-arm64-gnu': 13.5.5-canary.16+ '@next/swc-linux-arm64-musl': 13.5.5-canary.16+ '@next/swc-linux-x64-gnu': 13.5.5-canary.16+ '@next/swc-linux-x64-musl': 13.5.5-canary.16+ '@next/swc-win32-arm64-msvc': 13.5.5-canary.16+ '@next/swc-win32-ia32-msvc': 13.5.5-canary.16+ '@next/swc-win32-x64-msvc': 13.5.5-canary.16transitivePeerDependencies:- '@babel/core'- babel-plugin-macros