Skip to content

Commit

Permalink
updated telemetry service
Browse files Browse the repository at this point in the history
  • Loading branch information
tdurnford committed Dec 4, 2020
1 parent 52467aa commit 992d28d
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions Composer/packages/server/src/services/telemetry.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import fs from 'fs';

import * as AppInsights from 'applicationinsights';
import { TelemetryEventName, TelemetryEvents, TelemetryEventTypes, TelemetryEvent } from '@bfc/shared';

import { APPINSIGHTS_INSTRUMENTATIONKEY, piiProperties } from '../constants';
import { useElectronContext } from '../utility/electronContext';
import { Path } from '../utility/path';

import { SettingsService } from './settings';

const buildEnvPath = Path.join(__dirname, '../../env.json');

function getBuildEnvironment() {
if (fs.existsSync(buildEnvPath)) {
return JSON.parse(fs.readFileSync(buildEnvPath, 'utf-8'));
}

return {};
}

const instrumentationKey = APPINSIGHTS_INSTRUMENTATIONKEY || getBuildEnvironment()?.APPINSIGHTS_INSTRUMENTATIONKEY;

let client;
if (APPINSIGHTS_INSTRUMENTATIONKEY) {
AppInsights.setup(APPINSIGHTS_INSTRUMENTATIONKEY)
if (instrumentationKey) {
AppInsights.setup(instrumentationKey)
// turn off extra instrumentation
.setAutoCollectConsole(false)
.setAutoCollectDependencies(false)
Expand Down

0 comments on commit 992d28d

Please sign in to comment.