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
This commit is contained in:
Vaidehi Joshi 2020-06-22 10:52:16 -07:00 committed by GitHub
parent 019ce5e0d8
commit 178ee374ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 });
}
</script>