Skip to content

Commit 808d4dd

Browse files
committed
Merge branch 'master' into hond/plus-operator
2 parents 3ba5cd4 + 94edbde commit 808d4dd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

libraries/botbuilder-applicationinsights/src/applicationInsightsTelemetryClient.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import * as appInsights from 'applicationinsights';
99
import { Activity, BotTelemetryClient, TelemetryDependency, TelemetryEvent, TelemetryException, TelemetryTrace } from 'botbuilder-core';
1010
import * as cls from 'cls-hooked';
11+
import * as crypto from 'crypto';
1112
const ns: any = cls.createNamespace('my.request');
1213

1314
// This is the currently recommended work-around for using Application Insights with async/await
@@ -132,16 +133,19 @@ function addBotIdentifiers(envelope: appInsights.Contracts.Envelope, context: {
132133
const userId: string = activity.from ? activity.from.id : '';
133134
const channelId: string = activity.channelId || '';
134135
const conversationId: string = activity.conversation ? activity.conversation.id : '';
136+
// Hashed ID is used due to max session ID length for App Insights session Id
137+
const sessionId: string = conversationId ? crypto.createHash('sha256').update(conversationId).digest('base64') : '';
135138

136139
// set user id and session id
137140
envelope.tags[appInsights.defaultClient.context.keys.userId] = channelId + userId;
138-
envelope.tags[appInsights.defaultClient.context.keys.sessionId] = conversationId;
141+
envelope.tags[appInsights.defaultClient.context.keys.sessionId] = sessionId;
139142

140143
// Add additional properties
141144
telemetryItem.properties = telemetryItem.properties || {};
142145
telemetryItem.properties.activityId = activity.id;
143146
telemetryItem.properties.channelId = channelId;
144147
telemetryItem.properties.activityType = activity.type;
148+
telemetryItem.properties.conversationId = conversationId;
145149
}
146150

147151
return true;

0 commit comments

Comments
 (0)