mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-26 06:20:53 +00:00
c5f883ad83
Merge paywall-prompt and paywall-click events GitOrigin-RevId: d567631d08b89565f9a3049f9b88cc2d14a799c1
60 lines
1.5 KiB
JavaScript
60 lines
1.5 KiB
JavaScript
import { useCallback, useEffect } from 'react'
|
|
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()
|
|
|
|
useEffect(() => {
|
|
eventTracking.sendMB('paywall-prompt', { 'paywall-type': source })
|
|
}, [source])
|
|
|
|
const handleClick = useCallback(
|
|
event => {
|
|
event.preventDefault()
|
|
|
|
eventTracking.send('subscription-funnel', 'upgraded-free-trial', source)
|
|
eventTracking.sendMB('paywall-click', { 'paywall-type': source })
|
|
|
|
if (setStartedFreeTrial) {
|
|
setStartedFreeTrial(true)
|
|
}
|
|
|
|
const params = new URLSearchParams({
|
|
planCode: 'collaborator_free_trial_7_days',
|
|
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,
|
|
}
|