diff options
author | Justin R. Miller <incanus@users.noreply.github.com> | 2015-03-27 00:14:27 -0700 |
---|---|---|
committer | Justin R. Miller <incanus@users.noreply.github.com> | 2015-03-27 00:14:27 -0700 |
commit | 177a97aaf295295eb5528a64df4a664c59ea5c2f (patch) | |
tree | 8cbff13a882d5c0e1754a9ba6420c7a125166a09 | |
parent | 4a4d9c1a2d2b4e11735f8e5ccf0d0d7df567679b (diff) | |
parent | b330dbe7790c15de2ef6ace2914dfddcceb7bebe (diff) | |
download | qtlocation-mapboxgl-177a97aaf295295eb5528a64df4a664c59ea5c2f.tar.gz |
Merge pull request #1133 from mapbox/metrics-less-magic-strings
more metrics magic strings removals
-rw-r--r-- | include/mbgl/ios/MGLMapboxEvents.h | 30 | ||||
-rw-r--r-- | platform/ios/MGLMapView.mm | 44 | ||||
-rw-r--r-- | platform/ios/MGLMapboxEvents.m | 38 | ||||
-rw-r--r-- | platform/ios/MGLMetricsLocationManager.m | 6 |
4 files changed, 65 insertions, 53 deletions
diff --git a/include/mbgl/ios/MGLMapboxEvents.h b/include/mbgl/ios/MGLMapboxEvents.h index 541f21df43..a105f33d03 100644 --- a/include/mbgl/ios/MGLMapboxEvents.h +++ b/include/mbgl/ios/MGLMapboxEvents.h @@ -1,16 +1,24 @@ #import <Foundation/Foundation.h> -extern NSString *const MGLEventMapLoad; -extern NSString *const MGLEventMapTap; -extern NSString *const MGLEventMapSingleTap; -extern NSString *const MGLEventMapDoubleTap; -extern NSString *const MGLEventMapTwoFingerSingleTap; -extern NSString *const MGLEventMapQuickZoom; -extern NSString *const MGLEventMapPanStart; -extern NSString *const MGLEventMapPanEnd; -extern NSString *const MGLEventMapPinchStart; -extern NSString *const MGLEventMapRotateStart; -extern NSString *const MGLEventMapLocation; +extern NSString *const MGLEventTypeMapLoad; +extern NSString *const MGLEventTypeMapTap; +extern NSString *const MGLEventTypeMapDragEnd; +extern NSString *const MGLEventTypeLocation; + +extern NSString *const MGLEventKeyLatitude; +extern NSString *const MGLEventKeyLongitude; +extern NSString *const MGLEventKeyZoomLevel; +extern NSString *const MGLEventKeyPushEnabled; +extern NSString *const MGLEventKeyEmailEnabled; +extern NSString *const MGLEventKeyGestureID; + +extern NSString *const MGLEventGestureSingleTap; +extern NSString *const MGLEventGestureDoubleTap; +extern NSString *const MGLEventGestureTwoFingerSingleTap; +extern NSString *const MGLEventGestureQuickZoom; +extern NSString *const MGLEventGesturePanStart; +extern NSString *const MGLEventGesturePinchStart; +extern NSString *const MGLEventGestureRotateStart; @interface MGLMapboxEvents : NSObject diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index 92367a3cf2..8466303ed5 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -355,12 +355,12 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr; const mbgl::LatLng latLng = mbglMap->getLatLng(); const double zoom = mbglMap->getZoom(); - [MGLMapboxEvents pushEvent:MGLEventMapLoad withAttributes:@{ - @"lat": @(latLng.latitude), - @"lng": @(latLng.longitude), - @"zoom": @(zoom), - @"enabled.push": @([MGLMapboxEvents checkPushEnabled]), - @"enabled.email": [MGLMapboxEvents checkEmailEnabled] + [MGLMapboxEvents pushEvent:MGLEventTypeMapLoad withAttributes:@{ + MGLEventKeyLatitude: @(latLng.latitude), + MGLEventKeyLongitude: @(latLng.longitude), + MGLEventKeyZoomLevel: @(zoom), + MGLEventKeyPushEnabled: @([MGLMapboxEvents checkPushEnabled]), + MGLEventKeyEmailEnabled: [MGLMapboxEvents checkEmailEnabled] }]; return YES; @@ -586,7 +586,7 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr; - (void)handlePanGesture:(UIPanGestureRecognizer *)pan { - [self trackGestureEvent:MGLEventMapPanStart forRecognizer:pan]; + [self trackGestureEvent:MGLEventGesturePanStart forRecognizer:pan]; if ( ! self.isScrollEnabled) return; @@ -653,17 +653,17 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr; CLLocationCoordinate2D panCoordinate = [self convertPoint:pointInView toCoordinateFromView:pan.view]; double zoom = [self zoomLevel]; - [MGLMapboxEvents pushEvent:MGLEventMapPanEnd withAttributes:@{ - @"lat": @(panCoordinate.latitude), - @"lng": @(panCoordinate.longitude), - @"zoom": @(zoom) + [MGLMapboxEvents pushEvent:MGLEventTypeMapDragEnd withAttributes:@{ + MGLEventKeyLatitude: @(panCoordinate.latitude), + MGLEventKeyLongitude: @(panCoordinate.longitude), + MGLEventKeyZoomLevel: @(zoom) }]; } } - (void)handlePinchGesture:(UIPinchGestureRecognizer *)pinch { - [self trackGestureEvent:MGLEventMapPinchStart forRecognizer:pinch]; + [self trackGestureEvent:MGLEventGesturePinchStart forRecognizer:pinch]; if ( ! self.isZoomEnabled) return; @@ -701,7 +701,7 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr; - (void)handleRotateGesture:(UIRotationGestureRecognizer *)rotate { - [self trackGestureEvent:MGLEventMapRotateStart forRecognizer:rotate]; + [self trackGestureEvent:MGLEventGestureRotateStart forRecognizer:rotate]; if ( ! self.isRotateEnabled) return; @@ -743,7 +743,7 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr; - (void)handleSingleTapGesture:(UITapGestureRecognizer *)singleTap { - [self trackGestureEvent:MGLEventMapSingleTap forRecognizer:singleTap]; + [self trackGestureEvent:MGLEventGestureSingleTap forRecognizer:singleTap]; CGPoint tapPoint = [singleTap locationInView:self]; @@ -866,7 +866,7 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr; - (void)handleDoubleTapGesture:(UITapGestureRecognizer *)doubleTap { - [self trackGestureEvent:MGLEventMapDoubleTap forRecognizer:doubleTap]; + [self trackGestureEvent:MGLEventGestureDoubleTap forRecognizer:doubleTap]; if ( ! self.isZoomEnabled) return; @@ -897,7 +897,7 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr; - (void)handleTwoFingerTapGesture:(UITapGestureRecognizer *)twoFingerTap { - [self trackGestureEvent:MGLEventMapTwoFingerSingleTap forRecognizer:twoFingerTap]; + [self trackGestureEvent:MGLEventGestureTwoFingerSingleTap forRecognizer:twoFingerTap]; if ( ! self.isZoomEnabled) return; @@ -930,7 +930,7 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr; - (void)handleQuickZoomGesture:(UILongPressGestureRecognizer *)quickZoom { - [self trackGestureEvent:MGLEventMapQuickZoom forRecognizer:quickZoom]; + [self trackGestureEvent:MGLEventGestureQuickZoom forRecognizer:quickZoom]; if ( ! self.isZoomEnabled) return; @@ -984,11 +984,11 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr; CLLocationCoordinate2D gestureCoordinate = [self convertPoint:pointInView toCoordinateFromView:recognizer.view]; double zoom = [self zoomLevel]; - [MGLMapboxEvents pushEvent:MGLEventMapTap withAttributes:@{ - @"lat": @(gestureCoordinate.latitude), - @"lng": @(gestureCoordinate.longitude), - @"zoom": @(zoom), - @"gesture": gestureID + [MGLMapboxEvents pushEvent:MGLEventTypeMapTap withAttributes:@{ + MGLEventKeyLatitude: @(gestureCoordinate.latitude), + MGLEventKeyLongitude: @(gestureCoordinate.longitude), + MGLEventKeyZoomLevel: @(zoom), + MGLEventKeyGestureID: gestureID }]; } diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m index 39470a97ff..a38251541b 100644 --- a/platform/ios/MGLMapboxEvents.m +++ b/platform/ios/MGLMapboxEvents.m @@ -12,17 +12,25 @@ static NSString *const MGLMapboxEventsUserAgent = @"MapboxEventsiOS/1.0"; static NSString *const MGLMapboxEventsAPIBase = @"https://api.tiles.mapbox.com"; -NSString *const MGLEventMapLoad = @"map.load"; -NSString *const MGLEventMapTap = @"map.click"; -NSString *const MGLEventMapSingleTap = @"SingleTap"; -NSString *const MGLEventMapDoubleTap = @"DoubleTap"; -NSString *const MGLEventMapTwoFingerSingleTap = @"TwoFingerTap"; -NSString *const MGLEventMapQuickZoom = @"QuickZoom"; -NSString *const MGLEventMapPanStart = @"Pan"; -NSString *const MGLEventMapPanEnd = @"map.dragend"; -NSString *const MGLEventMapPinchStart = @"Pinch"; -NSString *const MGLEventMapRotateStart = @"Rotation"; -NSString *const MGLEventMapLocation = @"Location"; +NSString *const MGLEventTypeMapLoad = @"map.load"; +NSString *const MGLEventTypeMapTap = @"map.click"; +NSString *const MGLEventTypeMapDragEnd = @"map.dragend"; +NSString *const MGLEventTypeLocation = @"Location"; + +NSString *const MGLEventKeyLatitude = @"lat"; +NSString *const MGLEventKeyLongitude = @"lng"; +NSString *const MGLEventKeyZoomLevel = @"zoom"; +NSString *const MGLEventKeyPushEnabled = @"enabled.push"; +NSString *const MGLEventKeyEmailEnabled = @"enabled.email"; +NSString *const MGLEventKeyGestureID = @"gesture"; + +NSString *const MGLEventGestureSingleTap = @"SingleTap"; +NSString *const MGLEventGestureDoubleTap = @"DoubleTap"; +NSString *const MGLEventGestureTwoFingerSingleTap = @"TwoFingerTap"; +NSString *const MGLEventGestureQuickZoom = @"QuickZoom"; +NSString *const MGLEventGesturePanStart = @"Pan"; +NSString *const MGLEventGesturePinchStart = @"Pinch"; +NSString *const MGLEventGestureRotateStart = @"Rotation"; // // Threadsafety conventions: @@ -233,7 +241,7 @@ NSString *const MGLEventMapLocation = @"Location"; if (!event) return; - NSMutableDictionary *evt = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *evt = [[NSMutableDictionary alloc] initWithDictionary:attributeDictionary]; // mapbox-events stock attributes [evt setObject:event forKey:@"event"]; [evt setObject:@(1) forKey:@"version"]; @@ -252,11 +260,7 @@ NSString *const MGLEventMapLocation = @"Location"; [evt setValue:[weakSelf getCurrentCellularNetworkConnectionType] forKey:@"cellularNetworkType"]; [evt setValue:[weakSelf getWifiNetworkName] forKey:@"wifi"]; [evt setValue:@([weakSelf getContentSizeScale]) forKey:@"accessibilityFontScale"]; - - for (NSString *key in [attributeDictionary allKeys]) { - [evt setObject:[attributeDictionary valueForKey:key] forKey:key]; - } - + // Make Immutable Version NSDictionary *finalEvent = [NSDictionary dictionaryWithDictionary:evt]; diff --git a/platform/ios/MGLMetricsLocationManager.m b/platform/ios/MGLMetricsLocationManager.m index bdf6e14ae9..c0ff740b3a 100644 --- a/platform/ios/MGLMetricsLocationManager.m +++ b/platform/ios/MGLMetricsLocationManager.m @@ -43,9 +43,9 @@ - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { // Iterate through locations to pass all data for (CLLocation *loc in locations) { - [MGLMapboxEvents pushEvent:MGLEventMapLocation withAttributes:@{ - @"lat": @(loc.coordinate.latitude), - @"lng": @(loc.coordinate.longitude) + [MGLMapboxEvents pushEvent:MGLEventTypeLocation withAttributes:@{ + MGLEventKeyLatitude: @(loc.coordinate.latitude), + MGLEventKeyLongitude: @(loc.coordinate.longitude) }]; } } |