Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for download cta copy ab test #419

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions src/components/CTA.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,13 @@ const CTA = props => {
const location = useLocation()

useEffect(() => {
if (useTextTreatment) {
setText(textTreatment)
} else {
setText(textDefault)
}
const currentText = useTextTreatment ? textTreatment : textDefault
setText(currentText)
setCtaLink(linkDefault)
setIconBrowser('')

if (isDownloadBrowser && keyBrowser && downloadBrowsers[keyBrowser]) {
let newText = textDefault
let newText = currentText

newText = newText?.replace('$browser', downloadBrowsers[keyBrowser]?.text)

Expand All @@ -96,17 +93,23 @@ const CTA = props => {
newText = downloadBrowsers[keyBrowser].text
}

setText(newText)
setCtaLink(downloadBrowsers[keyBrowser]?.link)
setIconBrowser(downloadBrowsers[keyBrowser]?.icon)
}
})

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

if (!EXPERIMENT_FLAG_NAMES.includes(flagName)) {
return
}
const value = await getLaunchDarklyFlag('home-portfolio-cta-test')
const value = await getLaunchDarklyFlag(flagName)
setUseTextTreatment(value === 'treatment')
}

Expand All @@ -128,6 +131,11 @@ const CTA = props => {
ldClient?.flush()
}

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

if (flagName === 'navbar-view-portfolio-cta') {
const currentPath = removeLanguageCode(location?.pathname)
if (currentPath === '/') {
Expand Down
Loading