Example #1
0
        public void TestSaveSettingsSettings_WithOptInInitalizesClientId()
        {
            _objectUnderTest.OptIn    = true;
            _objectUnderTest.ClientId = null;

            _objectUnderTest.SaveSettingsToStorage();

            Assert.IsNotNull(_objectUnderTest.ClientId);
        }
        public void TestSaveSettingsSettingsInitalizesClientId()
        {
            var objectUnderTest = new AnalyticsOptions
            {
                OptIn    = true,
                ClientId = null
            };

            objectUnderTest.SaveSettingsToStorage();

            Assert.IsNotNull(objectUnderTest.ClientId);
        }
        public void TestSaveSettingsSettingsDiablesClientId()
        {
            var objectUnderTest = new AnalyticsOptions
            {
                ClientId = "test-client-id-string",
                OptIn    = false
            };

            objectUnderTest.SaveSettingsToStorage();

            Assert.IsNull(objectUnderTest.ClientId);
        }
Example #4
0
        /// <summary>
        /// Ensures that the opt-in dialog is shown to the user.
        /// </summary>
        public static void EnsureAnalyticsOptIn()
        {
            AnalyticsOptions settings = GoogleCloudExtensionPackage.Instance.AnalyticsSettings;

            if (!settings.DialogShown)
            {
                Debug.WriteLine("Showing the opt-in dialog.");
                settings.OptIn       = PromptAnalyticsOptIn();
                settings.DialogShown = true;
                settings.SaveSettingsToStorage();
            }
        }
Example #5
0
        /// <summary>
        /// Ensures that the opt-in dialog is shown to the user.
        /// </summary>
        public static void EnsureAnalyticsOptIn()
        {
            IGoogleCloudExtensionPackage package  = GoogleCloudExtensionPackage.Instance;
            AnalyticsOptions             settings = package.GeneralSettings;

            if (!settings.DialogShown)
            {
                Debug.WriteLine("Showing the opt-in dialog.");
                settings.OptIn       = package.UserPromptService.PromptUser(new AnalyticsOptInWindowContent());
                settings.DialogShown = true;
                settings.SaveSettingsToStorage();
            }
        }
        /// <summary>
        /// Checks the installed version vs the version that is running, and will report either a new install
        /// if no previous version is found, or an upgrade if a lower version is found. If the same version
        /// is found, nothing is reported.
        /// </summary>
        private async Task CheckInstallationStatusAsync()
        {
            await JoinableTaskFactory.SwitchToMainThreadAsync();

            AnalyticsOptions settings = GeneralSettings;

            if (settings.InstalledVersion == null)
            {
                // This is a new installation.
                Debug.WriteLine("New installation detected.");
                EventsReporterWrapper.ReportEvent(NewInstallEvent.Create());
            }
            else if (settings.InstalledVersion != ApplicationVersion)
            {
                // This is an upgrade (or different version installed).
                Debug.WriteLine($"Found new version {settings.InstalledVersion} different than current {ApplicationVersion}");

                if (!Version.TryParse(ApplicationVersion, out Version current))
                {
                    Debug.WriteLine($"Invalid application version: {ApplicationVersion}");
                    return;
                }
                if (!Version.TryParse(settings.InstalledVersion, out Version installed))
                {
                    Debug.WriteLine($"Invalid installed version: {settings.InstalledVersion}");
                    return;
                }

                if (installed < current)
                {
                    Debug.WriteLine($"Upgrade to version {ApplicationVersion} detected.");
                    EventsReporterWrapper.ReportEvent(UpgradeEvent.Create());
                }
            }
            else
            {
                Debug.WriteLine($"Same version {settings.InstalledVersion} detected.");
            }

            // Update the stored settings with the current version.
            settings.InstalledVersion = ApplicationVersion;
            settings.SaveSettingsToStorage();
        }
Example #7
0
        /// <summary>
        /// Checks the installed version vs the version that is running, and will report either a new install
        /// if no previous version is found, or an upgrade if a lower version is found. If the same version
        /// is found, nothing is reported.
        /// </summary>
        private void CheckInstallationStatus()
        {
            AnalyticsOptions settings = AnalyticsSettings;

            if (settings.InstalledVersion == null)
            {
                // This is a new installation.
                Debug.WriteLine("New installation detected.");
                EventsReporterWrapper.ReportEvent(NewInstallEvent.Create());
            }
            else if (settings.InstalledVersion != ApplicationVersion)
            {
                // This is an upgrade (or different version installed).
                Debug.WriteLine($"Found new version {settings.InstalledVersion} different than current {ApplicationVersion}");

                Version current, installed;
                if (!Version.TryParse(ApplicationVersion, out current))
                {
                    Debug.WriteLine($"Invalid application version: {ApplicationVersion}");
                    return;
                }
                if (!Version.TryParse(settings.InstalledVersion, out installed))
                {
                    Debug.WriteLine($"Invalid installed version: {settings.InstalledVersion}");
                    return;
                }

                if (installed < current)
                {
                    Debug.WriteLine($"Upgrade to version {ApplicationVersion} detected.");
                    EventsReporterWrapper.ReportEvent(UpgradeEvent.Create());
                }
            }
            else
            {
                Debug.WriteLine($"Same version {settings.InstalledVersion} detected.");
            }

            // Update the stored settings with the current version.
            settings.InstalledVersion = ApplicationVersion;
            settings.SaveSettingsToStorage();
        }