Skip to content

Commit 399f216

Browse files
authored
fix: wrap upgrade button and messaging with Google Optimize (#4503)
1 parent 555262d commit 399f216

File tree

5 files changed

+73
-51
lines changed

5 files changed

+73
-51
lines changed

docker/Dockerfile.chronograf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ ENV GLOBALSEARCH_API_KEY=
2727
ENV GLOBALSEARCH_APP_ID=
2828
# Google Experiments ENV vars
2929
ENV PAYG_CREDIT_EXPERIMENT_ID=
30+
ENV CREDIT_250_EXPERIMENT_ID=
3031

3132
# This is the origin of the URL needed to access the running container (optional)
3233
# ENV PUBLIC=http://foobar

docker/Dockerfile.chronograf.prod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ ARG GLOBALSEARCH_API_KEY
4040
ARG GLOBALSEARCH_APP_ID
4141
# Google Experiment ID for PAYG $250 Credit
4242
ARG PAYG_CREDIT_EXPERIMENT_ID
43+
# Google Experiment ID for Get $250 Credit
44+
ARG CREDIT_250_EXPERIMENT_ID
4345

4446
COPY . /repo/ui
4547
WORKDIR /repo/ui

src/cloud/components/RateLimitAlertContent.tsx

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
ComponentColor,
1313
} from '@influxdata/clockface'
1414
import CloudUpgradeButton from 'src/shared/components/CloudUpgradeButton'
15+
import {SafeBlankLink} from 'src/utils/SafeBlankLink'
1516

1617
// Actions
1718
import {showOverlay, dismissOverlay} from 'src/overlays/actions/overlays'
@@ -22,6 +23,10 @@ import {event} from 'src/cloud/utils/reporting'
2223

2324
// Utils
2425
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
26+
import {GoogleOptimizeExperiment} from 'src/cloud/components/experiments/GoogleOptimizeExperiment'
27+
28+
// Constants
29+
import {CREDIT_250_EXPERIMENT_ID} from 'src/shared/constants'
2530

