overleaf/services/web/public/coffee/main/account-upgrade.coffee

40 lines
1.3 KiB
CoffeeScript
Raw Normal View History

define [
"base"
], (App) ->
2016-07-12 15:41:22 +00:00
App.controller "FreeTrialModalController", ($scope, abTestManager, sixpack, event_tracking)->
$scope.buttonClass = "btn-primary"
2015-11-16 15:52:47 +00:00
$scope.startFreeTrial = (source, couponCode) ->
plan = 'collaborator_free_trial_7_days'
w = window.open()
go = () ->
ga?('send', 'event', 'subscription-funnel', 'upgraded-free-trial', source)
url = "/user/subscription/new?planCode=#{plan}&ssp=true"
if couponCode?
url = "#{url}&cc=#{couponCode}"
$scope.startedFreeTrial = true
2016-10-27 11:22:58 +00:00
switch source
when "dropbox"
sixpack.participate 'teaser-dropbox-text', ['default', 'dropbox-focused'], (variant) ->
event_tracking.sendMB "subscription-start-trial", { source, plan, variant }
2016-10-27 11:22:58 +00:00
when "history"
sixpack.participate 'teaser-history', ['default', 'focused'], (variant) ->
event_tracking.sendMB "subscription-start-trial", { source, plan, variant }
2016-10-27 11:22:58 +00:00
else
event_tracking.sendMB "subscription-start-trial", { source, plan }
w.location = url
2016-10-27 11:22:58 +00:00
if $scope.shouldABTestPlans
sixpack.participate 'plans-1610', ['default', 'heron', 'ibis'], (chosenVariation, rawResponse)->
if chosenVariation in ['heron', 'ibis']
plan = "collaborator_#{chosenVariation}"
go()
else
go()