5
5
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
6
*/
7
7
import * as os from 'os' ;
8
- import { Logger , SfdxConfigAggregator } from '@salesforce/core' ;
8
+ import { Logger , SfdxConfigAggregator , SfConfigProperties } from '@salesforce/core' ;
9
9
import { AsyncCreatable , env } from '@salesforce/kit' ;
10
10
11
11
import axios from 'axios' ;
12
12
import { AppInsights , Attributes , Properties , TelemetryOptions } from './appInsights' ;
13
13
import { TelemetryClient } from './exported' ;
14
14
15
- const DISABLE_TELEMETRY = 'disableTelemetry' ;
16
-
17
15
export { TelemetryOptions , Attributes , Properties , TelemetryClient } from './appInsights' ;
18
16
19
17
/**
@@ -41,7 +39,8 @@ export class TelemetryReporter extends AsyncCreatable<TelemetryOptions> {
41
39
if ( ! TelemetryReporter . config ) {
42
40
TelemetryReporter . config = await SfdxConfigAggregator . create ( { } ) ;
43
41
}
44
- const configValue = TelemetryReporter . config . getPropertyValue ( DISABLE_TELEMETRY ) ;
42
+ const configValue = TelemetryReporter . config . getPropertyValue ( SfConfigProperties . DISABLE_TELEMETRY ) ;
43
+ // SF_DISABLE_TELEMETRY is the proper name for this env that will be cheked by config.getPropertyValue. SFDX_DISABLE_INSIGHTS is present for backwards compatibility
45
44
const sfdxDisableInsights = configValue === 'true' || env . getBoolean ( 'SFDX_DISABLE_INSIGHTS' ) ;
46
45
return ! sfdxDisableInsights ;
47
46
}
@@ -167,7 +166,7 @@ export class TelemetryReporter extends AsyncCreatable<TelemetryOptions> {
167
166
* Setting the disableTelemetry config var to true will disable insights for errors and diagnostics.
168
167
*/
169
168
public isSfdxTelemetryEnabled ( ) : boolean {
170
- const configValue = this . config . getPropertyValue ( DISABLE_TELEMETRY ) ;
169
+ const configValue = this . config . getPropertyValue ( SfConfigProperties . DISABLE_TELEMETRY ) ;
171
170
const sfdxDisableInsights = configValue === 'true' || env . getBoolean ( 'SFDX_DISABLE_INSIGHTS' ) ;
172
171
// isEnabled = !sfdxDisableInsights
173
172
return ! sfdxDisableInsights ;
@@ -177,11 +176,11 @@ export class TelemetryReporter extends AsyncCreatable<TelemetryOptions> {
177
176
const isEnabled = this . isSfdxTelemetryEnabled ( ) ;
178
177
if ( isEnabled ) {
179
178
this . logger . warn (
180
- `Telemetry is enabled. This can be disabled by running sfdx force:config:set ${ DISABLE_TELEMETRY } =true`
179
+ `Telemetry is enabled. This can be disabled by running sfdx force:config:set ${ SfConfigProperties . DISABLE_TELEMETRY } =true`
181
180
) ;
182
181
} else {
183
182
this . logger . warn (
184
- `Telemetry is disabled. This can be enabled by running sfdx force:config:set ${ DISABLE_TELEMETRY } =false`
183
+ `Telemetry is disabled. This can be enabled by running sfdx force:config:set ${ SfConfigProperties . DISABLE_TELEMETRY } =false`
185
184
) ;
186
185
}
187
186
}
0 commit comments