Skip to content

Commit

Permalink
Merge pull request wikimedia#2923 from wikimedia/bug/T215329
Browse files Browse the repository at this point in the history
Log article language in edit events
  • Loading branch information
joewalsh authored Feb 15, 2019
2 parents 7d9c510 + 18bfb2d commit c727ba6
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 49 deletions.
24 changes: 12 additions & 12 deletions Wikipedia/Code/EditFunnel.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@

@property NSString *editSessionToken;

- (void)logStart;
- (void)logPreview;
- (void)logStart:(NSString *)language;
- (void)logPreview:(NSString *)language;
/**
* Parameter should be one of the string keys defined at
* https://meta.wikimedia.org/wiki/Schema_talk:MobileWikiAppEdit#Schema_missing_enum_for_editSummaryTapped
*/
- (void)logEditSummaryTap:(NSString *)editSummaryTapped;
- (void)logSavedRevision:(int)revID;
- (void)logCaptchaShown;
- (void)logCaptchaFailure;
- (void)logAbuseFilterWarning:(NSString *)name;
- (void)logAbuseFilterError:(NSString *)name;
- (void)logAbuseFilterWarningIgnore:(NSString *)name;
- (void)logAbuseFilterWarningBack:(NSString *)name;
- (void)logSaveAttempt;
- (void)logError:(NSString *)code;
- (void)logEditSummaryTap:(NSString *)editSummaryTapped language:(NSString *)language;
- (void)logSavedRevision:(int)revID language:(NSString *)language;
- (void)logCaptchaShown:(NSString *)language;
- (void)logCaptchaFailure:(NSString *)language;
- (void)logAbuseFilterWarning:(NSString *)name language:(NSString *)language;
- (void)logAbuseFilterError:(NSString *)name language:(NSString *)language;
- (void)logAbuseFilterWarningIgnore:(NSString *)name language:(NSString *)language;
- (void)logAbuseFilterWarningBack:(NSString *)name language:(NSString *)language;
- (void)logSaveAttempt:(NSString *)language;
- (void)logError:(NSString *)code language:(NSString *)language;

- (void)logWikidataDescriptionEditStart:(BOOL)isEditingExistingDescription language:(NSString *)language;
- (void)logWikidataDescriptionEditReady:(BOOL)isEditingExistingDescription language:(NSString *)language;
Expand Down
48 changes: 24 additions & 24 deletions Wikipedia/Code/EditFunnel.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,60 +32,60 @@ - (NSDictionary *)preprocessData:(NSDictionary *)eventData {

#pragma mark - EditFunnel methods

- (void)logStart {
[self log:@{kActionKey: @"start"}];
- (void)logStart:(NSString *)language {
[self log:@{kActionKey: @"start"} language:language] ;
}

- (void)logPreview {
[self log:@{kActionKey: @"preview"}];
- (void)logPreview:(NSString *)language {
[self log:@{kActionKey: @"preview"} language:language];
}

- (void)logEditSummaryTap:(NSString *)editSummaryTapped {
- (void)logEditSummaryTap:(NSString *)editSummaryTapped language:(NSString *)language {
[self log:@{kActionKey: @"editSummaryTap",
@"editSummaryTapped": editSummaryTapped ? editSummaryTapped : @""}];
@"editSummaryTapped": editSummaryTapped ? editSummaryTapped : @""} language:language];
}

- (void)logSavedRevision:(int)revID {
- (void)logSavedRevision:(int)revID language:(NSString *)language {
NSNumber *revIDNumber = [NSNumber numberWithInt:revID];
[self log:@{kActionKey: @"saved",
kRevisionIDKey: (revIDNumber ? revIDNumber : @"")}];
kRevisionIDKey: (revIDNumber ? revIDNumber : @"")} language:language];
}

- (void)logCaptchaShown {
[self log:@{kActionKey: @"captchaShown"}];
- (void)logCaptchaShown:(NSString *)language {
[self log:@{kActionKey: @"captchaShown"} language:language];
}

- (void)logCaptchaFailure {
[self log:@{kActionKey: @"captchaFailure"}];
- (void)logCaptchaFailure:(NSString *)language {
[self log:@{kActionKey: @"captchaFailure"} language:language];
}

- (void)logAbuseFilterWarning:(NSString *)name {
- (void)logAbuseFilterWarning:(NSString *)name language:(NSString *)language {
[self log:@{kActionKey: @"abuseFilterWarning",
@"abuseFilterName": (name ? name : @"")}];
@"abuseFilterName": (name ? name : @"")} language:language];
}

- (void)logAbuseFilterError:(NSString *)name {
- (void)logAbuseFilterError:(NSString *)name language:(NSString *)language {
[self log:@{kActionKey: @"abuseFilterError",
@"abuseFilterName": (name ? name : @"")}];
@"abuseFilterName": (name ? name : @"")} language:language];
}

- (void)logAbuseFilterWarningIgnore:(NSString *)name {
- (void)logAbuseFilterWarningIgnore:(NSString *)name language:(NSString *)language {
[self log:@{kActionKey: @"abuseFilterWarningIgnore",
@"abuseFilterName": (name ? name : @"")}];
@"abuseFilterName": (name ? name : @"")} language:language];
}

