Use the cursor:editor:update event to track user activity

It is strictly a superset of the change event we were using
before: if there's a change, there will be always a cursor
update, but there can be cursor updates (like when the user
presses the arrow keys) that don't change the document.

This is coherent with what we do to track user activity at

https://github.com/sharelatex/web-sharelatex-internal/blob/dfb994352112e3535aac7a2c415e12d8050b2987/public/coffee/ide/connection/ConnectionManager.coffee#L49-L50
This commit is contained in:
Alberto Fernández Capel
2018-01-24 17:20:30 +00:00
parent e42d1f9b13
commit 7d0d18ea5e
3 changed files with 13 additions and 13 deletions
+2
View File
@@ -176,6 +176,8 @@ define [
$scope.$broadcast('ide:loaded')
_loaded = true
$scope.$on 'cursor:editor:update', event_tracking.editingSessionHeartbeat
DARK_THEMES = [
"ambiance", "chaos", "clouds_midnight", "cobalt", "idle_fingers",
"merbivore", "merbivore_soft", "mono_industrial", "monokai",
@@ -301,8 +301,6 @@ define [
onChange = () ->
updateCount++
event_tracking.editingSessionHeartbeat()
if updateCount == 100
event_tracking.send 'editor-interaction', 'multi-doc-update'
scope.$emit "#{scope.name}:change"
+11 -11
View File
@@ -37,6 +37,16 @@ define [
localStorage CACHE_KEY, curCache
_sendEditingSessionHeartbeat = (segmentation) ->
$http({
url: "/editingSession/#{window.project_id}",
method: "PUT",
data: segmentation,
headers: {
"X-CSRF-Token": window.csrfToken
}
})
return {
send: (category, action, label, value)->
ga('send', 'event', category, action, label, value)
@@ -45,7 +55,7 @@ define [
editingSessionHeartbeat: (segmentation = {}) ->
return unless nextHeartbeat <= new Date()
@_sendEditingSessionHeartbeat(segmentation)
_sendEditingSessionHeartbeat(segmentation)
heartbeatsSent++
@@ -60,16 +70,6 @@ define [
nextHeartbeat = moment().add(backoffSecs, 'seconds').toDate()
_sendEditingSessionHeartbeat: (segmentation) ->
$http({
url: "/editingSession/#{window.project_id}",
method: "PUT",
data: segmentation,
headers: {
"X-CSRF-Token": window.csrfToken
}
})
sendMB: (key, segmentation = {}) ->
$http {
url: "/event/#{key}",