Skip to content
Snippets Groups Projects
Commit 0ee96d11 authored by Neuber, Eugen Ramon's avatar Neuber, Eugen Ramon :speech_balloon:
Browse files

Replay last event when user loges in

See issue #29
parent b1759f67
No related branches found
No related tags found
1 merge request!2Matomo web component
Pipeline #13000 failed
This commit is part of merge request !2. Comments created here will be created in the context of that merge request.
...@@ -11,6 +11,7 @@ export class MatomoElement extends DBPLitElement { ...@@ -11,6 +11,7 @@ export class MatomoElement extends DBPLitElement {
this.endpoint = ''; this.endpoint = '';
this.siteId = -1; this.siteId = -1;
this.isRunning = false; this.isRunning = false;
this.lastEvent = [];
} }
...@@ -91,6 +92,11 @@ export class MatomoElement extends DBPLitElement { ...@@ -91,6 +92,11 @@ export class MatomoElement extends DBPLitElement {
}); });
this.isRunning = true; this.isRunning = true;
if (this.lastEvent.length > 0) {
console.log('MatomoElement* (' + this.isRunning + '): ' + this.lastEvent[1] + ', ' + this.lastEvent[2]);
_paq.push(this.lastEvent);
this.lastEvent = [];
}
return; return;
} }
if (! loggedIn && this.isRunning) { if (! loggedIn && this.isRunning) {
...@@ -102,8 +108,11 @@ export class MatomoElement extends DBPLitElement { ...@@ -102,8 +108,11 @@ export class MatomoElement extends DBPLitElement {
track (action, message) { track (action, message) {
console.log('MatomoElement (' + this.isRunning + '): ' + action + ', ' + message); console.log('MatomoElement (' + this.isRunning + '): ' + action + ', ' + message);
const event = ['trackEvent', action, message];
if (this.isRunning) { if (this.isRunning) {
_paq.push(['trackEvent', action, message]); _paq.push(event);
} else {
this.lastEvent = event;
} }
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment