Add debug flag for debugging DevTools survey (#6487)
diff --git a/packages/devtools_app/lib/src/shared/development_helpers.dart b/packages/devtools_app/lib/src/shared/development_helpers.dart index 5be8c71..a3298e5 100644 --- a/packages/devtools_app/lib/src/shared/development_helpers.dart +++ b/packages/devtools_app/lib/src/shared/development_helpers.dart
@@ -6,6 +6,7 @@ import 'package:meta/meta.dart'; import 'globals.dart'; +import 'survey.dart'; /// Enable this flag to debug analytics when DevTools is run in debug or profile /// mode, otherwise analytics will only be sent in release builds. @@ -79,3 +80,28 @@ DevToolsExtensionConfig.pathKey: '/path/to/provider', }), ]; + +/// Enable this flag to debug the DevTools survey logic. +/// +/// When this flag is true, [debugSurveyMetadata] will be used instead of what +/// we normally fetch from +/// 'docs.flutter.dev/f/dart-devtools-survey-metadata.json'. +bool debugSurvey = false; + +/// The survey metadata that will be used instead of the live data from +/// 'docs.flutter.dev/f/dart-devtools-survey-metadata.json' when [debugSurvey] +/// is true; +final debugSurveyMetadata = DevToolsSurvey.parse( + { + '_comments': [ + 'uniqueId must be updated with each new survey so DevTools knows to re-prompt users.', + 'title should not exceed 45 characters.', + 'startDate and endDate should follow ISO 8601 standard with a timezone offset.', + ], + 'uniqueId': '2023-Q4', + 'title': 'Help improve DevTools! Take our 2023 Q4 survey.', + 'url': 'https://google.qualtrics.com/jfe/form/SV_2l4XcyscF8mQtDM', + 'startDate': '2023-09-20T09:00:00-07:00', + 'endDate': '2023-10-20T09:00:00-07:00', + }, +);
diff --git a/packages/devtools_app/lib/src/shared/survey.dart b/packages/devtools_app/lib/src/shared/survey.dart index 42fb1b2..400f8e0 100644 --- a/packages/devtools_app/lib/src/shared/survey.dart +++ b/packages/devtools_app/lib/src/shared/survey.dart
@@ -12,6 +12,7 @@ import 'analytics/analytics.dart' as ga; import 'config_specific/launch_url/launch_url.dart'; import 'config_specific/server/server.dart' as server; +import 'development_helpers.dart'; import 'globals.dart'; import 'primitives/utils.dart'; @@ -117,6 +118,9 @@ Future<DevToolsSurvey?> _fetchSurveyContent() async { try { + if (debugSurvey) { + return debugSurveyMetadata; + } final response = await get(_metadataUrl); if (response.statusCode == 200) { final Map<String, dynamic> contents = json.decode(response.body);
diff --git a/packages/devtools_app/test/shared/development_helpers_test.dart b/packages/devtools_app/test/shared/development_helpers_test.dart index 70d27c4..02e68fd 100644 --- a/packages/devtools_app/test/shared/development_helpers_test.dart +++ b/packages/devtools_app/test/shared/development_helpers_test.dart
@@ -9,5 +9,6 @@ test('debug flags are false', () { expect(debugAnalytics, isFalse); expect(debugDevToolsExtensions, isFalse); + expect(debugSurvey, isFalse); }); }