summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNadia Barbosa <nadiabarbosa@me.com>2018-10-05 19:10:58 -0400
committerNadia Barbosa <nadiabarbosa@me.com>2018-10-23 11:57:50 -0700
commit009082b6948ec31c01ea1e1b60937b76c33bee8e (patch)
treee98a9aa70eed980bd7830e873e706211bc962506
parent62af756ab8250e00a63776c2d32bf3123909eddb (diff)
downloadqtlocation-mapboxgl-upstream/add-offline-event.tar.gz
[ios] Log event when offline pack is createdupstream/add-offline-event
Only run MME code for iOS
-rw-r--r--platform/darwin/src/MGLOfflineRegion_Private.h5
-rw-r--r--platform/darwin/src/MGLOfflineStorage.mm17
-rw-r--r--platform/darwin/src/MGLShapeOfflineRegion.mm15
-rw-r--r--platform/darwin/src/MGLTilePyramidOfflineRegion.mm15
m---------platform/ios/vendor/mapbox-events-ios0
5 files changed, 52 insertions, 0 deletions
diff --git a/platform/darwin/src/MGLOfflineRegion_Private.h b/platform/darwin/src/MGLOfflineRegion_Private.h
index c1f3fd5200..75a023bcbb 100644
--- a/platform/darwin/src/MGLOfflineRegion_Private.h
+++ b/platform/darwin/src/MGLOfflineRegion_Private.h
@@ -14,6 +14,11 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (const mbgl::OfflineRegionDefinition)offlineRegionDefinition;
+/**
+ Attributes to be passed into the offline download start event
+ */
+@property (nonatomic, readonly) NSDictionary *offlineStartEventAttributes;
+
@end
NS_ASSUME_NONNULL_END
diff --git a/platform/darwin/src/MGLOfflineStorage.mm b/platform/darwin/src/MGLOfflineStorage.mm
index fd6dd2f998..e4fd525774 100644
--- a/platform/darwin/src/MGLOfflineStorage.mm
+++ b/platform/darwin/src/MGLOfflineStorage.mm
@@ -7,9 +7,15 @@
#import "MGLOfflinePack_Private.h"
#import "MGLOfflineRegion_Private.h"
#import "MGLTilePyramidOfflineRegion.h"
+#import "MGLShapeOfflineRegion.h"
#import "NSBundle+MGLAdditions.h"
#import "NSValue+MGLAdditions.h"
+#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
+#import "MMEConstants.h"
+#import "MGLMapboxEvents.h"
+#endif
+
#include <mbgl/actor/actor.hpp>
#include <mbgl/actor/scheduler.hpp>
#include <mbgl/storage/resource_transform.hpp>
@@ -357,6 +363,17 @@ const MGLExceptionName MGLUnsupportedRegionTypeException = @"MGLUnsupportedRegio
[[strongSelf mutableArrayValueForKey:@"packs"] addObject:pack];
if (completion) {
completion(pack, error);
+
+ #if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
+ NSMutableDictionary *offlineDownloadStartEventAttributes = [NSMutableDictionary dictionaryWithObject:MMEventTypeOfflineDownloadStart forKey:MMEEventKeyEvent];
+
+ if ([region conformsToProtocol:@protocol(MGLOfflineRegion_Private)]) {
+ NSDictionary *regionAttributes = ((id<MGLOfflineRegion_Private>)region).offlineStartEventAttributes;
+ [offlineDownloadStartEventAttributes addEntriesFromDictionary:regionAttributes];
+ }
+
+ [MGLMapboxEvents pushEvent:MMEventTypeOfflineDownloadStart withAttributes:offlineDownloadStartEventAttributes];
+ #endif
}
}];
}
diff --git a/platform/darwin/src/MGLShapeOfflineRegion.mm b/platform/darwin/src/MGLShapeOfflineRegion.mm
index e1393f1199..02ff2abfc5 100644
--- a/platform/darwin/src/MGLShapeOfflineRegion.mm
+++ b/platform/darwin/src/MGLShapeOfflineRegion.mm
@@ -12,6 +12,10 @@
#import "MGLShape_Private.h"
#import "MGLStyle.h"
+#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
+#import "MMEConstants.h"
+#endif
+
@interface MGLShapeOfflineRegion () <MGLOfflineRegion_Private, MGLShapeOfflineRegion_Private>
@end
@@ -22,6 +26,17 @@
@synthesize styleURL = _styleURL;
+#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
+-(NSDictionary *)offlineStartEventAttributes {
+ return @{
+ MMEEventKeyShapeForOfflineRegion: @"shaperegion",
+ MMEEventKeyMinZoomLevel: @(self.minimumZoomLevel),
+ MMEEventKeyMaxZoomLevel: @(self.maximumZoomLevel),
+ MMEEventKeyStyleURL: self.styleURL
+ };
+}
+#endif
+
+ (BOOL)supportsSecureCoding {
return YES;
}
diff --git a/platform/darwin/src/MGLTilePyramidOfflineRegion.mm b/platform/darwin/src/MGLTilePyramidOfflineRegion.mm
index 0766d224da..3a4f20bf51 100644
--- a/platform/darwin/src/MGLTilePyramidOfflineRegion.mm
+++ b/platform/darwin/src/MGLTilePyramidOfflineRegion.mm
@@ -9,6 +9,10 @@
#import "MGLGeometry_Private.h"
#import "MGLStyle.h"
+#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
+#import "MMEConstants.h"
+#endif
+
@interface MGLTilePyramidOfflineRegion () <MGLOfflineRegion_Private, MGLTilePyramidOfflineRegion_Private>
@end
@@ -19,6 +23,17 @@
@synthesize styleURL = _styleURL;
+#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
+-(NSDictionary *)offlineStartEventAttributes {
+ return @{
+ MMEEventKeyShapeForOfflineRegion: @"tileregion",
+ MMEEventKeyMinZoomLevel: @(self.minimumZoomLevel),
+ MMEEventKeyMaxZoomLevel: @(self.maximumZoomLevel),
+ MMEEventKeyStyleURL: self.styleURL
+ };
+}
+#endif
+
+ (BOOL)supportsSecureCoding {
return YES;
}
diff --git a/platform/ios/vendor/mapbox-events-ios b/platform/ios/vendor/mapbox-events-ios
-Subproject d5e86d0a749d94a8e5f032b9946f7683bdd8c8b
+Subproject 61fca377e82b4cfb5e99feea1f465eff1dabbf4