feat(mobs): new attribute string-dictionary messages

This commit is contained in:
Alex Kaminskii 2023-02-06 11:01:02 +01:00
parent 5af952a931
commit e8d2379943
15 changed files with 250 additions and 5 deletions

View file

@ -10,5 +10,5 @@ func IsIOSType(id int) bool {
}
func IsDOMType(id int) bool {
return 0 == id || 4 == id || 5 == id || 6 == id || 7 == id || 8 == id || 9 == id || 10 == id || 11 == id || 12 == id || 13 == id || 14 == id || 15 == id || 16 == id || 18 == id || 19 == id || 20 == id || 37 == id || 38 == id || 49 == id || 54 == id || 55 == id || 57 == id || 58 == id || 59 == id || 60 == id || 61 == id || 67 == id || 69 == id || 70 == id || 71 == id || 72 == id || 73 == id || 74 == id || 75 == id || 76 == id || 77 == id || 90 == id || 93 == id || 96 == id || 100 == id || 102 == id || 103 == id || 105 == id
return 0 == id || 4 == id || 5 == id || 6 == id || 7 == id || 8 == id || 9 == id || 10 == id || 11 == id || 12 == id || 13 == id || 14 == id || 15 == id || 16 == id || 18 == id || 19 == id || 20 == id || 37 == id || 38 == id || 49 == id || 50 == id || 51 == id || 54 == id || 55 == id || 57 == id || 58 == id || 59 == id || 60 == id || 61 == id || 67 == id || 69 == id || 70 == id || 71 == id || 72 == id || 73 == id || 74 == id || 75 == id || 76 == id || 77 == id || 90 == id || 93 == id || 96 == id || 100 == id || 102 == id || 103 == id || 105 == id
}

View file

