From b8be9992e49ea3b3c9a646a1767e64817abc1ee0 Mon Sep 17 00:00:00 2001
From: Patrizio Bekerle <patrizio@bekerle.com>
Date: Thu, 15 Apr 2021 10:56:32 +0200
Subject: [PATCH] Prevent Matomo complaining about empty action

---
 packages/matomo/src/matomo.js | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/packages/matomo/src/matomo.js b/packages/matomo/src/matomo.js
index 28cef91f..74730f73 100644
--- a/packages/matomo/src/matomo.js
+++ b/packages/matomo/src/matomo.js
@@ -164,8 +164,14 @@ export class MatomoElement extends DBPLitElement {
     pushEvent(event) {
         window._paq = window._paq || [];
 
+        // make sure the event action is a non-empty string
+        // prevents: "Error while logging event: Parameters `category` and `action` must not be empty or filled with whitespaces"
+        if (event[1] === null || event[1] === '' || event[1] === undefined) {
+            event[1] = 'empty';
+        }
+
         // make sure the event name is a non-empty string
-        if (event[2] === null || event[2] === '') {
+        if (event[2] === null || event[2] === '' || event[2] === undefined) {
             event[2] = 'empty';
         } else if (typeof event[2] === 'object') {
             event[2] = JSON.stringify(event[2]);
-- 
GitLab