Files
DefinitelyTyped/types/applicationinsights/applicationinsights-tests.ts
2017-03-24 14:27:52 -07:00

31 lines
1.1 KiB
TypeScript

import * as appInsights from "applicationinsights";
// basic use
appInsights.setup("<instrumentation_key>").start();
// basic use with auto-collection configuration
appInsights.setup("<instrumentation_key>")
.setAutoCollectRequests(false)
.setAutoCollectPerformance(false)
.setAutoCollectExceptions(false)
// no telemetry will be sent until .start() is called
// this prevents any of the auto-collectors from initializing
.enableVerboseLogging()
.start();
appInsights.client.trackEvent("custom event", {customProperty: "custom property value"});
appInsights.client.trackException(new Error("handled exceptions can be logged with this method"));
appInsights.client.trackMetric("custom metric", 3);
appInsights.client.trackTrace("trace message");
appInsights.client.trackDependency("dependency name", "commandName", 500, true);
// assign common properties to all telemetry
appInsights.client.commonProperties = {
environment: "dev"
};
// send any pending data and log the response
appInsights.client.sendPendingData(function (response) {
console.log(response);
});