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

Pavolum/add pii logging flag #3475

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ order: 3

## Additional Telemetry

By default, a Virtual Assistant or Skill template based project doesn't collect personally identifiable information (e.g. Conversation drill-down and transcripts) which will lead to the respective sections in the PowerBI dashboard to not show information. If you wish to collect this information make the following change to `Startup.cs`
By default, a Virtual Assistant or Skill template based project collects personally identifiable information (e.g. Conversation drill-down and transcripts) which will lead to the respective sections in the PowerBI dashboard to function as expected. If you wish to not collect this information make the following change to `appsettings.json`

Change this entry:

```csharp
services.AddSingleton<TelemetryLoggerMiddleware>();
"logPersonalInfo": true
```

To the following:

```csharp
services.AddSingleton<TelemetryLoggerMiddleware>(s=>new TelemetryLoggerMiddleware(s.GetService<IBotTelemetryClient>(), true));
"logPersonalInfo": false
```
6 changes: 3 additions & 3 deletions docs/_docs/virtual-assistant/handbook/feedback.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ This implementation allows for feedback to be collected when a child dialog of m
1) If you are using an older VA template it may contain references to `FeedbackMiddleware`. Check your bot adapter class (default adapter being `defaultadapter.cs`) and remove any reference to FeedbackMiddleware in your bot adapter.
1) To start collecting user feedback, add the feedback directory found in the **VirtualAssistantSample** project within the Enterprise Assistant sample to your VA. This will have all the utility and helper functions you will need.
1) Add feedback options to startup.cs
```csharp
services.AddSingleton(new FeedbackOptions());
```
```csharp
services.AddSingleton(new FeedbackOptions());
```

FeedbackOptions consists of the following. You can alter any of the properties when you declare your options in startup.cs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class MainDialog : ComponentDialog

