account-upgrade.js 1.0 KB

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