change(tracker): add nodes drop message

This commit is contained in:
nick-delirium 2023-03-17 11:13:27 +01:00 committed by Delirium
parent df90d3a8ca
commit d9ab7b6853
7 changed files with 76 additions and 20 deletions

View file

@ -2,7 +2,11 @@
package messages package messages
func IsReplayerType(id int) bool { func IsReplayerType(id int) bool {
<<<<<<< HEAD
return 1 != id && 3 != id && 17 != id && 23 != id && 24 != id && 25 != id && 26 != id && 27 != id && 28 != id && 29 != id && 30 != id && 31 != id && 32 != id && 33 != id && 35 != id && 42 != id && 52 != id && 56 != id && 62 != id && 63 != id && 64 != id && 66 != id && 78 != id && 80 != id && 81 != id && 82 != id && 125 != id && 126 != id && 127 != id && 112 != id && 107 != id && 91 != id && 92 != id && 94 != id && 95 != id && 97 != id && 98 != id && 99 != id && 101 != id && 104 != id && 110 != id && 111 != id return 1 != id && 3 != id && 17 != id && 23 != id && 24 != id && 25 != id && 26 != id && 27 != id && 28 != id && 29 != id && 30 != id && 31 != id && 32 != id && 33 != id && 35 != id && 42 != id && 52 != id && 56 != id && 62 != id && 63 != id && 64 != id && 66 != id && 78 != id && 80 != id && 81 != id && 82 != id && 125 != id && 126 != id && 127 != id && 112 != id && 107 != id && 91 != id && 92 != id && 94 != id && 95 != id && 97 != id && 98 != id && 99 != id && 101 != id && 104 != id && 110 != id && 111 != id
=======
return 1 != id && 3 != id && 17 != id && 23 != id && 24 != id && 25 != id && 26 != id && 27 != id && 28 != id && 29 != id && 30 != id && 31 != id && 32 != id && 33 != id && 35 != id && 42 != id && 52 != id && 56 != id && 62 != id && 63 != id && 64 != id && 66 != id && 78 != id && 80 != id && 81 != id && 82 != id && 115 != id && 125 != id && 126 != id && 127 != id && 107 != id && 91 != id && 92 != id && 94 != id && 95 != id && 97 != id && 98 != id && 99 != id && 101 != id && 104 != id && 110 != id && 111 != id
>>>>>>> 3e1b8c39f (change(tracker): add nodes drop message)
} }
func IsIOSType(id int) bool { func IsIOSType(id int) bool {

View file

@ -79,6 +79,7 @@ const (
MsgBatchMeta = 80 MsgBatchMeta = 80
MsgBatchMetadata = 81 MsgBatchMetadata = 81
MsgPartitionedMessage = 82 MsgPartitionedMessage = 82
MsgRemovedNodesCount = 115
MsgIssueEvent = 125 MsgIssueEvent = 125
MsgSessionEnd = 126 MsgSessionEnd = 126
MsgSessionSearch = 127 MsgSessionSearch = 127
@ -2029,6 +2030,29 @@ func (msg *PartitionedMessage) TypeID() int {
return 82 return 82
} }
type RemovedNodesCount struct {
message
NodesCount uint64
DOMDropped bool
}
func (msg *RemovedNodesCount) Encode() []byte {
buf := make([]byte, 21)
buf[0] = 115
p := 1
p = WriteUint(msg.NodesCount, buf, p)
p = WriteBoolean(msg.DOMDropped, buf, p)
return buf[:p]
}
func (msg *RemovedNodesCount) Decode() Message {
return msg
}
func (msg *RemovedNodesCount) TypeID() int {
return 115
}
type IssueEvent struct { type IssueEvent struct {
message message
MessageID uint64 MessageID uint64

View file

@ -708,6 +708,14 @@ class PartitionedMessage(Message):
self.part_total = part_total self.part_total = part_total
class RemovedNodesCount(Message):
__id__ = 115
def __init__(self, nodes_count, dom_dropped):
self.nodes_count = nodes_count
self.dom_dropped = dom_dropped
class IssueEvent(Message): class IssueEvent(Message):
__id__ = 125 __id__ = 125

View file

@ -630,6 +630,12 @@ class MessageCodec(Codec):
part_total=self.read_uint(reader) part_total=self.read_uint(reader)
) )
if message_id == 115:
return RemovedNodesCount(
nodes_count=self.read_uint(reader),
dom_dropped=self.read_boolean(reader)
)
if message_id == 125: if message_id == 125:
return IssueEvent( return IssueEvent(
message_id=self.read_uint(reader), message_id=self.read_uint(reader),

View file

@ -448,6 +448,31 @@ end
# 90-111 reserved iOS # 90-111 reserved iOS
message 112, 'InputChange', :replayer => false do
uint 'ID'
string 'Value'
boolean 'ValueMasked'
string 'Label'
int 'HesitationTime'
int 'InputDuration'
end
message 113, 'SelectionChange' do
uint 'SelectionStart'
uint 'SelectionEnd'
string 'Selection'
end
message 114, 'MouseThrashing' do
uint 'Timestamp'
end
message 115, 'RemovedNodesCount', :replayer => false do
uint 'NodesCount'
boolean 'DOMDropped'
end
## Backend-only ## Backend-only
message 125, 'IssueEvent', :replayer => false, :tracker => false do message 125, 'IssueEvent', :replayer => false, :tracker => false do
uint 'MessageID' uint 'MessageID'
@ -468,22 +493,3 @@ message 127, 'SessionSearch', :tracker => false, :replayer => false do
end end
# since tracker 4.1.10 # since tracker 4.1.10
message 112, 'InputChange', :replayer => false do
uint 'ID'
string 'Value'
boolean 'ValueMasked'
string 'Label'
int 'HesitationTime'
int 'InputDuration'
end
message 113, 'SelectionChange' do
uint 'SelectionStart'
uint 'SelectionEnd'
string 'Selection'
end
message 114, 'MouseThrashing' do
uint 'Timestamp'
end

View file

@ -26,6 +26,10 @@ export default class Nodes {
listeners.push([type, listener, useCapture]) listeners.push([type, listener, useCapture])
} }
getNodesCount() {
return this.nodes.length
}
registerNode(node: Node): [/*id:*/ number, /*isNew:*/ boolean] { registerNode(node: Node): [/*id:*/ number, /*isNew:*/ boolean] {
let id: number = (node as any)[this.node_id] let id: number = (node as any)[this.node_id]
const isNew = id === undefined const isNew = id === undefined

View file

@ -8,6 +8,7 @@ import {
CreateElementNode, CreateElementNode,
MoveNode, MoveNode,
RemoveNode, RemoveNode,
RemovedNodesCount,
} from '../messages.gen.js' } from '../messages.gen.js'
import App from '../index.js' import App from '../index.js'
import { import {
@ -216,6 +217,8 @@ export default abstract class Observer {
} }
private unbindTree(node: Node) { private unbindTree(node: Node) {
let removed = 0
const nodesCount = this.app.nodes.getNodesCount()
const id = this.app.nodes.unregisterNode(node) const id = this.app.nodes.unregisterNode(node)
if (id !== undefined && this.recents.get(id) === RecentsType.Removed) { if (id !== undefined && this.recents.get(id) === RecentsType.Removed) {
// Sending RemoveNode only for parent to maintain // Sending RemoveNode only for parent to maintain
@ -235,9 +238,10 @@ export default abstract class Observer {
false, false,
) )
while (walker.nextNode()) { while (walker.nextNode()) {
removed += 1
this.app.nodes.unregisterNode(walker.currentNode) this.app.nodes.unregisterNode(walker.currentNode)
} }
// MBTODO: count and send RemovedNodesCount (for the page crash detection in heuristics) this.app.send(RemovedNodesCount(removed, removed / nodesCount > 0.5))
} }
} }