File tree 3 files changed +24
-0
lines changed
3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 2
2
3
3
- Add global functions to the injected client for ` dart.developer.postEvent `
4
4
and ` dart.developer.registerExtension ` .
5
+ - Register new service extension ` ext.dwds.emitEvent ` so clients can emit
6
+ events. This is intended to be used for analytics.
5
7
6
8
## 11.0.2
7
9
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import 'package:logging/logging.dart';
11
11
import 'package:vm_service/vm_service.dart' ;
12
12
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart' ;
13
13
14
+ import 'events.dart' ;
14
15
import 'services/chrome_proxy_service.dart' show ChromeProxyService;
15
16
import 'services/debug_service.dart' ;
16
17
@@ -153,6 +154,13 @@ class DwdsVmClient {
153
154
});
154
155
await client.registerService ('ext.dwds.screenshot' , 'DWDS' );
155
156
157
+ client.registerServiceCallback ('ext.dwds.emitEvent' , (event) async {
158
+ emitEvent (DwdsEvent (
159
+ event['type' ] as String , event['payload' ] as Map <String , dynamic >));
160
+ return {'result' : Success ().toJson ()};
161
+ });
162
+ await client.registerService ('ext.dwds.emitEvent' , 'DWDS' );
163
+
156
164
client.registerServiceCallback ('_yieldControlToDDS' , (request) async {
157
165
final ddsUri = request['uri' ] as String ;
158
166
if (ddsUri == null ) {
Original file line number Diff line number Diff line change @@ -63,6 +63,20 @@ void main() {
63
63
bootstrap = isolate.rootLib;
64
64
});
65
65
66
+ test ('can emit event through service extension' , () async {
67
+ expect (
68
+ context.testServer.dwds.events,
69
+ emits (predicate ((DwdsEvent event) =>
70
+ event.type == 'foo-event' && event.payload['data' ] == 1234 )));
71
+
72
+ var response = await context.debugConnection.vmService
73
+ .callServiceExtension ('ext.dwds.emitEvent' , args: {
74
+ 'type' : 'foo-event' ,
75
+ 'payload' : {'data' : 1234 },
76
+ });
77
+ expect (response.type, 'Success' );
78
+ });
79
+
66
80
test ('emits EVALUATE events on evaluation success' , () async {
67
81
var expression = "helloString('world')" ;
68
82
expect (
You can’t perform that action at this time.
0 commit comments