MCPcopy
hub / github.com/ionic-team/capacitor / sendMetric

Function sendMetric

cli/src/telemetry.ts:114–132  ·  view source on GitHub ↗
(
  sysconfig: Pick<SystemConfig, 'machine' | 'telemetry'>,
  name: string,
  data: D,
)

Source from the content-addressed store, hash-verified

112 * If telemetry is enabled, send a metric via IPC to a forked process for uploading.
113 */
114export async function sendMetric<D>(
115 sysconfig: Pick<SystemConfig, 'machine' | 'telemetry'>,
116 name: string,
117 data: D,
118): Promise<void> {
119 if (sysconfig.telemetry && isInteractive()) {
120 const message: Metric<string, D> = {
121 name,
122 timestamp: new Date().toISOString(),
123 session_id: sysconfig.machine,
124 source: 'capacitor_cli',
125 value: data,
126 };
127
128 await send({ type: 'telemetry', data: message });
129 } else {
130 debug('Telemetry is off (user choice, non-interactive terminal, or CI)--not sending metric');
131 }
132}
133
134/**
135 * Resolve the iOS dependency manager for telemetry. Returns 'unknown' for

Callers 1

telemetryActionFunction · 0.85

Calls 2

isInteractiveFunction · 0.90
sendFunction · 0.90

Tested by

no test coverage detected