forked from organicmaps/organicmaps
[ios] Statistics fixes.
This commit is contained in:
parent
47028a436c
commit
124d43d83f
3 changed files with 12 additions and 14 deletions
|
@ -1,3 +1,4 @@
|
|||
#import "Statistics.h"
|
||||
#import "MWMCustomFacebookEvents.h"
|
||||
#import "3party/Alohalytics/src/alohalytics_objc.h"
|
||||
|
||||
|
@ -40,6 +41,9 @@ static int gStorageSubscriptionId = kNotSubscribed;
|
|||
|
||||
+ (void)optimizeExpenses
|
||||
{
|
||||
if (!Statistics.instance.enabled)
|
||||
return;
|
||||
|
||||
NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
|
||||
BOOL const isFirstSession = [Alohalytics isFirstSession];
|
||||
if (isFirstSession)
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
- (void)startSessionWithLaunchOptions:(NSDictionary *)launchOptions;
|
||||
- (void)logEvent:(NSString *)eventName;
|
||||
- (void)logInAppMessageEvent:(NSString *)eventName imageType:(NSString *)imageType;
|
||||
- (void)logEvent:(NSString *)eventName withParameters:(NSDictionary *)parameters;
|
||||
- (void)logApiUsage:(NSString *)programName;
|
||||
- (void)logLocation:(CLLocation *)location;
|
||||
|
|
|
@ -15,7 +15,6 @@ static constexpr char const * kStatisticsEnabledSettingsKey = "StatisticsEnabled
|
|||
if (self.enabled)
|
||||
{
|
||||
[Flurry startSession:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"FlurryKey"]];
|
||||
[Flurry setSessionReportsOnPauseEnabled:NO];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +22,7 @@ static constexpr char const * kStatisticsEnabledSettingsKey = "StatisticsEnabled
|
|||
{
|
||||
if (self.enabled)
|
||||
{
|
||||
static NSDate * lastUpdate;
|
||||
static NSDate * lastUpdate = nil;
|
||||
if (!lastUpdate || [[NSDate date] timeIntervalSinceDate:lastUpdate] > (60 * 60 * 3))
|
||||
{
|
||||
lastUpdate = [NSDate date];
|
||||
|
@ -44,19 +43,15 @@ static constexpr char const * kStatisticsEnabledSettingsKey = "StatisticsEnabled
|
|||
[self logEvent:eventName withParameters:nil];
|
||||
}
|
||||
|
||||
- (void)logInAppMessageEvent:(NSString *)eventName imageType:(NSString *)imageType
|
||||
{
|
||||
NSString * language = [[NSLocale preferredLanguages] firstObject];
|
||||
AppInfo * info = [AppInfo sharedInfo];
|
||||
[self logEvent:eventName withParameters:@{@"Type": imageType, @"Country" : info.countryCode, @"Language" : language, @"Id" : info.uniqueId}];
|
||||
}
|
||||
|
||||
- (void)logApiUsage:(NSString *)programName
|
||||
{
|
||||
if (programName)
|
||||
[self logEvent:@"Api Usage" withParameters: @{@"Application Name" : programName}];
|
||||
else
|
||||
[self logEvent:@"Api Usage" withParameters: @{@"Application Name" : @"Error passing nil as SourceApp name."}];
|
||||
if (self.enabled)
|
||||
{
|
||||
if (programName)
|
||||
[self logEvent:@"Api Usage" withParameters: @{@"Application Name" : programName}];
|
||||
else
|
||||
[self logEvent:@"Api Usage" withParameters: @{@"Application Name" : @"Error passing nil as SourceApp name."}];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)enabled
|
||||
|
|
Loading…
Add table
Reference in a new issue