@@ -172,44 +172,16 @@ function readToolIdFromWorkspaceClickTarget(target = null) {
172172 if ( ! ( target instanceof Element ) ) {
173173 return "" ;
174174 }
175- const closestWithToolId = target . closest ( "[data-tool-id], [data-tool-host-tool-id], [data-tool]" ) ;
176- const datasetToolId = normalizeTextParam (
177- closestWithToolId ?. getAttribute ( "data-tool-id" )
178- || closestWithToolId ?. getAttribute ( "data-tool-host-tool-id" )
179- || closestWithToolId ?. getAttribute ( "data-tool" )
180- || ""
181- ) ;
182- if ( datasetToolId ) {
183- return normalizeToken ( datasetToolId ) ;
184- }
185- const link = target . closest ( "a[href]" ) || target . querySelector ?. ( "a[href]" ) ;
186- const href = link instanceof HTMLAnchorElement ? link . getAttribute ( "href" ) || link . href : "" ;
187- if ( ! href ) {
188- return "" ;
189- }
190- try {
191- const url = new URL ( href , window . location . href ) ;
192- const pathname = decodeURIComponent ( url . pathname ) . replace ( / \\ / g, "/" ) ;
193- const match = manifest . tools . find ( ( entry ) => {
194- const launchPath = normalizeTextParam ( entry . launchPath ) . replace ( / \\ / g, "/" ) ;
195- const entryPoint = normalizeTextParam ( entry . entryPoint ) . replace ( / \\ / g, "/" ) ;
196- return ( launchPath && pathname . endsWith ( launchPath . replace ( / ^ \. \. \/ / , "/tools/" ) ) )
197- || ( entryPoint && pathname . endsWith ( `/tools/${ entryPoint } ` ) ) ;
198- } ) ;
199- return match ?. id || "" ;
200- } catch {
201- return "" ;
202- }
175+ const closestWithToolId = target . closest ( "[data-tool-id]" ) ;
176+ const datasetToolId = normalizeTextParam ( closestWithToolId ?. dataset ?. toolId ) ;
177+ return datasetToolId ? normalizeToken ( datasetToolId ) : "" ;
203178}
204179
205180function traceWorkspaceToolClick ( { target = null , datasetToolId = "" , resolvedToolId = "" , source = "" } = { } ) {
206181 const clickedText = target instanceof Element ? normalizeTextParam ( target . textContent || "" ) : "" ;
207182 const eventTarget = target instanceof Element ? target . tagName . toLowerCase ( ) : "" ;
208183 const closestToolId = target instanceof Element
209- ? normalizeTextParam ( target . closest ( "[data-tool-id], [data-tool-host-tool-id], [data-tool]" ) ?. getAttribute ( "data-tool-id" )
210- || target . closest ( "[data-tool-id], [data-tool-host-tool-id], [data-tool]" ) ?. getAttribute ( "data-tool-host-tool-id" )
211- || target . closest ( "[data-tool-id], [data-tool-host-tool-id], [data-tool]" ) ?. getAttribute ( "data-tool" )
212- || "" )
184+ ? normalizeTextParam ( target . closest ( "[data-tool-id]" ) ?. dataset ?. toolId )
213185 : "" ;
214186 console . log ( "[WORKSPACE_TOOL_CLICK]" , {
215187 source,
@@ -1566,15 +1538,10 @@ function bindPagerDelegatedEvents() {
15661538 const toolNavTarget = target . closest ( ".tools-platform-frame__nav-link, .tools-platform-frame__nav-tool-row" ) ;
15671539 if ( toolNavTarget instanceof Element ) {
15681540 const resolvedToolId = readToolIdFromWorkspaceClickTarget ( toolNavTarget ) ;
1569- const datasetToolId = normalizeTextParam (
1570- toolNavTarget . getAttribute ( "data-tool-id" )
1571- || toolNavTarget . getAttribute ( "data-tool-host-tool-id" )
1572- || toolNavTarget . getAttribute ( "data-tool" )
1573- || ""
1574- ) ;
1541+ const datasetToolId = normalizeTextParam ( toolNavTarget . closest ( "[data-tool-id]" ) ?. dataset ?. toolId ) ;
15751542 traceWorkspaceToolClick ( {
15761543 target : toolNavTarget ,
1577- datasetToolId : datasetToolId || resolvedToolId ,
1544+ datasetToolId,
15781545 resolvedToolId,
15791546 source : "tool-nav"
15801547 } ) ;
0 commit comments