The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Added ProBanner CTA
Steven Teycf46f13f4c22
diff --git a/components/layout/app/index.tsx b/components/layout/app/index.tsxindex af1fe64afd..d398b4abde 100644--- a/components/layout/app/index.tsx+++ b/components/layout/app/index.tsx@@ -1,15 +1,17 @@import dynamic from "next/dynamic";import Link from "next/link";import { useRouter } from "next/router";-import Script from "next/script";-import { ReactNode } from "react";+import { ReactNode, useEffect, useState } from "react";import { Toaster } from "react-hot-toast";import { Divider, Logo } from "@/components/shared/icons";import Meta from "../meta";import ProjectSelect from "./project-select";import UserDropdown from "./user-dropdown";--const CRISP_SCRIPT = `window.$crisp=[];window.CRISP_WEBSITE_ID="2c09b1ee-14c2-46d1-bf72-1dbb998a19e0";(function(){d=document;s=d.createElement("script");s.src="https://client.crisp.chat/l.js";s.async=1;d.getElementsByTagName("head")[0].appendChild(s);})();`;+import useProject from "@/lib/swr/use-project";+import { Crisp } from "crisp-sdk-web";+import { useSession } from "next-auth/react";+import ProBanner from "./pro-banner";+import Cookies from "js-cookie";const NavTabs = dynamic(() => import("./nav-tabs"), {ssr: false,@@ -30,17 +32,44 @@ export default function AppLayout({key?: string;};+ useEffect(() => {+ Crisp.configure("2c09b1ee-14c2-46d1-bf72-1dbb998a19e0");+ }, []);++ const { data: session } = useSession();+ useEffect(() => {+ if (session?.user?.email) {+ Crisp.user.setEmail(session.user.email);+ Crisp.user.setNickname(session.user.name || session.user.email);+ }+ }, [session]);++ const { id, name, plan, stripeId } = useProject();+ const [showProBanner, setShowProBanner] = useState(false);+ useEffect(() => {+ if (plan) {+ Crisp.session.setData({+ projectId: id,+ projectName: name,+ projectSlug: slug,+ plan,+ ...(stripeId && { stripeId }),+ });+ if (plan === "free" && !Cookies.get("hideProBanner")) {+ Crisp.chat.hide();+ setShowProBanner(true);+ } else {+ Crisp.chat.show();+ setShowProBanner(false);+ }+ }+ }, [plan, id, name, slug, stripeId]);+return (<div><Meta />- <Script- id="script-crisp"- dangerouslySetInnerHTML={{- __html: CRISP_SCRIPT,- }}- strategy="lazyOnload"- /><Toaster />+ {showProBanner && <ProBanner setShowProBanner={setShowProBanner} />}<divclassName={`min-h-screen w-full ${bgWhite ? "bg-white" : "bg-gray-50"}`}>diff --git a/components/layout/app/pro-banner.tsx b/components/layout/app/pro-banner.tsxnew file mode 100644index 0000000000..0a3e0ff9b1--- /dev/null+++ b/components/layout/app/pro-banner.tsx@@ -0,0 +1,40 @@+import Link from "next/link";+import { useRouter } from "next/router";+import Cookies from "js-cookie";+import { Dispatch, SetStateAction } from "react";++export default function ProBanner({+ setShowProBanner,+}: {+ setShowProBanner: Dispatch<SetStateAction<boolean>>;+}) {+ const router = useRouter();+ const { slug } = router.query;+ return (+ <div className="fixed bottom-5 z-10 mx-5 flex flex-col space-y-3 rounded-lg border border-gray-200 bg-white p-5 shadow-lg sm:right-5 sm:mx-auto sm:max-w-sm">+ <h3 className="text-lg font-semibold">Upgrade to Pro</h3>+ <p className="text-sm text-gray-500">+ It looks like you're currently on our free plan. Consider upgrading to+ Pro to enjoy higher limits, extra features, and support our open-source+ company.+ </p>+ <div className="flex space-x-5">+ <button+ onClick={() => {+ setShowProBanner(false);+ Cookies.set("hideProBanner", true, { expires: 7 });+ }}+ className="w-full rounded-md border border-gray-300 p-2 text-center text-sm font-medium text-gray-500 transition-all hover:border-gray-700 hover:text-gray-600"+ >+ Don't show again+ </button>+ <Link+ href={`/${slug}/settings/billing`}+ className="w-full rounded-md border border-black bg-black p-2 text-center text-sm font-medium text-white transition-all hover:bg-white hover:text-black"+ >+ Upgrade+ </Link>+ </div>+ </div>+ );+}diff --git a/package.json b/package.jsonindex 6180d01091..921e6648ef 100644--- a/package.json+++ b/package.json@@ -41,10 +41,12 @@"@visx/tooltip": "^2.16.0","cloudinary": "^1.32.0","cobe": "^0.6.2",+ "crisp-sdk-web": "^1.0.18","focus-trap-react": "^10.0.1","framer-motion": "^7.6.12","html-escaper": "^3.0.3","i": "^0.3.7",+ "js-cookie": "^3.0.5","lucide-react": "^0.172.0","mailing-core": "^0.9.1","ms": "^2.1.3",diff --git a/pages/api/auth/[...nextauth].tsx b/pages/api/auth/[...nextauth].tsxindex 92bf9d6109..3e68398923 100644--- a/pages/api/auth/[...nextauth].tsx+++ b/pages/api/auth/[...nextauth].tsx@@ -65,13 +65,11 @@ export const authOptions: NextAuthOptions = {async signIn(message) {if (message.isNewUser) {const email = message.user.email;- await Promise.all([- sendMarketingMail({- subject: "✨ Welcome to Dub",- to: email,- component: <WelcomeEmail />,- }),- ]);+ await sendMarketingMail({+ subject: "✨ Welcome to Dub",+ to: email,+ component: <WelcomeEmail />,+ });}},},diff --git a/yarn.lock b/yarn.lockindex d734092787..92d536eb47 100644--- a/yarn.lock+++ b/yarn.lock@@ -364,56 +364,56 @@semver "^7.3.5"tar "^6.1.11"-"@motionone/animation@^10.13.1":- version "10.14.0"- resolved "https://registry.yarnpkg.com/@motionone/animation/-/animation-10.14.0.tgz#2f2a3517183bb58d82e389aac777fe0850079de6"- integrity sha512-h+1sdyBP8vbxEBW5gPFDnj+m2DCqdlAuf2g6Iafb1lcMnqjsRXWlPw1AXgvUMXmreyhqmPbJqoNfIKdytampRQ==- dependencies:- "@motionone/easing" "^10.14.0"- "@motionone/types" "^10.14.0"- "@motionone/utils" "^10.14.0"+"@motionone/animation@^10.15.1":+ version "10.15.1"+ resolved "https://registry.yarnpkg.com/@motionone/animation/-/animation-10.15.1.tgz#4a85596c31cbc5100ae8eb8b34c459fb0ccf6807"+ integrity sha512-mZcJxLjHor+bhcPuIFErMDNyrdb2vJur8lSfMCsuCB4UyV8ILZLvK+t+pg56erv8ud9xQGK/1OGPt10agPrCyQ==+ dependencies:+ "@motionone/easing" "^10.15.1"+ "@motionone/types" "^10.15.1"+ "@motionone/utils" "^10.15.1"tslib "^2.3.1"-"@motionone/[email protected]":- version "10.13.1"- resolved "https://registry.yarnpkg.com/@motionone/dom/-/dom-10.13.1.tgz#fc29ea5d12538f21b211b3168e502cfc07a24882"- integrity sha512-zjfX+AGMIt/fIqd/SL1Lj93S6AiJsEA3oc5M9VkUr+Gz+juRmYN1vfvZd6MvEkSqEjwPQgcjN7rGZHrDB9APfQ==+"@motionone/dom@^10.15.3":+ version "10.15.5"+ resolved "https://registry.yarnpkg.com/@motionone/dom/-/dom-10.15.5.tgz#4af18f8136d85c2fc997cac98121c969f6731802"+ integrity sha512-Xc5avlgyh3xukU9tydh9+8mB8+2zAq+WlLsC3eEIp7Ax7DnXgY7Bj/iv0a4X2R9z9ZFZiaXK3BO0xMYHKbAAdA==dependencies:- "@motionone/animation" "^10.13.1"- "@motionone/generators" "^10.13.1"- "@motionone/types" "^10.13.0"- "@motionone/utils" "^10.13.1"+ "@motionone/animation" "^10.15.1"+ "@motionone/generators" "^10.15.1"+ "@motionone/types" "^10.15.1"+ "@motionone/utils" "^10.15.1"hey-listen "^1.0.8"tslib "^2.3.1"-"@motionone/easing@^10.14.0":- version "10.14.0"- resolved "https://registry.yarnpkg.com/@motionone/easing/-/easing-10.14.0.tgz#d8154b7f71491414f3cdee23bd3838d763fffd00"- integrity sha512-2vUBdH9uWTlRbuErhcsMmt1jvMTTqvGmn9fHq8FleFDXBlHFs5jZzHJT9iw+4kR1h6a4SZQuCf72b9ji92qNYA==+"@motionone/easing@^10.15.1":+ version "10.15.1"+ resolved "https://registry.yarnpkg.com/@motionone/easing/-/easing-10.15.1.tgz#95cf3adaef34da6deebb83940d8143ede3deb693"+ integrity sha512-6hIHBSV+ZVehf9dcKZLT7p5PEKHGhDwky2k8RKkmOvUoYP3S+dXsKupyZpqx5apjd9f+php4vXk4LuS+ADsrWw==dependencies:- "@motionone/utils" "^10.14.0"+ "@motionone/utils" "^10.15.1"tslib "^2.3.1"-"@motionone/generators@^10.13.1":- version "10.14.0"- resolved "https://registry.yarnpkg.com/@motionone/generators/-/generators-10.14.0.tgz#e05d9dd56da78a4b92db99185848a0f3db62242d"- integrity sha512-6kRHezoFfIjFN7pPpaxmkdZXD36tQNcyJe3nwVqwJ+ZfC0e3rFmszR8kp9DEVFs9QL/akWjuGPSLBI1tvz+Vjg==+"@motionone/generators@^10.15.1":+ version "10.15.1"+ resolved "https://registry.yarnpkg.com/@motionone/generators/-/generators-10.15.1.tgz#dc6abb11139d1bafe758a41c134d4c753a9b871c"+ integrity sha512-67HLsvHJbw6cIbLA/o+gsm7h+6D4Sn7AUrB/GPxvujse1cGZ38F5H7DzoH7PhX+sjvtDnt2IhFYF2Zp1QTMKWQ==dependencies:- "@motionone/types" "^10.14.0"- "@motionone/utils" "^10.14.0"+ "@motionone/types" "^10.15.1"+ "@motionone/utils" "^10.15.1"tslib "^2.3.1"-"@motionone/types@^10.13.0", "@motionone/types@^10.14.0":- version "10.14.0"- resolved "https://registry.yarnpkg.com/@motionone/types/-/types-10.14.0.tgz#148c34f3270b175397e49c3058b33fab405c21e3"- integrity sha512-3bNWyYBHtVd27KncnJLhksMFQ5o2MSdk1cA/IZqsHtA9DnRM1SYgN01CTcJ8Iw8pCXF5Ocp34tyAjY7WRpOJJQ==+"@motionone/types@^10.15.1":+ version "10.15.1"+ resolved "https://registry.yarnpkg.com/@motionone/types/-/types-10.15.1.tgz#89441b54285012795cbba8612cbaa0fa420db3eb"+ integrity sha512-iIUd/EgUsRZGrvW0jqdst8st7zKTzS9EsKkP+6c6n4MPZoQHwiHuVtTQLD6Kp0bsBLhNzKIBlHXponn/SDT4hA==-"@motionone/utils@^10.13.1", "@motionone/utils@^10.14.0":- version "10.14.0"- resolved "https://registry.yarnpkg.com/@motionone/utils/-/utils-10.14.0.tgz#a19a3464ed35b08506747b062d035c7bc9bbe708"- integrity sha512-sLWBLPzRqkxmOTRzSaD3LFQXCPHvDzyHJ1a3VP9PRzBxyVd2pv51/gMOsdAcxQ9n+MIeGJnxzXBYplUHKj4jkw==+"@motionone/utils@^10.15.1":+ version "10.15.1"+ resolved "https://registry.yarnpkg.com/@motionone/utils/-/utils-10.15.1.tgz#6b5f51bde75be88b5411e084310299050368a438"+ integrity sha512-p0YncgU+iklvYr/Dq4NobTRdAPv9PveRDUXabPEeOjBLSO/1FNB2phNTZxOxpi1/GZwYpAoECEa0Wam+nsmhSw==dependencies:- "@motionone/types" "^10.14.0"+ "@motionone/types" "^10.15.1"hey-listen "^1.0.8"tslib "^2.3.1"@@ -2616,6 +2616,11 @@ cors@~2.8.5:object-assign "^4"vary "^1"+crisp-sdk-web@^1.0.18:+ version "1.0.18"+ resolved "https://registry.yarnpkg.com/crisp-sdk-web/-/crisp-sdk-web-1.0.18.tgz#26f492900aeb4d209c967e5cce22508b7f04b480"+ integrity sha512-QjmtIY/GOhQenW9liswMAhzaZUKTn8JQjqLZkzMcnhdm3AlrMB83r2gIBUOxSZmSL80K3pl8U1ATadpC0ImEeA==+css-background-parser@^0.1.0:version "0.1.0"resolved "https://registry.yarnpkg.com/css-background-parser/-/css-background-parser-0.1.0.tgz#48a17f7fe6d4d4f1bca3177ddf16c5617950741b"@@ -3329,26 +3334,16 @@ fraction.js@^4.2.0:integrity sha512-MhLuK+2gUcnZe8ZHlaaINnQLl0xRIGRfcGk2yl8xoQAfHrSsL3rYu6FCmBdkdbhc9EPlwyGHewaRsvwRMJtAlA==framer-motion@^7.6.12:- version "7.6.12"- resolved "https://registry.yarnpkg.com/framer-motion/-/framer-motion-7.6.12.tgz#a1f228e00da03ceb78482ae4a7fba63be39d34e4"- integrity sha512-Xm1jPB91v6vIr9b+V3q6c96sPzU1jWdvN+Mv4CvIAY23ZIezGNIWxWNGIWj1We0CZ8SSOQkttz8921M10TQjXg==+ version "7.10.3"+ resolved "https://registry.yarnpkg.com/framer-motion/-/framer-motion-7.10.3.tgz#8b23f50bbc1ee8c830c869c5398e457d5272feb5"+ integrity sha512-k2ccYeZNSpPg//HTaqrU+4pRq9f9ZpaaN7rr0+Rx5zA4wZLbk547wtDzge2db1sB+1mnJ6r59P4xb+aEIi/W+w==dependencies:- "@motionone/dom" "10.13.1"- framesync "6.1.2"+ "@motionone/dom" "^10.15.3"hey-listen "^1.0.8"- popmotion "11.0.5"- style-value-types "5.1.2"tslib "2.4.0"optionalDependencies:"@emotion/is-prop-valid" "^0.8.2"- version "6.1.2"- resolved "https://registry.yarnpkg.com/framesync/-/framesync-6.1.2.tgz#755eff2fb5b8f3b4d2b266dd18121b300aefea27"- integrity sha512-jBTqhX6KaQVDyus8muwZbBeGGP0XgujBRbQ7gM7BRdS3CadCZIHiawyzYLnafYcvZIh5j8WE7cxZKFn7dXhu9g==- dependencies:- tslib "2.4.0"-fs-extra@^10.1.0:version "10.1.0"resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-10.1.0.tgz#02873cfbc4084dde127eaa5f9905eef2325d1abf"@@ -3934,6 +3929,11 @@ js-beautify@^1.6.14:glob "^8.0.3"nopt "^6.0.0"+js-cookie@^3.0.5:+ version "3.0.5"+ resolved "https://registry.yarnpkg.com/js-cookie/-/js-cookie-3.0.5.tgz#0b7e2fd0c01552c58ba86e0841f94dc2557dcdbc"+ integrity sha512-cEiJEAEoIbWfCZYKWhVwFuvPX1gETRYPw6LlaTKoxD3s2AkXzkCjnp6h0V77ozyqj0jakteJ4YqDJT830+lVGw==+"js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0:version "4.0.0"resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"@@ -5405,16 +5405,6 @@ pify@^2.3.0:resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"integrity sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==- version "11.0.5"- resolved "https://registry.yarnpkg.com/popmotion/-/popmotion-11.0.5.tgz#8e3e014421a0ffa30ecd722564fd2558954e1f7d"- integrity sha512-la8gPM1WYeFznb/JqF4GiTkRRPZsfaj2+kCxqQgr2MJylMmIKUwBfWW8Wa5fml/8gmtlD5yI01MP1QCZPWmppA==- dependencies:- framesync "6.1.2"- hey-listen "^1.0.8"- style-value-types "5.1.2"- tslib "2.4.0"-postcss-import@^14.1.0:version "14.1.0"resolved "https://registry.yarnpkg.com/postcss-import/-/postcss-import-14.1.0.tgz#a7333ffe32f0b8795303ee9e40215dac922781f0"@@ -6279,14 +6269,6 @@ stripe@^11.1.0:"@types/node" ">=8.1.0"qs "^6.11.0"- version "5.1.2"- resolved "https://registry.yarnpkg.com/style-value-types/-/style-value-types-5.1.2.tgz#6be66b237bd546048a764883528072ed95713b62"- integrity sha512-Vs9fNreYF9j6W2VvuDTP7kepALi7sk0xtk2Tu8Yxi9UoajJdEVpNpCov0HsLTqXvNGKX+Uv09pkozVITi1jf3Q==- dependencies:- hey-listen "^1.0.8"- tslib "2.4.0"-version "5.1.1"resolved "https://registry.yarnpkg.com/styled-jsx/-/styled-jsx-5.1.1.tgz#839a1c3aaacc4e735fed0781b8619ea5d0009d1f"@@ -6444,11 +6426,16 @@ [email protected]:resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3"integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==-tslib@^2.0.0, tslib@^2.0.1, tslib@^2.0.3, tslib@^2.1.0, tslib@^2.2.0, tslib@^2.3.1, tslib@^2.4.0, tslib@^2.4.1:+tslib@^2.0.0, tslib@^2.0.1, tslib@^2.0.3, tslib@^2.1.0, tslib@^2.2.0, tslib@^2.4.0, tslib@^2.4.1:version "2.4.1"resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.1.tgz#0d0bfbaac2880b91e22df0768e55be9753a5b17e"integrity sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==+tslib@^2.3.1:+ version "2.5.0"+ resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.0.tgz#42bfed86f5787aeb41d031866c8f402429e0fddf"+ integrity sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==+type-check@~0.3.2:version "0.3.2"resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72"