Brion VIBBER has uploaded a new change for review. https://gerrit.wikimedia.org/r/141926
Change subject: Work in progress: EventLogging opt-out switch ...................................................................... Work in progress: EventLogging opt-out switch todo: * show the subtitle text * i18n Change-Id: Iffd3ce1be2abd25005fbc1cca08fa3a9af887558 --- M wikipedia/AppDelegate.m M wikipedia/Data/Operations/DownloadSectionsOp.m M wikipedia/EventLogging/EventLoggingFunnel.m M wikipedia/Session/SessionSingleton.h M wikipedia/Session/SessionSingleton.m M wikipedia/View Controllers/Navigation/Secondary/SecondaryMenuViewController.m 6 files changed, 43 insertions(+), 11 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/apps/ios/wikipedia refs/changes/26/141926/1 diff --git a/wikipedia/AppDelegate.m b/wikipedia/AppDelegate.m index d36a165..df18e94 100644 --- a/wikipedia/AppDelegate.m +++ b/wikipedia/AppDelegate.m @@ -58,7 +58,8 @@ @"ZeroOnDialogShownOnce" : @NO, @"ZeroOffDialogShownOnce" : @NO, @"FakeZeroOn" : @NO, - @"LastHousekeepingDate" : [NSDate date] //[NSDate dateWithDaysBeforeNow:10] + @"LastHousekeepingDate" : [NSDate date], //[NSDate dateWithDaysBeforeNow:10] + @"SendUsageReports": @YES }; [[NSUserDefaults standardUserDefaults] registerDefaults:userDefaultsDefaults]; } diff --git a/wikipedia/Data/Operations/DownloadSectionsOp.m b/wikipedia/Data/Operations/DownloadSectionsOp.m index 2d35e3d..e79a130 100644 --- a/wikipedia/Data/Operations/DownloadSectionsOp.m +++ b/wikipedia/Data/Operations/DownloadSectionsOp.m @@ -43,8 +43,10 @@ params[@"sections"] = @"0"; - ReadingActionFunnel *funnel = [[ReadingActionFunnel alloc] init]; - params[@"appInstallID"] = funnel.appInstallID; + if ([SessionSingleton sharedInstance].sendUsageReports) { + ReadingActionFunnel *funnel = [[ReadingActionFunnel alloc] init]; + params[@"appInstallID"] = funnel.appInstallID; + } } self.request = [NSURLRequest getRequestWithURL: [[SessionSingleton sharedInstance] urlForDomain:domain] diff --git a/wikipedia/EventLogging/EventLoggingFunnel.m b/wikipedia/EventLogging/EventLoggingFunnel.m index 5d63b2b..2ebaa11 100644 --- a/wikipedia/EventLogging/EventLoggingFunnel.m +++ b/wikipedia/EventLogging/EventLoggingFunnel.m @@ -9,7 +9,7 @@ #import "EventLoggingFunnel.h" #import "LogEventOp.h" #import "QueuesSingleton.h" - +#import "SessionSingleton.h" @implementation EventLoggingFunnel @@ -29,11 +29,13 @@ -(void)log:(NSDictionary *)eventData { - LogEventOp *logOp = [[LogEventOp alloc] initWithSchema: self.schema - revision: self.revision - event: [self preprocessData:eventData]]; - - [[QueuesSingleton sharedInstance].eventLoggingQ addOperation:logOp]; + if ([SessionSingleton sharedInstance].sendUsageReports) { + LogEventOp *logOp = [[LogEventOp alloc] initWithSchema: self.schema + revision: self.revision + event: [self preprocessData:eventData]]; + + [[QueuesSingleton sharedInstance].eventLoggingQ addOperation:logOp]; + } } -(NSString *)singleUseUUID diff --git a/wikipedia/Session/SessionSingleton.h b/wikipedia/Session/SessionSingleton.h index eec1fe1..0459157 100644 --- a/wikipedia/Session/SessionSingleton.h +++ b/wikipedia/Session/SessionSingleton.h @@ -9,8 +9,10 @@ @interface SessionSingleton : NSObject +// Persistent settings and credentials @property (strong, nonatomic) KeychainCredentials *keychainCredentials; @property (strong, nonatomic) ZeroConfigState *zeroConfigState; +@property (nonatomic) BOOL sendUsageReports; // These 6 persist across app restarts. @property (strong, nonatomic) NSString *site; diff --git a/wikipedia/Session/SessionSingleton.m b/wikipedia/Session/SessionSingleton.m index d5a157e..49e41c4 100644 --- a/wikipedia/Session/SessionSingleton.m +++ b/wikipedia/Session/SessionSingleton.m @@ -158,4 +158,16 @@ return ([self.currentArticleTitle isEqualToString: mainArticleTitle]); } +-(BOOL)sendUsageReports +{ + NSNumber *val = [[NSUserDefaults standardUserDefaults] objectForKey:@"SendUsageReports"]; + return [val boolValue]; +} + +-(void)setSendUsageReports:(BOOL)sendUsageReports +{ + [[NSUserDefaults standardUserDefaults] setObject:@(sendUsageReports) forKey:@"SendUsageReports"]; +} + + @end diff --git a/wikipedia/View Controllers/Navigation/Secondary/SecondaryMenuViewController.m b/wikipedia/View Controllers/Navigation/Secondary/SecondaryMenuViewController.m index 2f0bd1d..d944210 100644 --- a/wikipedia/View Controllers/Navigation/Secondary/SecondaryMenuViewController.m +++ b/wikipedia/View Controllers/Navigation/Secondary/SecondaryMenuViewController.m @@ -45,7 +45,8 @@ SECONDARY_MENU_ROW_INDEX_ZERO_WARN_WHEN_LEAVING = 6, SECONDARY_MENU_ROW_INDEX_SEND_FEEDBACK = 7, SECONDARY_MENU_ROW_INDEX_PAGE_HISTORY = 8, - SECONDARY_MENU_ROW_INDEX_CREDITS = 9 + SECONDARY_MENU_ROW_INDEX_CREDITS = 9, + SECONDARY_MENU_ROW_INDEX_SEND_USAGE_REPORTS = 10 } SecondaryMenuRowIndex; #pragma mark - Private @@ -360,6 +361,14 @@ }.mutableCopy , @{ + @"title": @"Send usage reports", + @"subtitle": @"Allow Wikimedia to collect information about how you use the app to make the app better", + @"tag": @(SECONDARY_MENU_ROW_INDEX_SEND_USAGE_REPORTS), + @"icon": WIKIGLYPH_FLAG, + @"highlighted": @([SessionSingleton sharedInstance].sendUsageReports), + }.mutableCopy + , + @{ @"title": MWLocalizedString(@"zero-warn-when-leaving", nil), @"tag": @(SECONDARY_MENU_ROW_INDEX_ZERO_WARN_WHEN_LEAVING), @"icon": WIKIGLYPH_FLAG, @@ -413,7 +422,8 @@ NSDictionary *userInfo = [notification userInfo]; SecondaryMenuRowView *tappedItem = userInfo[@"tappedItem"]; - if (tappedItem.tag == SECONDARY_MENU_ROW_INDEX_ZERO_WARN_WHEN_LEAVING) animationDuration = 0.0f; + if (tappedItem.tag == SECONDARY_MENU_ROW_INDEX_ZERO_WARN_WHEN_LEAVING + || tappedItem.tag == SECONDARY_MENU_ROW_INDEX_SEND_USAGE_REPORTS) animationDuration = 0.0f; void(^performTapAction)() = ^(){ @@ -458,6 +468,9 @@ case SECONDARY_MENU_ROW_INDEX_ZERO_WARN_WHEN_LEAVING: [[SessionSingleton sharedInstance].zeroConfigState toggleWarnWhenLeaving]; break; + case SECONDARY_MENU_ROW_INDEX_SEND_USAGE_REPORTS: + [SessionSingleton sharedInstance].sendUsageReports = ![SessionSingleton sharedInstance].sendUsageReports; + break; case SECONDARY_MENU_ROW_INDEX_SEND_FEEDBACK: { NSString *mailtoUri = -- To view, visit https://gerrit.wikimedia.org/r/141926 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iffd3ce1be2abd25005fbc1cca08fa3a9af887558 Gerrit-PatchSet: 1 Gerrit-Project: apps/ios/wikipedia Gerrit-Branch: master Gerrit-Owner: Brion VIBBER <br...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits