Просмотр исходного кода

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
Alberto Fernández Capel 8 лет назад
Родитель
Сommit
7d0d18ea5e

+ 2 - 0
services/web/public/coffee/ide.coffee

@@ -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",

+ 0 - 2
services/web/public/coffee/ide/editor/directives/aceEditor.coffee

@@ -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
services/web/public/coffee/main/event.coffee

@@ -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}",