2631
interface Props {
2732
className?: string
@@ -43,38 +48,38 @@ interface UpgradeMessageProps {
4348
}
4449

4550
const UpgradeMessage: FC<UpgradeMessageProps> = ({limitText, link, type}) => {
46-
if (isFlagEnabled('credit250Experiment')) {
47-
return (
48-
<span className="upgrade-message">
49-
You hit the{' '}
50-
<a
51-
href={link}
52-
className="rate-alert--docs-link"
53-
target="_blank"
54-
rel="noreferrer"
55-
>
56-
{type === 'series cardinality' ? 'series cardinality' : 'query write'}
57-
</a>{' '}
58-
limit {limitText ?? ''} and your data stopped writing. Upgrade to get a
59-
free $250 credit for the first 30 days.
60-
</span>
61-
)
62-
}
63-
return (
51+
const original = (
6452
<span className="upgrade-message">
6553
Oh no! You hit the{' '}
66-
<a
67-
href={link}
68-
className="rate-alert--docs-link"
69-
target="_blank"
70-
rel="noreferrer"
71-
>
54+
<SafeBlankLink href={link}>
7255
{type === 'series cardinality' ? 'series cardinality' : 'query write'}
73-
</a>{' '}
56+
</SafeBlankLink>{' '}
7457
limit {limitText ?? ''} and your data stopped writing. Don't lose
7558
important metrics.
7659
</span>
7760
)
61+
62+
if (isFlagEnabled('credit250Experiment')) {
63+
return (
64+
<GoogleOptimizeExperiment
65+
experimentID={CREDIT_250_EXPERIMENT_ID}
66+
original={original}
67+
variants={[
68+
<span className="upgrade-message" key="1">
69+
You hit the{' '}
70+
<SafeBlankLink href={link}>
71+
{type === 'series cardinality'
72+
? 'series cardinality'
73+
: 'query write'}
74+
</SafeBlankLink>{' '}
75+
limit {limitText ?? ''} and your data stopped writing. Upgrade to
76+
get a free $250 credit for the first 30 days.
77+
</span>,
78+
]}
79+
/>
80+
)
81+
}
82+
return original
7883
}
7984

8085
export const UpgradeContent: FC<UpgradeProps> = ({
@@ -127,14 +132,9 @@ const RateLimitAlertContent: FC<Props> = ({className, location}) => {
127132
<div className={`${rateLimitAlertContentClass} rate-alert--content__payg`}>
128133
<span>
129134
Data in has stopped because you've hit the{' '}
130-
<a
131-
href="https://docs.influxdata.com/influxdb/v2.0/write-data/best-practices/resolve-high-cardinality/"
132-
className="rate-alert--docs-link"
133-
target="_blank"
134-
rel="noreferrer"
135-
>
135+
<SafeBlankLink href="https://docs.influxdata.com/influxdb/v2.0/write-data/best-practices/resolve-high-cardinality/">
136136
series cardinality
137-
</a>{' '}
137+
</SafeBlankLink>{' '}
138138
limit. Let's get it flowing again.
139139
</span>
140140
<FlexBox

src/shared/components/CloudUpgradeButton.tsx

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ import CloudOnly from 'src/shared/components/cloud/CloudOnly'
1616
// Utils
1717
import {shouldShowUpgradeButton} from 'src/me/selectors'
1818
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
19+
import {GoogleOptimizeExperiment} from 'src/cloud/components/experiments/GoogleOptimizeExperiment'
1920

21+
// Constants
22+
import {CREDIT_250_EXPERIMENT_ID} from 'src/shared/constants'
2023
interface OwnProps {
2124
buttonText?: string
2225
className?: string
@@ -47,28 +50,43 @@ const CloudUpgradeButton: FC<OwnProps> = ({
4750
history.push('/checkout')
4851
}
4952

50-
const promoMessage =
51-
isFlagEnabled('credit250Experiment') && showPromoMessage ? (
52-
<span className="credit-250-experiment-upgrade-button--text">
53-
Get $250 free credit
54-
</span>
55-
) : null
53+
const original = showUpgradeButton && (
54+
<Button
55+
className={cloudUpgradeButtonClass}
56+
icon={IconFont.CrownSolid_New}
57+
onClick={handleClick}
58+
shape={ButtonShape.Default}
59+
size={size}
60+
testID="cloud-upgrade--button"
61+
text={buttonText}
62+
/>
63+
)
5664

5765
return (
5866
<CloudOnly>
59-
{showUpgradeButton && (
60-
<span>
61-
{promoMessage}
62-
<Button
63-
icon={IconFont.CrownSolid_New}
64-
className={cloudUpgradeButtonClass}
65-
size={size}
66-
shape={ButtonShape.Default}
67-
onClick={handleClick}
68-
text={buttonText}
69-
testID="cloud-upgrade--button"
70-
/>
71-
</span>
67+
{isFlagEnabled('credit250Experiment') && showPromoMessage ? (
68+
<GoogleOptimizeExperiment
69+
experimentID={CREDIT_250_EXPERIMENT_ID}
70+
original={original}
71+
variants={[
72+
<span key="1">
73+
<span className="credit-250-experiment-upgrade-button--text">
74+
Get $250 free credit
75+
</span>
76+
<Button
77+
className={cloudUpgradeButtonClass}
78+
icon={IconFont.CrownSolid_New}
79+
onClick={handleClick}
80+
shape={ButtonShape.Default}
81+
size={size}
82+
testID="cloud-upgrade--button"
83+
text={buttonText}
84+
/>
85+
</span>,
86+
]}
87+
/>
88+
) : (
89+
original
7290
)}
7391
</CloudOnly>
7492
)

src/shared/constants/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,4 @@ export const GLOBALSEARCH_API_KEY = formatConstant(
166166
export const PAYG_CREDIT_DAYS = 30
167167
export const PAYG_MAX_CREDIT = 250
168168
export const PAYG_CREDIT_EXPERIMENT_ID = process.env.PAYG_CREDIT_EXPERIMENT_ID
169+
export const CREDIT_250_EXPERIMENT_ID = process.env.CREDIT_250_EXPERIMENT_ID

0 commit comments

Comments
 (0)