private readonly LocaleTemplateManager _templateManager;
private readonly BotServices _services;
private readonly BotSettings _settings;
private readonly OnboardingDialog _onboardingDialog;
private readonly SwitchSkillDialog _switchSkillDialog;
private readonly SkillsConfiguration _skillsConfig;
Expand All @@ -44,6 +45,7 @@ public class MainDialog : ComponentDialog
IServiceProvider serviceProvider)
: base(nameof(MainDialog))
{
_settings = serviceProvider.GetService<BotSettings>();
_services = serviceProvider.GetService<BotServices>();
_templateManager = serviceProvider.GetService<LocaleTemplateManager>();
_skillsConfig = serviceProvider.GetService<SkillsConfiguration>();
Expand Down Expand Up @@ -189,7 +191,8 @@ protected virtual QnAMakerDialog TryCreateQnADialog(string knowledgebaseId, Cogn
activeLearningCardTitle: _templateManager.GenerateActivityForLocale("QnaMakerAdaptiveLearningCardTitle").Text,
cardNoMatchText: _templateManager.GenerateActivityForLocale("QnaMakerNoMatchText").Text)
{
Id = knowledgebaseId
Id = knowledgebaseId,
LogPersonalInformation = _settings.LogPersonalData
};
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public BotServices(BotSettings settings, IBotTelemetryClient client)
luisOptions = new LuisRecognizerOptionsV3(dispatchApp)
{
TelemetryClient = telemetryClient,
LogPersonalInformation = true,
LogPersonalInformation = settings.LogPersonalData,
};
set.DispatchService = new LuisRecognizer(luisOptions);
}
Expand All @@ -49,7 +49,7 @@ public BotServices(BotSettings settings, IBotTelemetryClient client)
luisOptions = new LuisRecognizerOptionsV3(luisApp)
{
TelemetryClient = telemetryClient,
LogPersonalInformation = true,
LogPersonalInformation = settings.LogPersonalData,
};
set.LuisServices.Add(model.Id, new LuisRecognizer(luisOptions));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ namespace VirtualAssistantSample.Services
public class BotSettings : BotSettingsBase
{
public TokenExchangeConfig TokenExchangeConfig { get; set; }
public bool LogPersonalData { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ public void ConfigureServices(IServiceCollection services)
services.AddSingleton(Configuration);

// Load settings
var settings = new BotSettings();
var settings = new BotSettings()
{
LogPersonalData = Configuration.GetSection("logPersonalInfo")?.Value.ToLower() == "true"
};
Configuration.Bind(settings);
services.AddSingleton(settings);

Expand All @@ -81,7 +84,8 @@ public void ConfigureServices(IServiceCollection services)
services.AddSingleton<ITelemetryInitializer, OperationCorrelationTelemetryInitializer>();
services.AddSingleton<ITelemetryInitializer, TelemetryBotIdInitializer>();
services.AddSingleton<TelemetryInitializerMiddleware>();
services.AddSingleton<TelemetryLoggerMiddleware>();

services.AddSingleton<TelemetryLoggerMiddleware>(s => new TelemetryLoggerMiddleware(s.GetService<IBotTelemetryClient>(), settings.LogPersonalData));

// Configure bot services
services.AddSingleton<BotServices>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
},
"contentModerator": {
"key": ""
}
},
"logPersonalInfo": true
pavolum marked this conversation as resolved.
Show resolved Hide resolved
}
4 changes: 2 additions & 2 deletions samples/csharp/skill/SkillSample/Services/BotServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public BotServices(BotSettings settings, IBotTelemetryClient client)
luisOptions = new LuisRecognizerOptionsV3(dispatchApp)
{
TelemetryClient = telemetryClient,
LogPersonalInformation = true,
LogPersonalInformation = settings.LogPersonalData,
};
set.DispatchService = new LuisRecognizer(luisOptions);
}
Expand All @@ -49,7 +49,7 @@ public BotServices(BotSettings settings, IBotTelemetryClient client)
luisOptions = new LuisRecognizerOptionsV3(luisApp)
{
TelemetryClient = telemetryClient,
LogPersonalInformation = true,
LogPersonalInformation = settings.LogPersonalData,
};
set.LuisServices.Add(model.Id, new LuisRecognizer(luisOptions));
}
Expand Down
1 change: 1 addition & 0 deletions samples/csharp/skill/SkillSample/Services/BotSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ namespace SkillSample.Services
{
public class BotSettings : BotSettingsBase
{
public bool LogPersonalData { get; set; }
}
}
15 changes: 12 additions & 3 deletions samples/csharp/skill/SkillSample/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ public void ConfigureServices(IServiceCollection services)
});

// Load settings
var settings = new BotSettings();
var settings = new BotSettings()
{
LogPersonalData = Configuration.GetSection("logPersonalInfo")?.Value.ToLower() == "true"
};
Configuration.Bind(settings);
services.AddSingleton(settings);
services.AddSingleton<BotSettingsBase>(settings);
Expand All @@ -83,8 +86,14 @@ public void ConfigureServices(IServiceCollection services)
services.AddSingleton<ITelemetryInitializer, OperationCorrelationTelemetryInitializer>();
services.AddSingleton<ITelemetryInitializer, TelemetryBotIdInitializer>();
services.AddSingleton<TelemetryInitializerMiddleware>();
services.AddSingleton<TelemetryLoggerMiddleware>();

if (settings.LogPersonalData)
{
services.AddSingleton<TelemetryLoggerMiddleware>(s => new TelemetryLoggerMiddleware(s.GetService<IBotTelemetryClient>(), true));
pavolum marked this conversation as resolved.
Show resolved Hide resolved
}
else
{
services.AddSingleton<TelemetryLoggerMiddleware>();
}
// Configure bot services
services.AddSingleton<BotServices>();

Expand Down
3 changes: 2 additions & 1 deletion samples/csharp/skill/SkillSample/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
"containerId": "botstate-collection",
"databaseId": "botstate-db"
},
"properties": {}
"properties": {},
"logPersonalInfo": true
pavolum marked this conversation as resolved.
Show resolved Hide resolved
}