diff --git a/dwds/CHANGELOG.md b/dwds/CHANGELOG.md index 98e3350ef..c98fc9424 100644 --- a/dwds/CHANGELOG.md +++ b/dwds/CHANGELOG.md @@ -5,6 +5,7 @@ - Temporarily disable the paused in debugger overlay. - Add `SdkConfiguration` and `SdkConfigurationProvider` classes to allow for lazily created SDK configurations. +- Add an `ide` query parameter to the Dart DevTools URL for analytics. **Breaking changes:** - `Dwds.start` and `ExpressionCompilerService` now take diff --git a/dwds/lib/src/handlers/dev_handler.dart b/dwds/lib/src/handlers/dev_handler.dart index 5f7a68791..8dcd23728 100644 --- a/dwds/lib/src/handlers/dev_handler.dart +++ b/dwds/lib/src/handlers/dev_handler.dart @@ -375,8 +375,10 @@ class DevHandler { appServices.connectedInstanceId = appConnection.request.instanceId; dwdsStats.devToolsStart = DateTime.now(); - await _launchDevTools(appServices.chromeProxyService.remoteDebugger, - _constructDevToolsUri(appServices.debugService.uri)); + await _launchDevTools( + appServices.chromeProxyService.remoteDebugger, + _constructDevToolsUri(appServices.debugService.uri, + ideQueryParam: 'Dwds')); } Future _handleConnectRequest( @@ -523,16 +525,24 @@ class DevHandler { extensionDebugConnections.add(DebugConnection(appServices)); _servicesByAppId[appId] = appServices; } - final devToolsUri = _constructDevToolsUri( - await _servicesByAppId[appId].debugService.encodedUri); + final encodedUri = await _servicesByAppId[appId].debugService.encodedUri; dwdsStats.devToolsStart = DateTime.now(); - // If we only want the URI, then return early. + // If we only want the URI, this means we are embedding Dart DevTools in + // Chrome DevTools. Therefore return early. if (devToolsRequest.uriOnly != null && devToolsRequest.uriOnly) { + final devToolsUri = _constructDevToolsUri( + encodedUri, + ideQueryParam: 'ChromeDevTools', + ); extensionDebugger.sendEvent('dwds.devtoolsUri', devToolsUri); return; } + final devToolsUri = _constructDevToolsUri( + encodedUri, + ideQueryParam: 'DebugExtension', + ); await _launchDevTools(extensionDebugger, devToolsUri); }); } @@ -549,12 +559,18 @@ class DevHandler { }); } - String _constructDevToolsUri(String debugServiceUri) { + String _constructDevToolsUri( + String debugServiceUri, { + String ideQueryParam = '', + }) { return Uri( scheme: 'http', host: _devTools.hostname, port: _devTools.port, - queryParameters: {'uri': debugServiceUri}).toString(); + queryParameters: { + 'uri': debugServiceUri, + if (ideQueryParam.isNotEmpty) 'ide': ideQueryParam, + }).toString(); } } diff --git a/dwds/test/debug_extension_test.dart b/dwds/test/debug_extension_test.dart index 72bf7609f..e02655d17 100644 --- a/dwds/test/debug_extension_test.dart +++ b/dwds/test/debug_extension_test.dart @@ -78,6 +78,8 @@ void main() async { // TODO(grouma): switch back to `fixture.webdriver.title` when // https://github.com/flutter/devtools/issues/2045 is fixed. expect(await context.webDriver.pageSource, contains('Flutter')); + expect(await context.webDriver.currentUrl, + contains('ide=DebugExtension')); }); test('can close DevTools and relaunch', () async { diff --git a/dwds/test/devtools_test.dart b/dwds/test/devtools_test.dart index c0eb7a49c..501c5048e 100644 --- a/dwds/test/devtools_test.dart +++ b/dwds/test/devtools_test.dart @@ -47,6 +47,7 @@ void main() { // TODO(grouma): switch back to `fixture.webdriver.title` when // https://github.com/flutter/devtools/issues/2045 is fixed. expect(await context.webDriver.pageSource, contains('Flutter')); + expect(await context.webDriver.currentUrl, contains('ide=Dwds')); }); test(