Skip to content

Commit

Permalink
Merge pull request #4952 from wikimedia/T372517
Browse files Browse the repository at this point in the history
[ALT TEXT] Add additional action data when sending group assignment event
  • Loading branch information
mazevedofs authored Aug 29, 2024
2 parents eb66a78 + 350ad72 commit b9e2f33
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
6 changes: 5 additions & 1 deletion Wikipedia/Code/ArticleViewController+Editing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,11 @@ extension ArticleViewController: EditorViewControllerDelegate {

do {
try dataController.assignArticleEditorExperiment(isLoggedIn: isLoggedIn, project: project)
EditInteractionFunnel.shared.logAltTextDidAssignArticleEditorGroup(project: WikimediaProject(wmfProject: project))

if let user = dataStore.authenticationManager.getLoggedInUserCache(for: articleURL) {
EditInteractionFunnel.shared.logAltTextDidAssignArticleEditorGroup(username:user.name, userEditCount: user.editCount, articleTitle: articleTitle, image: filename, registrationDate: user.registrationDateString, project: WikimediaProject(wmfProject: project))
}

} catch let error {
DDLogWarn("Error assigning alt text article editor experiment: \(error)")
}
Expand Down
25 changes: 20 additions & 5 deletions Wikipedia/Code/EditInteractionFunnel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,20 @@ final class EditInteractionFunnel {

// MARK: Alt-Text-Experiment

func logAltTextDidAssignImageRecsGroup(project: WikimediaProject) {

func logAltTextDidAssignImageRecsGroup(username: String, userEditCount: UInt64, articleTitle: String, image: String, registrationDate: String?, project: WikimediaProject) {
guard let group = WMFAltTextDataController.shared?.assignedAltTextImageRecommendationsGroupForLogging() else {
return
}

var actionData: [String: String] = [:]
var actionData = ["article_title": articleTitle,
"image": image,
"username": username,
"event_user_revision_count": String(userEditCount)]

if let registrationDate {
actionData["user_create_date"] = registrationDate
}

switch group {
case "A":
actionData["exp_b_group"] = "a"
Expand All @@ -296,13 +303,21 @@ final class EditInteractionFunnel {
logEvent(activeInterface: .altTextEditingOnboarding, action: .groupAssignment, actionData: actionData, project: project)
}

func logAltTextDidAssignArticleEditorGroup(project: WikimediaProject) {
func logAltTextDidAssignArticleEditorGroup(username: String, userEditCount: UInt64, articleTitle: String, image: String, registrationDate: String?, project: WikimediaProject) {

guard let group = WMFAltTextDataController.shared?.assignedAltTextArticleEditorGroupForLogging() else {
return
}

var actionData: [String: String] = [:]
var actionData = ["article_title": articleTitle,
"image": image,
"username": username,
"event_user_revision_count": String(userEditCount)]

if let registrationDate {
actionData["user_create_date"] = registrationDate
}

switch group {
case "C":
actionData["exp_c_group"] = "c"
Expand Down
7 changes: 5 additions & 2 deletions Wikipedia/Code/ExploreViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1536,13 +1536,16 @@ extension ExploreViewController: WMFImageRecommendationsLoggingDelegate {

func logAltTextExperimentDidAssignGroup() {

guard let imageRecommendationsViewModel else {
guard let imageRecommendationsViewModel,
let lastRecommendation = imageRecommendationsViewModel.lastRecommendation,
let siteURL = dataStore.languageLinkController.appLanguage?.siteURL,
let user = dataStore.authenticationManager.getLoggedInUserCache(for: siteURL) else {
return
}

let project = WikimediaProject(wmfProject: imageRecommendationsViewModel.project)

Check notice on line 1546 in Wikipedia/Code/ExploreViewController.swift

View check run for this annotation

Xcode Cloud / Wikipedia | Run Tests | Test - iOS (Wikipedia)

Wikipedia/Code/ExploreViewController.swift#L1546

Initialization of immutable value 'project' was never used; consider replacing with assignment to '_' or removing it

EditInteractionFunnel.shared.logAltTextDidAssignImageRecsGroup(project: project)
EditInteractionFunnel.shared.logAltTextDidAssignImageRecsGroup(username:user.name, userEditCount: user.editCount, articleTitle: lastRecommendation.title, image: lastRecommendation.imageData.filename, registrationDate: user.registrationDateString, project: WikimediaProject(wmfProject: imageRecommendationsViewModel.project))
}

func logOnboardingDidTapPrimaryButton() {
Expand Down

0 comments on commit b9e2f33

Please sign in to comment.