Skip to content

Commit

Permalink
feat: add general mm download cta experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
blaiseup committed Oct 7, 2024
1 parent 1222848 commit 644de4e
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions src/components/CTA.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,18 @@ const CTA = props => {
})

useEffect(() => {
const initMetaMaskDownloadCTAExperiment = async () => {
if (!flagName?.startsWith('mm-download-cta')) {
return
}
const value = await getLaunchDarklyFlag('meta-mask-download-cta-test')
setUseTextTreatment(value === 'treatment')
}

const init = async () => {
const EXPERIMENT_FLAG_NAMES = [
'home-portfolio-cta-test',
'home-download-cta-test',
]

// Clean up with portfolio experiment
const EXPERIMENT_FLAG_NAMES = ['home-portfolio-cta-test']

if (!EXPERIMENT_FLAG_NAMES.includes(flagName)) {
return
Expand All @@ -115,6 +122,7 @@ const CTA = props => {
}

init()
initMetaMaskDownloadCTAExperiment()
}, [getLaunchDarklyFlag, setUseTextTreatment, flagName])

const [link, setLink] = React.useState(ctaLink)
Expand All @@ -127,13 +135,21 @@ const CTA = props => {
const handleCustomClick = e => {
const trackableClasses = ['ld-portfolio-link', 'ld-download-link']

if (flagName === 'home-portfolio-cta-test') {
ldClient?.track('home-portfolio-cta-click')
if (flagName === 'mm-download-cta-home-hero') {
ldClient?.track('home-hero-download-cta-click')
ldClient?.flush()
}

if (flagName === 'home-download-cta-test') {
ldClient?.track('home-download-cta-click')
if (flagName === 'mm-download-cta-header') {
const currentPath = removeLanguageCode(location?.pathname)
if (currentPath === '/') {
ldClient?.track('home-header-download-cta-click')
ldClient?.flush()
}
}

if (flagName === 'home-portfolio-cta-test') {
ldClient?.track('home-portfolio-cta-click')
ldClient?.flush()
}

Expand Down

0 comments on commit 644de4e

Please sign in to comment.