account-upgrade.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import * as eventTracking from '../infrastructure/event-tracking'
  2. function startFreeTrial(source, version, $scope) {
  3. const plan = 'collaborator_free_trial_7_days'
  4. const w = window.open()
  5. const go = function () {
  6. let url
  7. if (typeof ga === 'function') {
  8. ga('send', 'event', 'subscription-funnel', 'upgraded-free-trial', source)
  9. }
  10. eventTracking.sendMB(`${source}-paywall-click`)
  11. url = `/user/subscription/new?planCode=${plan}&ssp=true`
  12. url = `${url}&itm_campaign=${source}`
  13. if (version) {
  14. url = `${url}&itm_content=${version}`
  15. }
  16. if ($scope) {
  17. $scope.startedFreeTrial = true
  18. }
  19. w.location = url
  20. }
  21. go()
  22. }
  23. function upgradePlan(source, $scope) {
  24. const w = window.open()
  25. const go = function () {
  26. if (typeof ga === 'function') {
  27. ga('send', 'event', 'subscription-funnel', 'upgraded-plan', source)
  28. }
  29. const url = '/user/subscription'
  30. if ($scope) {
  31. $scope.startedFreeTrial = true
  32. }
  33. w.location = url
  34. }
  35. go()
  36. }
  37. function paywallPrompt(source) {
  38. eventTracking.sendMB(`${source}-paywall-prompt`)
  39. }
  40. export { startFreeTrial, upgradePlan, paywallPrompt }