MCPcopy Create free account
hub / github.com/Dart-Code/Dart-Code / isOptedOutOfDartToolingTelemetry

Method isOptedOutOfDartToolingTelemetry

src/extension/analytics.ts:241–265  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

239 /// to Dart Code. The prompt from the analysis server mentions "VS Code IDE plugins" which suggests the
240 /// mechanism for opting out would apply to Dart Code.
241 private isOptedOutOfDartToolingTelemetry(): boolean {
242 // Don't let this function ever throw.
243 try {
244 const configDirectory = isWin ? process.env.USERPROFILE : process.env.HOME;
245 if (!configDirectory) {
246 this.logger.warn(`No valid home dir to check Dart/Flutter analytics file, disabling analytics`);
247 return true;
248 }
249
250 const configFile = path.join(configDirectory, ".dart-tool", "dart-flutter-telemetry.config");
251 if (!fs.existsSync(configFile)) {
252 return false; // No file, means not opted out.
253 }
254 const configFileContents = fs.readFileSync(configFile).toString();
255 const optedOutRegex = /^reporting=0/m;
256 if (optedOutRegex.test(configFileContents)) {
257 this.logger.info(`Dart/Flutter tooling telemetry is opted-out, disabling for Dart Code`);
258 return true;
259 }
260 return false;
261 } catch (e) {
262 this.logger.warn(`Failed to check Dart/Flutter analytics file, disabling analytics: ${e}`);
263 return true;
264 }
265 }
266
267 /**
268 * Whether analytics are suppressed for any reason.

Callers 1

constructorMethod · 0.95

Calls 3

warnMethod · 0.65
infoMethod · 0.65
toStringMethod · 0.45

Tested by

no test coverage detected