diff options
author | Jason Wray <jason@mapbox.com> | 2016-01-13 16:38:03 -0500 |
---|---|---|
committer | Jason Wray <jason@mapbox.com> | 2016-01-20 18:57:43 -0500 |
commit | 4a3adddf3f4f833768f680d2d1e228c88f2e06e3 (patch) | |
tree | 2bd8c098631399678ddfb53f45934c533bc089ae /ios | |
parent | 27271768bd94068f53f58e030857922abc495555 (diff) | |
download | qtlocation-mapboxgl-4a3adddf3f4f833768f680d2d1e228c88f2e06e3.tar.gz |
[ios] add telemetry debug logging
You SHOULD NOT be using telemetry logging on any persons' devices who do
not explicitly understand the privacy implications of handling location
data.
Diffstat (limited to 'ios')
-rw-r--r-- | ios/app/MBXViewController.mm | 59 |
1 files changed, 42 insertions, 17 deletions
diff --git a/ios/app/MBXViewController.mm b/ios/app/MBXViewController.mm index 57817d752b..6a2b0cc3fa 100644 --- a/ios/app/MBXViewController.mm +++ b/ios/app/MBXViewController.mm @@ -144,9 +144,8 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = { delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil - otherButtonTitles:@"Reset North", - @"Reset Position", - @"Cycle debug options", + otherButtonTitles:@"Reset Position", + @"Cycle Debug Options", @"Empty Memory", @"Add 100 Points", @"Add 1,000 Points", @@ -156,6 +155,8 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = { @"Add Custom Callout Point", @"Remove Annotations", @"Toggle Custom Style Layer", + @"Print Telemetry Logfile", + @"Delete Telemetry Logfile", nil]; [sheet showFromBarButtonItem:self.navigationItem.leftBarButtonItem animated:YES]; @@ -165,33 +166,29 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = { { if (buttonIndex == actionSheet.firstOtherButtonIndex) { - [self.mapView resetNorth]; - } - else if (buttonIndex == actionSheet.firstOtherButtonIndex + 1) - { [self.mapView resetPosition]; } - else if (buttonIndex == actionSheet.firstOtherButtonIndex + 2) + else if (buttonIndex == actionSheet.firstOtherButtonIndex + 1) { [self.mapView cycleDebugOptions]; } - else if (buttonIndex == actionSheet.firstOtherButtonIndex + 3) + else if (buttonIndex == actionSheet.firstOtherButtonIndex + 2) { [self.mapView emptyMemoryCache]; } - else if (buttonIndex == actionSheet.firstOtherButtonIndex + 4) + else if (buttonIndex == actionSheet.firstOtherButtonIndex + 3) { [self parseFeaturesAddingCount:100]; } - else if (buttonIndex == actionSheet.firstOtherButtonIndex + 5) + else if (buttonIndex == actionSheet.firstOtherButtonIndex + 4) { [self parseFeaturesAddingCount:1000]; } - else if (buttonIndex == actionSheet.firstOtherButtonIndex + 6) + else if (buttonIndex == actionSheet.firstOtherButtonIndex + 5) { [self parseFeaturesAddingCount:10000]; } - else if (buttonIndex == actionSheet.firstOtherButtonIndex + 7) + else if (buttonIndex == actionSheet.firstOtherButtonIndex + 6) { // PNW triangle // @@ -258,19 +255,19 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = { free(polygonCoordinates); } } - else if (buttonIndex == actionSheet.firstOtherButtonIndex + 8) + else if (buttonIndex == actionSheet.firstOtherButtonIndex + 7) { [self startWorldTour:actionSheet]; } - else if (buttonIndex == actionSheet.firstOtherButtonIndex + 9) + else if (buttonIndex == actionSheet.firstOtherButtonIndex + 8) { [self presentAnnotationWithCustomCallout]; } - else if (buttonIndex == actionSheet.firstOtherButtonIndex + 10) + else if (buttonIndex == actionSheet.firstOtherButtonIndex + 9) { [self.mapView removeAnnotations:self.mapView.annotations]; } - else if (buttonIndex == actionSheet.firstOtherButtonIndex + 11) + else if (buttonIndex == actionSheet.firstOtherButtonIndex + 10) { if (_isShowingCustomStyleLayer) { @@ -281,6 +278,24 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = { [self insertCustomStyleLayer]; } } + else if (buttonIndex == actionSheet.firstOtherButtonIndex + 11) + { + NSString *fileContents = [NSString stringWithContentsOfFile:[self telemetryDebugLogfilePath] encoding:NSUTF8StringEncoding error:nil]; + NSLog(@"%@", fileContents); + } + else if (buttonIndex == actionSheet.firstOtherButtonIndex + 12) + { + NSString *filePath = [self telemetryDebugLogfilePath]; + if ([[NSFileManager defaultManager] isDeletableFileAtPath:filePath]) { + NSError *error; + BOOL success = [[NSFileManager defaultManager] removeItemAtPath:filePath error:&error]; + if (success) { + NSLog(@"Deleted telemetry log."); + } else { + NSLog(@"Error deleting telemetry log: %@", error.localizedDescription); + } + } + } } - (void)parseFeaturesAddingCount:(NSUInteger)featuresCount @@ -481,6 +496,16 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = { }]; } +- (NSString *)telemetryDebugLogfilePath +{ + NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; + [dateFormatter setDateFormat:@"yyyy'-'MM'-'dd"]; + [dateFormatter setTimeZone:[NSTimeZone systemTimeZone]]; + NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingPathComponent:[NSString stringWithFormat:@"telemetry_log-%@.json", [dateFormatter stringFromDate:[NSDate date]]]]; + + return filePath; +} + #pragma mark - Destruction - (void)dealloc |