Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/3party
diff options
context:
space:
mode:
authorAlex Zolotarev <alex@maps.me>2015-09-02 00:18:25 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 03:03:33 +0300
commitb099af7f137238f24af00729f4d1c04d543212ff (patch)
tree27557bc090305d019713b959e0f56bdfc172c856 /3party
parent7e9beccb4c5bf3470c5da5063938cb9cafa6ddb6 (diff)
[alohalytics][ios] Integrated enable/disable statistics code with iOS part.
Diffstat (limited to '3party')
-rw-r--r--3party/Alohalytics/src/alohalytics_objc.h4
-rw-r--r--3party/Alohalytics/src/apple/alohalytics_objc.mm33
2 files changed, 34 insertions, 3 deletions
diff --git a/3party/Alohalytics/src/alohalytics_objc.h b/3party/Alohalytics/src/alohalytics_objc.h
index 922c79089c..5b733fae4f 100644
--- a/3party/Alohalytics/src/alohalytics_objc.h
+++ b/3party/Alohalytics/src/alohalytics_objc.h
@@ -33,6 +33,10 @@
#import <CoreLocation/CoreLocation.h>
@interface Alohalytics : NSObject
+// Call it once to turn off events logging.
++ (void)disable;
+// Call it once to enable events logging again after disabling it.
++ (void)enable;
+ (void)setDebugMode:(BOOL)enable;
// Should be called in application:didFinishLaunchingWithOptions: or in application:willFinishLaunchingWithOptions:
// Final serverUrl is modified to $(serverUrl)/[ios|mac]/your.bundle.id/app.version
diff --git a/3party/Alohalytics/src/apple/alohalytics_objc.mm b/3party/Alohalytics/src/apple/alohalytics_objc.mm
index cbd655cc79..8439d89530 100644
--- a/3party/Alohalytics/src/apple/alohalytics_objc.mm
+++ b/3party/Alohalytics/src/apple/alohalytics_objc.mm
@@ -288,7 +288,7 @@ static void OnUploadFinished(alohalytics::ProcessingResult result) {
}
EndBackgroundTask();
}
-
+#endif // TARGET_OS_IPHONE
// Quick check if device has any active connection.
// Does not guarantee actual reachability of any host.
// Inspired by Apple's Reachability example:
@@ -315,19 +315,22 @@ bool IsConnectionActive() {
&& (flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0) {
return true;
}
+#if (TARGET_OS_IPHONE > 0)
if ((flags & kSCNetworkReachabilityFlagsIsWWAN) == kSCNetworkReachabilityFlagsIsWWAN) {
return true;
}
+#endif // TARGET_OS_IPHONE
return false;
}
-#endif // TARGET_OS_IPHONE
+//#endif // TARGET_OS_IPHONE
} // namespace
// Keys for NSUserDefaults.
static NSString * const kInstalledVersionKey = @"AlohalyticsInstalledVersion";
static NSString * const kFirstLaunchDateKey = @"AlohalyticsFirstLaunchDate";
static NSString * const kTotalSecondsInTheApp = @"AlohalyticsTotalSecondsInTheApp";
+static NSString * const kIsAlohalyticsDisabledKey = @"AlohalyticsDisabledKey";
// Used to calculate session length and total time spent in the app.
// setup should be called to activate counting.
@@ -371,8 +374,11 @@ static BOOL gIsFirstSession = NO;
.SetStoragePath(StoragePath());
NSUserDefaults * ud = [NSUserDefaults standardUserDefaults];
+ if ([ud boolForKey:kIsAlohalyticsDisabledKey]) {
+ instance.Disable();
+ }
+
// Calculate some basic statistics about installations/updates/launches.
- NSUserDefaults * userDataBase = [NSUserDefaults standardUserDefaults];
NSString * installedVersion = [ud objectForKey:kInstalledVersionKey];
BOOL shouldSendUpdatedSystemInformation = NO;
// Do not generate $install event for old users who did not have Alohalytics installed but already used the app.
@@ -563,4 +569,25 @@ static BOOL gIsFirstSession = NO;
return [Alohalytics fileCreationDate:[[NSBundle mainBundle] executablePath]];
}
++ (void)disable {
+ Stats & s = Stats::Instance();
+ s.LogEvent("$statisticsDisabled");
+ // Force uploading of all previous events.
+ if (IsConnectionActive())
+ s.Upload();
+ s.Disable();
+ NSUserDefaults * ud = [NSUserDefaults standardUserDefaults];
+ [ud setBool:YES forKey:kIsAlohalyticsDisabledKey];
+ [ud synchronize];
+}
+
++ (void)enable {
+ Stats & s = Stats::Instance();
+ s.Enable();
+ s.LogEvent("$statisticsEnabled");
+ NSUserDefaults * ud = [NSUserDefaults standardUserDefaults];
+ [ud setBool:NO forKey:kIsAlohalyticsDisabledKey];
+ [ud synchronize];
+}
+
@end