Move InstrumentationKey to AppInsights config file
This commit is contained in:
Родитель
bbb57c4afd
Коммит
8515919a92
|
@ -26,6 +26,8 @@ bld/
|
|||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# VS Code
|
||||
.vscode/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
|
@ -221,7 +223,7 @@ ClientBin/
|
|||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
|
@ -317,7 +319,7 @@ __pycache__/
|
|||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
|
@ -326,5 +328,5 @@ ASALocalRun/
|
|||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings">
|
||||
<InstrumentationKey></InstrumentationKey>
|
||||
<TelemetryInitializers>
|
||||
<Add Type="Microsoft.ApplicationInsights.WindowsDesktop.DeviceTelemetryInitializer, AppInsights.WindowsDesktop"/>
|
||||
<Add Type="Microsoft.ApplicationInsights.WindowsDesktop.SessionTelemetryInitializer, AppInsights.WindowsDesktop"/>
|
||||
|
|
|
@ -14,23 +14,14 @@ namespace WpfCoreApp.Telemetry
|
|||
|
||||
public static void Initialize()
|
||||
{
|
||||
var apiKey = System.Configuration.ConfigurationManager.AppSettings["InstrumentationKey"];
|
||||
TelemetryConfiguration.Active.TelemetryChannel.DeveloperMode = Debugger.IsAttached;
|
||||
TelemetryConfiguration.Active.TelemetryInitializers.Add(new AppVersionTelemetryInitializer());
|
||||
TelemetryConfiguration.Active.TelemetryInitializers.Add(new EnvironmentTelemetryInitializer());
|
||||
|
||||
if (!string.IsNullOrEmpty(apiKey) && apiKey != "__AppInsightsKey__")
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(apiKey))
|
||||
{
|
||||
TelemetryConfiguration.Active.InstrumentationKey = apiKey;
|
||||
TelemetryConfiguration.Active.TelemetryChannel.DeveloperMode = Debugger.IsAttached;
|
||||
TelemetryConfiguration.Active.TelemetryInitializers.Add(new AppVersionTelemetryInitializer());
|
||||
TelemetryConfiguration.Active.TelemetryInitializers.Add(new EnvironmentTelemetryInitializer());
|
||||
|
||||
_initialized = true;
|
||||
_client = new TelemetryClient();
|
||||
System.Windows.Application.Current.Startup += Application_Startup;
|
||||
System.Windows.Application.Current.Exit += Application_Exit;
|
||||
}
|
||||
}
|
||||
_initialized = true;
|
||||
_client = new TelemetryClient();
|
||||
System.Windows.Application.Current.Startup += Application_Startup;
|
||||
System.Windows.Application.Current.Exit += Application_Exit;
|
||||
}
|
||||
|
||||
private static void Application_Exit(object sender, System.Windows.ExitEventArgs e)
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="InstrumentationKey" value="__AppInsightsKey__" />
|
||||
</appSettings>
|
||||
</configuration>
|
|
@ -77,9 +77,9 @@ jobs:
|
|||
|
||||
- powershell: |
|
||||
# Update App Insights instrumentation key
|
||||
[xml]$doc = Get-Content ".\WpfCoreApp\app.config"
|
||||
$doc.configuration.appSettings.add.value = "$(AppInsightsKey)"
|
||||
$doc.save(".\WpfCoreApp\app.config")
|
||||
[xml]$doc = Get-Content ".\WpfCoreApp\ApplicationInsights.config"
|
||||
$doc.ApplicationInsights.InstrumentationKey = "$(AppInsightsKey)"
|
||||
$doc.save(".\WpfCoreApp\ApplicationInsights.config")
|
||||
|
||||
displayName: Set AppInsights Config
|
||||
env:
|
||||
|
|
Загрузка…
Ссылка в новой задаче