@ -48,6 +48,8 @@ const (
MsgNgRx = 47
MsgGraphQL = 48
MsgPerformanceTrack = 49
MsgStringDict = 50
MsgSetNodeAttributeDict = 51
MsgDOMDrop = 52
MsgResourceTiming = 53
MsgConnectionInformation = 54
@ -1316,6 +1318,54 @@ func (msg *PerformanceTrack) TypeID() int {
return 49
}
type StringDict struct {
message
Key string
Value string
}
func (msg *StringDict) Encode() []byte {
buf := make([]byte, 21+len(msg.Key)+len(msg.Value))
buf[0] = 50
p := 1
p = WriteString(msg.Key, buf, p)
p = WriteString(msg.Value, buf, p)
return buf[:p]
}
func (msg *StringDict) Decode() Message {
return msg
}
func (msg *StringDict) TypeID() int {
return 50
}
type SetNodeAttributeDict struct {
message
ID uint64
Name string
Value string
}
func (msg *SetNodeAttributeDict) Encode() []byte {
buf := make([]byte, 31+len(msg.Name)+len(msg.Value))
buf[0] = 51
p := 1
p = WriteUint(msg.ID, buf, p)
p = WriteString(msg.Name, buf, p)
p = WriteString(msg.Value, buf, p)
return buf[:p]
}
func (msg *SetNodeAttributeDict) Decode() Message {
return msg
}
func (msg *SetNodeAttributeDict) TypeID() int {
return 51
}
type DOMDrop struct {
message
Timestamp uint64

View file

@ -792,6 +792,33 @@ func DecodePerformanceTrack(reader BytesReader) (Message, error) {
return msg, err
}
func DecodeStringDict(reader BytesReader) (Message, error) {
var err error = nil
msg := &StringDict{}
if msg.Key, err = reader.ReadString(); err != nil {
return nil, err
}
if msg.Value, err = reader.ReadString(); err != nil {
return nil, err
}
return msg, err
}
func DecodeSetNodeAttributeDict(reader BytesReader) (Message, error) {
var err error = nil
msg := &SetNodeAttributeDict{}
if msg.ID, err = reader.ReadUint(); err != nil {
return nil, err
}
if msg.Name, err = reader.ReadString(); err != nil {
return nil, err
}
if msg.Value, err = reader.ReadString(); err != nil {
return nil, err
}
return msg, err
}
func DecodeDOMDrop(reader BytesReader) (Message, error) {
var err error = nil
msg := &DOMDrop{}
@ -1813,6 +1840,10 @@ func ReadMessage(t uint64, reader BytesReader) (Message, error) {
return DecodeGraphQL(reader)
case 49:
return DecodePerformanceTrack(reader)
case 50:
return DecodeStringDict(reader)
case 51:
return DecodeSetNodeAttributeDict(reader)
case 52:
return DecodeDOMDrop(reader)
case 53:

View file

@ -453,6 +453,23 @@ class PerformanceTrack(Message):
self.used_js_heap_size = used_js_heap_size
class StringDict(Message):
__id__ = 50
def __init__(self, key, value):
self.key = key
self.value = value
class SetNodeAttributeDict(Message):
__id__ = 51
def __init__(self, id, name, value):
self.id = id
self.name = name
self.value = value
class DOMDrop(Message):
__id__ = 52

View file

@ -431,6 +431,19 @@ class MessageCodec(Codec):
used_js_heap_size=self.read_uint(reader)
)
if message_id == 50:
return StringDict(
key=self.read_string(reader),
value=self.read_string(reader)
)
if message_id == 51:
return SetNodeAttributeDict(
id=self.read_uint(reader),
name=self.read_string(reader),
value=self.read_string(reader)
)
if message_id == 52:
return DOMDrop(
timestamp=self.read_uint(reader)

View file

@ -371,6 +371,28 @@ export default class RawMessageReader extends PrimitiveReader {
};
}
case 50: {
const key = this.readString(); if (key === null) { return resetPointer() }
const value = this.readString(); if (value === null) { return resetPointer() }
return {
tp: MType.StringDict,
key,
value,
};
}
case 51: {
const id = this.readUint(); if (id === null) { return resetPointer() }
const name = this.readString(); if (name === null) { return resetPointer() }
const value = this.readString(); if (value === null) { return resetPointer() }
return {
tp: MType.SetNodeAttributeDict,
id,
name,
value,
};
}
case 53: {
const timestamp = this.readUint(); if (timestamp === null) { return resetPointer() }
const duration = this.readUint(); if (duration === null) { return resetPointer() }

View file

@ -3,7 +3,7 @@
import { MType } from './raw.gen'
const DOM_TYPES = [0,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,37,38,49,54,55,57,58,59,60,61,67,69,70,71,72,73,74,75,76,77,90,93,96,100,102,103,105]
const DOM_TYPES = [0,4,5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,37,38,49,50,51,54,55,57,58,59,60,61,67,69,70,71,72,73,74,75,76,77,90,93,96,100,102,103,105]
export function isDOMType(t: MType) {
return DOM_TYPES.includes(t)
}

View file

@ -34,6 +34,8 @@ import type {
RawNgRx,
RawGraphQl,
RawPerformanceTrack,
RawStringDict,
RawSetNodeAttributeDict,
RawResourceTiming,
RawConnectionInformation,
RawSetPageVisibility,
@ -125,6 +127,10 @@ export type GraphQl = RawGraphQl & Timed
export type PerformanceTrack = RawPerformanceTrack & Timed
export type StringDict = RawStringDict & Timed
export type SetNodeAttributeDict = RawSetNodeAttributeDict & Timed
export type ResourceTiming = RawResourceTiming & Timed
export type ConnectionInformation = RawConnectionInformation & Timed

View file

@ -32,6 +32,8 @@ export const enum MType {
NgRx = 47,
GraphQl = 48,
PerformanceTrack = 49,
StringDict = 50,
SetNodeAttributeDict = 51,
ResourceTiming = 53,
ConnectionInformation = 54,
SetPageVisibility = 55,
@ -267,6 +269,19 @@ export interface RawPerformanceTrack {
usedJSHeapSize: number,
}
export interface RawStringDict {
tp: MType.StringDict,
key: string,
value: string,
}
export interface RawSetNodeAttributeDict {
tp: MType.SetNodeAttributeDict,
id: number,
name: string,
value: string,
}
export interface RawResourceTiming {
tp: MType.ResourceTiming,
timestamp: number,
@ -474,4 +489,4 @@ export interface RawIosNetworkCall {
}
export type RawMessage = RawTimestamp | RawSetPageLocation | RawSetViewportSize | RawSetViewportScroll | RawCreateDocument | RawCreateElementNode | RawCreateTextNode | RawMoveNode | RawRemoveNode | RawSetNodeAttribute | RawRemoveNodeAttribute | RawSetNodeData | RawSetCssData | RawSetNodeScroll | RawSetInputValue | RawSetInputChecked | RawMouseMove | RawNetworkRequest | RawConsoleLog | RawCssInsertRule | RawCssDeleteRule | RawFetch | RawProfiler | RawOTable | RawRedux | RawVuex | RawMobX | RawNgRx | RawGraphQl | RawPerformanceTrack | RawResourceTiming | RawConnectionInformation | RawSetPageVisibility | RawLoadFontFace | RawSetNodeFocus | RawLongTask | RawSetNodeAttributeURLBased | RawSetCssDataURLBased | RawCssInsertRuleURLBased | RawMouseClick | RawCreateIFrameDocument | RawAdoptedSsReplaceURLBased | RawAdoptedSsReplace | RawAdoptedSsInsertRuleURLBased | RawAdoptedSsInsertRule | RawAdoptedSsDeleteRule | RawAdoptedSsAddOwner | RawAdoptedSsRemoveOwner | RawZustand | RawIosSessionStart | RawIosCustomEvent | RawIosScreenChanges | RawIosClickEvent | RawIosPerformanceEvent | RawIosLog | RawIosNetworkCall;
export type RawMessage = RawTimestamp | RawSetPageLocation | RawSetViewportSize | RawSetViewportScroll | RawCreateDocument | RawCreateElementNode | RawCreateTextNode | RawMoveNode | RawRemoveNode | RawSetNodeAttribute | RawRemoveNodeAttribute | RawSetNodeData | RawSetCssData | RawSetNodeScroll | RawSetInputValue | RawSetInputChecked | RawMouseMove | RawNetworkRequest | RawConsoleLog | RawCssInsertRule | RawCssDeleteRule | RawFetch | RawProfiler | RawOTable | RawRedux | RawVuex | RawMobX | RawNgRx | RawGraphQl | RawPerformanceTrack | RawStringDict | RawSetNodeAttributeDict | RawResourceTiming | RawConnectionInformation | RawSetPageVisibility | RawLoadFontFace | RawSetNodeFocus | RawLongTask | RawSetNodeAttributeURLBased | RawSetCssDataURLBased | RawCssInsertRuleURLBased | RawMouseClick | RawCreateIFrameDocument | RawAdoptedSsReplaceURLBased | RawAdoptedSsReplace | RawAdoptedSsInsertRuleURLBased | RawAdoptedSsInsertRule | RawAdoptedSsDeleteRule | RawAdoptedSsAddOwner | RawAdoptedSsRemoveOwner | RawZustand | RawIosSessionStart | RawIosCustomEvent | RawIosScreenChanges | RawIosClickEvent | RawIosPerformanceEvent | RawIosLog | RawIosNetworkCall;

View file

@ -33,6 +33,8 @@ export const TP_MAP = {
47: MType.NgRx,
48: MType.GraphQl,
49: MType.PerformanceTrack,
50: MType.StringDict,
51: MType.SetNodeAttributeDict,
53: MType.ResourceTiming,
54: MType.ConnectionInformation,
55: MType.SetPageVisibility,

View file

@ -258,6 +258,19 @@ type TrPerformanceTrack = [
usedJSHeapSize: number,
]
type TrStringDict = [
type: 50,
key: string,
value: string,
]
type TrSetNodeAttributeDict = [
type: 51,
id: number,
name: string,
value: string,
]
type TrResourceTiming = [
type: 53,
timestamp: number,
@ -417,7 +430,7 @@ type TrPartitionedMessage = [
]
export type TrackerMessage = TrTimestamp | TrSetPageLocation | TrSetViewportSize | TrSetViewportScroll | TrCreateDocument | TrCreateElementNode | TrCreateTextNode | TrMoveNode | TrRemoveNode | TrSetNodeAttribute | TrRemoveNodeAttribute | TrSetNodeData | TrSetNodeScroll | TrSetInputTarget | TrSetInputValue | TrSetInputChecked | TrMouseMove | TrNetworkRequest | TrConsoleLog | TrPageLoadTiming | TrPageRenderTiming | TrCustomEvent | TrUserID | TrUserAnonymousID | TrMetadata | TrCSSInsertRule | TrCSSDeleteRule | TrFetch | TrProfiler | TrOTable | TrStateAction | TrRedux | TrVuex | TrMobX | TrNgRx | TrGraphQL | TrPerformanceTrack | TrResourceTiming | TrConnectionInformation | TrSetPageVisibility | TrLoadFontFace | TrSetNodeFocus | TrLongTask | TrSetNodeAttributeURLBased | TrSetCSSDataURLBased | TrTechnicalInfo | TrCustomIssue | TrCSSInsertRuleURLBased | TrMouseClick | TrCreateIFrameDocument | TrAdoptedSSReplaceURLBased | TrAdoptedSSInsertRuleURLBased | TrAdoptedSSDeleteRule | TrAdoptedSSAddOwner | TrAdoptedSSRemoveOwner | TrJSException | TrZustand | TrBatchMetadata | TrPartitionedMessage
export type TrackerMessage = TrTimestamp | TrSetPageLocation | TrSetViewportSize | TrSetViewportScroll | TrCreateDocument | TrCreateElementNode | TrCreateTextNode | TrMoveNode | TrRemoveNode | TrSetNodeAttribute | TrRemoveNodeAttribute | TrSetNodeData | TrSetNodeScroll | TrSetInputTarget | TrSetInputValue | TrSetInputChecked | TrMouseMove | TrNetworkRequest | TrConsoleLog | TrPageLoadTiming | TrPageRenderTiming | TrCustomEvent | TrUserID | TrUserAnonymousID | TrMetadata | TrCSSInsertRule | TrCSSDeleteRule | TrFetch | TrProfiler | TrOTable | TrStateAction | TrRedux | TrVuex | TrMobX | TrNgRx | TrGraphQL | TrPerformanceTrack | TrStringDict | TrSetNodeAttributeDict | TrResourceTiming | TrConnectionInformation | TrSetPageVisibility | TrLoadFontFace | TrSetNodeFocus | TrLongTask | TrSetNodeAttributeURLBased | TrSetCSSDataURLBased | TrTechnicalInfo | TrCustomIssue | TrCSSInsertRuleURLBased | TrMouseClick | TrCreateIFrameDocument | TrAdoptedSSReplaceURLBased | TrAdoptedSSInsertRuleURLBased | TrAdoptedSSDeleteRule | TrAdoptedSSAddOwner | TrAdoptedSSRemoveOwner | TrJSException | TrZustand | TrBatchMetadata | TrPartitionedMessage
export default function translate(tMsg: TrackerMessage): RawMessage | null {
switch(tMsg[0]) {
@ -680,6 +693,23 @@ export default function translate(tMsg: TrackerMessage): RawMessage | null {
}
}
case 50: {
return {
tp: MType.StringDict,
key: tMsg[1],
value: tMsg[2],
}
}
case 51: {
return {
tp: MType.SetNodeAttributeDict,
id: tMsg[1],
name: tMsg[2],
value: tMsg[3],
}
}
case 53: {
return {
tp: MType.ResourceTiming,

View file

@ -277,6 +277,18 @@ message 49, 'PerformanceTrack' do #, :replayer => :devtools --> requires player
uint 'TotalJSHeapSize'
uint 'UsedJSHeapSize'
end
# since 4.1.9
message 50, "StringDict" do
string "Key"
string "Value"
end
# since 4.1.9
message 51, "SetNodeAttributeDict" do
uint 'ID'
string 'Name'
string 'Value'
end
## 50,51
# Doesn't work properly. TODO: Make proper detections in tracker
message 52, 'DOMDrop', :tracker => false, :replayer => false do

View file

@ -39,6 +39,8 @@ export declare const enum Type {
NgRx = 47,
GraphQL = 48,
PerformanceTrack = 49,
StringDict = 50,
SetNodeAttributeDict = 51,
ResourceTiming = 53,
ConnectionInformation = 54,
SetPageVisibility = 55,
@ -317,6 +319,19 @@ export type PerformanceTrack = [
/*usedJSHeapSize:*/ number,
]
export type StringDict = [
/*type:*/ Type.StringDict,
/*key:*/ string,
/*value:*/ string,
]
export type SetNodeAttributeDict = [
/*type:*/ Type.SetNodeAttributeDict,
/*id:*/ number,
/*name:*/ string,
/*value:*/ string,
]
export type ResourceTiming = [
/*type:*/ Type.ResourceTiming,
/*timestamp:*/ number,
@ -476,5 +491,5 @@ export type PartitionedMessage = [
]
type Message = Timestamp | SetPageLocation | SetViewportSize | SetViewportScroll | CreateDocument | CreateElementNode | CreateTextNode | MoveNode | RemoveNode | SetNodeAttribute | RemoveNodeAttribute | SetNodeData | SetNodeScroll | SetInputTarget | SetInputValue | SetInputChecked | MouseMove | NetworkRequest | ConsoleLog | PageLoadTiming | PageRenderTiming | CustomEvent | UserID | UserAnonymousID | Metadata | CSSInsertRule | CSSDeleteRule | Fetch | Profiler | OTable | StateAction | Redux | Vuex | MobX | NgRx | GraphQL | PerformanceTrack | ResourceTiming | ConnectionInformation | SetPageVisibility | LoadFontFace | SetNodeFocus | LongTask | SetNodeAttributeURLBased | SetCSSDataURLBased | TechnicalInfo | CustomIssue | CSSInsertRuleURLBased | MouseClick | CreateIFrameDocument | AdoptedSSReplaceURLBased | AdoptedSSInsertRuleURLBased | AdoptedSSDeleteRule | AdoptedSSAddOwner | AdoptedSSRemoveOwner | JSException | Zustand | BatchMetadata | PartitionedMessage
type Message = Timestamp | SetPageLocation | SetViewportSize | SetViewportScroll | CreateDocument | CreateElementNode | CreateTextNode | MoveNode | RemoveNode | SetNodeAttribute | RemoveNodeAttribute | SetNodeData | SetNodeScroll | SetInputTarget | SetInputValue | SetInputChecked | MouseMove | NetworkRequest | ConsoleLog | PageLoadTiming | PageRenderTiming | CustomEvent | UserID | UserAnonymousID | Metadata | CSSInsertRule | CSSDeleteRule | Fetch | Profiler | OTable | StateAction | Redux | Vuex | MobX | NgRx | GraphQL | PerformanceTrack | StringDict | SetNodeAttributeDict | ResourceTiming | ConnectionInformation | SetPageVisibility | LoadFontFace | SetNodeFocus | LongTask | SetNodeAttributeURLBased | SetCSSDataURLBased | TechnicalInfo | CustomIssue | CSSInsertRuleURLBased | MouseClick | CreateIFrameDocument | AdoptedSSReplaceURLBased | AdoptedSSInsertRuleURLBased | AdoptedSSDeleteRule | AdoptedSSAddOwner | AdoptedSSRemoveOwner | JSException | Zustand | BatchMetadata | PartitionedMessage
export default Message

View file

@ -474,6 +474,30 @@ export function PerformanceTrack(
]
}
export function StringDict(
key: string,
value: string,
): Messages.StringDict {
return [
Messages.Type.StringDict,
key,
value,
]
}
export function SetNodeAttributeDict(
id: number,
name: string,
value: string,
): Messages.SetNodeAttributeDict {
return [
Messages.Type.SetNodeAttributeDict,
id,
name,
value,
]
}
export function ResourceTiming(
timestamp: number,
duration: number,

View file

@ -158,6 +158,14 @@ export default class MessageEncoder extends PrimitiveEncoder {
return this.int(msg[1]) && this.int(msg[2]) && this.uint(msg[3]) && this.uint(msg[4])
break
case Messages.Type.StringDict:
return this.string(msg[1]) && this.string(msg[2])
break
case Messages.Type.SetNodeAttributeDict:
return this.uint(msg[1]) && this.string(msg[2]) && this.string(msg[3])
break
case Messages.Type.ResourceTiming:
return this.uint(msg[1]) && this.uint(msg[2]) && this.uint(msg[3]) && this.uint(msg[4]) && this.uint(msg[5]) && this.uint(msg[6]) && this.string(msg[7]) && this.string(msg[8])
break