Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
12 changes: 9 additions & 3 deletions Composer/packages/electron-server/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import os from 'os';
import { join, resolve } from 'path';

import { AppUpdaterSettings, UserSettings } from '@bfc/shared';
Expand Down Expand Up @@ -163,9 +164,14 @@ async function loadServer() {
getARMTokenForTenant: OneAuthService.getARMTokenForTenant.bind(OneAuthService),
getTenants: OneAuthService.getTenants.bind(OneAuthService),
logOut: OneAuthService.signOut.bind(OneAuthService),
machineId,
sessionId,
composerVersion: app.getVersion(),
telemetryData: {
composerVersion: app.getVersion(),
machineId,
sessionId,
architecture: os.arch(),
cpu: os.cpus()[0]?.model,
memory: os.totalmem(),
},
});
log(`Server started at port: ${serverPort}`);
}
Expand Down
9 changes: 6 additions & 3 deletions Composer/packages/lib/code-editor/src/LuEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { LuFile } from '@botframework-composer/types';
import { LuFile, TelemetryClient } from '@botframework-composer/types';
import styled from '@emotion/styled';
import { EditorDidMount, Monaco } from '@monaco-editor/react';
import { FluentTheme, NeutralColors } from '@uifabric/fluent-theme';
Expand Down Expand Up @@ -76,6 +76,7 @@ export interface LULSPEditorProps extends BaseEditorProps {
}
| string;
toolbarHidden?: boolean;
telemetryClient: TelemetryClient;
onNavigateToLuPage?: (luFileId: string, luSectionId?: string) => void;
}

Expand Down Expand Up @@ -135,6 +136,7 @@ const LuEditor: React.FC<LULSPEditorProps> = (props) => {
onInit: onInitProp,
placeholder = defaultPlaceholder,
helpURL = LU_HELP,
telemetryClient,
...restProps
} = props;
const luServer = languageServer || defaultLUServer;
Expand Down Expand Up @@ -239,7 +241,7 @@ const LuEditor: React.FC<LULSPEditorProps> = (props) => {
if (luEdits?.scrollLine) {
editor.revealLineInCenter(luEdits?.scrollLine);
}

telemetryClient.track('LUEditorEntityDefinitionAdded', { entityType });
Comment thread
tdurnford marked this conversation as resolved.
Outdated
editor.focus();
}
}
Expand All @@ -248,11 +250,12 @@ const LuEditor: React.FC<LULSPEditorProps> = (props) => {
);

