Skip to content

Commit

Permalink
analytic os and screen size
Browse files Browse the repository at this point in the history
  • Loading branch information
jwallet committed Apr 30, 2020
1 parent 9ae1b8c commit 9177d55
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 19 deletions.
1 change: 0 additions & 1 deletion EspionSpotify.sln
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29609.76
Expand Down
19 changes: 14 additions & 5 deletions EspionSpotify/Analytics.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using PCLWebUtility;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Net.Http;
Expand All @@ -15,18 +16,25 @@ public class Analytics
private readonly string cid;
private readonly string cm;
private readonly string ul;
private readonly string ua;
private readonly string cs;
private readonly string sr;

public DateTime LastRequest { get; set; } = new DateTime();
public string LastAction { get; set; } = string.Empty;

public Analytics(string clientId, string version)
{
var osVersion = Environment.OSVersion.Version;
var osArchitecture = Environment.Is64BitOperatingSystem ? $"Win64; x64;" : $"x86";
var screenBounderies = System.Windows.Forms.Screen.PrimaryScreen.Bounds;
var osPlatform = $"Windows NT { Environment.OSVersion.Version.Major}.{Environment.OSVersion.Version.Minor}";

cid = clientId;
cm = version;
cs = $"Windows NT {osVersion.Major}.{osVersion.Minor}";
cs = Environment.OSVersion.ToString();
ul = CultureInfo.CurrentCulture.Name;
ua = WebUtility.UrlEncode($"Mozilla/5.0 ({osPlatform}; {osArchitecture}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36");
sr = $"{screenBounderies.Width}x{screenBounderies.Height}";
}

public static string GenerateCID()
Expand All @@ -48,9 +56,10 @@ public async Task<bool> LogAction(string action)
{ "av", cm }, // App version
{ "cn", "Spytify" }, // Campaign name
{ "an", "Spytify" }, // App name
{ "cs", cs}, // Campaign source, OS Version
{ "cs", WebUtility.UrlEncode(cs)}, // Campaign source, OS Version
{ "ul", ul }, // User Language
{ "ua", "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"}, // user-agent overwrite
{ "sr", sr }, // Screen resolution
{ "ua", ua }, // User-Agent overwrite
{ "dh", "jwallet.github.io/spy-spotify" }, // Document host
{ "dl", $"/{action}" }, // Document link
{ "dt", action }, // Document title
Expand Down
3 changes: 3 additions & 0 deletions EspionSpotify/EspionSpotify.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@
<TargetZone>LocalIntranet</TargetZone>
</PropertyGroup>
<PropertyGroup />
<PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="Accessibility" />
<Reference Include="DotNetZip, Version=1.11.0.0, Culture=neutral, PublicKeyToken=6583c7c814667745, processorArchitecture=MSIL">
Expand Down
4 changes: 2 additions & 2 deletions EspionSpotify/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions EspionSpotify/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,10 @@
</Setting>
<Setting Name="SpotifyAPISecretId" Type="System.String" Scope="User">
<Value Profile="(Default)">
ced9c679a66641f484e6740fff479e14
</Value>
</Setting>
<Setting Name="SpotifyAPIClientId" Type="System.String" Scope="User">
<Value Profile="(Default)">
412ea2302d86443e854740ba35e869cb
</Value>
</Setting>
</Settings>
Expand Down
15 changes: 6 additions & 9 deletions EspionSpotify/Properties/app.manifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
Expand All @@ -18,17 +18,11 @@
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
<applicationRequestMinimum>
<PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
<defaultAssemblyRequest permissionSetReference="Custom" />
</applicationRequestMinimum>
</security>
</trustInfo>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on and is
is designed to work with. Uncomment the appropriate elements and Windows will
automatically selected the most compatible environment. -->
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />
<!-- Windows 7 -->
Expand All @@ -41,6 +35,7 @@
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>

<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
Expand All @@ -52,6 +47,7 @@
</windowsSettings>
</application>
-->

<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<!--
<dependency>
Expand All @@ -67,4 +63,5 @@
</dependentAssembly>
</dependency>
-->
</assembly>

</assembly>

0 comments on commit 9177d55

Please sign in to comment.