@@ -404,10 +404,6 @@ export type ClawHubDownloadResult = {
404404 cleanup : ( ) => Promise < void > ;
405405} ;
406406
407- export type ClawHubInstallTelemetrySkill = {
408- version ?: string | null ;
409- } ;
410-
411407type FetchLike = ( input : string | URL | Request , init ?: RequestInit ) => Promise < Response > ;
412408
413409type ClawHubRequestParams = {
@@ -1619,21 +1615,20 @@ export async function downloadClawHubGitHubSkillArchive(params: {
16191615export async function reportClawHubSkillInstallTelemetry ( params : {
16201616 baseUrl ?: string ;
16211617 token ?: string ;
1622- root : string ;
1623- skills : Record < string , ClawHubInstallTelemetrySkill > ;
1618+ slug : string ;
1619+ ownerHandle ?: string ;
1620+ version ?: string | null ;
16241621 timeoutMs ?: number ;
16251622 fetchImpl ?: FetchLike ;
16261623} ) : Promise < void > {
16271624 const token = normalizeOptionalString ( params . token ) ?? ( await resolveClawHubAuthToken ( ) ) ;
16281625 if ( ! token || isClawHubTelemetryDisabled ( ) ) {
16291626 return ;
16301627 }
1631- const skills = Object . entries ( params . skills )
1632- . map ( ( [ slug , entry ] ) => ( {
1633- slug,
1634- version : entry . version ?? null ,
1635- } ) )
1636- . filter ( ( entry ) => entry . slug . length > 0 ) ;
1628+ const slug = params . slug . trim ( ) ;
1629+ if ( ! slug ) {
1630+ return ;
1631+ }
16371632
16381633 const { response, url, hasToken } = await clawhubRequest ( {
16391634 baseUrl : params . baseUrl ,
@@ -1643,13 +1638,10 @@ export async function reportClawHubSkillInstallTelemetry(params: {
16431638 timeoutMs : params . timeoutMs ,
16441639 fetchImpl : params . fetchImpl ,
16451640 json : {
1646- roots : [
1647- {
1648- rootId : digestSha256Hex ( path . resolve ( params . root ) ) ,
1649- label : formatTelemetryRootLabel ( params . root ) ,
1650- skills,
1651- } ,
1652- ] ,
1641+ event : "install" ,
1642+ slug,
1643+ ...( params . ownerHandle ? { ownerHandle : params . ownerHandle } : { } ) ,
1644+ version : params . version ?? undefined ,
16531645 } ,
16541646 } ) ;
16551647 if ( ! response . ok ) {
@@ -1665,20 +1657,6 @@ function isClawHubTelemetryDisabled(): boolean {
16651657 return [ "1" , "true" , "yes" , "on" ] . includes ( raw . trim ( ) . toLowerCase ( ) ) ;
16661658}
16671659
1668- function formatTelemetryRootLabel ( root : string ) : string {
1669- const home = os . homedir ( ) ;
1670- const absolute = path . resolve ( root ) ;
1671- if ( absolute === home ) {
1672- return "~" ;
1673- }
1674- const normalized = absolute . replaceAll ( "\\" , "/" ) ;
1675- const normalizedHome = home . replaceAll ( "\\" , "/" ) ;
1676- const withinHome = normalized . startsWith ( `${ normalizedHome } /` ) ;
1677- const stripped = withinHome ? normalized . slice ( normalizedHome . length + 1 ) : normalized ;
1678- const tail = stripped . split ( "/" ) . filter ( Boolean ) . slice ( - 2 ) . join ( "/" ) ;
1679- return withinHome ? `~/${ tail } ` : tail || absolute ;
1680- }
1681-
16821660/** Resolves the preferred latest package version from detail metadata. */
16831661export function resolveLatestVersionFromPackage ( detail : ClawHubPackageDetail ) : string | null {
16841662 return detail . package ?. latestVersion ?? detail . package ?. tags ?. latest ?? null ;
0 commit comments