Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.

Commit 7097d58

Browse files
authored
update to node telemetry bot (#18)
1 parent b6d3ac5 commit 7097d58

File tree

2 files changed

+6
-3
lines changed
  • documentation-samples/tutorial-web-app-bot-application-insights/v4/luis-nodejs-bot-johnsmith-src-telemetry

2 files changed

+6
-3
lines changed

documentation-samples/tutorial-web-app-bot-application-insights/v4/luis-nodejs-bot-johnsmith-src-telemetry/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ LuisAPIKey=<LUIS-query-prediction-endpoint-key>
33
LuisAppId=<LUIS-app-ID>
44
MicrosoftAppId=<web-app-bot-ID>
55
MicrosoftAppPassword=<web-app-bot-password>
6+
MicrosoftApplicationInsightsInstrumentationKey=<app-insights-instrumentation-key>
67
ScmType=None

documentation-samples/tutorial-web-app-bot-application-insights/v4/luis-nodejs-bot-johnsmith-src-telemetry/appInsightsLog.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
const appInsights = require('applicationinsights');
22
const _ = require("underscore");
3-
appInsights.setup("<appInsightsInstrumentationKeyValue>").start();
4-
const appInsightsClient = appInsights.defaultClient;
3+
54

65
// Log LUIS results to Application Insights
76
// must flatten as name/value pairs
87
var appInsightsLog = (botContext,luisResponse) => {
98

9+
appInsights.setup(process.env.MicrosoftApplicationInsightsInstrumentationKey).start();
10+
const appInsightsClient = appInsights.defaultClient;
11+
1012
// put bot context and LUIS results into single object
1113
var data = Object.assign({}, {'botContext': botContext._activity}, {'luisResponse': luisResponse});
1214

@@ -29,7 +31,7 @@ var appInsightsLog = (botContext,luisResponse) => {
2931
console.log(JSON.stringify(flattenedData));
3032

3133
// send data to Application Insights
32-
appInsightsClient.trackEvent({name: "LUIS-results", properties: flattenedData});
34+
appInsightsClient.trackTrace({message: "LUIS", severity: appInsights.Contracts.SeverityLevel.Information, properties: flattenedData});
3335
}
3436

3537
module.exports.appInsightsLog = appInsightsLog;

0 commit comments

Comments
 (0)