Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var monitor = (bot, options) => {
options = options || {};
if ((!options.instrumentationKey) &&
(!process.env.APPINSIGHTS_INSTRUMENTATIONKEY)){
throw new Error('App Insights instrumentation key was not provided in options or the environment variable APPINSIGHTS_INSTRUMENTATIONKEY');
}
appInsights.setup(options.instrumentationKey || process.env.APPINSIGHTS_INSTRUMENTATIONKEY).start();
client = appInsights.getClient(options.instrumentationKey || process.env.APPINSIGHTS_INSTRUMENTATIONKEY);
if (!options.sentimentKey && !process.env.CG_SENTIMENT_KEY) {
console.warn('No sentiment key was provided - text sentiments will not be collected');
} else {
_sentimentKey = options.sentimentKey || process.env.CG_SENTIMENT_KEY;
}
var transactions = options.transactions || [];
setup();
if (bot) {
// Adding middleware to intercept all received messages
bot.use({
botbuilder: function (session, next) {
try {
return new Promise(function (resolve) {
var sizes = {};
var counts = {};
for (var _i = 0, sorted_2 = sorted; _i < sorted_2.length; _i++) {
var entry = sorted_2[_i];
sizes[entry.name] = entry.totalSize;
counts[entry.name] = entry.totalCount;
}
appInsights.setup(productJson.aiConfig.asimovKey)
.setAutoCollectConsole(false)
.setAutoCollectExceptions(false)
.setAutoCollectPerformance(false)
.setAutoCollectRequests(false)
.start();
var client = appInsights.getClient(productJson.aiConfig.asimovKey);
client.config.endpointUrl = 'https://vortex.data.microsoft.com/collect/v1';
/* __GDPR__
"monacoworkbench/packagemetrics" : {
"commit" : {"classification": "SystemMetaData", "purpose": "PerformanceAndHealth" },
"size" : {"classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "isMeasurement": true },
"count" : {"classification": "SystemMetaData", "purpose": "PerformanceAndHealth", "isMeasurement": true }
}
*/
client.trackEvent("monacoworkbench/packagemetrics", { commit: commit, size: JSON.stringify(sizes), count: JSON.stringify(counts) });
client.sendPendingData(function () { return resolve(); });
});
}
function create(connector) {
appInsights.setup(process.env.APPINSIGHTS_INSTRUMENTATIONKEY).start();
var appInsightsClient = appInsights.getClient();
var HelpMessage = '\n * If you want to know which city I\'m using for my searches type \'current city\'. \n * Want to change the current city? Type \'change city to cityName\'. \n * Want to change it just for your searches? Type \'change my city to cityName\'';
var UserNameKey = 'UserName';
var UserWelcomedKey = 'UserWelcomed';
var CityKey = 'City';
// Setup bot with default dialog
var bot = new builder.UniversalBot(connector, function (session) {
var telemetry = telemetryModule.createTelemetry(session, { setDefault: false });
// initialize with default city
if (!session.conversationData[CityKey]) {
session.conversationData[CityKey] = 'Seattle';
telemetry.setDefault = true;
function setup() {
if (appinsightsInstrumentationkey) {
const appInsights = require('applicationinsights');
appInsights.setup(appinsightsInstrumentationkey);
appInsights.start();
client = appInsights.getClient(appinsightsInstrumentationkey);
console.log = trackTrace(TRACE_LEVEL_INFO, consoleLog);
console.warn = trackTrace(TRACE_LEVEL_WARNING, consoleWarn);
console.error = trackTrace(TRACE_LEVEL_ERROR, consoleError);
}
}
/*
* Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
* See LICENSE in the project root for license information.
*/
import * as fs from 'fs';
import * as request from 'request';
import * as rp from 'request-promise';
import * as chalk from 'chalk';
import * as appInsights from 'applicationinsights';
export const insight = appInsights.getClient('78cc7757-c7a2-4382-b801-bce73cf33d7a');
let baseUri = 'https://verificationservice.osi.office.net/ova/addincheckingagent.svc/api/addincheck';
let options = {
uri: baseUri,
method: 'POST',
headers: {
'Content-Type': 'application/xml'
},
resolveWithFullResponse: true
};
export async function validateManifest(manifest: string) : Promise {
try {
console.log('Calling validation service. This might take a moment...');
let response = await callOmexService(manifest, options);
if (response.statusCode === 200) {
let formattedBody = JSON.parse(response.body.trim());
function log(message) {
console.log(logCounter++ + " " + new Date().getHours() + ":" + new Date().getMinutes() + ":" + new Date().getSeconds() + " " + message);
appInsights.getClient().trackTrace(logCounter + " " + new Date().getHours() + ":" + new Date().getMinutes() + ":" + new Date().getSeconds() + " " + message);
}
constructor() {
console.log(`AI: constructor`)
this._client = appInsights.getClient('6ada6440-d926-4331-b914-d8f1ea3b012f');
let config = Utility.getConfiguration();
this._enableAppInsights = config.get('enableAppInsights');
}
constructor(key: string) {
this.client = applicationinsights.getClient(key);
let sessionKey = this.client.context.keys.sessionId;
this.client.context.tags[sessionKey] = uuidv4();
}
_.forEach(this.instrumentationKeys, (iKey) => {
let client = ApplicationInsights.getClient(iKey);
self.appInsightsClients.push(client);
});
}