mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #289 from sharelatex/pr-countly-pruning
Countly pruning
This commit is contained in:
commit
d6be52af27
5 changed files with 35 additions and 11 deletions
|
@ -56,9 +56,6 @@ html(itemscope, itemtype='http://schema.org/Product')
|
|||
Countly.url = '#{settings.analytics.countly.server}';
|
||||
!{ session.user ? 'Countly.device_id = "' + session.user._id + '";' : '' }
|
||||
|
||||
Countly.q.push(['track_sessions']);
|
||||
Countly.q.push(['track_pageview']);
|
||||
|
||||
(function() {
|
||||
var cly = document.createElement('script'); cly.type = 'text/javascript';
|
||||
cly.async = true;
|
||||
|
|
|
@ -72,13 +72,13 @@ define [
|
|||
# Tracking code.
|
||||
$scope.$watch "ui.view", (newView, oldView) ->
|
||||
if newView? and newView != "editor" and newView != "pdf"
|
||||
event_tracking.sendCountly "ide-open-view-#{ newView }"
|
||||
event_tracking.sendCountlyOnce "ide-open-view-#{ newView }-once"
|
||||
|
||||
$scope.$watch "ui.chatOpen", (isOpen) ->
|
||||
event_tracking.sendCountly "ide-open-chat" if isOpen
|
||||
event_tracking.sendCountlyOnce "ide-open-chat-once" if isOpen
|
||||
|
||||
$scope.$watch "ui.leftMenuShown", (isOpen) ->
|
||||
event_tracking.sendCountly "ide-open-left-menu" if isOpen
|
||||
event_tracking.sendCountlyOnce "ide-open-left-menu-once" if isOpen
|
||||
# End of tracking code.
|
||||
|
||||
window._ide = ide
|
||||
|
|
|
@ -333,7 +333,7 @@ define [
|
|||
|
||||
$scope.toggleLogs = () ->
|
||||
$scope.shouldShowLogs = !$scope.shouldShowLogs
|
||||
event_tracking.sendCountly "ide-open-logs" if $scope.shouldShowLogs
|
||||
event_tracking.sendCountlyOnce "ide-open-logs-once" if $scope.shouldShowLogs
|
||||
|
||||
$scope.showPdf = () ->
|
||||
$scope.pdf.view = "pdf"
|
||||
|
@ -499,7 +499,7 @@ define [
|
|||
|
||||
App.controller "PdfLogEntryController", ["$scope", "ide", "event_tracking", ($scope, ide, event_tracking) ->
|
||||
$scope.openInEditor = (entry) ->
|
||||
event_tracking.sendCountly 'logs-jump-to-location'
|
||||
event_tracking.sendCountlyOnce "logs-jump-to-location-once"
|
||||
entity = ide.fileTreeManager.findEntityByPath(entry.file)
|
||||
return if !entity? or entity.type != "doc"
|
||||
if entry.line?
|
||||
|
|
|
@ -3,7 +3,7 @@ define [
|
|||
], (App) ->
|
||||
App.controller "ShareController", ["$scope", "$modal", "event_tracking", ($scope, $modal, event_tracking) ->
|
||||
$scope.openShareProjectModal = () ->
|
||||
event_tracking.sendCountly "ide-open-share-modal"
|
||||
event_tracking.sendCountlyOnce "ide-open-share-modal-once"
|
||||
|
||||
$modal.open(
|
||||
templateUrl: "shareProjectModalTemplate"
|
||||
|
|
|
@ -1,8 +1,30 @@
|
|||
define [
|
||||
"base"
|
||||
"modules/localStorage"
|
||||
], (App) ->
|
||||
CACHE_KEY = "countlyEvents"
|
||||
|
||||
App.factory "event_tracking", (localStorage) ->
|
||||
_getEventCache = () ->
|
||||
eventCache = localStorage CACHE_KEY
|
||||
|
||||
# Initialize as an empy object if the event cache is still empty.
|
||||
if !eventCache?
|
||||
eventCache = {}
|
||||
localStorage CACHE_KEY, eventCache
|
||||
|
||||
return eventCache
|
||||
|
||||
_eventInCache = (key) ->
|
||||
curCache = _getEventCache()
|
||||
curCache[key] || false
|
||||
|
||||
_addEventToCache = (key) ->
|
||||
curCache = _getEventCache()
|
||||
curCache[key] = true
|
||||
|
||||
localStorage CACHE_KEY, curCache
|
||||
|
||||
App.factory "event_tracking", ->
|
||||
return {
|
||||
send: (category, action, label, value)->
|
||||
ga('send', 'event', category, action, label, value)
|
||||
|
@ -10,10 +32,15 @@ define [
|
|||
sendCountly: (key, segmentation) ->
|
||||
eventData = { key }
|
||||
eventData.segmentation = segmentation if segmentation?
|
||||
Countly?.q.push([ "add_event", eventData ]);
|
||||
Countly?.q.push([ "add_event", eventData ])
|
||||
|
||||
sendCountlySampled: (key, segmentation) ->
|
||||
@sendCountly key, segmentation if Math.random() < .01
|
||||
|
||||
sendCountlyOnce: (key, segmentation) ->
|
||||
if ! _eventInCache(key)
|
||||
_addEventToCache(key)
|
||||
@sendCountly key, segmentation
|
||||
}
|
||||
|
||||
# App.directive "countlyTrack", () ->
|
||||
|
|
Loading…
Reference in a new issue