[ios] Log interface clicks with Alohalytics.

This commit is contained in:
VladiMihaylenko 2015-03-24 19:06:35 +03:00 committed by Alex Zolotarev
parent 1a07605dd2
commit 13afbf8d4f
4 changed files with 45 additions and 5 deletions

View file

@ -16,6 +16,7 @@
#import "CountryTreeVC.h"
#import "Reachability.h"
#import "MWMAlertViewController.h"
#import "../../../3party/Alohalytics/src/alohalytics_objc.h"
#import "../../Common/CustomAlertView.h"
@ -42,6 +43,8 @@
#define FACEBOOK_URL @"http://www.facebook.com/MapsWithMe"
#define FACEBOOK_SCHEME @"fb://profile/111923085594432"
extern NSString * const kAlohalyticsTapEventKey = @"$onClick";
@interface NSValueWrapper : NSObject
-(NSValue *)getInnerValue;
@ -279,11 +282,13 @@
- (IBAction)zoomInPressed:(id)sender
{
[Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"+"];
GetFramework().Scale(2.0);
}
- (IBAction)zoomOutPressed:(id)sender
{
[Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"-"];
GetFramework().Scale(0.5);
}
@ -1027,16 +1032,25 @@
- (void)toolbar:(ToolbarView *)toolbar didPressItemWithName:(NSString *)itemName
{
if ([itemName isEqualToString:@"Location"])
{
[self onMyPositionClicked:nil];
}
else if ([itemName isEqualToString:@"Search"])
{
[Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"search"];
[self.searchView setState:SearchViewStateFullscreen animated:YES withCallback:YES];
}
else if ([itemName isEqualToString:@"Bookmarks"])
{
[Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"bookmarks"];
BookmarksRootVC * vc = [[BookmarksRootVC alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
else if ([itemName isEqualToString:@"Menu"])
{
[Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"menu"];
[self.bottomMenu setMenuHidden:NO animated:YES];
}
}
#pragma mark - Routing
@ -1142,16 +1156,19 @@
{
if ([itemName isEqualToString:@"Maps"])
{
[Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"downloader"];
CountryTreeVC * vc = [[CountryTreeVC alloc] initWithNodePosition:-1];
[self.navigationController pushViewController:vc animated:YES];
}
else if ([itemName isEqualToString:@"Settings"])
{
[Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"settingsAndMore"];
SettingsAndMoreVC * vc = [[SettingsAndMoreVC alloc] initWithStyle:UITableViewStyleGrouped];
[self.navigationController pushViewController:vc animated:YES];
}
else if ([itemName isEqualToString:@"Share"])
{
[Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"share@"];
CLLocation * location = [MapsAppDelegate theApp].m_locationManager.lastLocation;
if (location)
{

View file

@ -3,6 +3,9 @@
#import "UIViewController+Navigation.h"
#import "UIKitCategories.h"
#import <MessageUI/MFMailComposeViewController.h>
#import "../../3party/Alohalytics/src/alohalytics_objc.h"
extern NSString * const kAlohalyticsTapEventKey;
@interface CommunityVC () <MFMailComposeViewControllerDelegate>
@ -65,18 +68,22 @@
NSString * itemId = self.items[indexPath.section][@"Items"][indexPath.row][@"Id"];
if ([itemId isEqualToString:@"Facebook"])
{
[Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"likeOnFb"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://facebook.com/MapsWithMe"]];
}
else if ([itemId isEqualToString:@"Twitter"])
{
[Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"followOnTwitter"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://twitter.com/MAPS_ME"]];
}
else if ([itemId isEqualToString:@"Contact"])
{
[Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"contactUs"];
[self contact];
}
else if ([itemId isEqualToString:@"Subscribe"])
{
[Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"subscribeToNews"];
[self subscribe];
}
[tableView deselectRowAtIndexPath:indexPath animated:YES];

View file

@ -10,6 +10,9 @@
#import "WebViewController.h"
#import "CommunityVC.h"
#import "RichTextVC.h"
#import "../../3party/Alohalytics/src/alohalytics_objc.h"
extern NSString * const kAlohalyticsTapEventKey;
@interface SettingsAndMoreVC () <MFMailComposeViewControllerDelegate>
@ -125,34 +128,41 @@
NSString * itemId = self.items[indexPath.section][@"Items"][indexPath.row][@"Id"];
if ([itemId isEqualToString:@"About"])
{
[Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"about"];
[self about];
}
else if ([itemId isEqualToString:@"Community"])
{
[Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"community"];
CommunityVC * vc = [[CommunityVC alloc] initWithStyle:UITableViewStyleGrouped];
[self.navigationController pushViewController:vc animated:YES];
}
else if ([itemId isEqualToString:@"RateApp"])
{
[Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"rate"];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
[self rateApp];
}
else if ([itemId isEqualToString:@"Settings"])
{
[Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"settingsMiles"];
SettingsViewController * vc = [self.mainStoryboard instantiateViewControllerWithIdentifier:[SettingsViewController className]];
[self.navigationController pushViewController:vc animated:YES];
}
else if ([itemId isEqualToString:@"ReportBug"])
{
[Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"reportABug"];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
[self reportBug];
}
else if ([itemId isEqualToString:@"Help"])
{
[Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"help"];
[self help];
}
else if ([itemId isEqualToString:@"Copyright"])
{
[Alohalytics logEvent:kAlohalyticsTapEventKey withValue:@"copyright"];
[self copyright];
}
}

View file

@ -24,6 +24,7 @@
#include "../geometry/rect2d.hpp"
#include "../geometry/transformations.hpp"
#include "../../3party/Alohalytics/src/alohalytics.h"
namespace location
@ -306,23 +307,29 @@ bool State::IsModeHasPosition() const
void State::SwitchToNextMode()
{
string const kAlohalyticsClickEvent = "$onClick";
Mode currentMode = GetMode();
Mode newMode = currentMode;
if (!IsInRouting())
{
switch (currentMode)
{
case UnknownPosition:
alohalytics::LogEvent(kAlohalyticsClickEvent, "@UnknownPosition");
newMode = PendingPosition;
break;
case PendingPosition:
alohalytics::LogEvent(kAlohalyticsClickEvent, "@PendingPosition");
newMode = UnknownPosition;
m_afterPendingMode = Follow;
break;
case NotFollow:
alohalytics::LogEvent(kAlohalyticsClickEvent, "@NotFollow");
newMode = Follow;
break;
case Follow:
alohalytics::LogEvent(kAlohalyticsClickEvent, "@Follow");
if (IsRotationActive())
newMode = RotateAndFollow;
else
@ -332,11 +339,10 @@ void State::SwitchToNextMode()
}
break;
case RotateAndFollow:
{
newMode = UnknownPosition;
m_afterPendingMode = Follow;
break;
}
alohalytics::LogEvent(kAlohalyticsClickEvent, "@RotateAndFollow");
newMode = UnknownPosition;
m_afterPendingMode = Follow;
break;
}
}
else