<commit_before>﻿using GoogleAnalyticsTracker.Core;
using GoogleAnalyticsTracker.Core.TrackerParameters;
using GoogleAnalyticsTracker.Simple;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace FTAnalyzer.Utilities
{
    public static class SpecialMethods
    {
        public static IEnumerable<Control> GetAllControls(Control aControl)
        {
            Stack<Control> stack = new Stack<Control>();
            stack.Push(aControl);
            while (stack.Any())
            {
                var nextControl = stack.Pop();
                foreach (Control childControl in nextControl.Controls)
                    stack.Push(childControl);
                yield return nextControl;
            }
        }

        public static void SetFonts(Form form)
        {
            foreach (Control theControl in GetAllControls(form))
                if (theControl.Font.Name.Equals(Properties.FontSettings.Default.SelectedFont.Name))
                    theControl.Font = Properties.FontSettings.Default.SelectedFont;
        }

        public static async Task<TrackingResult> TrackEventAsync(this SimpleTracker tracker, string category, string action, string label, long value = 1)
        {
            var eventTrackingParameters = new EventTracking
            {
                ClientId = Properties.Settings.Default.GUID.ToString(),
                UserId = Properties.Settings.Default.GUID.ToString(),
                
                ApplicationName = "FTAnalyzer",
                ApplicationVersion = MainForm.VERSION,
                Category = category,
                Action = action,
                Label = label,
                Value = value,
                ScreenName = category,
                ScreenResolution = Screen.PrimaryScreen.Bounds.ToString(),
                CacheBuster = tracker.AnalyticsSession.GenerateCacheBuster(),
                CustomDimension1 = Analytics.DeploymentType,
                CustomDimension2 = Analytics.OSVersion,
                GoogleAdWordsId = "201-455-7333"
            };
            return await tracker.TrackAsync(eventTrackingParameters);
        }

        public static async Task<TrackingResult> TrackScreenviewAsync(this SimpleTracker tracker, string screen)
        {
            var screenViewTrackingParameters = new ScreenviewTracking
            {
                ClientId = Properties.Settings.Default.GUID.ToString(),
                UserId = Properties.Settings.Default.GUID.ToString(),

                ApplicationName = "FTAnalyzer",
                ApplicationVersion = Analytics.AppVersion,
                ScreenName = screen,
                ScreenResolution = Screen.PrimaryScreen.Bounds.ToString(),
                CacheBuster = tracker.AnalyticsSession.GenerateCacheBuster(),
                CustomDimension1 = Analytics.DeploymentType,
                CustomDimension2 = Analytics.OSVersion,
                GoogleAdWordsId = "201-455-7333"
            };
            Console.WriteLine(Properties.Settings.Default.GUID.ToString());
            return await tracker.TrackAsync(screenViewTrackingParameters);
        }
    }
}<commit_msg>add user language to analytics<commit_after>﻿using GoogleAnalyticsTracker.Core;
using GoogleAnalyticsTracker.Core.TrackerParameters;
using GoogleAnalyticsTracker.Simple;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace FTAnalyzer.Utilities
{
    public static class SpecialMethods
    {
        public static IEnumerable<Control> GetAllControls(Control aControl)
        {
            Stack<Control> stack = new Stack<Control>();
            stack.Push(aControl);
            while (stack.Any())
            {
                var nextControl = stack.Pop();
                foreach (Control childControl in nextControl.Controls)
                    stack.Push(childControl);
                yield return nextControl;
            }
        }

        public static void SetFonts(Form form)
        {
            foreach (Control theControl in GetAllControls(form))
                if (theControl.Font.Name.Equals(Properties.FontSettings.Default.SelectedFont.Name))
                    theControl.Font = Properties.FontSettings.Default.SelectedFont;
        }

        public static async Task<TrackingResult> TrackEventAsync(this SimpleTracker tracker, string category, string action, string label, long value = 1)
        {
            string resolution = Screen.PrimaryScreen.Bounds.ToString();
            var eventTrackingParameters = new EventTracking
            {
                ClientId = Properties.Settings.Default.GUID.ToString(),
                UserId = Properties.Settings.Default.GUID.ToString(),

                ApplicationName = "FTAnalyzer",
                ApplicationVersion = Analytics.AppVersion,
                Category = category,
                Action = action,
                Label = label,
                Value = value,
                ScreenName = category,
                ScreenResolution = resolution.Length > 11 ? resolution.Substring(9, resolution.Length - 10) : resolution,
                CacheBuster = tracker.AnalyticsSession.GenerateCacheBuster(),
                CustomDimension1 = Analytics.DeploymentType,
                CustomDimension2 = Analytics.OSVersion,
                GoogleAdWordsId = "201-455-7333",
                UserLanguage = CultureInfo.CurrentUICulture.EnglishName
            };
            return await tracker.TrackAsync(eventTrackingParameters);
        }

        public static async Task<TrackingResult> TrackScreenviewAsync(this SimpleTracker tracker, string screen)
        {
            string resolution = Screen.PrimaryScreen.Bounds.ToString();
            var screenViewTrackingParameters = new ScreenviewTracking
            {
                ClientId = Properties.Settings.Default.GUID.ToString(),
                UserId = Properties.Settings.Default.GUID.ToString(),

                ApplicationName = "FTAnalyzer",
                ApplicationVersion = Analytics.AppVersion,
                ScreenName = screen,
                ScreenResolution = resolution.Length > 11 ? resolution.Substring(9, resolution.Length - 10) : resolution,
                CacheBuster = tracker.AnalyticsSession.GenerateCacheBuster(),
                CustomDimension1 = Analytics.DeploymentType,
                CustomDimension2 = Analytics.OSVersion,
                GoogleAdWordsId = "201-455-7333",
                UserLanguage = CultureInfo.CurrentUICulture.EnglishName
            };
            return await tracker.TrackAsync(screenViewTrackingParameters);
        }
    }
}
{'fraction_non_alphanumeric': 0.0748188673665533, 'fraction_numerical': 0.008871802454532013, 'mean_word_length': 2.0717529518619435, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1543673', 'n_tokens_mistral': 1618, 'n_tokens_neox': 1501, 'n_words': 321}