|
7 | 7 | import Bowser from 'bowser'; |
8 | 8 | import StaticConfiguration from '../../StaticConfiguration'; |
9 | 9 | import { outputting } from '../stores/uiStore'; |
10 | | -import { logError, logMessage } from '../utils/logging'; |
| 10 | +import { logError, logEvent, logMessage } from '../utils/logging'; |
11 | 11 | import MBSpecs from './MBSpecs'; |
12 | 12 | import MicrobitConnection, { DeviceRequestStates } from './MicrobitConnection'; |
13 | 13 | import { UARTMessageType } from './Microbits'; |
@@ -83,7 +83,11 @@ export class MicrobitBluetooth implements MicrobitConnection { |
83 | 83 | } |
84 | 84 |
|
85 | 85 | async connect(...states: DeviceRequestStates[]): Promise<void> { |
86 | | - logMessage('Bluetooth connect', states); |
| 86 | + logEvent({ |
| 87 | + type: this.isReconnect ? 'Reconnect' : 'Connect', |
| 88 | + action: 'Bluetooth connect start', |
| 89 | + states, |
| 90 | + }); |
87 | 91 | if (this.duringExplicitConnectDisconnect) { |
88 | 92 | logMessage('Skipping connect attempt when one is already in progress'); |
89 | 93 | // Wait for the gattConnectPromise while showing a "connecting" dialog. |
@@ -170,8 +174,18 @@ export class MicrobitBluetooth implements MicrobitConnection { |
170 | 174 | states.forEach(s => this.inUseAs.add(s)); |
171 | 175 | states.forEach(s => stateOnAssigned(s, microbitVersion!)); |
172 | 176 | states.forEach(s => stateOnReady(s)); |
| 177 | + logEvent({ |
| 178 | + type: this.isReconnect ? 'Reconnect' : 'Connect', |
| 179 | + action: 'Bluetooth connect success', |
| 180 | + states, |
| 181 | + }); |
173 | 182 | } catch (e) { |
174 | 183 | logError('Bluetooth connect error', e); |
| 184 | + logEvent({ |
| 185 | + type: this.isReconnect ? 'Reconnect' : 'Connect', |
| 186 | + action: 'Bluetooth connect failed', |
| 187 | + states, |
| 188 | + }); |
175 | 189 | await this.disconnectInternal(false); |
176 | 190 | throw new Error('Failed to establish a connection!'); |
177 | 191 | } finally { |
|
0 commit comments