@pnp/cli-microsoft365
Version:
Manage Microsoft 365 and SharePoint Framework projects on any platform
38 lines • 1.2 kB
JavaScript
import appInsights from './appInsights.js';
import { cli } from './cli/cli.js';
import { settingsNames } from './settingsNames.js';
import { pid } from './utils/pid.js';
import { session } from './utils/session.js';
async function trackTelemetry(object) {
try {
const { commandName, properties, exception } = object;
appInsights.commonProperties.shell = pid.getProcessName(process.ppid) || '';
appInsights.context.tags[appInsights.context.keys.sessionId] = session.getId(process.ppid);
if (exception) {
appInsights.trackException({
exception
});
}
else {
appInsights.trackEvent({
name: commandName,
properties
});
}
await appInsights.flush();
}
catch { }
}
export const telemetry = {
trackEvent: async (commandName, properties, exception) => {
if (cli.getSettingWithDefaultValue(settingsNames.disableTelemetry, false)) {
return;
}
await trackTelemetry({
commandName,
properties,
exception
});
}
};
//# sourceMappingURL=telemetry.js.map