Mhurd has uploaded a new change for review. https://gerrit.wikimedia.org/r/125551
Change subject: First pass at event logging infrastructure. ...................................................................... First pass at event logging infrastructure. In this commit the only event being logged is the edit start. Change-Id: Ibaa292f1753caa2e547e15c73a60f92ecbcb7fb4 --- M Wikipedia.xcodeproj/project.pbxproj A wikipedia/Categories/UIViewController+LogEvent.h A wikipedia/Categories/UIViewController+LogEvent.m A wikipedia/Data/Operations/LogEventOp.h A wikipedia/Data/Operations/LogEventOp.m M wikipedia/Queues/QueuesSingleton.h M wikipedia/Queues/QueuesSingleton.m M wikipedia/View Controllers/WebView/WebViewController.m 8 files changed, 152 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/apps/ios/wikipedia refs/changes/51/125551/1 diff --git a/Wikipedia.xcodeproj/project.pbxproj b/Wikipedia.xcodeproj/project.pbxproj index 308b0b8..72dee5e 100644 --- a/Wikipedia.xcodeproj/project.pbxproj +++ b/Wikipedia.xcodeproj/project.pbxproj @@ -9,6 +9,8 @@ /* Begin PBXBuildFile section */ 0400EB0318AAEEC60043ECE2 /* UINavigationController+SearchNavStack.m in Sources */ = {isa = PBXBuildFile; fileRef = 0400EB0218AAEEC60043ECE2 /* UINavigationController+SearchNavStack.m */; }; 0402E10F18A3ABA900C3B679 /* NavBarContainerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0402E10E18A3ABA900C3B679 /* NavBarContainerView.m */; }; + 0406CEF618F8C390007EE43E /* LogEventOp.m in Sources */ = {isa = PBXBuildFile; fileRef = 0406CEF518F8C390007EE43E /* LogEventOp.m */; }; + 0406CEF918F8D6F7007EE43E /* UIViewController+LogEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = 0406CEF818F8D6F7007EE43E /* UIViewController+LogEvent.m */; }; 04082B5318ADA25A00FAF3D6 /* text_field_x_circle_gray.png in Resources */ = {isa = PBXBuildFile; fileRef = 04082B5118ADA25A00FAF3D6 /* text_field_x_circle_gray.png */; }; 04082B5518ADA25A00FAF3D6 /* text_field_x_circle_g...@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 04082B5218ADA25A00FAF3D6 /* text_field_x_circle_g...@2x.png */; }; 04090A33187F53E400577EDF /* clear.png in Resources */ = {isa = PBXBuildFile; fileRef = 04090A32187F53E400577EDF /* clear.png */; }; @@ -188,6 +190,10 @@ 0400EB0218AAEEC60043ECE2 /* UINavigationController+SearchNavStack.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UINavigationController+SearchNavStack.m"; sourceTree = "<group>"; }; 0402E10D18A3ABA900C3B679 /* NavBarContainerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavBarContainerView.h; sourceTree = "<group>"; }; 0402E10E18A3ABA900C3B679 /* NavBarContainerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NavBarContainerView.m; sourceTree = "<group>"; }; + 0406CEF418F8C390007EE43E /* LogEventOp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LogEventOp.h; sourceTree = "<group>"; }; + 0406CEF518F8C390007EE43E /* LogEventOp.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LogEventOp.m; sourceTree = "<group>"; }; + 0406CEF718F8D6F7007EE43E /* UIViewController+LogEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+LogEvent.h"; sourceTree = "<group>"; }; + 0406CEF818F8D6F7007EE43E /* UIViewController+LogEvent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+LogEvent.m"; sourceTree = "<group>"; }; 04082B5118ADA25A00FAF3D6 /* text_field_x_circle_gray.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = text_field_x_circle_gray.png; sourceTree = "<group>"; }; 04082B5218ADA25A00FAF3D6 /* text_field_x_circle_g...@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "text_field_x_circle_g...@2x.png"; sourceTree = "<group>"; }; 04090A32187F53E400577EDF /* clear.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = clear.png; sourceTree = "<group>"; }; @@ -944,6 +950,8 @@ isa = PBXGroup; children = ( 043F18DA18D9691D00D8489A /* TopActionSheet */, + 0406CEF718F8D6F7007EE43E /* UIViewController+LogEvent.h */, + 0406CEF818F8D6F7007EE43E /* UIViewController+LogEvent.m */, 04B91AA518E34BBC00FFAA1C /* UIView+TemporaryAnimatedXF.h */, 04B91AA618E34BBC00FFAA1C /* UIView+TemporaryAnimatedXF.m */, 04DB0BE818BD37F900B4BCF3 /* UIScrollView+ScrollSubviewToLocation.h */, @@ -1015,6 +1023,8 @@ 04D149E5188889CA006B4104 /* Operations */ = { isa = PBXGroup; children = ( + 0406CEF418F8C390007EE43E /* LogEventOp.h */, + 0406CEF518F8C390007EE43E /* LogEventOp.m */, 043C668818BE9A8E00580E9B /* PreviewWikiTextOp.h */, 043C668918BE9A8E00580E9B /* PreviewWikiTextOp.m */, 0476967A18BBFC9400071963 /* AccountCreationOp.h */, @@ -1530,6 +1540,7 @@ 0433542218A023FE009305F0 /* UIViewController+HideKeyboard.m in Sources */, 043F18E918D9885F00D8489A /* TitleSubtitleView.m in Sources */, C958EE3418CE73E600148D13 /* DownloadTitlesForRandomArticlesOp.m in Sources */, + 0406CEF918F8D6F7007EE43E /* UIViewController+LogEvent.m in Sources */, 04B91AB718E4D5B200FFAA1C /* TabularScrollView.m in Sources */, 04C695D218ED213000D9F2DA /* UIScrollView+NoHorizontalScrolling.m in Sources */, 04F0E2EE186FB2D100468738 /* TOCSectionCellView.m in Sources */, @@ -1555,6 +1566,7 @@ D4991445181D51DE00E6073C /* main.m in Sources */, 04C43AC0183442FC006C643B /* NSString+Extras.m in Sources */, 0447862F185145090050563B /* HistoryResultCell.m in Sources */, + 0406CEF618F8C390007EE43E /* LogEventOp.m in Sources */, 0476967C18BBFC9400071963 /* AccountCreationOp.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/wikipedia/Categories/UIViewController+LogEvent.h b/wikipedia/Categories/UIViewController+LogEvent.h new file mode 100644 index 0000000..8bb5785 --- /dev/null +++ b/wikipedia/Categories/UIViewController+LogEvent.h @@ -0,0 +1,11 @@ +// Created by Monte Hurd on 4/11/14. +// Copyright (c) 2013 Wikimedia Foundation. Provided under MIT-style license; please copy and modify! + +#import <UIKit/UIKit.h> +#import "LogEventOp.h" + +@interface UIViewController (LogEvent) + +-(void)logEvent:(NSDictionary *)event schema:(EventLogSchema)schema; + +@end diff --git a/wikipedia/Categories/UIViewController+LogEvent.m b/wikipedia/Categories/UIViewController+LogEvent.m new file mode 100644 index 0000000..35b61d3 --- /dev/null +++ b/wikipedia/Categories/UIViewController+LogEvent.m @@ -0,0 +1,15 @@ +// Created by Monte Hurd on 4/11/14. +// Copyright (c) 2013 Wikimedia Foundation. Provided under MIT-style license; please copy and modify! + +#import "UIViewController+LogEvent.h" +#import "QueuesSingleton.h" + +@implementation UIViewController (LogEvent) + +-(void)logEvent:(NSDictionary *)event schema:(EventLogSchema)schema +{ + LogEventOp *logOp = [[LogEventOp alloc] initWithSchema:schema event:event]; + [[QueuesSingleton sharedInstance].eventLoggingQ addOperation:logOp]; +} + +@end diff --git a/wikipedia/Data/Operations/LogEventOp.h b/wikipedia/Data/Operations/LogEventOp.h new file mode 100644 index 0000000..00a21eb --- /dev/null +++ b/wikipedia/Data/Operations/LogEventOp.h @@ -0,0 +1,27 @@ +// Created by Monte Hurd on 4/11/14. +// Copyright (c) 2013 Wikimedia Foundation. Provided under MIT-style license; please copy and modify! + +#import "MWNetworkOp.h" + +typedef enum { + + //https://meta.wikimedia.org/wiki/Schema:MobileWikiAppCreateAccount + LOG_SCHEMA_CREATEACCOUNT = 0, + + //https://meta.wikimedia.org/wiki/Schema:MobileWikiAppReadingSession + LOG_SCHEMA_READINGSESSION = 1, + + //https://meta.wikimedia.org/wiki/Schema:MobileWikiAppEdit + LOG_SCHEMA_EDIT = 2, + + //https://meta.wikimedia.org/wiki/Schema:MobileWikiAppLogin + LOG_SCHEMA_LOGIN = 3 + +} EventLogSchema; + +@interface LogEventOp : MWNetworkOp + +- (id)initWithSchema: (EventLogSchema)schema + event: (NSDictionary *)event; + +@end diff --git a/wikipedia/Data/Operations/LogEventOp.m b/wikipedia/Data/Operations/LogEventOp.m new file mode 100644 index 0000000..200d0d8 --- /dev/null +++ b/wikipedia/Data/Operations/LogEventOp.m @@ -0,0 +1,81 @@ +// Created by Monte Hurd on 4/11/14. +// Copyright (c) 2013 Wikimedia Foundation. Provided under MIT-style license; please copy and modify! + +#import "LogEventOp.h" +#import "NSURLRequest+DictionaryRequest.h" +#import "NSString+Extras.h" + +#define LOG_ENDPOINT @"https://bits.wikimedia.org/event.gif" + +@implementation LogEventOp + +-(NSUInteger)getRevisionForSchema:(EventLogSchema)schema +{ + switch (schema) { + case LOG_SCHEMA_CREATEACCOUNT: + return 8134803; + break; + case LOG_SCHEMA_READINGSESSION: + return 8134785; + break; + case LOG_SCHEMA_EDIT: + return 8134783; + break; + case LOG_SCHEMA_LOGIN: + return 8134781; + break; + default: + return 0; + break; + } +} + +-(NSString *)getNameForSchema:(EventLogSchema)schema +{ + switch (schema) { + case LOG_SCHEMA_CREATEACCOUNT: + return @"MobileWikiAppCreateAccount"; + break; + case LOG_SCHEMA_READINGSESSION: + return @"MobileWikiAppReadingSession"; + break; + case LOG_SCHEMA_EDIT: + return @"MobileWikiAppEdit"; + break; + case LOG_SCHEMA_LOGIN: + return @"MobileWikiAppLogin"; + break; + default: + return @""; + break; + } +} + +- (id)initWithSchema: (EventLogSchema)schema + event: (NSDictionary *)event +{ + self = [super init]; + if (self) { + + NSDictionary *payload = + @{ + @"event" : event, + @"revision" : @([self getRevisionForSchema:schema]), + @"schema" : [self getNameForSchema:schema] + }; + + NSData *payloadJsonData = [NSJSONSerialization dataWithJSONObject:payload options:0 error:nil]; + NSString *payloadJsonString = [[NSString alloc] initWithData:payloadJsonData encoding:NSUTF8StringEncoding]; + NSString *encodedPayloadJsonString = [payloadJsonString urlEncodedUTF8String]; + NSString *urlString = [NSString stringWithFormat:@"%@?%@;", LOG_ENDPOINT, encodedPayloadJsonString]; + + self.request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:urlString]]; + + self.completionBlock = ^(){ + //NSLog(@"EVENT LOGGING COMPLETED"); + }; + } + return self; +} + +@end diff --git a/wikipedia/Queues/QueuesSingleton.h b/wikipedia/Queues/QueuesSingleton.h index 2ddf96b..1311666 100644 --- a/wikipedia/Queues/QueuesSingleton.h +++ b/wikipedia/Queues/QueuesSingleton.h @@ -19,6 +19,8 @@ @property (strong, nonatomic) NSOperationQueue *randomArticleQ; +@property (strong, nonatomic) NSOperationQueue *eventLoggingQ; + + (QueuesSingleton *)sharedInstance; @end diff --git a/wikipedia/Queues/QueuesSingleton.m b/wikipedia/Queues/QueuesSingleton.m index 613a959..1acb481 100644 --- a/wikipedia/Queues/QueuesSingleton.m +++ b/wikipedia/Queues/QueuesSingleton.m @@ -30,6 +30,7 @@ self.zeroRatedMessageStringQ = [[NSOperationQueue alloc] init]; self.accountCreationQ = [[NSOperationQueue alloc] init]; self.randomArticleQ = [[NSOperationQueue alloc] init]; + self.eventLoggingQ = [[NSOperationQueue alloc] init]; //[self setupQMonitorLogging]; } return self; diff --git a/wikipedia/View Controllers/WebView/WebViewController.m b/wikipedia/View Controllers/WebView/WebViewController.m index b1d4564..d7bef80 100644 --- a/wikipedia/View Controllers/WebView/WebViewController.m +++ b/wikipedia/View Controllers/WebView/WebViewController.m @@ -26,6 +26,7 @@ #import "UIViewController+HideKeyboard.h" #import "UIWebView+HideScrollGradient.h" #import "UIWebView+ElementLocation.h" +#import "UIViewController+LogEvent.h" #import "UIView+RemoveConstraints.h" #import "UIViewController+Alert.h" #import "Section+ImageRecords.h" @@ -608,6 +609,8 @@ [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/125551 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibaa292f1753caa2e547e15c73a60f92ecbcb7fb4 Gerrit-PatchSet: 1 Gerrit-Project: apps/ios/wikipedia Gerrit-Branch: master Gerrit-Owner: Mhurd <mh...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits