Skip to content

Commit

Permalink
[fix] 修复Analytics名称不正确的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
zxbmmmmmmmmm committed May 4, 2024
1 parent 840359f commit e50444d
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 16 deletions.
14 changes: 13 additions & 1 deletion FluentWeather.Uwp.Shared/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,19 @@ public bool DeveloperMode
OnPropertyChanged();
}
}

public bool IsAnalyticsEnabled
{
#if DEBUG
get => GetSettings(nameof(IsAnalyticsEnabled), false);
#else
get => GetSettings(nameof(IsAnalyticsEnabled), true);
#endif
set
{
ApplicationData.Current.LocalSettings.Values[nameof(IsAnalyticsEnabled)] = value;
OnPropertyChanged();
}
}
public bool NotificationsDebugMode
{
get => GetSettings(nameof(NotificationsDebugMode), false);
Expand Down
9 changes: 7 additions & 2 deletions FluentWeather.Uwp/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,13 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
Window.Current.Activate();
}
ActiveArguments = e.Arguments;
var service = DIContainer.Locator.ServiceProvider.GetService<AppAnalyticsService>();
service.Start();

if(Common.Settings.IsAnalyticsEnabled)
{
var service = DIContainer.Locator.ServiceProvider.GetService<AppAnalyticsService>();
service.Start();
}

ThemeHelper.SetRequestTheme(Common.Settings.ApplicationTheme);//重新设置主题以加载主题资源
}

Expand Down
1 change: 1 addition & 0 deletions FluentWeather.Uwp/Controls/Dialogs/AboutDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public void Close()
[RelayCommand]
public void EnableDeveloperMode()
{
Locator.ServiceProvider.GetService<AppAnalyticsService>()?.TrackDeveloperModeEnabled();
Common.Settings.DeveloperMode = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using FluentWeather.Uwp.QWeatherProvider.Views;
using FluentWeather.DIContainer;
using FluentWeather.Uwp.Helpers.Analytics;
using Microsoft.Extensions.DependencyInjection;

// https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板

Expand Down Expand Up @@ -49,6 +52,7 @@ private async void RestartButton_Click(object sender, RoutedEventArgs e)
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
RestartInfoBar.IsOpen = true;
Locator.ServiceProvider.GetService<AppAnalyticsService>()?.TrackProviderChanged(Common.Settings.ProviderConfig.ToString());
}
//public static bool Equals<TKey, TValue>(IList<KeyValuePair<TKey, TValue>> x,
// IList<KeyValuePair<TKey, TValue>> y)
Expand Down
10 changes: 7 additions & 3 deletions FluentWeather.Uwp/Controls/Settings/DeveloperSettingSection.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,22 @@
Padding="12"
Click="OpenLog_Click"
IsClickEnabled="True" />
<controls:SettingsCard Padding="12" Header="Set Language">
<TextBox Text="{x:Bind app:Common.Settings.Language,Mode=TwoWay}" />
</controls:SettingsCard>
<controls:SettingsCard
x:Name="OOBECard"
Padding="12"
Click="OOBECard_Click"
Header="Enter OOBE"
IsClickEnabled="True" />
<controls:SettingsCard Padding="12" Header="Set Language">
<TextBox Text="{x:Bind app:Common.Settings.Language,Mode=TwoWay}" />
</controls:SettingsCard>
<controls:SettingsCard Header="Notification debug mode" Padding="12">
<ToggleSwitch IsOn="{x:Bind app:Common.Settings.NotificationsDebugMode, Mode=TwoWay}" Style="{StaticResource DefaultToggleSwitchStyle}" />
</controls:SettingsCard>
<controls:SettingsCard Header="Enable analytics" Padding="12">
<ToggleSwitch IsOn="{x:Bind app:Common.Settings.IsAnalyticsEnabled, Mode=TwoWay}" Style="{StaticResource DefaultToggleSwitchStyle}" />
</controls:SettingsCard>
</controls:SettingsExpander.Items>

</controls:SettingsExpander>
</UserControl>
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using FluentWeather.DIContainer;
using FluentWeather.Uwp.Behaviors;
using FluentWeather.Uwp.Helpers;
using FluentWeather.Uwp.Helpers.Analytics;
using FluentWeather.Uwp.Pages;
using FluentWeather.Uwp.Shared;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -100,6 +103,7 @@ private async void RestartButton_Click(object sender, RoutedEventArgs e)
private void ThemeStyleButtons_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
RestartInfoBar.IsOpen = true;
Locator.ServiceProvider.GetService<AppAnalyticsService>()?.TrackThemeChanged(Common.Settings.Theme.ToString());
}

private void ApplyBlurButton_Click(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -128,6 +132,7 @@ private async void SelectPageFile_Click(object sender, RoutedEventArgs e)
await file.CopyAsync(folder,"MainPage.xaml");
RestartInfoBar.IsOpen = true;
Common.Settings.EnableCustomPage = true;
Locator.ServiceProvider.GetService<AppAnalyticsService>()?.TrackMainPageChanged(file.Name);
}
}
}
22 changes: 13 additions & 9 deletions FluentWeather.Uwp/Helpers/Analytics/AppAnalyticsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ public virtual void TrackTokenChanged()
}
public virtual void TrackWeatherDataObtained()
{
TrackEvent("TrackWeatherDataObtained");
TrackEvent("WeatherDataObtained");
}
public virtual void TrackTyphoonDialogOpened()
{
TrackEvent("TrackTyphoonDialogOpened");
TrackEvent("TyphoonDialogOpened");
}
public virtual void TrackProviderChanged(string providerName)
{
TrackEvent("TrackProviderChanged","ProviderName",providerName,false);
TrackEvent("ProviderChanged","ProviderName",providerName,false);
}
public virtual void TrackThemeChanged(string themeName)
{
Expand All @@ -71,27 +71,31 @@ public virtual void TrackMainPageChanged(string fileName)
}
public virtual void TrackDailyViewEntered()
{
TrackEvent("TrackDailyViewEntered");
TrackEvent("DailyViewEntered");
}
public virtual void TrackUpdateManualChecked()
{
TrackEvent("TrackUpdateManualChecked");
TrackEvent("UpdateManualChecked");
}
public virtual void TrackAboutOpened()
{
TrackEvent("TrackAboutOpened");
TrackEvent("AboutOpened");
}
public virtual void TrackUpdateViewed(string updateVersion)
{
TrackEvent("TrackUpdateViewed","UpdateVersion",updateVersion);
TrackEvent("UpdateViewed","UpdateVersion",updateVersion);
}
public virtual void TrackCitySaved(string cityName)
{
TrackEvent("TrackCitySaved", "CityName",cityName);
TrackEvent("CitySaved", "CityName",cityName);
}
public virtual void TrackDefaultLocationChanged(string cityName)
{
TrackEvent("TrackAboutOpened", "CityName", cityName);
TrackEvent("DefaultLocationChanged", "CityName", cityName);
}
public virtual void TrackDeveloperModeEnabled()
{
TrackEvent("DeveloperModeEnabled");
}
#endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class AppCenterAnalyticsService : AppAnalyticsService
public override void Start()
{
base.Start();
AppCenterService.Start("507a5f67-6c14-432d-bcc3-4619144ecd38", typeof(AppCenter), typeof(Crashes));
AppCenterService.Start(Constants.AppCenterSecret, typeof(AppCenter), typeof(Crashes));
}
public override void TrackEvent(string name, IDictionary<string, string> properties = null, bool addDefaultProperties = true)
{
Expand Down

0 comments on commit e50444d

Please sign in to comment.