Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[ios] Log event when offline pack is created
Browse files Browse the repository at this point in the history
  • Loading branch information
captainbarbosa committed Oct 16, 2018
1 parent 6cc13e5 commit a71e3d2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 28 additions & 0 deletions platform/darwin/src/MGLOfflineStorage.mm
Expand Up @@ -3,10 +3,13 @@
#import "MGLFoundation_Private.h"
#import "MGLAccountManager_Private.h"
#import "MGLGeometry_Private.h"
#import "MGLMapboxEvents.h"
#import "MGLNetworkConfiguration.h"
#import "MGLOfflinePack_Private.h"
#import "MGLOfflineRegion_Private.h"
#import "MGLTilePyramidOfflineRegion.h"
#import "MGLShapeOfflineRegion.h"
#import "MMEConstants.h"
#import "NSBundle+MGLAdditions.h"
#import "NSValue+MGLAdditions.h"

Expand Down Expand Up @@ -357,6 +360,31 @@ - (void)addPackForRegion:(id <MGLOfflineRegion>)region withContext:(NSData *)con
[[strongSelf mutableArrayValueForKey:@"packs"] addObject:pack];
if (completion) {
completion(pack, error);

MGLTilePyramidOfflineRegion *tileRegion = MGL_OBJC_DYNAMIC_CAST(region, MGLTilePyramidOfflineRegion);
MGLShapeOfflineRegion *shapeRegion = MGL_OBJC_DYNAMIC_CAST(region, MGLShapeOfflineRegion);

NSDictionary *attributes;

if ([region isKindOfClass:[MGLTilePyramidOfflineRegion class]]) {
attributes = @{
@"event": MMEventTypeOfflineDownloadStart,
@"shapeForOfflineRegion": @"tileregion",
@"minZoom": [NSNumber numberWithDouble:tileRegion.minimumZoomLevel],
@"maxZoom": [NSNumber numberWithDouble:tileRegion.maximumZoomLevel],
@"styleURL": region.styleURL
};
} else {
attributes = @{
@"event": MMEventTypeOfflineDownloadStart,
@"shapeForOfflineRegion": @"shaperegion",
@"minZoom": [NSNumber numberWithDouble:shapeRegion.minimumZoomLevel],
@"maxZoom": [NSNumber numberWithDouble:shapeRegion.maximumZoomLevel],
@"styleURL": region.styleURL
};
}

[MGLMapboxEvents pushEvent:MMEventTypeOfflineDownloadStart withAttributes:attributes];
}
}];
}
Expand Down

0 comments on commit a71e3d2

Please sign in to comment.