Invite members for task experiment

Merged Alex Buijs requested to merge invite-members-for-task into master

What does this MR do?

This MR adds an experiment for the following flow:

  • Add an invite link to the create and verify track in-product marketing emails
  • When clicking the link, open the invite member modal on the group's dashboard page
  • After selecting a minimum access level of Developer, show the various tasks
  • After selecting at least 1 task, show the project dropdown
  • When adding existing users to a group and tasks are selected, create issues for the tasks in the selected project and assign the users. If an open issue already exists for the task, just assign them.
  • When adding new users to a group and tasks are selected, create issues for the tasks in the selected project and assign the user when the they sign up. If an open issue already exists for the task, just assign them.
  • Redirect new users to the assigned issues after signing up

Screenshots or Screencasts (strongly suggested)

Screencast

This is an 8 minute YouTube video demo on GitLab's Unfiltered playlist: https://youtu.be/_xbLksgYvHw.

Screenshots

The in-product marketing email with the invite link Create-a-project-in-GitLab-in-5-minutes
The open modal on the group dashboard page with the task options and project selector Group-1-_-GitLab
The open modal on the group dashboard page when there are no projects yet Group-2-_-GitLab
The invite email for existing users with all tasks assigned Access-to-the-test-group-was-granted
The invite email for new users with all tasks assigned Alex-Buijs-invited-you-to-join-GitLab

How to setup and validate locally (strongly suggested)

  1. Enable the experiment (in rails console)
    Feature.enable(:invite_members_for_task)
  2. Send an in-product marketing email (in rails console)
    group = Group.last
    user = group.owners.last
    Notify.in_product_marketing_email(user.id, group.id, :create, 0).deliver_now
  3. View the email by visiting http://localhost:3000/rails/letter_opener
  4. Click the Invite them to help out. link in the email

Database migrations

Up
== 20211004122540 CreateMemberTasks: migrating ================================
-- create_table(:member_tasks, {})
   -> 0.0173s
== 20211004122540 CreateMemberTasks: migrated (0.0173s) =======================

== 20211005112404 AddMemberIdForeignKeyToMemberTasks: migrating ===============
-- transaction_open?()
   -> 0.0000s
-- foreign_keys(:member_tasks)
   -> 0.0034s
-- transaction_open?()
   -> 0.0000s
-- execute("ALTER TABLE member_tasks\nADD CONSTRAINT fk_12816d4bbb\nFOREIGN KEY (member_id)\nREFERENCES members (id)\nON DELETE CASCADE\nNOT VALID;\n")
   -> 0.0014s
-- execute("SET statement_timeout TO 0")
   -> 0.0005s
-- execute("ALTER TABLE member_tasks VALIDATE CONSTRAINT fk_12816d4bbb;")
   -> 0.0029s
-- execute("RESET statement_timeout")
   -> 0.0005s
== 20211005112404 AddMemberIdForeignKeyToMemberTasks: migrated (0.0128s) ======

== 20211005112645 AddProjectIdForeignKeyToMemberTasks: migrating ==============
-- transaction_open?()
   -> 0.0000s
-- foreign_keys(:member_tasks)
   -> 0.0022s
-- transaction_open?()
   -> 0.0000s
-- execute("ALTER TABLE member_tasks\nADD CONSTRAINT fk_ab636303dd\nFOREIGN KEY (project_id)\nREFERENCES projects (id)\nON DELETE CASCADE\nNOT VALID;\n")
   -> 0.0029s
-- execute("ALTER TABLE member_tasks VALIDATE CONSTRAINT fk_ab636303dd;")
   -> 0.0102s
== 20211005112645 AddProjectIdForeignKeyToMemberTasks: migrated (0.0224s) =====
Down
== 20211005112645 AddProjectIdForeignKeyToMemberTasks: reverting ==============
-- transaction_open?()
   -> 0.0000s
-- remove_foreign_key(:member_tasks, {:column=>:project_id})
   -> 0.0048s
== 20211005112645 AddProjectIdForeignKeyToMemberTasks: reverted (0.0264s) =====

== 20211005112404 AddMemberIdForeignKeyToMemberTasks: reverting ===============
-- transaction_open?()
   -> 0.0000s
-- remove_foreign_key(:member_tasks, {:column=>:member_id})
   -> 0.0031s
== 20211005112404 AddMemberIdForeignKeyToMemberTasks: reverted (0.0287s) ======

== 20211004122540 CreateMemberTasks: reverting ================================
-- drop_table(:member_tasks, {})
   -> 0.0031s
== 20211004122540 CreateMemberTasks: reverted (0.0065s) =======================

Issue: gitlab-org/growth/team-tasks#432 (closed)

Experiment tracking issue: #339747 (closed)

Edited by Alex Buijs