mirror of
https://github.com/bitwarden/mobile
synced 2025-12-15 07:43:37 +00:00
Remove userid from Ga service, not being used
This commit is contained in:
@@ -9,8 +9,6 @@ namespace Bit.Android.Services
|
|||||||
{
|
{
|
||||||
public class GoogleAnalyticsService : IGoogleAnalyticsService
|
public class GoogleAnalyticsService : IGoogleAnalyticsService
|
||||||
{
|
{
|
||||||
private const string UserId = "&uid";
|
|
||||||
|
|
||||||
private readonly GoogleAnalytics _instance;
|
private readonly GoogleAnalytics _instance;
|
||||||
private readonly IAuthService _authService;
|
private readonly IAuthService _authService;
|
||||||
private readonly Tracker _tracker;
|
private readonly Tracker _tracker;
|
||||||
@@ -33,16 +31,10 @@ namespace Bit.Android.Services
|
|||||||
_tracker.EnableAutoActivityTracking(true);
|
_tracker.EnableAutoActivityTracking(true);
|
||||||
_tracker.SetClientId(appIdService.AnonymousAppId);
|
_tracker.SetClientId(appIdService.AnonymousAppId);
|
||||||
|
|
||||||
var gaOptOut = settings.GetValueOrDefault(Constants.SettingGAOptOut, false);
|
var gaOptOut = settings.GetValueOrDefault(Constants.SettingGaOptOut, false);
|
||||||
SetAppOptOut(gaOptOut);
|
SetAppOptOut(gaOptOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RefreshUserId()
|
|
||||||
{
|
|
||||||
_tracker.Set(UserId, null);
|
|
||||||
_setUserId = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void TrackAppEvent(string eventName, string label = null)
|
public void TrackAppEvent(string eventName, string label = null)
|
||||||
{
|
{
|
||||||
TrackEvent("App", eventName, label);
|
TrackEvent("App", eventName, label);
|
||||||
@@ -63,7 +55,6 @@ namespace Bit.Android.Services
|
|||||||
builder.SetLabel(label);
|
builder.SetLabel(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetUserId();
|
|
||||||
_tracker.Send(builder.Build());
|
_tracker.Send(builder.Build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,26 +64,15 @@ namespace Bit.Android.Services
|
|||||||
builder.SetDescription(message);
|
builder.SetDescription(message);
|
||||||
builder.SetFatal(fatal);
|
builder.SetFatal(fatal);
|
||||||
|
|
||||||
SetUserId();
|
|
||||||
_tracker.Send(builder.Build());
|
_tracker.Send(builder.Build());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TrackPage(string pageName)
|
public void TrackPage(string pageName)
|
||||||
{
|
{
|
||||||
SetUserId();
|
|
||||||
_tracker.SetScreenName(pageName);
|
_tracker.SetScreenName(pageName);
|
||||||
_tracker.Send(new HitBuilders.ScreenViewBuilder().Build());
|
_tracker.Send(new HitBuilders.ScreenViewBuilder().Build());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetUserId()
|
|
||||||
{
|
|
||||||
if(_setUserId && _authService.IsAuthenticated)
|
|
||||||
{
|
|
||||||
_tracker.Set(UserId, _authService.UserId);
|
|
||||||
_setUserId = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispatch(Action completionHandler = null)
|
public void Dispatch(Action completionHandler = null)
|
||||||
{
|
{
|
||||||
_instance.DispatchLocalHits();
|
_instance.DispatchLocalHits();
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ namespace Bit.App.Abstractions
|
|||||||
{
|
{
|
||||||
public interface IGoogleAnalyticsService
|
public interface IGoogleAnalyticsService
|
||||||
{
|
{
|
||||||
void RefreshUserId();
|
|
||||||
void TrackPage(string pageName);
|
void TrackPage(string pageName);
|
||||||
void TrackAppEvent(string eventName, string label = null);
|
void TrackAppEvent(string eventName, string label = null);
|
||||||
void TrackExtensionEvent(string eventName, string label = null);
|
void TrackExtensionEvent(string eventName, string label = null);
|
||||||
|
|||||||
@@ -226,7 +226,6 @@ namespace Bit.App
|
|||||||
await Task.Run(() => deviceApiRepository.PutClearTokenAsync(appIdService.AppId)).ConfigureAwait(false);
|
await Task.Run(() => deviceApiRepository.PutClearTokenAsync(appIdService.AppId)).ConfigureAwait(false);
|
||||||
|
|
||||||
_googleAnalyticsService.TrackAppEvent("LoggedOut");
|
_googleAnalyticsService.TrackAppEvent("LoggedOut");
|
||||||
_googleAnalyticsService.RefreshUserId();
|
|
||||||
|
|
||||||
Device.BeginInvokeOnMainThread(() => Current.MainPage = new ExtendedNavigationPage(new HomePage()));
|
Device.BeginInvokeOnMainThread(() => Current.MainPage = new ExtendedNavigationPage(new HomePage()));
|
||||||
if(!string.IsNullOrWhiteSpace(logoutMessage))
|
if(!string.IsNullOrWhiteSpace(logoutMessage))
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
public const string SettingFingerprintUnlockOn = "setting:fingerprintUnlockOn";
|
public const string SettingFingerprintUnlockOn = "setting:fingerprintUnlockOn";
|
||||||
public const string SettingPinUnlockOn = "setting:pinUnlockOn";
|
public const string SettingPinUnlockOn = "setting:pinUnlockOn";
|
||||||
public const string SettingLockSeconds = "setting:lockSeconds";
|
public const string SettingLockSeconds = "setting:lockSeconds";
|
||||||
public const string SettingGAOptOut = "setting:googleAnalyticsOptOut";
|
public const string SettingGaOptOut = "setting:googleAnalyticsOptOut";
|
||||||
|
|
||||||
public const string PasswordGeneratorLength = "pwGenerator:length";
|
public const string PasswordGeneratorLength = "pwGenerator:length";
|
||||||
public const string PasswordGeneratorUppercase = "pwGenerator:uppercase";
|
public const string PasswordGeneratorUppercase = "pwGenerator:uppercase";
|
||||||
|
|||||||
@@ -221,7 +221,6 @@ namespace Bit.App.Pages
|
|||||||
_authService.UserId = _tokenService.TokenUserId;
|
_authService.UserId = _tokenService.TokenUserId;
|
||||||
_authService.Email = _tokenService.TokenEmail;
|
_authService.Email = _tokenService.TokenEmail;
|
||||||
_settings.AddOrUpdateValue(Constants.LastLoginEmail, _authService.Email);
|
_settings.AddOrUpdateValue(Constants.LastLoginEmail, _authService.Email);
|
||||||
_googleAnalyticsService.RefreshUserId();
|
|
||||||
_googleAnalyticsService.TrackAppEvent("LoggedIn");
|
_googleAnalyticsService.TrackAppEvent("LoggedIn");
|
||||||
|
|
||||||
if(Device.OS == TargetPlatform.Android)
|
if(Device.OS == TargetPlatform.Android)
|
||||||
|
|||||||
@@ -183,7 +183,6 @@ namespace Bit.App.Pages
|
|||||||
_authService.UserId = _tokenService.TokenUserId;
|
_authService.UserId = _tokenService.TokenUserId;
|
||||||
_authService.Email = _tokenService.TokenEmail;
|
_authService.Email = _tokenService.TokenEmail;
|
||||||
_settings.AddOrUpdateValue(Constants.LastLoginEmail, _authService.Email);
|
_settings.AddOrUpdateValue(Constants.LastLoginEmail, _authService.Email);
|
||||||
_googleAnalyticsService.RefreshUserId();
|
|
||||||
_googleAnalyticsService.TrackAppEvent("LoggedIn From Two-step");
|
_googleAnalyticsService.TrackAppEvent("LoggedIn From Two-step");
|
||||||
|
|
||||||
if(Device.OS == TargetPlatform.Android)
|
if(Device.OS == TargetPlatform.Android)
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ namespace Bit.App.Pages
|
|||||||
AnalyticsCell = new ExtendedSwitchCell
|
AnalyticsCell = new ExtendedSwitchCell
|
||||||
{
|
{
|
||||||
Text = AppResources.DisableGA,
|
Text = AppResources.DisableGA,
|
||||||
On = _settings.GetValueOrDefault(Constants.SettingGAOptOut, false)
|
On = _settings.GetValueOrDefault(Constants.SettingGaOptOut, false)
|
||||||
};
|
};
|
||||||
|
|
||||||
FoldersCell = new ExtendedTextCell
|
FoldersCell = new ExtendedTextCell
|
||||||
@@ -429,7 +429,7 @@ namespace Bit.App.Pages
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_settings.AddOrUpdateValue(Constants.SettingGAOptOut, cell.On);
|
_settings.AddOrUpdateValue(Constants.SettingGaOptOut, cell.On);
|
||||||
_googleAnalyticsService.SetAppOptOut(cell.On);
|
_googleAnalyticsService.SetAppOptOut(cell.On);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ namespace Bit.iOS.Core.Services
|
|||||||
{
|
{
|
||||||
private readonly ITracker _tracker;
|
private readonly ITracker _tracker;
|
||||||
private readonly IAuthService _authService;
|
private readonly IAuthService _authService;
|
||||||
private bool _setUserId = true;
|
|
||||||
|
|
||||||
public GoogleAnalyticsService(
|
public GoogleAnalyticsService(
|
||||||
IAppIdService appIdService,
|
IAppIdService appIdService,
|
||||||
@@ -24,16 +23,10 @@ namespace Bit.iOS.Core.Services
|
|||||||
_tracker.SetAllowIdfaCollection(true);
|
_tracker.SetAllowIdfaCollection(true);
|
||||||
_tracker.Set(GaiConstants.ClientId, appIdService.AnonymousAppId);
|
_tracker.Set(GaiConstants.ClientId, appIdService.AnonymousAppId);
|
||||||
|
|
||||||
var gaOptOut = settings.GetValueOrDefault(App.Constants.SettingGAOptOut, false);
|
var gaOptOut = settings.GetValueOrDefault(App.Constants.SettingGaOptOut, false);
|
||||||
SetAppOptOut(gaOptOut);
|
SetAppOptOut(gaOptOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RefreshUserId()
|
|
||||||
{
|
|
||||||
_tracker.Set(GaiConstants.UserId, null);
|
|
||||||
_setUserId = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void TrackAppEvent(string eventName, string label = null)
|
public void TrackAppEvent(string eventName, string label = null)
|
||||||
{
|
{
|
||||||
TrackEvent("App", eventName, label);
|
TrackEvent("App", eventName, label);
|
||||||
@@ -46,7 +39,6 @@ namespace Bit.iOS.Core.Services
|
|||||||
|
|
||||||
public void TrackEvent(string category, string eventName, string label = null)
|
public void TrackEvent(string category, string eventName, string label = null)
|
||||||
{
|
{
|
||||||
SetUserId();
|
|
||||||
var dict = DictionaryBuilder.CreateEvent(category, eventName, label, null).Build();
|
var dict = DictionaryBuilder.CreateEvent(category, eventName, label, null).Build();
|
||||||
_tracker.Send(dict);
|
_tracker.Send(dict);
|
||||||
Gai.SharedInstance.Dispatch();
|
Gai.SharedInstance.Dispatch();
|
||||||
@@ -54,14 +46,12 @@ namespace Bit.iOS.Core.Services
|
|||||||
|
|
||||||
public void TrackException(string message, bool fatal)
|
public void TrackException(string message, bool fatal)
|
||||||
{
|
{
|
||||||
SetUserId();
|
|
||||||
var dict = DictionaryBuilder.CreateException(message, fatal).Build();
|
var dict = DictionaryBuilder.CreateException(message, fatal).Build();
|
||||||
_tracker.Send(dict);
|
_tracker.Send(dict);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TrackPage(string pageName)
|
public void TrackPage(string pageName)
|
||||||
{
|
{
|
||||||
SetUserId();
|
|
||||||
_tracker.Set(GaiConstants.ScreenName, pageName);
|
_tracker.Set(GaiConstants.ScreenName, pageName);
|
||||||
var dict = DictionaryBuilder.CreateScreenView().Build();
|
var dict = DictionaryBuilder.CreateScreenView().Build();
|
||||||
_tracker.Send(dict);
|
_tracker.Send(dict);
|
||||||
@@ -75,15 +65,6 @@ namespace Bit.iOS.Core.Services
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetUserId()
|
|
||||||
{
|
|
||||||
if(_setUserId && _authService.IsAuthenticated)
|
|
||||||
{
|
|
||||||
_tracker.Set(GaiConstants.UserId, _authService.UserId);
|
|
||||||
_setUserId = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetAppOptOut(bool optOut)
|
public void SetAppOptOut(bool optOut)
|
||||||
{
|
{
|
||||||
Gai.SharedInstance.OptOut = optOut;
|
Gai.SharedInstance.OptOut = optOut;
|
||||||
|
|||||||
Reference in New Issue
Block a user