Skip to content

Commit

Permalink
Fixed prettier issues related to telemetry.
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyanziano committed Jan 24, 2019
1 parent 81727fe commit d49cc6e
Show file tree
Hide file tree
Showing 47 changed files with 1,185 additions and 22,751 deletions.
9 changes: 7 additions & 2 deletions packages/app/client/src/commands/botCommands.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,14 @@ describe('The bot commands', () => {
);
handler({});
expect(spy).toHaveBeenCalledWith({});
expect(remoteCallArgs[0][0]).toBe(SharedConstants.Commands.Telemetry.TrackEvent);
expect(remoteCallArgs[0][0]).toBe(
SharedConstants.Commands.Telemetry.TrackEvent
);
expect(remoteCallArgs[0][1]).toBe('bot_open');
expect(remoteCallArgs[0][2]).toEqual({ method: 'bots_list', numOfServices: undefined });
expect(remoteCallArgs[0][2]).toEqual({
method: 'bots_list',
numOfServices: undefined,
});
});

it('should make the appropriate calls to close a bot', () => {
Expand Down
12 changes: 9 additions & 3 deletions packages/app/client/src/commands/botCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,20 @@ export function registerCommands(commandRegistry: CommandRegistryImpl) {

// ---------------------------------------------------------------------------
// Switches the current active bot
commandRegistry.registerCommand(Commands.Bot.Switch, (bot: BotConfigWithPath | string) => {
commandRegistry.registerCommand(
Commands.Bot.Switch,
(bot: BotConfigWithPath | string) => {
let numOfServices;
if (typeof bot !== 'string') {
numOfServices = bot.services && bot.services.length;
}
CommandServiceImpl.remoteCall(Commands.Telemetry.TrackEvent, 'bot_open', { method: 'bots_list', numOfServices });
CommandServiceImpl.remoteCall(Commands.Telemetry.TrackEvent, 'bot_open', {
method: 'bots_list',
numOfServices,
});
return ActiveBotHelper.confirmAndSwitchBots(bot);
});
}
);

// ---------------------------------------------------------------------------
// Closes the current active bot
Expand Down
4 changes: 3 additions & 1 deletion packages/app/client/src/commands/emulatorCommands.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ describe('The emulator commands', () => {
const remoteCallSpy = jest
.spyOn(CommandServiceImpl, 'remoteCall')
.mockResolvedValue('transcript.transcript');
const callSpy = jest.spyOn(CommandServiceImpl, 'call');
const callSpy = jest
.spyOn(CommandServiceImpl, 'call')
.mockResolvedValue(null);

await handler();

Expand Down
16 changes: 10 additions & 6 deletions packages/app/client/src/commands/emulatorCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ export function registerCommands(commandRegistry: CommandRegistryImpl) {
CommandServiceImpl.remoteCall(TrackEvent, 'livechat_openRemote');
}

store.dispatch(EditorActions.open({
contentType: Constants.CONTENT_TYPE_LIVE_CHAT,
documentId,
isGlobal: false
}));
store.dispatch(
EditorActions.open({
contentType: Constants.CONTENT_TYPE_LIVE_CHAT,
documentId,
isGlobal: false,
})
);
return documentId;
}
);
Expand Down Expand Up @@ -143,7 +145,9 @@ export function registerCommands(commandRegistry: CommandRegistryImpl) {
dialogOptions
);
await CommandServiceImpl.call(Emulator.OpenTranscript, filename);
CommandServiceImpl.remoteCall(TrackEvent, 'transcriptFile_open', { method: 'file_menu' });
CommandServiceImpl.remoteCall(TrackEvent, 'transcriptFile_open', {
method: 'file_menu',
});
} catch (e) {
const errMsg = `Error while opening transcript file: ${e}`;
const notification = newNotification(errMsg);
Expand Down
6 changes: 4 additions & 2 deletions packages/app/client/src/commands/uiCommands.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
//
import { SharedConstants } from '@bfemulator/app-shared';
import { CommandRegistryImpl } from '@bfemulator/sdk-shared';

import {
CONTENT_TYPE_APP_SETTINGS,
DOCUMENT_ID_APP_SETTINGS,
Expand All @@ -56,9 +57,10 @@ import {
OpenBotDialogContainer,
SecretPromptDialogContainer,
} from '../ui/dialogs';
import { registerCommands } from './uiCommands';
import { CommandServiceImpl } from '../platform/commands/commandServiceImpl';

import { registerCommands } from './uiCommands';

jest.mock('../ui/dialogs', () => ({
AzureLoginPromptDialogContainer: class {},
AzureLoginSuccessDialogContainer: class {},
Expand Down Expand Up @@ -154,7 +156,7 @@ describe('the uiCommands', () => {

it('should set the proper href on the theme tag when the SwitchTheme command is dispatched', () => {
const remoteCallSpy = jest.spyOn(CommandServiceImpl, 'remoteCall');
let link = document.createElement('link');
const link = document.createElement('link');
link.id = 'themeVars';
document.querySelector('head').appendChild(link);
registry.getCommand(Commands.SwitchTheme).handler('light', './light.css');
Expand Down
4 changes: 3 additions & 1 deletion packages/app/client/src/commands/uiCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ export function registerCommands(commandRegistry: CommandRegistry) {
link => link.href
); // href is fully qualified
store.dispatch(switchTheme(themeName, themeComponents));
CommandServiceImpl.remoteCall(Telemetry.TrackEvent, 'app_chooseTheme', { themeName });
CommandServiceImpl.remoteCall(Telemetry.TrackEvent, 'app_chooseTheme', {
themeName,
});
}
);

Expand Down
5 changes: 4 additions & 1 deletion packages/app/client/src/data/sagas/azureAuthSaga.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ describe('The azureAuthSaga', () => {
ct++;
}
expect(ct).toBe(5);
expect(remoteCallSpy).toHaveBeenCalledWith(SharedConstants.Commands.Telemetry.TrackEvent, 'signIn_failure');
expect(remoteCallSpy).toHaveBeenCalledWith(
SharedConstants.Commands.Telemetry.TrackEvent,
'signIn_failure'
);
});

it('should contain 6 steps when the Azure login dialog prompt is confirmed and auth succeeds', async () => {
Expand Down
21 changes: 17 additions & 4 deletions packages/app/client/src/data/sagas/azureAuthSaga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,25 @@ export function* getArmToken(
// Result must be 1 which is a confirmation to sign in to Azure
return result;
}
const { RetrieveArmToken, PersistAzureLoginChanged } = SharedConstants.Commands.Azure;
const {
RetrieveArmToken,
PersistAzureLoginChanged,
} = SharedConstants.Commands.Azure;
const { TrackEvent } = SharedConstants.Commands.Telemetry;
azureAuth = yield call(CommandServiceImpl.remoteCall.bind(CommandServiceImpl), RetrieveArmToken);
azureAuth = yield call(
CommandServiceImpl.remoteCall.bind(CommandServiceImpl),
RetrieveArmToken
);
if (azureAuth && !('error' in azureAuth)) {
const persistLogin = yield DialogService.showDialog(action.payload.loginSuccessDialog, azureAuth);
yield call(CommandServiceImpl.remoteCall.bind(CommandServiceImpl), PersistAzureLoginChanged, persistLogin);
const persistLogin = yield DialogService.showDialog(
action.payload.loginSuccessDialog,
azureAuth
);
yield call(
CommandServiceImpl.remoteCall.bind(CommandServiceImpl),
PersistAzureLoginChanged,
persistLogin
);
CommandServiceImpl.remoteCall(TrackEvent, 'signIn_success');
} else {
yield DialogService.showDialog(action.payload.loginFailedDialog);
Expand Down
19 changes: 10 additions & 9 deletions packages/app/client/src/data/sagas/resourceSagas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,15 @@ describe('The ResourceSagas', () => {
expect(mockLocalCommandsCalled).toEqual([
{
commandName: 'chat:open',
args: ['the/file/path/chat.chat', true]
}
args: ['the/file/path/chat.chat', true],
},
]);
expect(mockRemoteCommandsCalled).toEqual([
{
commandName: SharedConstants.Commands.Telemetry.TrackEvent,
args: ['chatFile_open']
}
])
args: ['chatFile_open'],
},
]);
});

it('should open a transcript file', async () => {
Expand All @@ -273,14 +273,15 @@ describe('The ResourceSagas', () => {
expect(mockLocalCommandsCalled).toEqual([
{
commandName: 'transcript:open',
args: ['the/file/path/transcript.transcript']
}
args: ['the/file/path/transcript.transcript'],
},
]);
expect(mockRemoteCommandsCalled).toEqual([
{
commandName: SharedConstants.Commands.Telemetry.TrackEvent,
args: ['transcriptFile_open', { method: 'resources_pane' }]
}])
args: ['transcriptFile_open', { method: 'resources_pane' }],
},
]);
});
});

Expand Down
4 changes: 3 additions & 1 deletion packages/app/client/src/data/sagas/resourcesSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ function* doOpenResource(
CommandServiceImpl.remoteCall(TrackEvent, 'chatFile_open');
} else if (isTranscriptFile(path)) {
yield CommandServiceImpl.call(OpenTranscript, path);
CommandServiceImpl.remoteCall(TrackEvent, 'transcriptFile_open', { method: 'resources_pane' });
CommandServiceImpl.remoteCall(TrackEvent, 'transcriptFile_open', {
method: 'resources_pane',
});
}
// unknown types just fall into the abyss
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,20 +229,32 @@ export class AppSettingsEditor extends React.Component<
label="Use a sign-in verification code for OAuthCards"
/>
<SmallHeader>Application Updates</SmallHeader>
<Checkbox className={ styles.checkboxOverrides }
checked={ uncommitted.autoUpdate }
onChange={ this.onChangeAutoInstallUpdates }
label="Automatically download and install updates"/>
<Checkbox className={ styles.checkboxOverrides }
checked={ uncommitted.usePrereleases }
onChange={ this.onChangeUsePrereleases }
label="Use pre-release versions"/>
<Checkbox
className={styles.checkboxOverrides}
checked={uncommitted.autoUpdate}
onChange={this.onChangeAutoInstallUpdates}
label="Automatically download and install updates"
/>
<Checkbox
className={styles.checkboxOverrides}
checked={uncommitted.usePrereleases}
onChange={this.onChangeUsePrereleases}
label="Use pre-release versions"
/>
<SmallHeader>Data Collection</SmallHeader>
<Checkbox className={ styles.checkboxOverrides }
checked={ uncommitted.collectUsageData }
onChange={ this.onChangeCollectUsageData }
label="Help improve the Emulator by allowing us to collect usage data."/>
<a target="_blank" href="https://aka.ms/bot-framework-emulator-data-collection">Learn more.</a>
<Checkbox
className={styles.checkboxOverrides}
checked={uncommitted.collectUsageData}
onChange={this.onChangeCollectUsageData}
label="Help improve the Emulator by allowing us to collect usage data."
/>
<a
target="_blank"
href="https://aka.ms/bot-framework-emulator-data-collection"
rel="noopener noreferrer"
>
Learn more.
</a>
</Column>
</Row>
<Row className={styles.buttonRow} justify={RowJustification.Right}>
Expand Down Expand Up @@ -275,8 +287,10 @@ export class AppSettingsEditor extends React.Component<
};

private onChangeCollectUsageData = (): void => {
this.setUncommittedState({ collectUsageData: !this.state.uncommitted.collectUsageData });
}
this.setUncommittedState({
collectUsageData: !this.state.uncommitted.collectUsageData,
});
};

private setUncommittedState(patch: any) {
this.setState(state => {
Expand Down Expand Up @@ -329,7 +343,7 @@ export class AppSettingsEditor extends React.Component<
locale: uncommitted.locale.trim(),
usePrereleases: uncommitted.usePrereleases,
autoUpdate: uncommitted.autoUpdate,
collectUsageData: uncommitted.collectUsageData
collectUsageData: uncommitted.collectUsageData,
};

CommandServiceImpl.remoteCall(Commands.Settings.SaveAppSettings, settings)
Expand Down
Loading

0 comments on commit d49cc6e

Please sign in to comment.