overleaf/services/web/frontend/js/main/project-list/left-hand-menu-promo-controller.js
nate stemen dda4ce18d3 Merge pull request #2556 from overleaf/cmg-missing-analytics
Add missing Google Analytics events

GitOrigin-RevId: 37f8ca52829ea00bd73b2cd1e0045c48839ea970
2020-02-04 04:18:59 +00:00

33 lines
1 KiB
JavaScript

define(['base'], App =>
App.controller('LeftHandMenuPromoController', function(
$scope,
UserAffiliationsDataService,
eventTracking
) {
$scope.hasProjects = window.data.projects.length > 0
$scope.userHasNoSubscription = window.userHasNoSubscription
$scope.upgradeSubscription = function() {
eventTracking.send('subscription-funnel', 'project-page', 'upgrade')
}
$scope.share = function() {
eventTracking.send('subscription-funnel', 'project-page', 'sharing')
}
const _userHasNoAffiliation = function() {
$scope.userEmails = []
$scope.userAffiliations = []
return UserAffiliationsDataService.getUserEmails().then(function(emails) {
$scope.userEmails = emails
$scope.userAffiliations = emails
.filter(email => email.affiliation)
.map(email => email.affiliation)
$scope.userOnPayingUniversity = $scope.userAffiliations.some(
affiliation => affiliation.institution.licence !== 'free'
)
})
}
_userHasNoAffiliation()
}))