const insertEntity = useCallback(
(entityName: string) => {
(entityName: string, entityType: string) => {
if (editor) {
const edits = computeInsertLuEntityEdits(entityName, editor);
if (edits) {
editor.executeEdits('toolbarMenu', edits);
telemetryClient.track('LUEditorEntityTagAdded', { entityType });
Comment thread
tdurnford marked this conversation as resolved.
Outdated
editor.focus();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const buttonStyles = {
};

type Props = {
onInsertEntity: (entityName: string) => void;
onInsertEntity: (entityName: string, eventType: string) => void;
labelingMenuVisible: boolean;
insertEntityDisabled: boolean;
tagEntityDisabled: boolean;
Expand All @@ -47,7 +47,7 @@ export const InsertEntityButton = React.memo((props: Props) => {
(_, item?: IContextualMenuItem) => {
const entity = item?.data as LuEntity;
if (entity) {
onInsertEntity(entity.Name);
onInsertEntity(entity.Name, entity.Type);
}
},
[onInsertEntity]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type Props = {
luFile?: LuFile;
labelingMenuVisible: boolean;
onDefineEntity: (entityType: ToolbarLuEntityType, entityName?: string) => void;
onInsertEntity: (entityName: string) => void;
onInsertEntity: (entityName: string, entityType: string) => void;
};

export const LuEditorToolbar = React.memo((props: Props) => {
Expand Down
4 changes: 2 additions & 2 deletions Composer/packages/lib/code-editor/src/lu/LuLabelingMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Props = {
editor: any;
luFile?: LuFile;
onMenuToggled?: (visible: boolean) => void;
onInsertEntity: (entityName: string) => void;
onInsertEntity: (entityName: string, entityType: string) => void;
};

export const LuLabelingMenu = ({ editor, luFile, onMenuToggled, onInsertEntity }: Props) => {
Expand Down Expand Up @@ -79,7 +79,7 @@ export const LuLabelingMenu = ({ editor, luFile, onMenuToggled, onInsertEntity }
(_, item?: IContextualMenuItem) => {
const entity = item?.data as LuEntity;
if (entity) {
onInsertEntity(entity.Name);
onInsertEntity(entity.Name, entity.Type);
}
setMenuTargetElm(null);
},
Expand Down
22 changes: 19 additions & 3 deletions Composer/packages/server/src/services/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ const getTelemetryContext = () => {
const electronContext = useElectronContext();

if (electronContext) {
const { sessionId, machineId, composerVersion } = electronContext;
const {
telemetryData: { composerVersion, sessionId, machineId, architecture, cpu, memory },
} = electronContext;
const { telemetry = {} } = SettingsService.getSettings();
return { sessionId, userId: machineId, telemetry, composerVersion };
return { sessionId, userId: machineId, telemetry, composerVersion, architecture, cpu, memory };
}

return {};
Expand All @@ -39,7 +41,7 @@ if (instrumentationKey) {
// do not collect the user's machine name
AppInsights.defaultClient.context.tags[AppInsights.defaultClient.context.keys.cloudRoleInstance] = '';
AppInsights.defaultClient.addTelemetryProcessor((envelope: AppInsights.Contracts.Envelope, context): boolean => {
const { sessionId, telemetry, composerVersion, userId } = getTelemetryContext();
const { sessionId, telemetry, composerVersion, userId, architecture, cpu, memory } = getTelemetryContext();

if (!telemetry?.allowDataCollection) {
return false;
Expand Down Expand Up @@ -70,6 +72,20 @@ if (instrumentationKey) {
data.baseData.properties.composerVersion = composerVersion;
}

if (data.baseData.name === 'SessionStarted') {
if (architecture) {
data.baseData.properties.architecture = architecture;
}

if (cpu) {
data.baseData.properties.cpu = cpu;
}

if (memory) {
data.baseData.properties.memory = memory;
}
}

// remove PII
for (const property of piiProperties) {
if (data.baseData.properties[property] !== undefined) {
Expand Down
11 changes: 8 additions & 3 deletions Composer/packages/server/src/utility/electronContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ export type ElectronContext = {
getARMTokenForTenant: (tenantId: string) => Promise<string>;
getTenants: () => Promise<AzureTenant[]>;
logOut: () => void;
machineId: string;
sessionId: string;
composerVersion: string;
telemetryData: {
composerVersion: string;
machineId: string;
sessionId: string;
architecture: string;
cpu?: string;
memory: number;
};
};

let context;
Expand Down
8 changes: 7 additions & 1 deletion Composer/packages/types/src/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ type LgEditorEvents = {
};
};

type LuEditorEvents = {
LUEditorEntityTagAdded: { entityType: string };
LUEditorEntityDefinitionAdded: { entityType: string };
};

type WebChatEvents = {
WebChatPaneOpened: undefined;
WebChatPaneClosed: undefined;
Expand Down Expand Up @@ -185,7 +190,8 @@ export type TelemetryEvents = ApplicationEvents &
AppSettingsEvents &
PageView &
LgEditorEvents &
WebChatEvents;
WebChatEvents &
LuEditorEvents;

export type TelemetryEventName = keyof TelemetryEvents;

Expand Down
1 change: 1 addition & 0 deletions Composer/packages/ui-plugins/luis/src/LuisIntentEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const LuisIntentEditor: React.FC<FieldProps<string>> = (props) => {
luOption={{ fileId: luFile.id, sectionId: luIntent.Name, projectId, luFeatures }}
placeholder={placeholder || inlineModePlaceholder}
value={luIntent.Body}
telemetryClient={shellApi.telemetryClient}
onChange={commitChanges}
onChangeSettings={handleSettingsChange}
onNavigateToLuPage={navigateToLuPage}
Expand Down