@@ -102,7 +102,7 @@ void main() {
102102 });
103103
104104 test ('Honor legacy flutter analytics opt out' , () {
105- // Create the file for the dart legacy opt out
105+ // Create the file for the flutter legacy opt out
106106 final flutterLegacyConfigFile =
107107 home.childDirectory ('.dart' ).childFile ('dartdev.json' );
108108 flutterLegacyConfigFile.createSync (recursive: true );
@@ -134,7 +134,7 @@ void main() {
134134 });
135135
136136 test ('Telemetry enabled if legacy flutter analytics is enabled' , () {
137- // Create the file for the dart legacy opt out
137+ // Create the file for the flutter legacy opt out
138138 final flutterLegacyConfigFile =
139139 home.childDirectory ('.dart' ).childFile ('dartdev.json' );
140140 flutterLegacyConfigFile.createSync (recursive: true );
@@ -165,6 +165,78 @@ void main() {
165165 expect (analytics.telemetryEnabled, true );
166166 });
167167
168+ test ('Honor legacy devtools analytics opt out' , () {
169+ // Create the file for the devtools legacy opt out
170+ final devtoolsLegacyConfigFile =
171+ home.childDirectory ('.flutter-devtools' ).childFile ('.devtools' );
172+ devtoolsLegacyConfigFile.createSync (recursive: true );
173+ devtoolsLegacyConfigFile.writeAsStringSync ('''
174+ {
175+ "analyticsEnabled": false,
176+ "isFirstRun": false,
177+ "lastReleaseNotesVersion": "2.31.0",
178+ "2023-Q4": {
179+ "surveyActionTaken": false,
180+ "surveyShownCount": 0
181+ }
182+ }
183+ ''' );
184+
185+ // The main analytics instance, other instances can be spawned within tests
186+ // to test how to instances running together work
187+ analytics = Analytics .test (
188+ tool: initialTool,
189+ homeDirectory: home,
190+ measurementId: measurementId,
191+ apiSecret: apiSecret,
192+ flutterChannel: flutterChannel,
193+ toolsMessageVersion: toolsMessageVersion,
194+ toolsMessage: toolsMessage,
195+ flutterVersion: flutterVersion,
196+ dartVersion: dartVersion,
197+ fs: fs,
198+ platform: platform,
199+ );
200+
201+ expect (analytics.telemetryEnabled, false );
202+ });
203+
204+ test ('Telemetry enabled if legacy devtools analytics is enabled' , () {
205+ // Create the file for the devtools legacy opt out
206+ final devtoolsLegacyConfigFile =
207+ home.childDirectory ('.flutter-devtools' ).childFile ('.devtools' );
208+ devtoolsLegacyConfigFile.createSync (recursive: true );
209+ devtoolsLegacyConfigFile.writeAsStringSync ('''
210+ {
211+ "analyticsEnabled": true,
212+ "isFirstRun": false,
213+ "lastReleaseNotesVersion": "2.31.0",
214+ "2023-Q4": {
215+ "surveyActionTaken": false,
216+ "surveyShownCount": 0
217+ }
218+ }
219+ ''' );
220+
221+ // The main analytics instance, other instances can be spawned within tests
222+ // to test how to instances running together work
223+ analytics = Analytics .test (
224+ tool: initialTool,
225+ homeDirectory: home,
226+ measurementId: measurementId,
227+ apiSecret: apiSecret,
228+ flutterChannel: flutterChannel,
229+ toolsMessageVersion: toolsMessageVersion,
230+ toolsMessage: toolsMessage,
231+ flutterVersion: flutterVersion,
232+ dartVersion: dartVersion,
233+ fs: fs,
234+ platform: platform,
235+ );
236+
237+ expect (analytics.telemetryEnabled, true );
238+ });
239+
168240 test ('Telemetry disabled if dart config file corrupted' , () {
169241 // Create the file for the dart legacy opt out with text that
170242 // is not valid JSON
@@ -199,8 +271,46 @@ NOT VALID JSON
199271 expect (analytics.telemetryEnabled, false );
200272 });
201273
274+ test ('Telemetry disabled if devtools config file corrupted' , () {
275+ // Create the file for the devtools legacy opt out with text that
276+ // is not valid JSON
277+ final devtoolsLegacyConfigFile =
278+ home.childDirectory ('.flutter-devtools' ).childFile ('.devtools' );
279+ devtoolsLegacyConfigFile.createSync (recursive: true );
280+ devtoolsLegacyConfigFile.writeAsStringSync ('''
281+ NOT VALID JSON
282+ {
283+ "analyticsEnabled": true,
284+ "isFirstRun": false,
285+ "lastReleaseNotesVersion": "2.31.0",
286+ "2023-Q4": {
287+ "surveyActionTaken": false,
288+ "surveyShownCount": 0
289+ }
290+ }
291+ ''' );
292+
293+ // The main analytics instance, other instances can be spawned within tests
294+ // to test how to instances running together work
295+ analytics = Analytics .test (
296+ tool: initialTool,
297+ homeDirectory: home,
298+ measurementId: measurementId,
299+ apiSecret: apiSecret,
300+ flutterChannel: flutterChannel,
301+ toolsMessageVersion: toolsMessageVersion,
302+ toolsMessage: toolsMessage,
303+ flutterVersion: flutterVersion,
304+ dartVersion: dartVersion,
305+ fs: fs,
306+ platform: platform,
307+ );
308+
309+ expect (analytics.telemetryEnabled, false );
310+ });
311+
202312 test ('Telemetry disabled if flutter config file corrupted' , () {
203- // Create the file for the dart legacy opt out with text that
313+ // Create the file for the flutter legacy opt out with text that
204314 // is not valid JSON
205315 final fluttterLegacyConfigFile =
206316 home.childDirectory ('.dart' ).childFile ('dartdev.json' );
0 commit comments