Brion VIBBER has submitted this change and it was merged.
Change subject: Added more logging events.
......................................................................
Added more logging events.
Fixed bug where edit right arrow tap after captcha or
abuse filter messages were shown would cause the
sign-on/save-anon choice buttons to be presented
again instead of taking proper progressive action.
Change-Id: I675dd35bdb931f610f7a6bb4982ff23255a2c34d
---
M wikipedia/Categories/UIViewController+LogEvent.h
M wikipedia/Categories/UIViewController+LogEvent.m
M wikipedia/Data/Operations/LogEventOp.m
M wikipedia/View Controllers/AccountCreation/AccountCreationViewController.m
M wikipedia/View Controllers/Login/LoginViewController.m
M wikipedia/View Controllers/Preview/PreviewAndSaveViewController.m
M wikipedia/View Controllers/TopNav/NavController.h
M wikipedia/View Controllers/TopNav/NavController.m
M wikipedia/View Controllers/WebView/WebViewController.m
9 files changed, 159 insertions(+), 7 deletions(-)
Approvals:
Brion VIBBER: Verified; Looks good to me, approved
diff --git a/wikipedia/Categories/UIViewController+LogEvent.h
b/wikipedia/Categories/UIViewController+LogEvent.h
index 8bb5785..cb099b3 100644
--- a/wikipedia/Categories/UIViewController+LogEvent.h
+++ b/wikipedia/Categories/UIViewController+LogEvent.h
@@ -6,6 +6,7 @@
@interface UIViewController (LogEvent)
--(void)logEvent:(NSDictionary *)event schema:(EventLogSchema)schema;
+-(void)logEvent: (NSDictionary *)event
+ schema: (EventLogSchema)schema;
@end
diff --git a/wikipedia/Categories/UIViewController+LogEvent.m
b/wikipedia/Categories/UIViewController+LogEvent.m
index 35b61d3..58febfe 100644
--- a/wikipedia/Categories/UIViewController+LogEvent.m
+++ b/wikipedia/Categories/UIViewController+LogEvent.m
@@ -6,9 +6,12 @@
@implementation UIViewController (LogEvent)
--(void)logEvent:(NSDictionary *)event schema:(EventLogSchema)schema
+-(void)logEvent: (NSDictionary *)event
+ schema: (EventLogSchema)schema
{
- LogEventOp *logOp = [[LogEventOp alloc] initWithSchema:schema event:event];
+ LogEventOp *logOp = [[LogEventOp alloc] initWithSchema: schema
+ event: event];
+
[[QueuesSingleton sharedInstance].eventLoggingQ addOperation:logOp];
}
diff --git a/wikipedia/Data/Operations/LogEventOp.m
b/wikipedia/Data/Operations/LogEventOp.m
index addfff7..31b9083 100644
--- a/wikipedia/Data/Operations/LogEventOp.m
+++ b/wikipedia/Data/Operations/LogEventOp.m
@@ -7,6 +7,8 @@
#define LOG_ENDPOINT @"https://bits.wikimedia.org/event.gif"
+//#define LOG_ENDPOINT @"http://localhost:8000/event.gif"
+
@implementation LogEventOp
-(NSDictionary *)getSchemaData
diff --git a/wikipedia/View
Controllers/AccountCreation/AccountCreationViewController.m b/wikipedia/View
Controllers/AccountCreation/AccountCreationViewController.m
index f27baa2..7df4311 100644
--- a/wikipedia/View Controllers/AccountCreation/AccountCreationViewController.m
+++ b/wikipedia/View Controllers/AccountCreation/AccountCreationViewController.m
@@ -15,6 +15,7 @@
#import "LoginViewController.h"
#import "UINavigationController+SearchNavStack.h"
#import "WMF_Colors.h"
+#import "UIViewController+LogEvent.h"
#define NAV ((NavController *)self.navigationController)
@@ -71,6 +72,9 @@
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(navItemTappedNotification:) name:@"NavItemTapped"
object:nil];
[self.usernameField becomeFirstResponder];
+
+ [self logEvent: @{@"action": @"start"}
+ schema: LOG_SCHEMA_CREATEACCOUNT];
//[self prepopulateTextFieldsForDebugging];
}
@@ -153,7 +157,11 @@
if (_showCaptchaContainer != showCaptchaContainer) {
_showCaptchaContainer = showCaptchaContainer;
if (showCaptchaContainer){
- [self.captchaViewController.captchaTextBox
performSelector:@selector(becomeFirstResponder) withObject:nil afterDelay:0.4f];
+ [self.captchaViewController.captchaTextBox performSelector:
@selector(becomeFirstResponder)
+ withObject: nil
afterDelay:0.4f];
+
+ [self logEvent: @{@"action": @"captchaShown"}
+ schema: LOG_SCHEMA_CREATEACCOUNT];
}
}
}
@@ -312,6 +320,9 @@
//NSLog(@"AccountCreationOp result = %@",
result);
+ [self logEvent: @{@"action":
@"accountCreated"}
+ schema: LOG_SCHEMA_CREATEACCOUNT];
+
dispatch_async(dispatch_get_main_queue(),
^(){
[self showAlert:result];
[self showAlert:@""];
@@ -327,6 +338,12 @@
} errorBlock: ^(NSError *error){
[self showAlert:error.localizedDescription];
+ [self logEvent: @{@"action": @"error"}
+ schema: LOG_SCHEMA_CREATEACCOUNT];
+
+ [self logEvent: @{@"errorText":
error.localizedDescription}
+ schema: LOG_SCHEMA_CREATEACCOUNT];
+
switch (error.code) {
case
ACCOUNT_CREATION_ERROR_NEEDS_CAPTCHA:{
self.captchaId =
error.userInfo[@"captchaId"];
diff --git a/wikipedia/View Controllers/Login/LoginViewController.m
b/wikipedia/View Controllers/Login/LoginViewController.m
index 96fd8f9..4be9318 100644
--- a/wikipedia/View Controllers/Login/LoginViewController.m
+++ b/wikipedia/View Controllers/Login/LoginViewController.m
@@ -13,6 +13,7 @@
#import "AccountCreationViewController.h"
#import "UIButton+ColorMask.h"
#import "WMF_Colors.h"
+#import "UIViewController+LogEvent.h"
#define NAV ((NavController *)self.navigationController)
@@ -125,10 +126,26 @@
// Listen for nav bar taps.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(navItemTappedNotification:) name:@"NavItemTapped"
object:nil];
+
+ [self logEvent: @{@"action": @"start"}
+ schema: LOG_SCHEMA_LOGIN];
+
+ if (NAV.isEditorOnNavstack) {
+ [self logEvent: @{@"source": @"edit"}
+ schema: LOG_SCHEMA_LOGIN];
+ }else{
+ [self logEvent: @{@"source": @"navigation"}
+ schema: LOG_SCHEMA_LOGIN];
+ }
}
-(void)save
{
+ if (NAV.isEditorOnNavstack) {
+ [self logEvent: @{@"action": @"loginAttempt"}
+ schema: LOG_SCHEMA_EDIT];
+ }
+
[self loginWithUserName: self.usernameField.text
password: self.passwordField.text
onSuccess: ^{
@@ -203,6 +220,14 @@
[self cloneSessionCookies];
//printCookies();
+
+ [self logEvent: @{@"action": @"login"}
+ schema: LOG_SCHEMA_LOGIN];
+
+ if (NAV.isEditorOnNavstack) {
+ [self logEvent: @{@"action": @"loginSuccess"}
+ schema: LOG_SCHEMA_EDIT];
+ }
} cancelledBlock: ^(NSError *error){
@@ -216,6 +241,16 @@
[self showAlert:error.localizedDescription];
[[NSOperationQueue mainQueue]
addOperationWithBlock:failBlock];
+
+
+ [self logEvent: @{@"action": @"error"}
+ schema: LOG_SCHEMA_LOGIN];
+
+ if (NAV.isEditorOnNavstack) {
+ [self logEvent: @{@"action": @"loginFailure"}
+ schema: LOG_SCHEMA_EDIT];
+ }
+
}];
@@ -228,6 +263,9 @@
NSLog(@"loginTokenOp token = %@",
tokenRetrieved);
loginOp.token = tokenRetrieved;
+ [self logEvent: @{@"loginSessionToken":
tokenRetrieved}
+ schema: LOG_SCHEMA_LOGIN];
+
} cancelledBlock: ^(NSError *error){
[self showAlert:@""];
@@ -239,6 +277,10 @@
[self showAlert:error.localizedDescription];
[[NSOperationQueue mainQueue]
addOperationWithBlock:failBlock];
+
+ [self logEvent: @{@"errorText":
error.localizedDescription}
+ schema: LOG_SCHEMA_LOGIN];
+
}];
@@ -278,6 +320,9 @@
- (IBAction)createAccountButtonPushed:(id)sender
{
+ [self logEvent: @{@"action": @"createAccountAttempt"}
+ schema: LOG_SCHEMA_LOGIN];
+
AccountCreationViewController *createAcctVC =
[self.navigationController.storyboard
instantiateViewControllerWithIdentifier:@"AccountCreationViewController"];
[self.navigationController pushViewController:createAcctVC animated:YES];
}
diff --git a/wikipedia/View Controllers/Preview/PreviewAndSaveViewController.m
b/wikipedia/View Controllers/Preview/PreviewAndSaveViewController.m
index 44deed1..37bc1b7 100644
--- a/wikipedia/View Controllers/Preview/PreviewAndSaveViewController.m
+++ b/wikipedia/View Controllers/Preview/PreviewAndSaveViewController.m
@@ -25,6 +25,7 @@
#import "Defines.h"
#import "WMF_Colors.h"
#import "CommunicationBridge.h"
+#import "UIViewController+LogEvent.h"
#define NAV ((NavController *)self.navigationController)
@@ -81,11 +82,23 @@
switch (tappedItem.tag) {
case NAVBAR_BUTTON_ARROW_LEFT:
[self.navigationController popViewControllerAnimated:YES];
+
+ if(NAV.navBarMode == NAVBAR_MODE_EDIT_WIKITEXT_WARNING){
+ [self logEvent: @{@"action": @"abuseFilterWarningBack"}
+ schema: LOG_SCHEMA_EDIT];
+ }
+
break;
case NAVBAR_BUTTON_CHECK:
case NAVBAR_BUTTON_ARROW_RIGHT: /* for captcha submit button */
{
[self saveOrShowSignInActionSheetIfNotLoggedIn];
+
+ if(NAV.navBarMode == NAVBAR_MODE_EDIT_WIKITEXT_WARNING){
+ [self logEvent: @{@"action": @"abuseFilterWarningIgnore"}
+ schema: LOG_SCHEMA_EDIT];
+ }
+
}
break;
default:
@@ -117,6 +130,9 @@
object: nil];
self.previewWebViewBottomConstraint.constant =
EDIT_SUMMARY_DOCK_DISTANCE_FROM_BOTTOM;
+
+ [self logEvent: @{@"action": @"preview"}
+ schema: LOG_SCHEMA_EDIT];
}
-(void)htmlAlertWasHidden
@@ -272,6 +288,10 @@
}
break;
case TOP_ACTION_SHEET_SAVE:
+
+ [self logEvent: @{@"action": @"saveAnonExplicit"}
+ schema: LOG_SCHEMA_EDIT];
+
[self save];
break;
default:
@@ -284,7 +304,15 @@
- (void)saveOrShowSignInActionSheetIfNotLoggedIn
{
- if(![SessionSingleton sharedInstance].keychainCredentials.userName){
+ if(
+ ![SessionSingleton sharedInstance].keychainCredentials.userName
+ &&
+ !(NAV.navBarMode == NAVBAR_MODE_EDIT_WIKITEXT_CAPTCHA)
+ &&
+ !(NAV.navBarMode == NAVBAR_MODE_EDIT_WIKITEXT_WARNING)
+ &&
+ !(NAV.navBarMode == NAVBAR_MODE_EDIT_WIKITEXT_DISALLOW)
+ ){
NAV.navBarMode = NAVBAR_MODE_EDIT_WIKITEXT_LOGIN_OR_SAVE_ANONYMOUSLY;
@@ -316,6 +344,15 @@
- (void)save
{
+ [self logEvent: @{@"action": @"save"}
+ schema: LOG_SCHEMA_EDIT];
+
+ NSString *userName = [SessionSingleton
sharedInstance].keychainCredentials.userName;
+ if (userName) {
+ [self logEvent: @{@"userName": userName}
+ schema: LOG_SCHEMA_EDIT];
+ }
+
NSString *editSummary = [self.editSummaryViewController getSummary];
// Use static flag to prevent save when save already in progress.
@@ -343,6 +380,11 @@
}];
}
+ if(NAV.navBarMode == NAVBAR_MODE_EDIT_WIKITEXT_CAPTCHA){
+ [self logEvent: @{@"action": @"captchaSolve"}
+ schema: LOG_SCHEMA_EDIT];
+ }
+
} cancelledBlock:^(NSError *error){
NSString *errorMsg = error.localizedDescription;
[self showAlert:errorMsg];
@@ -356,6 +398,12 @@
switch (error.code) {
case WIKITEXT_UPLOAD_ERROR_NEEDS_CAPTCHA:
{
+
+ if(NAV.navBarMode == NAVBAR_MODE_EDIT_WIKITEXT_CAPTCHA){
+ [self logEvent: @{@"action": @"captchaFailure"}
+ schema: LOG_SCHEMA_EDIT];
+ }
+
// If the server said a captcha was required, present the
captcha image.
NSString *captchaUrl = error.userInfo[@"captchaUrl"];
NSString *captchaId = error.userInfo[@"captchaId"];
@@ -418,10 +466,18 @@
NAV.navBarMode = NAVBAR_MODE_EDIT_WIKITEXT_DISALLOW;
bannerImage = @"abuse-filter-disallowed.png";
bannerColor = WMF_COLOR_RED;
+
+ [self logEvent: @{@"action": @"abuseFilterError"}
+ schema: LOG_SCHEMA_EDIT];
+
}else{
NAV.navBarMode = NAVBAR_MODE_EDIT_WIKITEXT_WARNING;
bannerImage = @"abuse-filter-flag-white.png";
bannerColor = WMF_COLOR_ORANGE;
+
+ [self logEvent: @{@"action": @"abuseFilterWarning"}
+ schema: LOG_SCHEMA_EDIT];
+
}
NSString *restyledWarningHtml = [self
restyleAbuseFilterWarningHtml:warningHtml];
@@ -432,6 +488,17 @@
];
});
}
+ break;
+
+ case WIKITEXT_UPLOAD_ERROR_SERVER:
+ case WIKITEXT_UPLOAD_ERROR_UNKNOWN:
+
+ [self logEvent: @{@"action": @"error"}
+ schema: LOG_SCHEMA_EDIT];
+
+ [self logEvent: @{@"errorText": error.localizedDescription}
+ schema: LOG_SCHEMA_EDIT];
+
break;
default:
@@ -456,6 +523,9 @@
//NSLog(@"article.domain = %@",
article.domain);
editTokens[article.domain] = editToken;
[SessionSingleton
sharedInstance].keychainCredentials.editTokens = editTokens;
+
+ [self logEvent: @{@"editSessionToken":
editToken}
+ schema: LOG_SCHEMA_EDIT];
}
}];
}
@@ -527,6 +597,9 @@
-(void)revealCaptcha
{
+ [self logEvent: @{@"action": @"captchaShown"}
+ schema: LOG_SCHEMA_EDIT];
+
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.35];
[UIView setAnimationTransition: UIViewAnimationTransitionNone
diff --git a/wikipedia/View Controllers/TopNav/NavController.h b/wikipedia/View
Controllers/TopNav/NavController.h
index 399b111..28c0f20 100644
--- a/wikipedia/View Controllers/TopNav/NavController.h
+++ b/wikipedia/View Controllers/TopNav/NavController.h
@@ -47,6 +47,7 @@
@property (nonatomic) NavBarStyle navBarStyle;
@property (nonatomic) NavBarMode navBarMode;
+@property (nonatomic, readonly) BOOL isEditorOnNavstack;
-(id)getNavBarItem:(NavBarItemTag)tag;
diff --git a/wikipedia/View Controllers/TopNav/NavController.m b/wikipedia/View
Controllers/TopNav/NavController.m
index 7e15691..8195975 100644
--- a/wikipedia/View Controllers/TopNav/NavController.m
+++ b/wikipedia/View Controllers/TopNav/NavController.m
@@ -19,6 +19,7 @@
#import "SessionSingleton.h"
#import "WebViewController.h"
#import "UIView+TemporaryAnimatedXF.h"
+#import "SectionEditorViewController.h"
@interface NavController (){
@@ -791,4 +792,12 @@
}
}
+#pragma mark Is editing
+
+-(BOOL)isEditorOnNavstack
+{
+ id editVC = [self
searchNavStackForViewControllerOfClass:[SectionEditorViewController class]];
+ return editVC ? YES : NO;
+}
+
@end
diff --git a/wikipedia/View Controllers/WebView/WebViewController.m
b/wikipedia/View Controllers/WebView/WebViewController.m
index d7bef80..e93ad9c 100644
--- a/wikipedia/View Controllers/WebView/WebViewController.m
+++ b/wikipedia/View Controllers/WebView/WebViewController.m
@@ -184,6 +184,9 @@
-(void)showSectionEditor
{
+ [self logEvent: @{@"action": @"start"}
+ schema: LOG_SCHEMA_EDIT];
+
SectionEditorViewController *sectionEditVC =
[self.navigationController.storyboard
instantiateViewControllerWithIdentifier:@"SectionEditorViewController"];
@@ -608,8 +611,6 @@
[self.bridge addListener:@"editClicked" withBlock:^(NSString *messageType,
NSDictionary *payload) {
[weakSelf tocHide];
weakSelf.sectionToEditIndex = [[payload[@"href"]
stringByReplacingOccurrencesOfString:@"edit_section_" withString:@""]
integerValue];
-
- [weakSelf logEvent:@{@"action": @"start"} schema:LOG_SCHEMA_EDIT];
[weakSelf.self showSectionEditor];
}];
--
To view, visit https://gerrit.wikimedia.org/r/125935
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I675dd35bdb931f610f7a6bb4982ff23255a2c34d
Gerrit-PatchSet: 3
Gerrit-Project: apps/ios/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Mhurd <[email protected]>
Gerrit-Reviewer: Brion VIBBER <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits