diff --git a/platform/darwin/src/MGLOfflineRegion_Private.h b/platform/darwin/src/MGLOfflineRegion_Private.h index c1f3fd520..75a023bcb 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 87df6912f..c5b08b8bc 100644 --- a/platform/darwin/src/MGLOfflineStorage.mm +++ b/platform/darwin/src/MGLOfflineStorage.mm @@ -7,11 +7,17 @@ #import "MGLOfflinePack_Private.h" #import "MGLOfflineRegion_Private.h" #import "MGLTilePyramidOfflineRegion.h" +#import "MGLShapeOfflineRegion.h" #import "NSBundle+MGLAdditions.h" #import "NSValue+MGLAdditions.h" #import "NSDate+MGLAdditions.h" #import "NSData+MGLAdditions.h" +#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR +#import "MMEConstants.h" +#import "MGLMapboxEvents.h" +#endif + #include #include #include @@ -361,6 +367,17 @@ const MGLExceptionName MGLUnsupportedRegionTypeException = @"MGLUnsupportedRegio 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)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 e1393f119..7a2de8a82 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 () @end @@ -22,6 +26,17 @@ @synthesize styleURL = _styleURL; +-(NSDictionary *)offlineStartEventAttributes { + return @{ + #if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR + 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 0766d224d..2e06be679 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 () @end @@ -19,6 +23,17 @@ @synthesize styleURL = _styleURL; +-(NSDictionary *)offlineStartEventAttributes { + return @{ + #if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR + 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 index d5e86d0a7..61fca377e 160000 --- a/platform/ios/vendor/mapbox-events-ios +++ b/platform/ios/vendor/mapbox-events-ios @@ -1 +1 @@ -Subproject commit d5e86d0a749d94a8e5f032b9946f7683bdd8c8be +Subproject commit 61fca377e82b4cfb5e99feea1f465eff1dabbf4e