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-07-16 14:04:48 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:56:03 +0300
commiteac44c05694fc42c334802517f239f5b9fd5489b (patch)
tree0d27c86fcd3196767f73710cf55656892ca97482 /3party
parenta698fb188aa0ccb2be9342c6ecea8e3c4d7b84a0 (diff)
[alohalytics] Initialize user agent on each launch, not only on install/update events.
Diffstat (limited to '3party')
-rw-r--r--3party/Alohalytics/src/apple/alohalytics_objc.mm35
1 files changed, 19 insertions, 16 deletions
diff --git a/3party/Alohalytics/src/apple/alohalytics_objc.mm b/3party/Alohalytics/src/apple/alohalytics_objc.mm
index b36a11e4d0..62eda99572 100644
--- a/3party/Alohalytics/src/apple/alohalytics_objc.mm
+++ b/3party/Alohalytics/src/apple/alohalytics_objc.mm
@@ -140,14 +140,7 @@ static std::string RectToString(CGRect const & rect) {
}
// Logs some basic device's info.
-static void LogSystemInformation() {
- // Initialize User Agent later, as it takes significant time at startup.
- dispatch_async(dispatch_get_main_queue(), ^{
- gBrowserUserAgent = [[[UIWebView alloc] initWithFrame:CGRectZero] stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];
- if (gBrowserUserAgent) {
- Stats::Instance().LogEvent("$browserUserAgent", ToStdString(gBrowserUserAgent));
- }
- });
+static void LogSystemInformation(NSString * userAgent) {
UIDevice * device = [UIDevice currentDevice];
UIScreen * screen = [UIScreen mainScreen];
std::string preferredLanguages;
@@ -186,6 +179,10 @@ static void LogSystemInformation() {
info.emplace("screenNativeBounds", RectToString(screen.nativeBounds));
info.emplace("screenNativeScale", std::to_string(screen.nativeScale));
}
+ if (userAgent) {
+ info.emplace("browserUserAgent", ToStdString(userAgent));
+ }
+
Stats & instance = Stats::Instance();
instance.LogEvent("$iosDeviceInfo", info);
@@ -372,6 +369,7 @@ bool IsConnectionActive() {
// Calculate some basic statistics about installations/updates/launches.
NSUserDefaults * userDataBase = [NSUserDefaults standardUserDefaults];
NSString * installedVersion = [userDataBase objectForKey:@"AlohalyticsInstalledVersion"];
+ BOOL shouldSendUpdatedSystemInformation = NO;
if (installationId.second && isFirstLaunch && installedVersion == nil) {
// Documents folder modification time can be interpreted as a "first app launch time" or an approx. "app install time".
// App bundle modification time can be interpreted as an "app update time".
@@ -380,11 +378,7 @@ bool IsConnectionActive() {
{"bundleTimestampMillis", PathTimestampMillis([bundle executablePath])}});
[userDataBase setValue:version forKey:@"AlohalyticsInstalledVersion"];
[userDataBase synchronize];
-#if (TARGET_OS_IPHONE > 0)
- LogSystemInformation();
-#else
- static_cast<void>(options); // Unused variable warning fix.
-#endif // TARGET_OS_IPHONE
+ shouldSendUpdatedSystemInformation = YES;
} else {
if (installedVersion == nil || ![installedVersion isEqualToString:version]) {
instance.LogEvent("$update", {{"CFBundleShortVersionString", [version UTF8String]},
@@ -392,9 +386,7 @@ bool IsConnectionActive() {
{"bundleTimestampMillis", PathTimestampMillis([bundle executablePath])}});
[userDataBase setValue:version forKey:@"AlohalyticsInstalledVersion"];
[userDataBase synchronize];
-#if (TARGET_OS_IPHONE > 0)
- LogSystemInformation();
-#endif // TARGET_OS_IPHONE
+ shouldSendUpdatedSystemInformation = YES;
}
}
instance.LogEvent("$launch"
@@ -402,6 +394,17 @@ bool IsConnectionActive() {
, ParseLaunchOptions(options)
#endif // TARGET_OS_IPHONE
);
+#if (TARGET_OS_IPHONE > 0)
+ // Initialize User-Agent asynchronously and log additional system info for iOS, as it takes significant time at startup.
+ dispatch_async(dispatch_get_main_queue(), ^{
+ gBrowserUserAgent = [[[UIWebView alloc] initWithFrame:CGRectZero] stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];
+ if (shouldSendUpdatedSystemInformation) {
+ LogSystemInformation(gBrowserUserAgent);
+ }
+ });
+#else
+ static_cast<void>(options); // Unused variable warning fix.
+#endif // TARGET_OS_IPHONE
}
+ (void)forceUpload {