Skip to content

Commit 9a45590

Browse files
authored
Adds an IDE query parameter to the Dart DevTools URL (#1522)
1 parent ed4cfd0 commit 9a45590

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

dwds/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Temporarily disable the paused in debugger overlay.
66
- Add `SdkConfiguration` and `SdkConfigurationProvider` classes to allow
77
for lazily created SDK configurations.
8+
- Add an `ide` query parameter to the Dart DevTools URL for analytics.
89

910
**Breaking changes:**
1011
- `Dwds.start` and `ExpressionCompilerService` now take

dwds/lib/src/handlers/dev_handler.dart

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,10 @@ class DevHandler {
375375

376376
appServices.connectedInstanceId = appConnection.request.instanceId;
377377
dwdsStats.devToolsStart = DateTime.now();
378-
await _launchDevTools(appServices.chromeProxyService.remoteDebugger,
379-
_constructDevToolsUri(appServices.debugService.uri));
378+
await _launchDevTools(
379+
appServices.chromeProxyService.remoteDebugger,
380+
_constructDevToolsUri(appServices.debugService.uri,
381+
ideQueryParam: 'Dwds'));
380382
}
381383

382384
Future<AppConnection> _handleConnectRequest(
@@ -523,16 +525,24 @@ class DevHandler {
523525
extensionDebugConnections.add(DebugConnection(appServices));
524526
_servicesByAppId[appId] = appServices;
525527
}
526-
final devToolsUri = _constructDevToolsUri(
527-
await _servicesByAppId[appId].debugService.encodedUri);
528+
final encodedUri = await _servicesByAppId[appId].debugService.encodedUri;
528529
dwdsStats.devToolsStart = DateTime.now();
529530

530-
// If we only want the URI, then return early.
531+
// If we only want the URI, this means we are embedding Dart DevTools in
532+
// Chrome DevTools. Therefore return early.
531533
if (devToolsRequest.uriOnly != null && devToolsRequest.uriOnly) {
534+
final devToolsUri = _constructDevToolsUri(
535+
encodedUri,
536+
ideQueryParam: 'ChromeDevTools',
537+
);
532538
extensionDebugger.sendEvent('dwds.devtoolsUri', devToolsUri);
533539
return;
534540
}
535541

542+
final devToolsUri = _constructDevToolsUri(
543+
encodedUri,
544+
ideQueryParam: 'DebugExtension',
545+
);
536546
await _launchDevTools(extensionDebugger, devToolsUri);
537547
});
538548
}
@@ -549,12 +559,18 @@ class DevHandler {
549559
});
550560
}
551561

552-
String _constructDevToolsUri(String debugServiceUri) {
562+
String _constructDevToolsUri(
563+
String debugServiceUri, {
564+
String ideQueryParam = '',
565+
}) {
553566
return Uri(
554567
scheme: 'http',
555568
host: _devTools.hostname,
556569
port: _devTools.port,
557-
queryParameters: {'uri': debugServiceUri}).toString();
570+
queryParameters: {
571+
'uri': debugServiceUri,
572+
if (ideQueryParam.isNotEmpty) 'ide': ideQueryParam,
573+
}).toString();
558574
}
559575
}
560576

dwds/test/debug_extension_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ void main() async {
7878
// TODO(grouma): switch back to `fixture.webdriver.title` when
7979
// https://github.com/flutter/devtools/issues/2045 is fixed.
8080
expect(await context.webDriver.pageSource, contains('Flutter'));
81+
expect(await context.webDriver.currentUrl,
82+
contains('ide=DebugExtension'));
8183
});
8284

8385
test('can close DevTools and relaunch', () async {

dwds/test/devtools_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ void main() {
4747
// TODO(grouma): switch back to `fixture.webdriver.title` when
4848
// https://github.com/flutter/devtools/issues/2045 is fixed.
4949
expect(await context.webDriver.pageSource, contains('Flutter'));
50+
expect(await context.webDriver.currentUrl, contains('ide=Dwds'));
5051
});
5152

5253
test(

0 commit comments

Comments
 (0)