Skip to content

Commit

Permalink
Added GameAnalytics
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanjon2040 committed Mar 6, 2021
1 parent e6ea9ab commit c8446ec
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 2 deletions.
4 changes: 2 additions & 2 deletions UE4 Network Profiler/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<hc:GlowWindow
<hc:GlowWindow x:Name="UnrealNetworkProfilerMainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:hc="https://handyorg.github.io/handycontrol"
x:Class="NetworkProfiler.MainWindow"
mc:Ignorable="d"
Title="Unreal Engine Network Profiler" Height="720" Width="1280">
Title="Unreal Engine Network Profiler" Height="720" Width="1280" Closing="UnrealNetworkProfilerMainWindow_Closing">
<hc:GlowWindow.NonClientAreaContent>
<StackPanel VerticalAlignment="Stretch" Orientation="Horizontal">
<Separator Width="10" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="10,0,0,0"/>
Expand Down
42 changes: 42 additions & 0 deletions UE4 Network Profiler/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
using Microsoft.Win32;
using System.Windows;
using ScottPlot.Plottable;
using GameAnalyticsSDK.Net;
using System.Reflection;

namespace NetworkProfiler
{
Expand Down Expand Up @@ -76,6 +78,11 @@ public enum SeriesType : int

public partial class MainWindow
{
// Please DO NOT change this. If you don't want Analytics, set both GAME_KEY and SECRET_KEY to null ///////////////////
private static readonly string GAME_KEY = "81ebb126baf40ca75b9ce26e2f3e7ad2"; // null
private static readonly string SECRET_KEY = "18f49fbf8da84dadaff7ca0ad76ab01f78771725"; // null
///////////////////////////////////////////////////////////////////////////////////////////////

/** Currently selected frame on chart */
//int CurrentFrame = 0;

Expand Down Expand Up @@ -104,6 +111,36 @@ public MainWindow()
SetDefaultLineView();
NetworkChart.Plot.Legend(true, ScottPlot.Alignment.UpperLeft);
DataContext = this;

if (GAME_KEY != null && SECRET_KEY != null)
{
GameAnalytics.ConfigureBuild($"Unreal Network Profiler v{GetProductVersionString()}");
GameAnalytics.Initialize(GAME_KEY, SECRET_KEY);

#if DEBUG
GameAnalytics.AddDesignEvent("Program:Start:Debug");
#else
GameAnalytics.AddDesignEvent("Program:Start:Release");
#endif
}
}

private static string GetProductVersionString()
{
Version ProductVersion = Assembly.GetEntryAssembly().GetName().Version;
string ReturnValue = $"{ProductVersion.Major}.{ProductVersion.Minor}";

if (ProductVersion.Build > 0)
{
ReturnValue += $".{ProductVersion.Build}";
}

if (ProductVersion.Revision > 0)
{
ReturnValue += $".{ProductVersion.Revision}";
}

return ReturnValue;
}

private void SetDefaultLineView()
Expand Down Expand Up @@ -529,6 +566,11 @@ private void MaxProfileMinutesTextBox_TextChanged(object sender, TextChangedEven
MaxProfileMinutesTextBox.Text = "";
}
}

private void UnrealNetworkProfilerMainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
GameAnalytics.EndSession();
}
}

public class FilterValues
Expand Down
18 changes: 18 additions & 0 deletions UE4 Network Profiler/UE4 Network Profiler.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -36,9 +38,15 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="GameAnalytics.Mono, Version=1.0.7702.25490, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\GameAnalytics.Mono.SDK.3.1.2\lib\net45\GameAnalytics.Mono.dll</HintPath>
</Reference>
<Reference Include="HandyControl, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\HandyControl.3.0.0\lib\net47\HandyControl.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.3.8\lib\net45\NLog.dll</HintPath>
</Reference>
<Reference Include="ScottPlot, Version=4.1.9.0, Culture=neutral, PublicKeyToken=86698dc10387c39e, processorArchitecture=MSIL">
<HintPath>..\packages\ScottPlot.4.1.9-beta\lib\net461\ScottPlot.dll</HintPath>
</Reference>
Expand All @@ -47,6 +55,9 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Data.SQLite, Version=1.0.102.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\packages\GameAnalytics.Mono.SDK.3.1.2\lib\net45\System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Drawing.Common, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Drawing.Common.6.0.0-preview.1.21102.12\lib\net461\System.Drawing.Common.dll</HintPath>
Expand Down Expand Up @@ -125,4 +136,11 @@
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\GameAnalytics.Mono.SDK.3.1.2\build\net45\GameAnalytics.Mono.SDK.targets" Condition="Exists('..\packages\GameAnalytics.Mono.SDK.3.1.2\build\net45\GameAnalytics.Mono.SDK.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\GameAnalytics.Mono.SDK.3.1.2\build\net45\GameAnalytics.Mono.SDK.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\GameAnalytics.Mono.SDK.3.1.2\build\net45\GameAnalytics.Mono.SDK.targets'))" />
</Target>
</Project>
2 changes: 2 additions & 0 deletions UE4 Network Profiler/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="GameAnalytics.Mono.SDK" version="3.1.2" targetFramework="net472" />
<package id="HandyControl" version="3.0.0" targetFramework="net472" />
<package id="NLog" version="4.3.8" targetFramework="net472" />
<package id="ScottPlot" version="4.1.9-beta" targetFramework="net472" />
<package id="ScottPlot.WPF" version="4.1.9-beta" targetFramework="net472" />
<package id="System.Drawing.Common" version="6.0.0-preview.1.21102.12" targetFramework="net472" />
Expand Down

0 comments on commit c8446ec

Please # to comment.