Merge branch 'master' of github.com:sharelatex/web-sharelatex

This commit is contained in:
Shane Kilkelly 2016-07-06 15:39:12 +01:00
commit 21eb104928
9 changed files with 120 additions and 19 deletions

View file

@ -48,17 +48,50 @@ html(itemscope, itemtype='http://schema.org/Product')
script(type='text/javascript').
window.ga = function() { console.log("Sending to GA", arguments) };
// Heap Analytics
if (settings.analytics && settings.analytics.heap && session && session.user)
// Countly Analytics
if (settings.analytics && settings.analytics.countly && settings.analytics.countly.token)
script(type="text/javascript").
window.heap=window.heap||[],heap.load=function(e,t){window.heap.appid=e,window.heap.config=t=t||{};var n=t.forceSSL||"https:"===document.location.protocol,a=document.createElement("script");a.type="text/javascript",a.async=!0,a.src=(n?"https:":"http:")+"//cdn.heapanalytics.com/js/heap-"+e+".js";var o=document.getElementsByTagName("script")[0];o.parentNode.insertBefore(a,o);for(var r=function(e){return function(){heap.push([e].concat(Array.prototype.slice.call(arguments,0)))}},p=["clearEventProperties","identify","setEventProperties","track","unsetEventProperty"],c=0;c<p.length;c++)heap[p[c]]=r(p[c])};
heap.load("#{settings.analytics.heap.token}");
script(type="text/javascript").
heap.identify({
handle: "#{session.user._id}",
email: "#{session.user.email}",
})
// End Heap Analytics
var Countly = Countly || {};
Countly.q = Countly.q || [];
Countly.app_key = '#{settings.analytics.countly.token}';
Countly.url = 'https://try.count.ly';
Countly.q.push(['track_sessions']);
Countly.q.push(['track_pageview']);
(function() {
var cly = document.createElement('script'); cly.type = 'text/javascript';
cly.async = true;
//enter url of script here
cly.src = 'https://cdnjs.cloudflare.com/ajax/libs/countly-sdk-web/16.6.0/countly.min.js';
cly.onload = function(){Countly.init()};
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(cly, s);
})();
if (session && session.user)
script(type="text/javascript").
Countly.q.push(['change_id', '#{session.user._id}', true ]);
Countly.q.push(['user_details', {
email: '#{session.user.email}',
custom: {
userId: '#{session.user._id}',
}
}]);
if (justRegistered)
script(type="text/javascript").
Countly.q.push(['add_event',{
key: 'user-registered'
}]);
if (justLoggedIn)
script(type="text/javascript").
Countly.q.push(['add_event',{
key: 'user-logged-in'
}]);
// End countly Analytics
script(type="text/javascript").
window.csrfToken = "#{csrfToken}";

View file

@ -35,7 +35,7 @@ div.full-size(
resize-on="layout:main:resize,layout:pdf:resize",
annotations="pdf.logEntryAnnotations[editor.open_doc_id]",
read-only="!permissions.write",
on-ctrl-enter="recompile"
on-ctrl-enter="recompileViaKey"
)
.ui-layout-east

View file

