Skip to content
This repository was archived by the owner on Jun 30, 2022. It is now read-only.

Commit 5e41052

Browse files
lauren-millsdarrenj
authored andcommitted
[VA] Implemented SDK telemetry fix for websocket connection (#2490)
* updated to latest preview packages * implemented telemetry fix * fixed broken tests
1 parent fb804f9 commit 5e41052

File tree

9 files changed

+45
-53
lines changed

9 files changed

+45
-53
lines changed

templates/Virtual-Assistant-Template/csharp/Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<RestoreAdditionalProjectSources>
1212
https://botbuilder.myget.org/F/aitemplates/api/v3/index.json;
1313
https://botbuilder.myget.org/F/botbuilder-declarative/api/v3/index.json;
14+
https://botbuilder.myget.org/F/botbuilder-v4-dotnet-daily/api/v3/index.json;
1415
</RestoreAdditionalProjectSources>
1516
</PropertyGroup>
1617

templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample.Tests/BotTestBase.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ public virtual void Initialize()
7979
Services.AddSingleton(ActivityGenerator);
8080
Services.AddTransient<MainDialog>();
8181
Services.AddTransient<OnboardingDialog>();
82-
Services.AddTransient<QnAMakerDialog>();
8382
Services.AddTransient<List<SkillDialog>>();
8483
Services.AddSingleton<TestAdapter, DefaultTestAdapter>();
8584
Services.AddTransient<IBot, DefaultActivityHandler<MainDialog>>();

templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample.Tests/VirtualAssistantSample.Tests.csproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@
66
<NoWarn>NU1701</NoWarn>
77
</PropertyGroup>
88

9+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
10+
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
11+
<WarningsAsErrors />
12+
</PropertyGroup>
13+
914
<ItemGroup>
1015
<PackageReference Include="Microsoft.AspNetCore.All" />
1116
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.2" />
12-
<PackageReference Include="Microsoft.Bot.Builder" Version="4.6.0-Daily-2019-09-25-01" />
17+
<PackageReference Include="Microsoft.Bot.Builder" Version="4.6.0-preview-191005-1" />
1318
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.2.0" />
1419
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
1520
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />

templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Adapters/DefaultAdapter.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using Microsoft.Bot.Builder;
55
using Microsoft.Bot.Builder.Azure;
6+
using Microsoft.Bot.Builder.Integration.ApplicationInsights.Core;
67
using Microsoft.Bot.Builder.Integration.AspNet.Core;
78
using Microsoft.Bot.Builder.LanguageGeneration;
89
using Microsoft.Bot.Builder.Solutions.Feedback;
@@ -20,6 +21,7 @@ public DefaultAdapter(
2021
TemplateEngine templateEngine,
2122
ConversationState conversationState,
2223
ICredentialProvider credentialProvider,
24+
TelemetryInitializerMiddleware telemetryMiddleware,
2325
IBotTelemetryClient telemetryClient)
2426
: base(credentialProvider)
2527
{
@@ -31,10 +33,11 @@ public DefaultAdapter(
3133
telemetryClient.TrackException(exception);
3234
};
3335

36+
Use(telemetryMiddleware);
37+
3438
// Uncomment the following line for local development without Azure Storage
3539
// Use(new TranscriptLoggerMiddleware(new MemoryTranscriptStore()));
3640
Use(new TranscriptLoggerMiddleware(new AzureBlobTranscriptStore(settings.BlobStorage.ConnectionString, settings.BlobStorage.Container)));
37-
Use(new TelemetryLoggerMiddleware(telemetryClient, logPersonalInformation: true));
3841
Use(new ShowTypingMiddleware());
3942
Use(new FeedbackMiddleware(conversationState, telemetryClient));
4043
Use(new SetLocaleMiddleware(settings.DefaultLocale ?? "en-us"));

templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Adapters/DefaultWebSocketAdapter.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using Microsoft.Bot.Builder;
55
using Microsoft.Bot.Builder.Azure;
6+
using Microsoft.Bot.Builder.Integration.ApplicationInsights.Core;
67
using Microsoft.Bot.Builder.LanguageGeneration;
78
using Microsoft.Bot.Builder.Solutions.Middleware;
89
using Microsoft.Bot.Builder.StreamingExtensions;
@@ -20,6 +21,7 @@ public DefaultWebSocketAdapter(
2021
BotSettings settings,
2122
TemplateEngine templateEngine,
2223
ICredentialProvider credentialProvider,
24+
TelemetryInitializerMiddleware telemetryMiddleware,
2325
IBotTelemetryClient telemetryClient)
2426
: base(config, credentialProvider)
2527
{
@@ -31,10 +33,11 @@ public DefaultWebSocketAdapter(
3133
telemetryClient.TrackException(exception);
3234
};
3335

36+
Use(telemetryMiddleware);
37+
3438
// Uncomment the following line for local development without Azure Storage
3539
// Use(new TranscriptLoggerMiddleware(new MemoryTranscriptStore()));
3640
Use(new TranscriptLoggerMiddleware(new AzureBlobTranscriptStore(settings.BlobStorage.ConnectionString, settings.BlobStorage.Container)));
37-
Use(new TelemetryLoggerMiddleware(telemetryClient, logPersonalInformation: true));
3841
Use(new ShowTypingMiddleware());
3942
Use(new SetLocaleMiddleware(settings.DefaultLocale ?? "en-us"));
4043
Use(new EventDebuggerMiddleware());

templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Bots/DefaultActivityHandler.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using Microsoft.Bot.Builder.Dialogs;
77
using Microsoft.Bot.Schema;
88
using Microsoft.Extensions.DependencyInjection;
9-
using VirtualAssistantSample.Extensions;
109

1110
namespace VirtualAssistantSample.Bots
1211
{

templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Extensions/DialogExtensions.cs

Lines changed: 0 additions & 26 deletions
This file was deleted.

templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/Startup.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System;
55
using System.IO;
66
using System.Linq;
7-
using Microsoft.ApplicationInsights;
7+
using Microsoft.ApplicationInsights.Extensibility;
88
using Microsoft.AspNetCore.Builder;
99
using Microsoft.AspNetCore.Hosting;
1010
using Microsoft.AspNetCore.Mvc;
@@ -56,8 +56,6 @@ public void ConfigureServices(IServiceCollection services)
5656
{
5757
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
5858

59-
var provider = services.BuildServiceProvider();
60-
6159
// Load settings
6260
var settings = new BotSettings();
6361
Configuration.Bind(settings);
@@ -70,9 +68,11 @@ public void ConfigureServices(IServiceCollection services)
7068

7169
// Configure telemetry
7270
services.AddApplicationInsightsTelemetry();
73-
var telemetryClient = new BotTelemetryClient(new TelemetryClient());
74-
services.AddSingleton<IBotTelemetryClient>(telemetryClient);
75-
services.AddBotApplicationInsights(telemetryClient);
71+
services.AddSingleton<IBotTelemetryClient, BotTelemetryClient>();
72+
services.AddSingleton<ITelemetryInitializer, OperationCorrelationTelemetryInitializer>();
73+
services.AddSingleton<ITelemetryInitializer, TelemetryBotIdInitializer>();
74+
services.AddSingleton<TelemetryInitializerMiddleware>();
75+
services.AddSingleton<TelemetryLoggerMiddleware>();
7676

7777
// Configure bot services
7878
services.AddSingleton<BotServices>();
@@ -95,9 +95,12 @@ public void ConfigureServices(IServiceCollection services)
9595
services.AddTransient<MainDialog>();
9696
services.AddTransient<OnboardingDialog>();
9797

98+
// Register skill dialogs
99+
var provider = services.BuildServiceProvider();
98100
foreach (var skill in settings.Skills)
99101
{
100102
var userState = provider.GetService<UserState>();
103+
var telemetryClient = provider.GetService<IBotTelemetryClient>();
101104
var authDialog = BuildAuthDialog(skill, settings, appCredentials);
102105
var credentials = new MicrosoftAppCredentialsEx(settings.MicrosoftAppId, settings.MicrosoftAppPassword, skill.MSAappId);
103106
services.AddTransient(sp => new SkillDialog(skill, credentials, telemetryClient, userState, authDialog));
@@ -125,8 +128,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
125128
app.UseDeveloperExceptionPage();
126129
}
127130

128-
app.UseBotApplicationInsights()
129-
.UseDefaultFiles()
131+
app.UseDefaultFiles()
130132
.UseStaticFiles()
131133
.UseWebSockets()
132134
.UseMvc();

templates/Virtual-Assistant-Template/csharp/Sample/VirtualAssistantSample/VirtualAssistantSample.csproj

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
<NoWarn>NU1701</NoWarn>
66
</PropertyGroup>
77

8+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
9+
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
10+
<WarningsAsErrors />
11+
</PropertyGroup>
12+
813
<ItemGroup>
914
<PackageReference Include="AdaptiveCards" Version="1.2.0" />
1015
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.10.0" />
@@ -14,22 +19,23 @@
1419
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.2" />
1520
<PackageReference Include="Microsoft.Azure.CognitiveServices.ContentModerator" Version="2.0.0" />
1621
<PackageReference Include="Microsoft.Azure.CognitiveServices.Language" Version="1.0.1-preview" />
17-
<PackageReference Include="Microsoft.Bot.Builder" Version="4.6.0-Daily-2019-09-25-01" />
18-
<PackageReference Include="Microsoft.Bot.Builder.AI.Luis" Version="4.6.0-Daily-2019-09-25-01" />
19-
<PackageReference Include="Microsoft.Bot.Builder.AI.QnA" Version="4.6.0-Daily-2019-09-25-01" />
20-
<PackageReference Include="Microsoft.Bot.Builder.ApplicationInsights" Version="4.6.0-Daily-2019-09-25-01" />
21-
<PackageReference Include="Microsoft.Bot.Builder.Azure" Version="4.6.0-Daily-2019-09-25-01" />
22-
<PackageReference Include="Microsoft.Bot.Builder.Dialogs" Version="4.6.0-Daily-2019-09-25-01" />
23-
<PackageReference Include="Microsoft.Bot.Builder.Integration.ApplicationInsights.Core" Version="4.6.0-Daily-2019-09-25-01" />
24-
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.6.0-Daily-2019-09-25-01" />
22+
<PackageReference Include="Microsoft.Bot.Builder" Version="4.6.0-preview-191005-1" />
23+
<PackageReference Include="Microsoft.Bot.Builder.AI.Luis" Version="4.6.0-preview-191005-1" />
24+
<PackageReference Include="Microsoft.Bot.Builder.AI.QnA" Version="4.6.0-preview-191005-1" />
25+
<PackageReference Include="Microsoft.Bot.Builder.ApplicationInsights" Version="4.6.0-preview-191005-1" />
26+
<PackageReference Include="Microsoft.Bot.Builder.Azure" Version="4.6.0-preview-191005-1" />
27+
<PackageReference Include="Microsoft.Bot.Builder.Dialogs" Version="4.6.0-preview-191005-1" />
28+
<PackageReference Include="Microsoft.Bot.Builder.Integration.ApplicationInsights.Core" Version="4.6.0-preview-191005-1" />
29+
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.6.0-preview-191005-1" />
2530
<PackageReference Include="Microsoft.Bot.Builder.LanguageGeneration" Version="4.6.0-Daily-2019-09-25-01" />
26-
<PackageReference Include="Microsoft.Bot.Builder.Skills" Version="4.6.0-daily59" />
27-
<PackageReference Include="Microsoft.Bot.Builder.Solutions" Version="4.6.0-daily59" />
31+
<PackageReference Include="Microsoft.Bot.Builder.LanguageGeneration.Templates" Version="4.6.0-Daily-2019-10-04-01" />
32+
<PackageReference Include="Microsoft.Bot.Builder.Skills" Version="4.6.0-daily62" />
33+
<PackageReference Include="Microsoft.Bot.Builder.Solutions" Version="4.6.0-daily62" />
2834
<PackageReference Include="Microsoft.Bot.Builder.StreamingExtensions" Version="4.6.0-Daily-2019-09-25-01" />
29-
<PackageReference Include="Microsoft.Bot.Builder.TemplateManager" Version="4.6.0-Daily-2019-09-25-01" />
30-
<PackageReference Include="Microsoft.Bot.Configuration" Version="4.6.0-Daily-2019-09-25-01" />
31-
<PackageReference Include="Microsoft.Bot.Connector" Version="4.6.0-Daily-2019-09-25-01" />
32-
<PackageReference Include="Microsoft.Bot.Schema" Version="4.6.0-Daily-2019-09-25-01" />
35+
<PackageReference Include="Microsoft.Bot.Builder.TemplateManager" Version="4.6.0-preview-191005-1" />
36+
<PackageReference Include="Microsoft.Bot.Configuration" Version="4.6.0-preview-191005-1" />
37+
<PackageReference Include="Microsoft.Bot.Connector" Version="4.6.0-preview-191005-1" />
38+
<PackageReference Include="Microsoft.Bot.Schema" Version="4.6.0-preview-191005-1" />
3339
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
3440
<PackageReference Include="Microsoft.Extensions.Options" Version="2.2.0" />
3541
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.0" />

0 commit comments

Comments
 (0)