Skip to content

Commit

Permalink
Custom goals
Browse files Browse the repository at this point in the history
  • Loading branch information
mgax committed Dec 18, 2023
1 parent 7b06dbe commit 6cca1ec
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions ietf/static_src/js/pages.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
import '../../blog/js/index';
import '../../utils/js/ab_testing';
11 changes: 11 additions & 0 deletions ietf/utils/js/ab_testing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
document.querySelector("html").addEventListener("click", (e) => {
if (e.target.tagName == "A") {
const href = e.target.getAttribute("href") || ""
if (href.startsWith("https://www.ietf.org/mailman/listinfo/")) {
wagtailAbTesting.triggerEvent("navigate-mailman")
}
if (href.startsWith("https://registration.ietf.org")) {

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High

'
https://registration.ietf.org
' may be followed by an arbitrary host name.
wagtailAbTesting.triggerEvent("navigate-registration")
}
}
})
23 changes: 23 additions & 0 deletions ietf/utils/wagtail_hooks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from django.conf import settings
from django.utils.html import format_html
from wagtail import hooks
from wagtail.models import Page
from wagtail_ab_testing.events import BaseEvent
from wagtail_modeladmin.options import ModelAdmin, modeladmin_register
from wagtailorderable.modeladmin.mixins import OrderableMixin

Expand Down Expand Up @@ -28,3 +30,24 @@ class MenuItemAdmin(OrderableMixin, ModelAdmin):


modeladmin_register(MenuItemAdmin)


class NavigateToRegistrationWebsite(BaseEvent):
name = "Navigate to registration website"


class NavigateToMailmanWebsite(BaseEvent):
name = "Navigate to Mailman website"


class SubmitDonationFormEvent(BaseEvent):
name = "Submit donation form"


@hooks.register("register_ab_testing_event_types")
def register_ab_testing_event_types():
return {
"navigate-registration": NavigateToRegistrationWebsite(),
"navigate-mailman": NavigateToMailmanWebsite(),
"submit-donation-form": SubmitDonationFormEvent(),
}

0 comments on commit 6cca1ec

Please sign in to comment.