예제 #1
0
        static Tracker()
        {
            Version         = Assembly.GetEntryAssembly().GetName().Version;
            ExtraParameters = new Dictionary <string, string>();
            ExtraParameters[BeaconParameter.Browser.ScreenResolution] = String.Format(
                "{0}x{1}",
                System.Windows.SystemParameters.PrimaryScreenWidth,
                System.Windows.SystemParameters.PrimaryScreenHeight);
            ExtraParameters[BeaconParameter.Browser.ScreenColorDepth] = String.Format(
                "{0}-bit",
                Screen.PrimaryScreen.BitsPerPixel);

            var osPlatform      = Environment.OSVersion.Platform.ToString();
            var osVersion       = Environment.OSVersion.Version.ToString();
            var osVersionString = Environment.OSVersion.VersionString;

            UserAgent = String.Format("{0}/{1} ({2}; {3}; {4})", "HearthstoneTracker", Version, osPlatform, osVersion, osVersionString);
            instance  = new HsTracker("UA-46945463-6", "app.hearthstonetracker.com")
            {
                UseSsl        = false,
                UserAgent     = UserAgent,
                ThrowOnErrors = false,
                Language      = CultureInfo.InstalledUICulture.Name
            };

            using (var reg = new AnalyticsRegistrySettings())
            {
                // note: use field here
                isEnabled = reg.ShareUsageStatistics;
            }
        }
예제 #2
0
        static Tracker()
        {
            Version = Assembly.GetEntryAssembly().GetName().Version;
            ExtraParameters = new Dictionary<string, string>();
            ExtraParameters[BeaconParameter.Browser.ScreenResolution] = String.Format(
                    "{0}x{1}",
                    System.Windows.SystemParameters.PrimaryScreenWidth,
                    System.Windows.SystemParameters.PrimaryScreenHeight);
            ExtraParameters[BeaconParameter.Browser.ScreenColorDepth] = String.Format(
                    "{0}-bit",
                    Screen.PrimaryScreen.BitsPerPixel);

            var osPlatform = Environment.OSVersion.Platform.ToString();
            var osVersion = Environment.OSVersion.Version.ToString();
            var osVersionString = Environment.OSVersion.VersionString;
            UserAgent = String.Format("{0}/{1} ({2}; {3}; {4})", "HearthstoneTracker", Version, osPlatform, osVersion, osVersionString);
            instance = new HsTracker("UA-46945463-6", "app.hearthstonetracker.com")
            {
                UseSsl = false,
                UserAgent = UserAgent,
                ThrowOnErrors = false,
                Language = CultureInfo.InstalledUICulture.Name
            };

            using (var reg = new AnalyticsRegistrySettings())
            {
                // note: use field here
                isEnabled = reg.ShareUsageStatistics;
            }
        }
 private void LoadSettings()
 {
     using (var reg = new AnalyticsRegistrySettings())
     {
         ShareUsageStatistics = reg.ShareUsageStatistics;
     }
 }
 private void LoadSettings()
 {
     using (var reg = new AnalyticsRegistrySettings())
     {
         ShareUsageStatistics = reg.ShareUsageStatistics;
     }
 }
예제 #5
0
 private void SaveCookie(AnalyticsCookie cookie)
 {
     using (var reg = new AnalyticsRegistrySettings())
     {
         var pstor = string.Format("{0}.{1}.{2}.{3}",
                                   cookie.UniqueVisitorId,
                                   cookie.FirstVisitTime,
                                   cookie.PreviousVisitTime,
                                   cookie.SessionCount);
         reg.Cookie = pstor;
     }
 }
 private void SaveCookie(AnalyticsCookie cookie)
 {
     using (var reg = new AnalyticsRegistrySettings())
     {
         var pstor = string.Format("{0}.{1}.{2}.{3}",
             cookie.UniqueVisitorId,
             cookie.FirstVisitTime,
             cookie.PreviousVisitTime,
             cookie.SessionCount);
         reg.Cookie = pstor;
     }
 }
예제 #7
0
        public string GenerateSessionId()
        {
            if (this.SessionId == null)
            {
                this.SessionId = new Random((int)DateTime.UtcNow.Ticks).Next(100000000, 999999999).ToString((IFormatProvider)CultureInfo.InvariantCulture);
                AnalyticsCookie cookie;
                using (var reg = new AnalyticsRegistrySettings())
                {
                    cookie = ParseCookie(reg.Cookie);
                }
                cookie.SessionCount++;
                SaveCookie(cookie);
            }

            return(this.SessionId);
        }
        public string GenerateCookieValue()
        {
            AnalyticsCookie cookie;
            using (var reg = new AnalyticsRegistrySettings())
            {
                cookie = ParseCookie(reg.Cookie);
            }

            var currentVisitTime = DateTime.UtcNow.ToUnixTime();

            var cookiestr = string.Format(
                "__utma=1.{0}.{1}.{2}.{3}.{4};+__utmz=1.{3}.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none);",
                cookie.UniqueVisitorId,
                cookie.FirstVisitTime,
                cookie.PreviousVisitTime,
                currentVisitTime,
                cookie.SessionCount);

            cookie.PreviousVisitTime = currentVisitTime;
            SaveCookie(cookie);

            return cookiestr;
        }
예제 #9
0
        public string GenerateCookieValue()
        {
            AnalyticsCookie cookie;

            using (var reg = new AnalyticsRegistrySettings())
            {
                cookie = ParseCookie(reg.Cookie);
            }

            var currentVisitTime = DateTime.UtcNow.ToUnixTime();

            var cookiestr = string.Format(
                "__utma=1.{0}.{1}.{2}.{3}.{4};+__utmz=1.{3}.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none);",
                cookie.UniqueVisitorId,
                cookie.FirstVisitTime,
                cookie.PreviousVisitTime,
                currentVisitTime,
                cookie.SessionCount);

            cookie.PreviousVisitTime = currentVisitTime;
            SaveCookie(cookie);

            return(cookiestr);
        }
        public string GenerateSessionId()
        {
            if (this.SessionId == null)
            {
                this.SessionId = new Random((int)DateTime.UtcNow.Ticks).Next(100000000, 999999999).ToString((IFormatProvider)CultureInfo.InvariantCulture);
                AnalyticsCookie cookie;
                using (var reg = new AnalyticsRegistrySettings())
                {
                    cookie = ParseCookie(reg.Cookie);
                }
                cookie.SessionCount++;
                SaveCookie(cookie);
            }

            return this.SessionId;
        }