mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 19:23:49 -05:00
Log and report events like sending and receiving updates
This commit is contained in:
parent
81cb986f89
commit
869a4c8c18
3 changed files with 34 additions and 12 deletions
|
@ -81,6 +81,12 @@ define [
|
|||
delete @_joinCallbacks
|
||||
|
||||
_onUpdateApplied: (update) ->
|
||||
@ide.pushEvent "received-update",
|
||||
doc_id: @doc_id
|
||||
remote_doc_id: update?.doc
|
||||
wantToBeJoined: @wantToBeJoined
|
||||
update: update
|
||||
|
||||
if update?.doc == @doc_id and @doc?
|
||||
@doc.processUpdateFromServer update
|
||||
|
||||
|
@ -93,6 +99,8 @@ define [
|
|||
@doc?.updateConnectionState "disconnected"
|
||||
|
||||
_onReconnect: () ->
|
||||
@ide.pushEvent "reconnected:afterJoinProject"
|
||||
|
||||
@connected = true
|
||||
if @wantToBeJoined or @doc?.hasBufferedOps()
|
||||
@_joinDoc (error) =>
|
||||
|
@ -137,10 +145,22 @@ define [
|
|||
|
||||
_bindToShareJsDocEvents: () ->
|
||||
@doc.on "error", (error, meta) => @_onError error, meta
|
||||
@doc.on "externalUpdate", () => @trigger "externalUpdate"
|
||||
@doc.on "remoteop", () => @trigger "remoteop"
|
||||
@doc.on "op:sent", () => @trigger "op:sent"
|
||||
@doc.on "op:acknowledged", () => @trigger "op:acknowledged"
|
||||
@doc.on "externalUpdate", () =>
|
||||
@ide.pushEvent "externalUpdate",
|
||||
doc_id: @doc_id
|
||||
@trigger "externalUpdate"
|
||||
@doc.on "remoteop", () =>
|
||||
@ide.pushEvent "remoteop",
|
||||
doc_id: @doc_id
|
||||
@trigger "remoteop"
|
||||
@doc.on "op:sent", () =>
|
||||
@ide.pushEvent "op:sent",
|
||||
doc_id: @doc_id
|
||||
@trigger "op:sent"
|
||||
@doc.on "op:acknowledged", () =>
|
||||
@ide.pushEvent "op:acknowledged",
|
||||
doc_id: @doc_id
|
||||
@trigger "op:acknowledged"
|
||||
|
||||
_onError: (error, meta = {}) ->
|
||||
console.error "ShareJS error", error, meta
|
||||
|
|
|
@ -161,14 +161,18 @@ define [
|
|||
buttons: [ text: "OK" ]
|
||||
}
|
||||
|
||||
recentEvents: []
|
||||
|
||||
pushEvent: (type, meta = {}) ->
|
||||
@recentEvents.push type: type, meta: meta, date: new Date()
|
||||
if @recentEvents.length > 10
|
||||
@recentEvents.shift()
|
||||
|
||||
reportError: (error, meta = {}) ->
|
||||
meta.client_id = @socket?.socket?.sessionid
|
||||
meta.transport = @socket?.socket?.transport?.name
|
||||
meta.client_now = new Date()
|
||||
meta.last_connected = @connectionManager.lastConnected
|
||||
meta.second_last_connected = @connectionManager.secondLastConnected
|
||||
meta.last_disconnected = @connectionManager.lastDisconnected
|
||||
meta.second_last_disconnected = @connectionManager.secondLastDisconnected
|
||||
meta.recent_events = @recentEvents
|
||||
errorObj = {}
|
||||
for key in Object.getOwnPropertyNames(error)
|
||||
errorObj[key] = error[key]
|
||||
|
|
|
@ -8,15 +8,13 @@ define [
|
|||
@socket = @ide.socket
|
||||
@socket.on "connect", () =>
|
||||
@connected = true
|
||||
@secondLastConnected = @lastConnected
|
||||
@lastConnected = new Date()
|
||||
@ide.pushEvent("connected")
|
||||
@hideModal()
|
||||
@cancelReconnect()
|
||||
|
||||
@socket.on 'disconnect', () =>
|
||||
@connected = false
|
||||
@secondLastDisconnected = @lastDisconnected
|
||||
@lastDisconnected = new Date()
|
||||
@ide.pushEvent("disconnected")
|
||||
@ide.trigger "disconnect"
|
||||
setTimeout(=>
|
||||
ga('send', 'event', 'editor-interaction', 'disconnect')
|
||||
|
|
Loading…
Reference in a new issue