Instrumented key events in extension

This commit is contained in:
Kyle Spearrin 2016-08-04 00:25:10 -04:00
parent a831c9ac4f
commit 561c972c96
6 changed files with 40 additions and 5 deletions

View file

@ -36,12 +36,25 @@ namespace Bit.Android.Services
_setUserId = true; _setUserId = true;
} }
public void TrackEvent(string category, string eventName) public void TrackAppEvent(string eventName, string label = null)
{
TrackEvent("App", eventName, label);
}
public void TrackExtensionEvent(string eventName, string label = null)
{
throw new NotSupportedException();
}
public void TrackEvent(string category, string eventName, string label = null)
{ {
var builder = new HitBuilders.EventBuilder(); var builder = new HitBuilders.EventBuilder();
builder.SetCategory(category); builder.SetCategory(category);
builder.SetAction(eventName); builder.SetAction(eventName);
builder.SetLabel("AppEvent"); if(label != null)
{
builder.SetLabel(label);
}
SetUserId(); SetUserId();
_tracker.Send(builder.Build()); _tracker.Send(builder.Build());

View file

@ -4,7 +4,9 @@
{ {
void RefreshUserId(); void RefreshUserId();
void TrackPage(string pageName); void TrackPage(string pageName);
void TrackEvent(string category, string eventName); void TrackAppEvent(string eventName, string label = null);
void TrackExtensionEvent(string eventName, string label = null);
void TrackEvent(string category, string eventName, string label = null);
void TrackException(string message, bool fatal); void TrackException(string message, bool fatal);
} }
} }

View file

@ -28,10 +28,20 @@ namespace Bit.iOS.Core.Services
_setUserId = true; _setUserId = true;
} }
public void TrackEvent(string category, string eventName) public void TrackAppEvent(string eventName, string label = null)
{
TrackEvent("App", eventName, label);
}
public void TrackExtensionEvent(string eventName, string label = null)
{
TrackEvent("Extension", eventName, label);
}
public void TrackEvent(string category, string eventName, string label = null)
{ {
SetUserId(); SetUserId();
var dict = DictionaryBuilder.CreateEvent(category, eventName, "AppEvent", null).Build(); var dict = DictionaryBuilder.CreateEvent(category, eventName, label, null).Build();
_tracker.Send(dict); _tracker.Send(dict);
Gai.SharedInstance.Dispatch(); Gai.SharedInstance.Dispatch();
} }

View file

@ -29,6 +29,7 @@ namespace Bit.iOS.Extension
private bool _setupHockeyApp = false; private bool _setupHockeyApp = false;
private readonly JsonSerializerSettings _jsonSettings = private readonly JsonSerializerSettings _jsonSettings =
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }; new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
private IGoogleAnalyticsService _googleAnalyticsService;
public LoadingViewController(IntPtr handle) : base(handle) public LoadingViewController(IntPtr handle) : base(handle)
{ } { }
@ -36,6 +37,7 @@ namespace Bit.iOS.Extension
public override void ViewDidLoad() public override void ViewDidLoad()
{ {
base.ViewDidLoad(); base.ViewDidLoad();
_googleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>();
View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f); View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f);
_context.ExtContext = ExtensionContext; _context.ExtContext = ExtensionContext;
@ -293,6 +295,8 @@ namespace Bit.iOS.Extension
var dict = list as NSDictionary; var dict = list as NSDictionary;
action(dict); action(dict);
_googleAnalyticsService.TrackExtensionEvent("ProviderType", type);
Debug.WriteLine("BW LOG, ProviderType: " + _context.ProviderType); Debug.WriteLine("BW LOG, ProviderType: " + _context.ProviderType);
Debug.WriteLine("BW LOG, Url: " + _context.Url); Debug.WriteLine("BW LOG, Url: " + _context.Url);
Debug.WriteLine("BW LOG, Title: " + _context.SiteTitle); Debug.WriteLine("BW LOG, Title: " + _context.SiteTitle);

View file

@ -18,6 +18,7 @@ namespace Bit.iOS.Extension
{ {
private IPasswordGenerationService _passwordGenerationService; private IPasswordGenerationService _passwordGenerationService;
private ISettings _settings; private ISettings _settings;
private IGoogleAnalyticsService _googleAnalyticsService;
public PasswordGeneratorViewController(IntPtr handle) : base(handle) public PasswordGeneratorViewController(IntPtr handle) : base(handle)
{ } { }
@ -44,6 +45,7 @@ namespace Bit.iOS.Extension
{ {
_passwordGenerationService = Resolver.Resolve<IPasswordGenerationService>(); _passwordGenerationService = Resolver.Resolve<IPasswordGenerationService>();
_settings = Resolver.Resolve<ISettings>(); _settings = Resolver.Resolve<ISettings>();
_googleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>();
View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f); View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f);
@ -171,6 +173,7 @@ namespace Bit.iOS.Extension
private void GeneratePassword() private void GeneratePassword()
{ {
_googleAnalyticsService.TrackExtensionEvent("GeneratePassword");
PasswordLabel.Text = _passwordGenerationService.GeneratePassword( PasswordLabel.Text = _passwordGenerationService.GeneratePassword(
length: LengthCell.Value, length: LengthCell.Value,
uppercase: UppercaseCell.Switch.On, uppercase: UppercaseCell.Switch.On,

View file

@ -23,6 +23,7 @@ namespace Bit.iOS.Extension
private IFolderService _folderService; private IFolderService _folderService;
private IConnectivity _connectivity; private IConnectivity _connectivity;
private IEnumerable<Folder> _folders; private IEnumerable<Folder> _folders;
private IGoogleAnalyticsService _googleAnalyticsService;
public SiteAddViewController(IntPtr handle) : base(handle) public SiteAddViewController(IntPtr handle) : base(handle)
{ } { }
@ -51,6 +52,7 @@ namespace Bit.iOS.Extension
_siteService = Resolver.Resolve<ISiteService>(); _siteService = Resolver.Resolve<ISiteService>();
_connectivity = Resolver.Resolve<IConnectivity>(); _connectivity = Resolver.Resolve<IConnectivity>();
_folderService = Resolver.Resolve<IFolderService>(); _folderService = Resolver.Resolve<IFolderService>();
_googleAnalyticsService = Resolver.Resolve<IGoogleAnalyticsService>();
View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f); View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f);
@ -164,6 +166,7 @@ namespace Bit.iOS.Extension
if(saveTask.Result.Succeeded) if(saveTask.Result.Succeeded)
{ {
_googleAnalyticsService.TrackExtensionEvent("SiteCreated");
if(SiteListController != null) if(SiteListController != null)
{ {
SiteListController.DismissModal(); SiteListController.DismissModal();