- (void)logAbuseFilterWarningBack:(NSString *)name {
- (void)logAbuseFilterWarningBack:(NSString *)name language:(NSString *)language {
[self log:@{kActionKey: @"abuseFilterWarningBack",
@"abuseFilterName": (name ? name : @"")}];
@"abuseFilterName": (name ? name : @"")} language:language];
}

- (void)logSaveAttempt {
[self log:@{kActionKey: @"saveAttempt"}];
- (void)logSaveAttempt:(NSString *)language {
[self log:@{kActionKey: @"saveAttempt"} language:language];
}

- (void)logError:(NSString *)code {
- (void)logError:(NSString *)code language:(NSString *)language {
[self log:@{kActionKey: @"error",
@"errorText": (code ? code : @"")}];
@"errorText": (code ? code : @"")} language:language];
}

- (void)logWikidataDescriptionEditStart:(BOOL)isEditingExistingDescription language:(NSString *)language {
Expand Down
2 changes: 1 addition & 1 deletion Wikipedia/Code/EditPreviewViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class EditPreviewViewController: UIViewController, Themeable, WMFOpenExternalLin
navigationItem.rightBarButtonItem = UIBarButtonItem(title: CommonStrings.nextTitle, style: .done, target: self, action: #selector(self.goForward))
navigationItem.rightBarButtonItem?.tintColor = theme.colors.link

funnel?.logPreview()
funnel?.logPreview(section?.articleLanguage)

preview()

Expand Down
22 changes: 11 additions & 11 deletions Wikipedia/Code/EditSaveViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class EditSaveViewController: WMFScrollViewController, Themeable, UITextFieldDel

@objc private func goBack() {
if mode == .abuseFilterWarning {
funnel?.logAbuseFilterWarningBack(abuseFilterCode)
funnel?.logAbuseFilterWarningBack(abuseFilterCode, language: section?.articleLanguage)
}

navigationController?.popViewController(animated: true)
Expand All @@ -92,7 +92,7 @@ class EditSaveViewController: WMFScrollViewController, Themeable, UITextFieldDel
switch mode {
case .abuseFilterWarning:
save()
funnel?.logAbuseFilterWarningIgnore(abuseFilterCode)
funnel?.logAbuseFilterWarningIgnore(abuseFilterCode, language: section?.articleLanguage)
case .captcha:
save()
default:
Expand Down Expand Up @@ -195,7 +195,7 @@ class EditSaveViewController: WMFScrollViewController, Themeable, UITextFieldDel
private func save() {
WMFAlertManager.sharedInstance.showAlert(WMFLocalizedStringWithDefaultValue("wikitext-upload-save", nil, nil, "Publishing...", "Alert text shown when changes to section wikitext are being published\n{{Identical|Publishing}}"), sticky: true, dismissPreviousAlerts: true, tapCallBack: nil)

funnel?.logSaveAttempt()
funnel?.logSaveAttempt(section?.articleLanguage)

if (savedPagesFunnel != nil) {
savedPagesFunnel?.logEditAttempt(withArticleURL: section?.article?.url)
Expand Down Expand Up @@ -238,7 +238,7 @@ class EditSaveViewController: WMFScrollViewController, Themeable, UITextFieldDel
notifyDelegate()
return
}
funnel?.logSavedRevision(newRevID)
funnel?.logSavedRevision(newRevID, language: section?.articleLanguage)
notifyDelegate()
}

Expand All @@ -249,14 +249,14 @@ class EditSaveViewController: WMFScrollViewController, Themeable, UITextFieldDel
switch errorType {
case .needsCaptcha:
if mode == .captcha {
funnel?.logCaptchaFailure()
funnel?.logCaptchaFailure(section?.articleLanguage)
}

let captchaUrl = URL(string: nsError.userInfo["captchaUrl"] as? String ?? "")
let captchaId = nsError.userInfo["captchaId"] as? String ?? ""
WMFAlertManager.sharedInstance.showErrorAlert(nsError, sticky: false, dismissPreviousAlerts: true, tapCallBack: nil)
captchaViewController?.captcha = WMFCaptcha(captchaID: captchaId, captchaURL: captchaUrl!)
funnel?.logCaptchaShown()
funnel?.logCaptchaShown(section?.articleLanguage)
mode = .captcha
highlightCaptchaSubmitButton(false)
dispatchOnMainQueueAfterDelayInSeconds(0.1) { // Prevents weird animation.
Expand All @@ -271,23 +271,23 @@ class EditSaveViewController: WMFScrollViewController, Themeable, UITextFieldDel
WMFAlertManager.sharedInstance.showErrorAlert(nsError, sticky: false, dismissPreviousAlerts: true, tapCallBack: nil)
mode = .abuseFilterDisallow
abuseFilterCode = nsError.userInfo["code"] as! String
funnel?.logAbuseFilterError(abuseFilterCode)
funnel?.logAbuseFilterError(abuseFilterCode, language: section?.articleLanguage)
} else {
WMFAlertManager.sharedInstance.showWarningAlert(nsError.localizedDescription, sticky: false, dismissPreviousAlerts: true, tapCallBack: nil)
mode = .abuseFilterWarning
abuseFilterCode = nsError.userInfo["code"] as! String
funnel?.logAbuseFilterWarning(abuseFilterCode)
funnel?.logAbuseFilterWarning(abuseFilterCode, language: section?.articleLanguage)
}

let alertType: AbuseFilterAlertType = (errorType == .abuseFilterDisallowed) ? .disallow : .warning
showAbuseFilterAlert(for: alertType)

case .server, .unknown:
WMFAlertManager.sharedInstance.showErrorAlert(nsError, sticky: true, dismissPreviousAlerts: true, tapCallBack: nil)
funnel?.logError("other")
funnel?.logError("other", language: section?.articleLanguage)
default:
WMFAlertManager.sharedInstance.showErrorAlert(nsError, sticky: true, dismissPreviousAlerts: true, tapCallBack: nil)
funnel?.logError("other")
funnel?.logError("other", language: section?.articleLanguage)
}
}

Expand Down Expand Up @@ -387,7 +387,7 @@ class EditSaveViewController: WMFScrollViewController, Themeable, UITextFieldDel
}

func cannedButtonTapped(type: EditSummaryViewCannedButtonType) {
funnel?.logEditSummaryTap(type.eventLoggingKey)
funnel?.logEditSummaryTap(type.eventLoggingKey, language: section?.articleLanguage)
}

// Keep bottom divider and license/login labels at bottom of screen while remaining scrollable.
Expand Down
2 changes: 2 additions & 0 deletions Wikipedia/Code/MWKSection.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ extern NSString *const MWKSectionShareSnippetXPath;
@property (readonly, assign, nonatomic) int sectionId; // required; -> id
@property (readonly, assign, nonatomic) BOOL references; // optional; marked by presence of key with empty string in JSON

@property (readonly, copy, nonatomic, nullable) NSString *articleLanguage;

/**
* Lazily-initialized HTML content of this section.
*
Expand Down
3 changes: 3 additions & 0 deletions Wikipedia/Code/MWKSection.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ @interface MWKSection ()

@property (readwrite, weak, nonatomic, nullable) MWKSection *parent;
@property (readwrite, strong, nonatomic, nullable) NSMutableArray *mutableChildren;
@property (readwrite, copy, nonatomic, nullable) NSString *articleLanguage;

@end

Expand Down Expand Up @@ -52,6 +53,8 @@ - (instancetype)initWithArticle:(MWKArticle *)article dict:(NSDictionary *)dict
self.text = [self optionalString:@"text" dict:dict];

self.mutableChildren = [NSMutableArray new];

self.articleLanguage = article.url.wmf_language;
}
return self;
}
Expand Down
2 changes: 1 addition & 1 deletion Wikipedia/Code/SectionEditorViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class SectionEditorViewController: UIViewController {
return
}

self.editFunnel?.logStart()
self.editFunnel?.logStart(section.article?.url.wmf_language)

if let protectionStatus = section.article?.protection,
let allowedGroups = protectionStatus.allowedGroups(forAction: "edit") as? [String],
Expand Down

0 comments on commit c727ba6

Please sign in to comment.