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}';
|
Countly.url = '#{settings.analytics.countly.server}';
|
||||||
!{ session.user ? 'Countly.device_id = "' + session.user._id + '";' : '' }
|
!{ session.user ? 'Countly.device_id = "' + session.user._id + '";' : '' }
|
||||||
|
|
||||||
Countly.q.push(['track_sessions']);
|
|
||||||
Countly.q.push(['track_pageview']);
|
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var cly = document.createElement('script'); cly.type = 'text/javascript';
|
var cly = document.createElement('script'); cly.type = 'text/javascript';
|
||||||
cly.async = true;
|
cly.async = true;
|
||||||
|
|
|
@ -72,13 +72,13 @@ define [
|
||||||
# Tracking code.
|
# Tracking code.
|
||||||
$scope.$watch "ui.view", (newView, oldView) ->
|
$scope.$watch "ui.view", (newView, oldView) ->
|
||||||
if newView? and newView != "editor" and newView != "pdf"
|
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) ->
|
$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) ->
|
$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.
|
# End of tracking code.
|
||||||
|
|
||||||
window._ide = ide
|
window._ide = ide
|
||||||
|
|
|
@ -333,7 +333,7 @@ define [
|
||||||
|
|
||||||
$scope.toggleLogs = () ->
|
$scope.toggleLogs = () ->
|
||||||
$scope.shouldShowLogs = !$scope.shouldShowLogs
|
$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.showPdf = () ->
|
||||||
$scope.pdf.view = "pdf"
|
$scope.pdf.view = "pdf"
|
||||||
|
@ -499,7 +499,7 @@ define [
|
||||||
|
|
||||||
App.controller "PdfLogEntryController", ["$scope", "ide", "event_tracking", ($scope, ide, event_tracking) ->
|
App.controller "PdfLogEntryController", ["$scope", "ide", "event_tracking", ($scope, ide, event_tracking) ->
|
||||||
$scope.openInEditor = (entry) ->
|
$scope.openInEditor = (entry) ->
|
||||||
event_tracking.sendCountly 'logs-jump-to-location'
|
event_tracking.sendCountlyOnce "logs-jump-to-location-once"
|
||||||
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?
|
||||||
|
|
|
@ -3,7 +3,7 @@ define [
|
||||||
], (App) ->
|
], (App) ->
|
||||||
App.controller "ShareController", ["$scope", "$modal", "event_tracking", ($scope, $modal, event_tracking) ->
|
App.controller "ShareController", ["$scope", "$modal", "event_tracking", ($scope, $modal, event_tracking) ->
|
||||||
$scope.openShareProjectModal = () ->
|
$scope.openShareProjectModal = () ->
|
||||||
event_tracking.sendCountly "ide-open-share-modal"
|
event_tracking.sendCountlyOnce "ide-open-share-modal-once"
|
||||||
|
|
||||||
$modal.open(
|
$modal.open(
|
||||||
templateUrl: "shareProjectModalTemplate"
|
templateUrl: "shareProjectModalTemplate"
|
||||||
|
|
|
@ -1,8 +1,30 @@
|
||||||
define [
|
define [
|
||||||
"base"
|
"base"
|
||||||
|
"modules/localStorage"
|
||||||
], (App) ->
|
], (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 {
|
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)
|
||||||
|
@ -10,10 +32,15 @@ define [
|
||||||
sendCountly: (key, segmentation) ->
|
sendCountly: (key, segmentation) ->
|
||||||
eventData = { key }
|
eventData = { key }
|
||||||
eventData.segmentation = segmentation if segmentation?
|
eventData.segmentation = segmentation if segmentation?
|
||||||
Countly?.q.push([ "add_event", eventData ]);
|
Countly?.q.push([ "add_event", eventData ])
|
||||||
|
|
||||||
sendCountlySampled: (key, segmentation) ->
|
sendCountlySampled: (key, segmentation) ->
|
||||||
@sendCountly key, segmentation if Math.random() < .01
|
@sendCountly key, segmentation if Math.random() < .01
|
||||||
|
|
||||||
|
sendCountlyOnce: (key, segmentation) ->
|
||||||
|
if ! _eventInCache(key)
|
||||||
|
_addEventToCache(key)
|
||||||
|
@sendCountly key, segmentation
|
||||||
}
|
}
|
||||||
|
|
||||||
# App.directive "countlyTrack", () ->
|
# App.directive "countlyTrack", () ->
|
||||||
|
|
Loading…
Reference in a new issue