google_analytics: Track realm registration separately from user signup.

While the function which processes the realm registration and
signup remains the same, we use different urls and functions to
call the process so that we can separately track them. This will
help us know the conversion rate of realm registration after
receiving the confirmation link.
This commit is contained in:
Aman Agrawal 2023-02-24 08:08:26 +00:00 committed by Tim Abbott
parent 6a4c12b41e
commit c928c87645
5 changed files with 27 additions and 6 deletions

View File

@ -13,7 +13,7 @@ requisite context to make a useful signup form. Therefore, we immediately
post to another view which executes in our code to produce the desired form.
#}
<form id="register" action="/accounts/register/" method="post">
<form id="register" action="{{ registration_url }}" method="post">
{{ csrf_input }}
<input type="hidden" value="{{ key }}" name="key"/>
<input type="hidden" value="1" name="from_confirmation"/>

View File

@ -306,7 +306,7 @@ class TestGenerateRealmCreationLink(ZulipTestCase):
# Bypass sending mail for confirmation, go straight to creation form
result = self.client_get(result["Location"])
self.assert_in_response('action="/accounts/register/"', result)
self.assert_in_response('action="/realm/register/"', result)
# Original link is now dead
result = self.client_get(generated_link)

View File

@ -3625,7 +3625,7 @@ class RealmCreationTest(ZulipTestCase):
"key": find_key_by_email(email),
"from_confirmation": "1",
}
result = self.client_post("/accounts/register/", payload)
result = self.client_post("/realm/register/", payload)
# Assert that the form did not prompt the user for enabling
# marketing emails.
self.assert_not_in_success_response(['input id="id_enable_marketing_emails"'], result)

View File

@ -116,14 +116,24 @@ def get_prereg_key_and_redirect(
accidentally adding an extra character after pasting).
"""
try:
check_prereg_key(request, confirmation_key)
prereg_user = check_prereg_key(request, confirmation_key)
except ConfirmationKeyError as e:
return render_confirmation_key_error(request, e)
realm_creation = prereg_user.realm_creation
registration_url = reverse("accounts_register")
if realm_creation:
registration_url = reverse("realm_register")
return render(
request,
"confirmation/confirm_preregistrationuser.html",
context={"key": confirmation_key, "full_name": full_name},
context={
"key": confirmation_key,
"full_name": full_name,
"registration_url": registration_url,
},
)
@ -150,8 +160,17 @@ def check_prereg_key(request: HttpRequest, confirmation_key: str) -> Preregistra
@add_google_analytics
@require_post
def realm_register(*args: Any, **kwargs: Any) -> HttpResponse:
return registration_helper(*args, **kwargs)
@require_post
def accounts_register(*args: Any, **kwargs: Any) -> HttpResponse:
return registration_helper(*args, **kwargs)
@has_request_variables
def accounts_register(
def registration_helper(
request: HttpRequest,
key: str = REQ(default=""),
timezone: str = REQ(default="", converter=to_timezone_or_empty),

View File

@ -127,6 +127,7 @@ from zerver.views.registration import (
get_prereg_key_and_redirect,
new_realm_send_confirm,
realm_redirect,
realm_register,
signup_send_confirm,
)
from zerver.views.report import (
@ -579,6 +580,7 @@ i18n_urls = [
name="new_realm_send_confirm",
),
path("accounts/register/", accounts_register, name="accounts_register"),
path("realm/register/", realm_register, name="realm_register"),
path(
"accounts/do_confirm/<confirmation_key>",
get_prereg_key_and_redirect,