From 178ee374ff31dce401e338bddc38ba8b9f6e5ec7 Mon Sep 17 00:00:00 2001 From: Vaidehi Joshi Date: Mon, 22 Jun 2020 10:52:16 -0700 Subject: [PATCH] Notify Honeybadger when no id can be found for a welcome notification (#8831) * Notify Honeybadger when no id can be found for a welcome notification Also add the event's target's text to the tracking data for a welcome notification's click event. * Destructure text and title from event.target --- app/views/notifications/index.html.erb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/views/notifications/index.html.erb b/app/views/notifications/index.html.erb index 2e5773387..d38ae45c2 100644 --- a/app/views/notifications/index.html.erb +++ b/app/views/notifications/index.html.erb @@ -25,9 +25,13 @@ * * @param {Event} The click event on the notification. */ - function trackNotification(e) { - let title = e.target.parentElement.id - ahoy.track("Clicked Welcome Notification", { title }); + function trackNotification(event) { + const { parentElement: { id: title }, text } = event.target; + if (!title) { + Honeybadger.notify(`Could not find parentElement.id when clicking on event target text: ${text}`); + } + + ahoy.track("Clicked Welcome Notification", { title, text }); }