How to use the applicationinsights.getClient function in applicationinsights

To help you get started, we’ve selected a few applicationinsights examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / botbuilder-instrumentation / src / index.js View on Github external
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 {
github microsoft / vscode / build / lib / stats.js View on Github external
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(); });
    });
}
github nzthiago / BotInsightsTests / Node / bot.js View on Github external
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;
github CatalystCode / project-fortis / project-fortis-services / src / clients / appinsights / AppInsightsClient.js View on Github external
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);
  }
}
github OfficeDev / office-addin-validator / src / util.ts View on Github external
/*
 * 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());
github anastasiia-zolochevska / signaling-server / server.js View on Github external
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);
}
github formulahendry / vscode-azure-iot-toolkit / src / appInsightsClient.ts View on Github external
constructor() {
        console.log(`AI: constructor`)
        this._client = appInsights.getClient('6ada6440-d926-4331-b914-d8f1ea3b012f');
        let config = Utility.getConfiguration();
        this._enableAppInsights = config.get('enableAppInsights');
    }
github openT2T / opent2t / node / lib / AppInsightsTrackerTransport.ts View on Github external
constructor(key: string) {
        this.client = applicationinsights.getClient(key);
        let sessionKey = this.client.context.keys.sessionId;
        this.client.context.tags[sessionKey] = uuidv4();
    }
github Azure / botbuilder-instrumentation / dist / main.js View on Github external
_.forEach(this.instrumentationKeys, (iKey) => {
                let client = ApplicationInsights.getClient(iKey);
                self.appInsightsClients.push(client);
            });
        }