@@ -44,7 +44,7 @@ import {
4444} from "./engine-seams"
4545import { declaredBounded , fingerprint , notify , printLine , resolveBinding , versionOf , which } from "./engine-probes"
4646import { OFFER_RECHECK_MS , OFFER_SKIP_TTL_MS , installCommand , offerOrNotify , type EngineOffer } from "./engine-offer"
47- import { trackAttach , trackEngineError } from "./engine-telemetry"
47+ import { attachKey , trackAttach , trackEngineError } from "./engine-telemetry"
4848import {
4949 ENGINE_BINARY ,
5050 INSTALL_HELPS ,
@@ -360,8 +360,9 @@ type SessionRecord = {
360360 /** The workspace the directory was linked to when the boundary settled this
361361 * outcome. */
362362 linked ?: { id : string ; name : string } | null
363- /** The last outcome reported to telemetry; a transient record carries the previous one. */
364- tracked ?: Outcome
363+ /** The key of the last attach reported to telemetry (workspace and outcome); a transient record
364+ * carries the previous one. */
365+ tracked ?: string
365366}
366367const sessions = new Map < string , SessionRecord > ( )
367368const declaredCache = new Map < string , { value : Declared | null ; at : number } > ( )
@@ -374,13 +375,12 @@ function record(
374375 extra : { engineVersion ?: string | null ; transient ?: boolean } = { } ,
375376) : SessionRecord {
376377 const previous = sessions . get ( sessionID )
377- // telemetry: a settled outcome, when it changed, named for the directory's workspace . A transient
378- // record (the retry sentinel) reports nothing and keeps the last reported outcome for the next
378+ // telemetry: a settled outcome, when it or the workspace it settled for changed . A transient
379+ // record (the retry sentinel) reports nothing and keeps the last reported key for the next
379380 // comparison.
380- const tracked = extra . transient ? previous ?. tracked : outcome
381- if ( ! extra . transient ) {
382- trackAttach ( outcome , previous ?. tracked , { ...extra , workspaceId : Number ( linkedWorkspace ( ) ?. id ) } , sessionID )
383- }
381+ const workspaceId = Number ( linkedWorkspace ( ) ?. id ) || undefined
382+ const tracked = extra . transient ? previous ?. tracked : attachKey ( outcome , workspaceId )
383+ if ( ! extra . transient ) trackAttach ( outcome , previous ?. tracked , { ...extra , workspaceId } , sessionID )
384384 sessions . delete ( sessionID )
385385 const next : SessionRecord = {
386386 outcome,
0 commit comments