Mhurd has submitted this change and it was merged. Change subject: Initial SavedPages eventlogging for iOS ......................................................................
Initial SavedPages eventlogging for iOS now with the actual classes Change-Id: Iba7164704a950e53a60988f194787fa97b4415fd --- M Wikipedia.xcodeproj/project.pbxproj M wikipedia/Data/Operations/LogEventOp.h M wikipedia/Data/Operations/LogEventOp.m M wikipedia/EventLogging/EventLoggingFunnel.h M wikipedia/EventLogging/EventLoggingFunnel.m A wikipedia/EventLogging/SavedPagesFunnel.h A wikipedia/EventLogging/SavedPagesFunnel.m M wikipedia/Importer/ArticleImporter.m M wikipedia/View Controllers/Preview/PreviewAndSaveViewController.h M wikipedia/View Controllers/Preview/PreviewAndSaveViewController.m M wikipedia/View Controllers/SavedPages/SavedPagesViewController.m M wikipedia/View Controllers/SectionEditor/SectionEditorViewController.h M wikipedia/View Controllers/SectionEditor/SectionEditorViewController.m M wikipedia/View Controllers/WebView/WebViewController.m 14 files changed, 168 insertions(+), 7 deletions(-) Approvals: Mhurd: Verified; Looks good to me, approved diff --git a/Wikipedia.xcodeproj/project.pbxproj b/Wikipedia.xcodeproj/project.pbxproj index fc9284e..ecebe49 100644 --- a/Wikipedia.xcodeproj/project.pbxproj +++ b/Wikipedia.xcodeproj/project.pbxproj @@ -179,6 +179,7 @@ D46CD8C518A1AC4F0042959E /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = D46CD8C218A1AC4F0042959E /* Localizable.strings */; }; D474CC15182AE196002BDE45 /* MWSite.m in Sources */ = {isa = PBXBuildFile; fileRef = D474CC14182AE196002BDE45 /* MWSite.m */; }; D47FEE2019C8CB0000B998C8 /* Main_iPhone.strings in Resources */ = {isa = PBXBuildFile; fileRef = D47FEE1E19C8CB0000B998C8 /* Main_iPhone.strings */; }; + D47BF5D4197870390067C3BC /* SavedPagesFunnel.m in Sources */ = {isa = PBXBuildFile; fileRef = D47BF5D3197870390067C3BC /* SavedPagesFunnel.m */; }; D4991439181D51DE00E6073C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D4991438181D51DE00E6073C /* Foundation.framework */; }; D499143B181D51DE00E6073C /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D499143A181D51DE00E6073C /* CoreGraphics.framework */; }; D499143D181D51DE00E6073C /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D499143C181D51DE00E6073C /* UIKit.framework */; }; @@ -644,6 +645,8 @@ D47FEE2619C8CB6B00B998C8 /* cs */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = cs; path = cs.lproj/Main_iPhone.strings; sourceTree = "<group>"; }; D47FEE2719C8CBB400B998C8 /* ta */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ta; path = ta.lproj/Main_iPhone.strings; sourceTree = "<group>"; }; D47FEE2819C8CC2600B998C8 /* pt-BR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "pt-BR.lproj/Localizable.strings"; sourceTree = "<group>"; }; + D47BF5D2197870390067C3BC /* SavedPagesFunnel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SavedPagesFunnel.h; path = EventLogging/SavedPagesFunnel.h; sourceTree = "<group>"; }; + D47BF5D3197870390067C3BC /* SavedPagesFunnel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SavedPagesFunnel.m; path = EventLogging/SavedPagesFunnel.m; sourceTree = "<group>"; }; D4991435181D51DE00E6073C /* Wikipedia.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Wikipedia.app; sourceTree = BUILT_PRODUCTS_DIR; }; D4991438181D51DE00E6073C /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; D499143A181D51DE00E6073C /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; @@ -1632,6 +1635,8 @@ D4F277FA194235A00032BA38 /* ProtectedEditAttemptFunnel.m */, D4F277FC194235B50032BA38 /* ToCInteractionFunnel.h */, D4F277FD194235B50032BA38 /* ToCInteractionFunnel.m */, + D47BF5D2197870390067C3BC /* SavedPagesFunnel.h */, + D47BF5D3197870390067C3BC /* SavedPagesFunnel.m */, ); name = EventLogging; sourceTree = "<group>"; @@ -2060,6 +2065,7 @@ 04C43A9D183440B0006C643B /* MWCrumbyTest.m in Sources */, D4991445181D51DE00E6073C /* main.m in Sources */, 04CFA123194B94980088269A /* MenuButton.m in Sources */, + D47BF5D4197870390067C3BC /* SavedPagesFunnel.m in Sources */, 04C43AC0183442FC006C643B /* NSString+Extras.m in Sources */, 04CCCFEE1935093A00E3F60C /* SecondaryMenuRowView.m in Sources */, 0442F57B19006DCC00F55DF9 /* PageHistoryLabel.m in Sources */, diff --git a/wikipedia/Data/Operations/LogEventOp.h b/wikipedia/Data/Operations/LogEventOp.h index 5e562ad..f910e6c 100644 --- a/wikipedia/Data/Operations/LogEventOp.h +++ b/wikipedia/Data/Operations/LogEventOp.h @@ -10,6 +10,7 @@ */ - (id)initWithSchema: (NSString *)schema revision: (int)revision - event: (NSDictionary *)event; + event: (NSDictionary *)event + wiki: (NSString *)wiki; @end diff --git a/wikipedia/Data/Operations/LogEventOp.m b/wikipedia/Data/Operations/LogEventOp.m index d718130..508d2d5 100644 --- a/wikipedia/Data/Operations/LogEventOp.m +++ b/wikipedia/Data/Operations/LogEventOp.m @@ -16,19 +16,17 @@ - (id)initWithSchema: (NSString *)schema revision: (int)revision event: (NSDictionary *)event + wiki: (NSString *)wiki { self = [super init]; if (self) { - - SessionSingleton *session = [SessionSingleton sharedInstance]; - NSString *wiki = [session.domain stringByAppendingString:@"wiki"]; NSDictionary *payload = @{ @"event" : event, @"revision" : @(revision), @"schema" : schema, - @"wiki" : wiki, + @"wiki" : wiki }; NSData *payloadJsonData = [NSJSONSerialization dataWithJSONObject:payload options:0 error:nil]; diff --git a/wikipedia/EventLogging/EventLoggingFunnel.h b/wikipedia/EventLogging/EventLoggingFunnel.h index e3109d6..168f638 100644 --- a/wikipedia/EventLogging/EventLoggingFunnel.h +++ b/wikipedia/EventLogging/EventLoggingFunnel.h @@ -47,12 +47,23 @@ * get run through preprocessData: and then sent off to the * background logging operation queue. * - * For convenience, derivded classes should contain specific + * The current wiki as recorded in the SessionSingleton will + * be used as the target of the logging request. + * + * For convenience, derived classes should contain specific * log* methods for each potential logging action variant for * readibility in calling code (and type safety on params!) */ -(void)log:(NSDictionary *)eventData; +/** + * In some cases logging should go to a specific wiki + * other than the one in the session. Call this as necessary. + * + * Wiki parameter is a dbname, not a domain or hostname! + */ +-(void)log:(NSDictionary *)eventData wiki:(NSString *)wiki; + /** * Helper function to generate a per-use UUID diff --git a/wikipedia/EventLogging/EventLoggingFunnel.m b/wikipedia/EventLogging/EventLoggingFunnel.m index 2ebaa11..18c30a3 100644 --- a/wikipedia/EventLogging/EventLoggingFunnel.m +++ b/wikipedia/EventLogging/EventLoggingFunnel.m @@ -29,10 +29,18 @@ -(void)log:(NSDictionary *)eventData { + SessionSingleton *session = [SessionSingleton sharedInstance]; + NSString *wiki = [session.domain stringByAppendingString:@"wiki"]; + [self log:eventData forWiki:wiki]; +} + +-(void)log:(NSDictionary *)eventData forWiki:(NSString *)wiki +{ if ([SessionSingleton sharedInstance].sendUsageReports) { LogEventOp *logOp = [[LogEventOp alloc] initWithSchema: self.schema revision: self.revision - event: [self preprocessData:eventData]]; + event: [self preprocessData:eventData] + wiki: wiki]; [[QueuesSingleton sharedInstance].eventLoggingQ addOperation:logOp]; } diff --git a/wikipedia/EventLogging/SavedPagesFunnel.h b/wikipedia/EventLogging/SavedPagesFunnel.h new file mode 100644 index 0000000..b33f74f --- /dev/null +++ b/wikipedia/EventLogging/SavedPagesFunnel.h @@ -0,0 +1,52 @@ +// +// SavedPagesFunnel.h +// Wikipedia +// +// Created by Brion on 7/17/14. +// Copyright (c) 2014 Wikimedia Foundation. All rights reserved. +// + +#import "EventLoggingFunnel.h" + +@interface SavedPagesFunnel : EventLoggingFunnel + +@property NSString *appInstallID; + +-(id)init; + +/** + * Log the saving of a new page to the saved set. + */ +-(void)logSaveNew; + +/** + * What does this represent? Update of a single page, or of the entire data set? + */ +-(void)logUpdate; + +/** + * What does this represent? Import of a single page, or of the entire data set? + */ +-(void)logImportOnSubdomain:(NSString *)subdomain; + +/** + * Log the removal of a saved page from the saved list + */ +-(void)logDelete; + +/** + * @fixme What does this represent + */ +-(void)logEditAttempt; + +/** + * @fixme What does this represent + */ +-(void)logEditRefresh; + +/** + * @fixme What does this represent + */ +-(void)logEditAfterRefresh; + +@end diff --git a/wikipedia/EventLogging/SavedPagesFunnel.m b/wikipedia/EventLogging/SavedPagesFunnel.m new file mode 100644 index 0000000..a83cf48 --- /dev/null +++ b/wikipedia/EventLogging/SavedPagesFunnel.m @@ -0,0 +1,62 @@ +// +// SavedPagesFunnel.m +// Wikipedia +// +// Created by Brion on 7/17/14. +// Copyright (c) 2014 Wikimedia Foundation. All rights reserved. +// + +#import "SavedPagesFunnel.h" + +@implementation SavedPagesFunnel + +-(id)init +{ + // http://meta.wikimedia.org/wiki/Schema:MobileWikiAppSavedPages + self = [super initWithSchema:@"MobileWikiAppSavedPages" version:8909354]; + if (self) { + self.appInstallID = [self persistentUUID:@"SavedPages"]; + } + return self; +} + +-(void)logSaveNew +{ + [self log:@{@"action": @"savenew"}]; +} + +-(void)logUpdate +{ + [self log:@{@"action": @"update"}]; +} + +-(void)logImportOnSubdomain:(NSString *)subdomain +{ + [self log:@{@"action": @"import"} + wiki:[subdomain stringByAppendingString:@"wiki"]]; +} + +-(void)logDelete +{ + [self log:@{@"action": @"delete"}]; +} + +-(void)logEditAttempt +{ + [self log:@{@"action": @"editattempt"}]; +} + +// Doesn't seem to be relevant to iOS version? +-(void)logEditRefresh +{ + [self log:@{@"action": @"editrefresh"}]; +} + +// Doesn't seem to be relevant to iOS version? +-(void)logEditAfterRefresh +{ + [self log:@{@"action": @"editafterrefresh"}]; +} + + +@end diff --git a/wikipedia/Importer/ArticleImporter.m b/wikipedia/Importer/ArticleImporter.m index 5910851..37963d9 100644 --- a/wikipedia/Importer/ArticleImporter.m +++ b/wikipedia/Importer/ArticleImporter.m @@ -8,6 +8,7 @@ #import "SessionSingleton.h" #import "NSManagedObjectContext+SimpleFetch.h" #import "WikipediaAppUtils.h" +#import "SavedPagesFunnel.h" @implementation ArticleImporter @@ -18,6 +19,7 @@ [context performBlock:^{ + SavedPagesFunnel *funnel = [[SavedPagesFunnel alloc] init]; NSError *error = nil; for (NSDictionary *articleDict in articleDictionaries) { @@ -82,6 +84,7 @@ [article addSavedObject:saved]; + [funnel logImportOnSubdomain:lang]; } // Save all the additions from the loop above in one go. diff --git a/wikipedia/View Controllers/Preview/PreviewAndSaveViewController.h b/wikipedia/View Controllers/Preview/PreviewAndSaveViewController.h index 4ba92aa..785e4ba 100644 --- a/wikipedia/View Controllers/Preview/PreviewAndSaveViewController.h +++ b/wikipedia/View Controllers/Preview/PreviewAndSaveViewController.h @@ -13,6 +13,7 @@ @property (strong, nonatomic) NSManagedObjectID *sectionID; @property (strong, nonatomic) NSString *wikiText; @property (strong, nonatomic) EditFunnel *funnel; +@property (strong, nonatomic) SavedPagesFunnel *savedPagesFunnel; @property (strong, nonatomic) NSString *abuseFilterCode; -(void)reloadCaptchaPushed:(id)sender; diff --git a/wikipedia/View Controllers/Preview/PreviewAndSaveViewController.m b/wikipedia/View Controllers/Preview/PreviewAndSaveViewController.m index 7d98d9f..96aa630 100644 --- a/wikipedia/View Controllers/Preview/PreviewAndSaveViewController.m +++ b/wikipedia/View Controllers/Preview/PreviewAndSaveViewController.m @@ -535,6 +535,9 @@ NSString *title = section.fromTitle ? section.fromTitle : section.article.title; [self.funnel logSaveAttempt]; + if (self.savedPagesFunnel) { + [self.savedPagesFunnel logEditAttempt]; + } UploadSectionWikiTextOp *uploadWikiTextOp = [[UploadSectionWikiTextOp alloc] initForPageTitle:title domain:section.article.domain section:section.index wikiText:self.wikiText summary:editSummary captchaId:self.captchaId captchaWord:self.captchaViewController.captchaTextBox.text completionBlock:^(NSDictionary *resultDict){ diff --git a/wikipedia/View Controllers/SavedPages/SavedPagesViewController.m b/wikipedia/View Controllers/SavedPages/SavedPagesViewController.m index f9c2e3a..b737cf9 100644 --- a/wikipedia/View Controllers/SavedPages/SavedPagesViewController.m +++ b/wikipedia/View Controllers/SavedPages/SavedPagesViewController.m @@ -18,6 +18,7 @@ #import "MenuButton.h" #import "TopMenuViewController.h" #import "CoreDataHousekeeping.h" +#import "SavedPagesFunnel.h" #define SAVED_PAGES_TITLE_TEXT_COLOR [UIColor colorWithWhite:0.0f alpha:0.7f] #define SAVED_PAGES_TEXT_COLOR [UIColor colorWithWhite:0.0f alpha:1.0f] @@ -32,6 +33,8 @@ @property (strong, nonatomic) NSMutableArray *savedPagesDataArray; @property (strong, nonatomic) IBOutlet UITableView *tableView; + +@property (strong, nonatomic) SavedPagesFunnel *funnel; @end @@ -109,6 +112,8 @@ [super viewDidLoad]; articleDataContext_ = [ArticleDataContextSingleton sharedInstance]; + + self.funnel = [[SavedPagesFunnel alloc] init]; self.navigationItem.hidesBackButton = YES; @@ -313,6 +318,8 @@ [self.tableView endUpdates]; [self setEmptyOverlayAndTrashIconVisibility]; + + [self.funnel logDelete]; } }]; @@ -341,6 +348,7 @@ // core data. for (Saved *savedRecord in savedRecords) { [articleDataContext_.mainContext deleteObject:savedRecord.article]; + [self.funnel logDelete]; } NSError *saveError = nil; [articleDataContext_.mainContext save:&saveError]; diff --git a/wikipedia/View Controllers/SectionEditor/SectionEditorViewController.h b/wikipedia/View Controllers/SectionEditor/SectionEditorViewController.h index 116d299..f118c4a 100644 --- a/wikipedia/View Controllers/SectionEditor/SectionEditorViewController.h +++ b/wikipedia/View Controllers/SectionEditor/SectionEditorViewController.h @@ -4,6 +4,7 @@ #import <UIKit/UIKit.h> #import "MWNetworkOp.h" #import "EditFunnel.h" +#import "SavedPagesFunnel.h" @class NSManagedObjectID; @@ -11,5 +12,6 @@ @property (strong, nonatomic) NSManagedObjectID *sectionID; @property EditFunnel *funnel; +@property SavedPagesFunnel *savedPagesFunnel; @end diff --git a/wikipedia/View Controllers/SectionEditor/SectionEditorViewController.m b/wikipedia/View Controllers/SectionEditor/SectionEditorViewController.m index cd8b677..11a76cd 100644 --- a/wikipedia/View Controllers/SectionEditor/SectionEditorViewController.m +++ b/wikipedia/View Controllers/SectionEditor/SectionEditorViewController.m @@ -253,6 +253,7 @@ previewVC.sectionID = self.sectionID; previewVC.wikiText = self.editTextView.text; previewVC.funnel = self.funnel; + previewVC.savedPagesFunnel = self.savedPagesFunnel; [ROOT pushViewController:previewVC animated:YES]; } diff --git a/wikipedia/View Controllers/WebView/WebViewController.m b/wikipedia/View Controllers/WebView/WebViewController.m index a4ac2dc..4dcfd04 100644 --- a/wikipedia/View Controllers/WebView/WebViewController.m +++ b/wikipedia/View Controllers/WebView/WebViewController.m @@ -58,6 +58,7 @@ #import "WikiGlyphLabel.h" #import "WikiGlyph_Chars_iOS.h" #import "NSString+FormattedAttributedString.h" +#import "SavedPagesFunnel.h" //#import "UIView+Debugging.h" @@ -1069,6 +1070,8 @@ if (!articleID) return; Article *article = (Article *)[articleDataContext_.mainContext objectWithID:articleID]; if (!article) return; + + SavedPagesFunnel *funnel = [[SavedPagesFunnel alloc] init]; if (article.saved.count == 0) { // Show alert. [self showPageSavedAlertMessageForTitle:article.title]; @@ -1077,6 +1080,7 @@ Saved *saved = [NSEntityDescription insertNewObjectForEntityForName:@"Saved" inManagedObjectContext:articleDataContext_.mainContext]; saved.dateSaved = [NSDate date]; [article addSavedObject:saved]; + [funnel logSaveNew]; }else{ // Unsave! //[articleDataContext_.mainContext deleteObject:article.saved.anyObject]; @@ -1084,6 +1088,7 @@ [articleDataContext_.mainContext deleteObject:obj]; } [self fadeAlert]; + [funnel logDelete]; } NSError *error = nil; [articleDataContext_.mainContext save:&error]; -- To view, visit https://gerrit.wikimedia.org/r/160496 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iba7164704a950e53a60988f194787fa97b4415fd Gerrit-PatchSet: 3 Gerrit-Project: apps/ios/wikipedia Gerrit-Branch: master Gerrit-Owner: Brion VIBBER <br...@wikimedia.org> Gerrit-Reviewer: Mhurd <mh...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits