2025-06-18 18:50:46 +02:00
"use strict" ;
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
exports . telemetryCommand = void 0 ;
const tslib _1 = require ( "tslib" ) ;
const colors _1 = tslib _1 . _ _importDefault ( require ( "../colors" ) ) ;
const errors _1 = require ( "../errors" ) ;
const log _1 = require ( "../log" ) ;
const sysconfig _1 = require ( "../sysconfig" ) ;
2025-07-06 20:20:48 +02:00
const THANK _YOU = ` \n Thank you for helping to make Capacitor better! 💖 ` +
` \n Information about the data we collect is available on our website: ${ colors _1 . default . strong ( 'https://capacitorjs.com/docs/next/cli/telemetry' ) } \n ` ;
2025-06-18 18:50:46 +02:00
async function telemetryCommand ( onOrOff ) {
const sysconfig = await ( 0 , sysconfig _1 . readConfig ) ( ) ;
const enabled = interpretEnabled ( onOrOff ) ;
if ( typeof enabled === 'boolean' ) {
if ( sysconfig . telemetry === enabled ) {
log _1 . logger . info ( ` Telemetry is already ${ colors _1 . default . strong ( enabled ? 'on' : 'off' ) } ` ) ;
}
else {
await ( 0 , sysconfig _1 . writeConfig ) ( { ... sysconfig , telemetry : enabled } ) ;
( 0 , log _1 . logSuccess ) ( ` You have ${ colors _1 . default . strong ( ` opted ${ enabled ? 'in' : 'out' } ` ) } ${ enabled ? 'for' : 'of' } telemetry on this machine. ` ) ;
if ( enabled ) {
2025-07-06 20:20:48 +02:00
log _1 . output . write ( THANK _YOU ) ;
2025-06-18 18:50:46 +02:00
}
}
}
else {
log _1 . logger . info ( ` Telemetry is ${ colors _1 . default . strong ( sysconfig . telemetry ? 'on' : 'off' ) } ` ) ;
}
}
exports . telemetryCommand = telemetryCommand ;
function interpretEnabled ( onOrOff ) {
switch ( onOrOff ) {
case 'on' :
return true ;
case 'off' :
return false ;
case undefined :
return undefined ;
}
( 0 , errors _1 . fatal ) ( ` Argument must be ${ colors _1 . default . strong ( 'on' ) } or ${ colors _1 . default . strong ( 'off' ) } (or left unspecified) ` ) ;
}