mirror of
https://github.com/bitwarden/mobile.git
synced 2024-11-28 12:35:40 +01:00
Created anonymous app id for google analytics.
This commit is contained in:
parent
a267bf9cf7
commit
98ceaba5f5
@ -28,7 +28,7 @@ namespace Bit.Android.Services
|
||||
_tracker.EnableExceptionReporting(true);
|
||||
_tracker.EnableAdvertisingIdCollection(true);
|
||||
_tracker.EnableAutoActivityTracking(true);
|
||||
_tracker.SetClientId(appIdService.AppId);
|
||||
_tracker.SetClientId(appIdService.AnonymousAppId);
|
||||
}
|
||||
|
||||
public void RefreshUserId()
|
||||
|
@ -3,5 +3,6 @@
|
||||
public interface IAppIdService
|
||||
{
|
||||
string AppId { get; }
|
||||
string AnonymousAppId { get; }
|
||||
}
|
||||
}
|
||||
|
@ -6,34 +6,36 @@ namespace Bit.App.Services
|
||||
public class AppIdService : IAppIdService
|
||||
{
|
||||
private const string AppIdKey = "appId";
|
||||
private const string AnonymousAppIdKey = "anonymousAppId";
|
||||
private readonly ISecureStorageService _secureStorageService;
|
||||
private Guid? _appId;
|
||||
private Guid? _anonymousAppId;
|
||||
|
||||
public AppIdService(ISecureStorageService secureStorageService)
|
||||
{
|
||||
_secureStorageService = secureStorageService;
|
||||
}
|
||||
|
||||
public string AppId
|
||||
public string AppId => GetAppId(AppIdKey, ref _appId);
|
||||
public string AnonymousAppId => GetAppId(AnonymousAppIdKey, ref _anonymousAppId);
|
||||
|
||||
private string GetAppId(string key, ref Guid? appId)
|
||||
{
|
||||
get
|
||||
if(appId.HasValue)
|
||||
{
|
||||
if(_appId.HasValue)
|
||||
{
|
||||
return _appId.Value.ToString();
|
||||
return appId.Value.ToString();
|
||||
}
|
||||
|
||||
var appIdBytes = _secureStorageService.Retrieve(AppIdKey);
|
||||
var appIdBytes = _secureStorageService.Retrieve(key);
|
||||
if(appIdBytes != null)
|
||||
{
|
||||
_appId = new Guid(appIdBytes);
|
||||
return _appId.Value.ToString();
|
||||
appId = new Guid(appIdBytes);
|
||||
return appId.Value.ToString();
|
||||
}
|
||||
|
||||
_appId = Guid.NewGuid();
|
||||
_secureStorageService.Store(AppIdKey, _appId.Value.ToByteArray());
|
||||
return _appId.Value.ToString();
|
||||
}
|
||||
appId = Guid.NewGuid();
|
||||
_secureStorageService.Store(key, appId.Value.ToByteArray());
|
||||
return appId.Value.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ namespace Bit.iOS.Core.Services
|
||||
Gai.SharedInstance.TrackUncaughtExceptions = true;
|
||||
_tracker = Gai.SharedInstance.GetTracker("UA-81915606-1");
|
||||
_tracker.SetAllowIdfaCollection(true);
|
||||
_tracker.Set(GaiConstants.ClientId, appIdService.AppId);
|
||||
_tracker.Set(GaiConstants.ClientId, appIdService.AnonymousAppId);
|
||||
}
|
||||
|
||||
public void RefreshUserId()
|
||||
|
Loading…
Reference in New Issue
Block a user