Skip to content

Adds an IDE query parameter to the Dart DevTools URL #1522

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dwds/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 23 additions & 7 deletions dwds/lib/src/handlers/dev_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<AppConnection> _handleConnectRequest(
Expand Down Expand Up @@ -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);
});
}
Expand All @@ -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();
}
}

Expand Down
2 changes: 2 additions & 0 deletions dwds/test/debug_extension_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions dwds/test/devtools_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down