2014-11-24 18:59:55 -05:00
|
|
|
define [
|
|
|
|
"base"
|
|
|
|
], (App) ->
|
2016-07-12 11:41:22 -04:00
|
|
|
App.controller "FreeTrialModalController", ($scope, abTestManager, sixpack, event_tracking)->
|
2014-11-24 18:59:55 -05:00
|
|
|
|
2015-10-27 19:35:13 -04:00
|
|
|
$scope.buttonClass = "btn-primary"
|
2014-11-24 18:59:55 -05:00
|
|
|
|
2015-11-16 10:52:47 -05:00
|
|
|
$scope.startFreeTrial = (source, couponCode) ->
|
2016-10-25 05:47:14 -04:00
|
|
|
plan = 'collaborator_free_trial_7_days'
|
2016-07-13 04:49:57 -04:00
|
|
|
|
2015-11-17 09:56:03 -05:00
|
|
|
w = window.open()
|
2016-10-25 06:46:52 -04:00
|
|
|
go = () ->
|
2016-10-25 05:47:14 -04:00
|
|
|
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 07:22:58 -04:00
|
|
|
|
2016-10-27 07:35:11 -04: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 07:22:58 -04:00
|
|
|
|
2016-10-27 07:35:11 -04:00
|
|
|
when "history"
|
|
|
|
sixpack.participate 'teaser-history', ['default', 'focused'], (variant) ->
|
|
|
|
event_tracking.sendMB "subscription-start-trial", { source, plan, variant }
|
2016-10-27 07:22:58 -04:00
|
|
|
|
2016-10-27 07:35:11 -04:00
|
|
|
else
|
|
|
|
event_tracking.sendMB "subscription-start-trial", { source, plan }
|
|
|
|
|
2016-10-25 05:47:14 -04:00
|
|
|
w.location = url
|
2016-10-27 07:22:58 -04:00
|
|
|
|
2016-10-25 06:46:52 -04:00
|
|
|
if $scope.shouldABTestPlans
|
|
|
|
sixpack.participate 'plans-1610', ['default', 'heron', 'ibis'], (chosenVariation, rawResponse)->
|
|
|
|
if chosenVariation in ['heron', 'ibis']
|
|
|
|
plan = "collaborator_#{chosenVariation}"
|
|
|
|
go()
|
|
|
|
else
|
|
|
|
go()
|