@ -119,7 +119,11 @@ div.full-size.pdf(ng-controller="PdfController")
ng-bind-html="wikiEnabled ? entry.humanReadableHint : stripHTMLFromString(entry.humanReadableHint)")
.card-hint-actions.clearfix
.card-hint-ext-link(ng-if="wikiEnabled")
a(ng-href="{{ entry.extraInfoURL }}", target="_blank")
a(
ng-href="{{ entry.extraInfoURL }}",
ng-click="trackLogHintsLearnMore()"
target="_blank"
)
i.fa.fa-external-link
|&nbsp;#{translate("log_hint_extra_info")}
.card-hint-feedback(

View file

@ -42,7 +42,7 @@ define [
ReferencesManager
) ->
App.controller "IdeController", ($scope, $timeout, ide, localStorage) ->
App.controller "IdeController", ($scope, $timeout, ide, localStorage, event_tracking) ->
# Don't freak out if we're already in an apply callback
$scope.$originalApply = $scope.$apply
$scope.$apply = (fn = () ->) ->
@ -69,6 +69,16 @@ define [
$scope.chat = {}
# Tracking code.
$scope.$watch "ui.view", (newView, oldView) ->
event_tracking.sendCountly "ide-open-view-#{ newView }" if newView?
$scope.$watch "ui.chatOpen", (isOpen) ->
event_tracking.sendCountly "ide-open-chat" if isOpen
$scope.$watch "ui.leftMenuShown", (isOpen) ->
event_tracking.sendCountly "ide-open-left-menu" if isOpen
# End of tracking code.
window._ide = ide

View file

@ -2,8 +2,10 @@ define [
"base"
"ace/ace"
], (App) ->
App.controller "HotkeysController", ($scope, $modal) ->
App.controller "HotkeysController", ($scope, $modal, event_tracking) ->
$scope.openHotkeysModal = ->
event_tracking.sendCountly "ide-open-hotkeys-modal"
$modal.open {
templateUrl: "hotkeysModalTemplate"
controller: "HotkeysModalController"

View file

@ -16,8 +16,12 @@ define [
$scope.wikiEnabled = window.wikiEnabled;
# log hints tracking
$scope.trackLogHintsLearnMore = () ->
event_tracking.sendCountly "logs-hints-learn-more"
trackLogHintsFeedback = (isPositive, hintId) ->
event_tracking.send 'log-hints', (if isPositive then 'feedback-positive' else 'feedback-negative'), hintId
event_tracking.sendCountly "log-hints-feedback", { isPositive, hintId }
$scope.trackLogHintsPositiveFeedback = (hintId) -> trackLogHintsFeedback true, hintId
$scope.trackLogHintsNegativeFeedback = (hintId) -> trackLogHintsFeedback false, hintId
@ -247,7 +251,10 @@ define [
return path
$scope.recompile = (options = {}) ->
event_tracking.sendCountly "editor-recompile", options
return if $scope.pdf.compiling
$scope.pdf.compiling = true
ide.$scope.$broadcast("flush-changes")
@ -267,6 +274,9 @@ define [
# This needs to be public.
ide.$scope.recompile = $scope.recompile
# This method is a simply wrapper and exists only for tracking purposes.
ide.$scope.recompileViaKey = () ->
$scope.recompile { keyShortcut: true }
$scope.clearCache = () ->
$http {
@ -280,6 +290,7 @@ define [
$scope.toggleLogs = () ->
$scope.shouldShowLogs = !$scope.shouldShowLogs
event_tracking.sendCountly "ide-open-logs" if $scope.shouldShowLogs
$scope.showPdf = () ->
$scope.pdf.view = "pdf"
@ -287,6 +298,7 @@ define [
$scope.toggleRawLog = () ->
$scope.pdf.showRawLog = !$scope.pdf.showRawLog
event_tracking.sendCountly "logs-view-raw" if $scope.pdf.showRawLog
$scope.openClearCacheModal = () ->
modalInstance = $modal.open(
@ -439,8 +451,9 @@ define [
ide.editorManager.openDoc(doc, gotoLine: line)
]
App.controller "PdfLogEntryController", ["$scope", "ide", ($scope, ide) ->
App.controller "PdfLogEntryController", ["$scope", "ide", "event_tracking", ($scope, ide, event_tracking) ->
$scope.openInEditor = (entry) ->
event_tracking.sendCountly 'logs-jump-to-location'
entity = ide.fileTreeManager.findEntityByPath(entry.file)
return if !entity? or entity.type != "doc"
if entry.line?

View file

@ -1,19 +1,43 @@
define [
"base"
], (App) ->
App.factory "settings", ["ide", (ide) ->
App.factory "settings", ["ide", "event_tracking", (ide, event_tracking) ->
return {
saveSettings: (data) ->
# Tracking code.
for key in Object.keys(data)
changedSetting = key
changedSettingVal = data[key]
event_tracking.sendCountly "setting-changed", { changedSetting, changedSettingVal }
# End of tracking code.
data._csrf = window.csrfToken
ide.$http.post "/user/settings", data
saveProjectSettings: (data) ->
# Tracking code.
for key in Object.keys(data)
changedSetting = key
changedSettingVal = data[key]
event_tracking.sendCountly "project-setting-changed", { changedSetting, changedSettingVal}
# End of tracking code.
data._csrf = window.csrfToken
ide.$http.post "/project/#{ide.project_id}/settings", data
saveProjectAdminSettings: (data) ->
# Tracking code.
for key in Object.keys(data)
changedSetting = key
changedSettingVal = data[key]
event_tracking.sendCountly "project-admin-setting-changed", { changedSetting, changedSettingVal }
# End of tracking code.
data._csrf = window.csrfToken
ide.$http.post "/project/#{ide.project_id}/settings/admin", data
}
]

View file

@ -1,8 +1,10 @@
define [
"base"
], (App) ->
App.controller "ShareController", ["$scope", "$modal", ($scope, $modal) ->
App.controller "ShareController", ["$scope", "$modal", "event_tracking", ($scope, $modal, event_tracking) ->
$scope.openShareProjectModal = () ->
event_tracking.sendCountly "ide-open-share-modal"
$modal.open(
templateUrl: "shareProjectModalTemplate"
controller: "ShareProjectModalController"

View file

@ -6,10 +6,23 @@ define [
return {
send: (category, action, label, value)->
ga('send', 'event', category, action, label, value)
event_name = "#{action}-#{category}"
window?.heap?.track?(event_name, {label, value})
sendCountly: (key, segmentation) ->
eventData = { key }
eventData.segmentation = segmentation if segmentation?
Countly?.q.push([ "add_event", eventData ]);
}
# App.directive "countlyTrack", () ->
# return {
# restrict: "A"
# scope: false,
# link: (scope, el, attrs) ->
# eventKey = attrs.countlyTrack
# if (eventKey?)
# el.on "click", () ->
# console.log eventKey
# }
#header
$('.navbar a').on "click", (e)->