@@ -102,7 +102,7 @@ void main() {
102
102
});
103
103
104
104
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
106
106
final flutterLegacyConfigFile =
107
107
home.childDirectory ('.dart' ).childFile ('dartdev.json' );
108
108
flutterLegacyConfigFile.createSync (recursive: true );
@@ -134,7 +134,7 @@ void main() {
134
134
});
135
135
136
136
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
138
138
final flutterLegacyConfigFile =
139
139
home.childDirectory ('.dart' ).childFile ('dartdev.json' );
140
140
flutterLegacyConfigFile.createSync (recursive: true );
@@ -165,6 +165,78 @@ void main() {
165
165
expect (analytics.telemetryEnabled, true );
166
166
});
167
167
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
+
168
240
test ('Telemetry disabled if dart config file corrupted' , () {
169
241
// Create the file for the dart legacy opt out with text that
170
242
// is not valid JSON
@@ -199,8 +271,46 @@ NOT VALID JSON
199
271
expect (analytics.telemetryEnabled, false );
200
272
});
201
273
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
+
202
312
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
204
314
// is not valid JSON
205
315
final fluttterLegacyConfigFile =
206
316
home.childDirectory ('.dart' ).childFile ('dartdev.json' );
0 commit comments