From 20883ddba4c29d2be8fbca3f54c9a2e090ac26fc Mon Sep 17 00:00:00 2001 From: Patrizio Bekerle <patrizio@bekerle.com> Date: Tue, 27 Apr 2021 09:32:36 +0200 Subject: [PATCH] Send Matomo tracking events to "self" instead of parent in the app shell --- packages/app-shell/src/app-shell.js | 4 ++-- packages/common/src/adapter-lit-element.js | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/app-shell/src/app-shell.js b/packages/app-shell/src/app-shell.js index a13f9692..654ad8b2 100644 --- a/packages/app-shell/src/app-shell.js +++ b/packages/app-shell/src/app-shell.js @@ -276,7 +276,7 @@ export class AppShell extends ScopedElementsMixin(AdapterLitElement) { this.router.update(); // tell a dbp-provider to update the "lang" property - this.sendSetPropertyEvent('lang', lang); + this.sendSetPropertyEvent('lang', lang, true); } } @@ -750,7 +750,7 @@ export class AppShell extends ScopedElementsMixin(AdapterLitElement) { } track(action, message) { - this.sendSetPropertyEvent('analytics-event', {'category': action, 'action': message}); + this.sendSetPropertyEvent('analytics-event', {'category': action, 'action': message}, true); } _renderActivity() { diff --git a/packages/common/src/adapter-lit-element.js b/packages/common/src/adapter-lit-element.js index 93ac8c5f..ea57e4c1 100644 --- a/packages/common/src/adapter-lit-element.js +++ b/packages/common/src/adapter-lit-element.js @@ -307,9 +307,10 @@ export class AdapterLitElement extends LitElement { * * @param name * @param value + * @param sendToSelf Set this to "true" if the event should be sent to oneself instead of the parent (e.g. in the app shell if there isn't a provider around it) * @returns {boolean} */ - sendSetPropertyEvent(name, value) { + sendSetPropertyEvent(name, value, sendToSelf = false) { // Logger.debug("dbp-set-property", name, value); const event = new CustomEvent('dbp-set-property', { @@ -320,7 +321,7 @@ export class AdapterLitElement extends LitElement { // dispatch the dbp-set-property event to the parent (if there is any) so that the current element // doesn't terminate the event if it has the attribute set itself - const element = this.parentElement ? this.parentElement : this; + const element = this.parentElement && !sendToSelf ? this.parentElement : this; return element.dispatchEvent(event); } -- GitLab