11/* eslint-disable @typescript-eslint/no-non-null-assertion */
2- import { useEffect } from 'react' ;
2+ import { useEffect , useState } from 'react' ;
33import { useRouter } from 'next/router' ;
44import Layout from '@/components/layout/Layout' ;
55import Script from 'next/script' ;
66import { PromoCodeName } from '@/lib/types' ;
7+ import { saveCelloFirstVisit , isCelloExpired } from '@/lib/cookies' ;
78import Footer from '@/components/layout/footers/Footer' ;
89import usePricing from '@/hooks/usePricing' ;
910import Navbar from '@/components/layout/navbars/Navbar' ;
@@ -65,6 +66,7 @@ function CombinedSpecialOffer({
6566 pathname,
6667} : CombinedSpecialOfferProps ) : JSX . Element {
6768 const router = useRouter ( ) ;
69+ const [ isCelloAttributionExpired , setIsCelloAttributionExpired ] = useState ( true ) ;
6870 const selectedPathname = ALLOWED_PATHS . find ( ( p ) => p === pathname ) ;
6971 const isDarkMode = selectedPathname ? DARK_MODE_PATHS . includes ( selectedPathname ) : false ;
7072 const isValentinesMode = selectedPathname === 'love' ;
@@ -79,6 +81,11 @@ function CombinedSpecialOffer({
7981 }
8082 } , [ selectedPathname , router ] ) ;
8183
84+ useEffect ( ( ) => {
85+ saveCelloFirstVisit ( ) ;
86+ setIsCelloAttributionExpired ( isCelloExpired ( ) ) ;
87+ } , [ ] ) ;
88+
8289 const couponCode = COUPON_CODES [ pathname ] ;
8390 const metatags = metatagsDescriptions . find ( ( desc ) => desc . id === 'special-offer' ) ;
8491
@@ -148,7 +155,13 @@ function CombinedSpecialOffer({
148155 lang = { lang }
149156 robots = "noindex, follow"
150157 >
151- < Script src = { process . env . NEXT_PUBLIC_CELLO_ATTRIBUTION_URL } type = "module" strategy = "afterInteractive" />
158+ { ! isCelloAttributionExpired && (
159+ < Script
160+ src = "https://assets.cello.so/attribution/latest/cello-attribution.js"
161+ type = "module"
162+ strategy = "afterInteractive"
163+ />
164+ ) }
152165 < Navbar lang = { lang } textContent = { navbarLang } cta = { [ 'payment' ] } isLinksHidden hideLogoLink hideCTA />
153166
154167 < HeroSection
0 commit comments