Skip to content

Commit 9630ebd

Browse files
authored
Merge pull request #41 from sillsdev/add-device-ui-language
Added DeviceUILanguage application property in support of "Top 5 Devi…
2 parents 4c9bbdc + b42c993 commit 9630ebd

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

DesktopAnalytics.sln.DotSettings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
22
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=API/@EntryIndexedValue">API</s:String>
33
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IO/@EntryIndexedValue">IO</s:String>
4+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=UI/@EntryIndexedValue">UI</s:String>
45
<s:Boolean x:Key="/Default/UserDictionary/Words/=Analytics/@EntryIndexedValue">True</s:Boolean>
56
<s:Boolean x:Key="/Default/UserDictionary/Words/=Mixpanel/@EntryIndexedValue">True</s:Boolean>
67
<s:Boolean x:Key="/Default/UserDictionary/Words/=netapi/@EntryIndexedValue">True</s:Boolean>

src/DesktopAnalytics/Analytics.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,17 +220,25 @@ public Analytics(string apiSecret, UserInfo userInfo, Dictionary<string,
220220
ReportIpAddressOfThisMachineAsync(); //this will take a while and may fail, so just do it when/if we can
221221

222222
var assembly = assemblyToUseForVersion ?? Assembly.GetEntryAssembly();
223-
var versionNumberWithBuild = assembly.GetName().Version?.ToString() ?? "";
224-
string versionNumber = versionNumberWithBuild.Split('.').Take(2).Aggregate((a, b) => a + "." + b);
223+
var versionNumberWithBuild = assembly?.GetName().Version?.ToString() ?? "";
224+
var versionNumber = versionNumberWithBuild.Split('.').Take(2).Aggregate((a, b) => a + "." + b);
225225
SetApplicationProperty("Version", versionNumber);
226226
SetApplicationProperty("FullVersion", versionNumberWithBuild);
227227
SetApplicationProperty("UserName", GetUserNameForEvent());
228228
SetApplicationProperty("Browser", GetOperatingSystemLabel());
229229
SetApplicationProperty("OS Version Number", GetOperatingSystemVersionLabel());
230230
SetApplicationProperty("64bit OS", Environment.Is64BitOperatingSystem.ToString());
231231
SetApplicationProperty("64bit App", Environment.Is64BitProcess.ToString());
232-
233-
232+
// This (and "64bit OS" above) really belong in Context, but segment.io doesn't seem
233+
// to convey context to Mixpanel in a reliable/predictable form.
234+
var ci = CultureInfo.CurrentUICulture;
235+
const string invariantCulture = "iv";
236+
var installedUICulture = !IsNullOrEmpty(ci.TwoLetterISOLanguageName) &&
237+
ci.TwoLetterISOLanguageName != invariantCulture
238+
? ci.TwoLetterISOLanguageName
239+
: ci.ThreeLetterISOLanguageName;
240+
SetApplicationProperty("DeviceUILanguage", installedUICulture);
241+
234242
if (IsNullOrEmpty(AnalyticsSettings.Default.LastVersionLaunched))
235243
{
236244
//"Created" is a special property that segment.io understands and coverts to equivalents in various analytics services

src/SampleApp/Program.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ static int Main(string[] args)
1818

1919
if (!Enum.TryParse<ClientType>(args[1], true, out var clientType))
2020
{
21-
Console.WriteLine($"Usage: SampleApp <analyticsApiSecret> <Segment|Mixpanel|???>{Environment.NewLine}Unrecoginzed client type: {args[1]}");
21+
Console.WriteLine($"Usage: SampleApp <analyticsApiSecret> <Segment|Mixpanel|???>{Environment.NewLine}Unrecognized client type: {args[1]}");
2222
return 1;
2323
}
2424

@@ -29,7 +29,8 @@ static int Main(string[] args)
2929
3030
UILanguageCode= "fr"
3131
};
32-
userInfo.OtherProperties.Add("HowIUseIt","This is a really long explanation of how I use this product to see how much you would be able to extract from Mixpanel.\r\nAnd a second line of it.");
32+
userInfo.OtherProperties.Add("HowIUseIt",
33+
"This is a really long explanation of how I use this product to see how much you would be able to extract from Mixpanel.\r\nAnd a second line of it.");
3334

3435
var propsForEveryEvent = new Dictionary<string, string> {{"channel", "beta"}};
3536
using (new Analytics(args[0], userInfo, propertiesThatGoWithEveryEvent: propsForEveryEvent, clientType: clientType))

0 commit comments

Comments
 (0)