@@ -489,8 +489,11 @@ local options = {
489489 token = "TKN-secret" ,
490490 flushSeconds = 5 ,
491491 experiments = { qa = { active = false , players = { ["2" ] = "b" } } },
492+ recordSeconds = 180 ,
493+ positions = { "round_result" },
492494 },
493495 zones = false ,
496+ positions = { "down" },
494497}
495498local trove1 = Trove .new ()
496499local core1 = ServerAnalytics .new (options , { trove = trove1 , server = kernel }, trove1 )
@@ -508,6 +511,8 @@ local hiReg = hiFor(regular)
508511check ("hi: new player" , hiNew ~= nil and hiNew .pid == newbiePid and hiNew .newp == true and hiNew .rec == true , hiNew and hiNew .pid )
509512check ("hi: returning player" , hiReg ~= nil and hiReg .newp == false and hiReg .rec == false )
510513check ("hi: tech interval" , hiNew .tech == 60 )
514+ check ("hi: recording window (recordSeconds)" , hiNew .rsec == 180 , hiNew .rsec )
515+ check ("hi: the settings' position names" , hiNew .pos ~= nil and # hiNew .pos == 1 and hiNew .pos [1 ] == "round_result" )
511516-- Per-player overrides: each hello carries only its own player's entry, never the others' ids.
512517check ("hi: own forced variant only" , hiReg .exps .qa ~= nil and hiReg .exps .qa .player == "b" and hiReg .exps .qa .players == nil and hiReg .exps .qa .active == false )
513518check ("hi: no entry, no player" , hiNew .exps .qa ~= nil and hiNew .exps .qa .player == nil and hiNew .exps .qa .players == nil )
@@ -625,6 +630,37 @@ core1:track(newbie, "custom", "after_exp", nil)
625630local rows = store ().events .rows
626631local quest = rowsNamed (rows , "custom" , "quest_done" )[1 ]
627632check ("track: row" , quest and quest .pid == newbiePid and quest .props == '{"quest":"tutorial"}' and quest .src == "server" )
633+ -- Positions: px/py/pz of the character root, rounded to 0.1, on request or by event name; never over the game's own.
634+ local newbieRoot = { Position = roblox .Vector3 .new (10.04 , 3.06 , - 5.56 ) }
635+ function newbieRoot :IsA (class )
636+ return class == "BasePart"
637+ end
638+ newbie .Character = {}
639+ function newbie .Character :FindFirstChild (name )
640+ return if name == "HumanoidRootPart" then newbieRoot else nil
641+ end
642+ core1 :track (newbie , "custom" , "tapped" , { a = 1 }, newbie )
643+ core1 :track (newbie , "custom" , "down" , { by = "fall" })
644+ core1 :track (newbie , "custom" , "round_result" , nil )
645+ core1 :track (newbie , "custom" , "down" , { px = 1 , py = 2 , pz = 3 })
646+ core1 :track (newbie , "custom" , "seen_regular" , nil , regular ) -- the regular has no character
647+ core1 :track (nil , "custom" , "down" , nil ) -- no player: nothing to read
648+ core1 :track (newbie , "funnel" , "down" , { i = 1 })
649+ local function propsOf (name , index , kind )
650+ local row = rowsNamed (store ().events .rows , kind or "custom" , name )[index or 1 ]
651+ return row and serde .decode ("json" , row .props ) or {}, row and row .props
652+ end
653+ local tapped , tappedText = propsOf ("tapped" )
654+ check ("position on request: rounded" , tapped .px == 10 and tapped .py == 3.1 and tapped .pz == - 5.6 and tapped .a == 1 , tappedText )
655+ local downs = rowsNamed (store ().events .rows , "custom" , "down" )
656+ check ("position by options.positions" , # downs == 3 and serde .decode ("json" , downs [1 ].props ).pz == - 5.6 and serde .decode ("json" , downs [1 ].props ).by == "fall" , downs [1 ] and downs [1 ].props )
657+ check ("position by the settings' positions" , propsOf ("round_result" ).py == 3.1 )
658+ check ("position never overrides the game's px/py/pz" , downs [2 ] and downs [2 ].props == '{"px":1,"py":2,"pz":3}' or false , downs [2 ] and downs [2 ].props )
659+ check ("position: none without a character" , propsOf ("seen_regular" ).px == nil and select (2 , propsOf ("seen_regular" )) == "{}" )
660+ check ("position: none for a server-only event" , downs [3 ] and downs [3 ].props == "{}" and downs [3 ].pid == "" , downs [3 ] and downs [3 ].props )
661+ check ("position on other game-code kinds (funnel) by name" , propsOf ("down" , 1 , "funnel" ).px == 10 )
662+ check ("quest_done untouched (not listed)" , rowsNamed (store ().events .rows , "custom" , "quest_done" )[1 ].props == '{"quest":"tutorial"}' )
663+ newbie .Character = nil
628664local serverThing = rowsNamed (rows , "custom" , "server_thing" )[1 ]
629665check ("server-only event" , serverThing and serverThing .pid == "" and serverThing .sid == "" and serverThing .dev == "unknown" and serverThing .props == "{}" )
630666check ("activity rows per player" , # rowsNamed (rows , "state" , "activity" ) == 2 )
@@ -691,6 +727,8 @@ check("recording data", buffer.tostring(C.fromBase64(recs[1].data)) == buffer.to
691727check ("recording t" , math.abs (recs [1 ].t - (nowMs () - 1000 - 50 )) < 200 )
692728local metaEnd = rowsNamed (store ().events .rows , "recording_meta" , "end" )[1 ]
693729check ("recording_meta start + end" , # rowsNamed (store ().events .rows , "recording_meta" , "start" ) == 1 and metaEnd and serde .decode ("json" , metaEnd .props ).why == "window" )
730+ local metaStart = rowsNamed (store ().events .rows , "recording_meta" , "start" )[1 ]
731+ check ("recording_meta start: share and window" , metaStart and serde .decode ("json" , metaStart .props ).secs == 180 and serde .decode ("json" , metaStart .props ).share == 1 , metaStart and metaStart .props )
694732
695733-- Fleet rows: a heartbeat at start, the replayed reports once each.
696734check ("fleet heartbeat" , # rowsNamed (store ().fleet .rows , "fleet" , "heartbeat" ) == 1 )
0 commit comments