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'). script(type='text/javascript').
window.ga = function() { console.log("Sending to GA", arguments) }; window.ga = function() { console.log("Sending to GA", arguments) };
// Heap Analytics // Countly Analytics
if (settings.analytics && settings.analytics.heap && session && session.user) if (settings.analytics && settings.analytics.countly && settings.analytics.countly.token)
script(type="text/javascript"). 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])}; var Countly = Countly || {};
heap.load("#{settings.analytics.heap.token}"); Countly.q = Countly.q || [];
script(type="text/javascript"). Countly.app_key = '#{settings.analytics.countly.token}';
heap.identify({ Countly.url = 'https://try.count.ly';
handle: "#{session.user._id}",
email: "#{session.user.email}", Countly.q.push(['track_sessions']);
}) Countly.q.push(['track_pageview']);
// End Heap Analytics
(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"). script(type="text/javascript").
window.csrfToken = "#{csrfToken}"; window.csrfToken = "#{csrfToken}";

View file

@ -35,7 +35,7 @@ div.full-size(
resize-on="layout:main:resize,layout:pdf:resize", resize-on="layout:main:resize,layout:pdf:resize",
annotations="pdf.logEntryAnnotations[editor.open_doc_id]", annotations="pdf.logEntryAnnotations[editor.open_doc_id]",
read-only="!permissions.write", read-only="!permissions.write",
on-ctrl-enter="recompile" on-ctrl-enter="recompileViaKey"
) )
.ui-layout-east .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)") ng-bind-html="wikiEnabled ? entry.humanReadableHint : stripHTMLFromString(entry.humanReadableHint)")
.card-hint-actions.clearfix .card-hint-actions.clearfix
.card-hint-ext-link(ng-if="wikiEnabled") .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 i.fa.fa-external-link
|&nbsp;#{translate("log_hint_extra_info")} |&nbsp;#{translate("log_hint_extra_info")}
.card-hint-feedback( .card-hint-feedback(

View file

@ -42,7 +42,7 @@ define [
ReferencesManager 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 # Don't freak out if we're already in an apply callback
$scope.$originalApply = $scope.$apply $scope.$originalApply = $scope.$apply
$scope.$apply = (fn = () ->) -> $scope.$apply = (fn = () ->) ->
@ -69,6 +69,16 @@ define [
$scope.chat = {} $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 window._ide = ide

View file

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

View file

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

View file

@ -1,19 +1,43 @@
define [ define [
"base" "base"
], (App) -> ], (App) ->
App.factory "settings", ["ide", (ide) -> App.factory "settings", ["ide", "event_tracking", (ide, event_tracking) ->
return { return {
saveSettings: (data) -> 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 data._csrf = window.csrfToken
ide.$http.post "/user/settings", data ide.$http.post "/user/settings", data
saveProjectSettings: (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 data._csrf = window.csrfToken
ide.$http.post "/project/#{ide.project_id}/settings", data ide.$http.post "/project/#{ide.project_id}/settings", data
saveProjectAdminSettings: (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 data._csrf = window.csrfToken
ide.$http.post "/project/#{ide.project_id}/settings/admin", data ide.$http.post "/project/#{ide.project_id}/settings/admin", data
} }
] ]

View file

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

View file

@ -6,10 +6,23 @@ define [
return { return {
send: (category, action, label, value)-> send: (category, action, label, value)->
ga('send', 'event', 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 #header
$('.navbar a').on "click", (e)-> $('.navbar a').on "click", (e)->