Skip to content

Commit e77cd91

Browse files
author
Benjamin Pasero
committed
some message telemetry (for microsoft#22388)
1 parent 4644b60 commit e77cd91

2 files changed

Lines changed: 34 additions & 22 deletions

File tree

src/vs/workbench/services/message/browser/messageList.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,18 @@ export class MessageList {
190190
private doShowMessage(id: Error, message: string, severity: Severity, onHide: () => void): () => void;
191191
private doShowMessage(id: IMessageWithAction, message: string, severity: Severity, onHide: () => void): () => void;
192192
private doShowMessage(id: any, message: string, severity: Severity, onHide: () => void): () => void {
193+
const actions = (<IMessageWithAction>id).actions;
194+
const source = (<IMessageWithAction>id).source;
195+
196+
// Telemetry (TODO@Ben remove me later)
197+
/* __GDPR__
198+
"showMessage" : {
199+
"message" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
200+
"source" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
201+
"buttons" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
202+
}
203+
*/
204+
this.telemetryService.publicLog('showMessage', { message, source, buttons: actions ? actions.map(a => a.label) : void 0 });
193205

194206
// Trigger Auto-Purge of messages to keep list small
195207
this.purgeMessages();
@@ -200,8 +212,8 @@ export class MessageList {
200212
text: message,
201213
severity: severity,
202214
time: Date.now(),
203-
actions: (<IMessageWithAction>id).actions,
204-
source: (<IMessageWithAction>id).source,
215+
actions,
216+
source,
205217
onHide
206218
});
207219

src/vs/workbench/services/message/electron-browser/messageService.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { IConfirmation, Severity, IChoiceService, IConfirmationResult } from 'vs
1313
import { isLinux } from 'vs/base/common/platform';
1414
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
1515
import { Action } from 'vs/base/common/actions';
16-
import { IWindowService, IMessageBoxResult } from 'vs/platform/windows/common/windows';
16+
import { IWindowService } from 'vs/platform/windows/common/windows';
1717
import { mnemonicButtonLabel } from 'vs/base/common/labels';
1818

1919
export class MessageService extends WorkbenchMessageService implements IChoiceService {
@@ -27,31 +27,22 @@ export class MessageService extends WorkbenchMessageService implements IChoiceSe
2727
}
2828

2929
public confirmWithCheckbox(confirmation: IConfirmation): TPromise<IConfirmationResult> {
30-
const opts = this.getConfirmOptions(confirmation);
31-
32-
return this.showMessageBoxWithCheckbox(opts).then(result => {
33-
return {
34-
confirmed: result.button === 0 ? true : false,
35-
checkboxChecked: result.checkboxChecked
36-
} as IConfirmationResult;
37-
});
38-
}
39-
40-
private showMessageBoxWithCheckbox(opts: Electron.MessageBoxOptions): TPromise<IMessageBoxResult> {
41-
opts = this.massageMessageBoxOptions(opts);
30+
const opts = this.massageMessageBoxOptions(this.getConfirmOptions(confirmation));
4231

4332
return this.windowService.showMessageBox(opts).then(result => {
33+
const button = isLinux ? opts.buttons.length - result.button - 1 : result.button;
34+
4435
return {
45-
button: isLinux ? opts.buttons.length - result.button - 1 : result.button,
36+
confirmed: button === 0 ? true : false,
4637
checkboxChecked: result.checkboxChecked
47-
} as IMessageBoxResult;
38+
} as IConfirmationResult;
4839
});
4940
}
5041

5142
public confirm(confirmation: IConfirmation): TPromise<boolean> {
5243
const opts = this.getConfirmOptions(confirmation);
5344

54-
return this.showMessageBox(opts).then(result => result === 0 ? true : false);
45+
return this.doShowMessageBox(opts).then(result => result === 0 ? true : false);
5546
}
5647

5748
private getConfirmOptions(confirmation: IConfirmation): Electron.MessageBoxOptions {
@@ -94,16 +85,25 @@ export class MessageService extends WorkbenchMessageService implements IChoiceSe
9485

9586
public choose(severity: Severity, message: string, options: string[], cancelId: number, modal: boolean = false): TPromise<number> {
9687
if (modal) {
97-
const type: 'none' | 'info' | 'error' | 'question' | 'warning' = severity === Severity.Info ? 'question' : severity === Severity.Error ? 'error' : severity === Severity.Warning ? 'warning' : 'none';
98-
99-
return this.showMessageBox({ message, buttons: options, type, cancelId });
88+
return this.doChooseModal(severity, message, options, cancelId);
10089
}
10190

91+
return this.doChooseWithMessage(severity, message, options);
92+
}
93+
94+
private doChooseModal(severity: Severity, message: string, options: string[], cancelId: number): TPromise<number> {
95+
const type: 'none' | 'info' | 'error' | 'question' | 'warning' = severity === Severity.Info ? 'question' : severity === Severity.Error ? 'error' : severity === Severity.Warning ? 'warning' : 'none';
96+
97+
return this.doShowMessageBox({ message, buttons: options, type, cancelId });
98+
}
99+
100+
private doChooseWithMessage(severity: Severity, message: string, options: string[]): TPromise<number> {
102101
let onCancel: () => void = null;
103102

104103
const promise = new TPromise<number>((c, e) => {
105104
const callback = (index: number) => () => {
106105
c(index);
106+
107107
return TPromise.as(true);
108108
};
109109

@@ -115,7 +115,7 @@ export class MessageService extends WorkbenchMessageService implements IChoiceSe
115115
return promise;
116116
}
117117

118-
private showMessageBox(opts: Electron.MessageBoxOptions): TPromise<number> {
118+
private doShowMessageBox(opts: Electron.MessageBoxOptions): TPromise<number> {
119119
opts = this.massageMessageBoxOptions(opts);
120120

121121
return this.windowService.showMessageBox(opts).then(result => isLinux ? opts.buttons.length - result.button - 1 : result.button);

0 commit comments

Comments
 (0)