2021-06-23 05:37:08 -04:00
|
|
|
import { useCallback, useEffect } from 'react'
|
2021-04-30 16:20:16 -04:00
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import { Button } from 'react-bootstrap'
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import * as eventTracking from '../../infrastructure/event-tracking'
|
|
|
|
|
|
|
|
export default function StartFreeTrialButton({
|
|
|
|
buttonStyle = 'info',
|
|
|
|
children,
|
|
|
|
classes = {},
|
|
|
|
setStartedFreeTrial,
|
|
|
|
source,
|
|
|
|
}) {
|
|
|
|
const { t } = useTranslation()
|
|
|
|
|
2021-06-10 04:04:21 -04:00
|
|
|
useEffect(() => {
|
|
|
|
eventTracking.sendMB(`${source}-paywall-prompt`)
|
|
|
|
}, [source])
|
|
|
|
|
2021-04-30 16:20:16 -04:00
|
|
|
const handleClick = useCallback(
|
|
|
|
event => {
|
|
|
|
event.preventDefault()
|
|
|
|
|
|
|
|
eventTracking.send('subscription-funnel', 'upgraded-free-trial', source)
|
2021-06-10 04:04:21 -04:00
|
|
|
eventTracking.sendMB(`${source}-paywall-click`)
|
2021-04-30 16:20:16 -04:00
|
|
|
|
|
|
|
if (setStartedFreeTrial) {
|
|
|
|
setStartedFreeTrial(true)
|
|
|
|
}
|
|
|
|
|
|
|
|
const params = new URLSearchParams({
|
2021-06-10 04:04:21 -04:00
|
|
|
planCode: 'collaborator_free_trial_7_days',
|
2021-04-30 16:20:16 -04:00
|
|
|
ssp: 'true',
|
|
|
|
itm_campaign: source,
|
|
|
|
})
|
|
|
|
|
|
|
|
window.open(`/user/subscription/new?${params}`)
|
|
|
|
},
|
|
|
|
[setStartedFreeTrial, source]
|
|
|
|
)
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Button
|
|
|
|
bsStyle={buttonStyle}
|
|
|
|
onClick={handleClick}
|
|
|
|
className={classes.button}
|
|
|
|
>
|
|
|
|
{children || t('start_free_trial')}
|
|
|
|
</Button>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
StartFreeTrialButton.propTypes = {
|
|
|
|
buttonStyle: PropTypes.string,
|
|
|
|
children: PropTypes.any,
|
|
|
|
classes: PropTypes.shape({
|
|
|
|
button: PropTypes.string.isRequired,
|
|
|
|
}),
|
|
|
|
setStartedFreeTrial: PropTypes.func,
|
|
|
|
source: PropTypes.string.isRequired,
|
|
|
|
}
|