MCPcopy Create free account
hub / github.com/TanStack/cli / runWithTelemetry

Function runWithTelemetry

packages/cli/src/cli.ts:584–611  ·  view source on GitHub ↗
(
    command: string,
    opts: {
      json?: boolean
      properties?: Record<string, unknown>
    },
    action: (telemetry: TelemetryClient) => Promise<T>,
  )

Source from the content-addressed store, hash-verified

582 }
583
584 async function runWithTelemetry<T>(
585 command: string,
586 opts: {
587 json?: boolean
588 properties?: Record<string, unknown>
589 },
590 action: (telemetry: TelemetryClient) => Promise<T>,
591 ) {
592 const telemetry = await createTelemetryClient({ json: opts.json })
593 const startedAt = Date.now()
594 currentTelemetry = telemetry
595 telemetry.captureCommandStarted(command, {
596 ...getInvocationTelemetryProperties(),
597 ...opts.properties,
598 cli_version: VERSION,
599 })
600
601 try {
602 const result = await action(telemetry)
603 await telemetry.captureCommandCompleted(command, Date.now() - startedAt)
604 return result
605 } catch (error) {
606 await telemetry.captureCommandFailed(command, Date.now() - startedAt, error)
607 throw error
608 } finally {
609 currentTelemetry = undefined
610 }
611 }
612
613 program
614 .name(name)

Callers 2

handleCreateFunction · 0.85
cliFunction · 0.85

Calls 6

createTelemetryClientFunction · 0.85
nowMethod · 0.80
captureCommandStartedMethod · 0.80
captureCommandFailedMethod · 0.80

Tested by

no test coverage detected