mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
c634f51eee
Add paywall prompt events GitOrigin-RevId: 6b1b3b384590f14828f37210b2e14047e2ee33d6
52 lines
1.1 KiB
JavaScript
52 lines
1.1 KiB
JavaScript
import * as eventTracking from '../infrastructure/event-tracking'
|
|
|
|
function startFreeTrial(source, version, $scope) {
|
|
const plan = 'collaborator_free_trial_7_days'
|
|
|
|
const w = window.open()
|
|
const go = function () {
|
|
let url
|
|
if (typeof ga === 'function') {
|
|
ga('send', 'event', 'subscription-funnel', 'upgraded-free-trial', source)
|
|
}
|
|
eventTracking.sendMB(`${source}-paywall-click`)
|
|
|
|
url = `/user/subscription/new?planCode=${plan}&ssp=true`
|
|
url = `${url}&itm_campaign=${source}`
|
|
if (version) {
|
|
url = `${url}&itm_content=${version}`
|
|
}
|
|
|
|
if ($scope) {
|
|
$scope.startedFreeTrial = true
|
|
}
|
|
|
|
w.location = url
|
|
}
|
|
|
|
go()
|
|
}
|
|
|
|
function upgradePlan(source, $scope) {
|
|
const w = window.open()
|
|
const go = function () {
|
|
if (typeof ga === 'function') {
|
|
ga('send', 'event', 'subscription-funnel', 'upgraded-plan', source)
|
|
}
|
|
const url = '/user/subscription'
|
|
|
|
if ($scope) {
|
|
$scope.startedFreeTrial = true
|
|
}
|
|
|
|
w.location = url
|
|
}
|
|
|
|
go()
|
|
}
|
|
|
|
function paywallPrompt(source) {
|
|
eventTracking.sendMB(`${source}-paywall-prompt`)
|
|
}
|
|
|
|
export { startFreeTrial, upgradePlan, paywallPrompt }
|