diff --git a/.idea/wordRotator.iml b/.idea/wordRotator.iml index 86ac3ff..93b726a 100755 --- a/.idea/wordRotator.iml +++ b/.idea/wordRotator.iml @@ -3,7 +3,6 @@ - diff --git a/public/html/application/setting-template.html b/public/html/application/setting-template.html index aa32557..a8080df 100644 --- a/public/html/application/setting-template.html +++ b/public/html/application/setting-template.html @@ -1 +1 @@ -

\ No newline at end of file +

\ No newline at end of file diff --git a/public/js/app.js b/public/js/app.js index 0bcc033..9145988 100755 --- a/public/js/app.js +++ b/public/js/app.js @@ -3168,6 +3168,11 @@ function applyPolyfills() { elem.addEventListener("transitionend", transEndLis); elem.addEventListener("transitioncancel", transCancelledLis); }); + //Fallback + setTimeout(() => { + resolve(false); + }, (time+delay)*1000); + //Nach Seitenneuzeichnen, damit chrome das immer macht (und FF auch) requestAnimationFrame(function () { requestAnimationFrame(function () { @@ -3190,7 +3195,6 @@ function applyPolyfills() { elem.removeEventListener("transitioncancel", transCancelledLis); elem.style.opacity = null; elem.style.transition = null; - console.log("transEnd"); resolve(true, e); }; @@ -3199,13 +3203,11 @@ function applyPolyfills() { elem.removeEventListener("transitioncancel", transCancelledLis); elem.style.opacity = null; elem.style.transition = null; - console.log("transCancelled"); resolve(false, e); }; elem.addEventListener("transitionend", transEndLis); elem.addEventListener("transitioncancel", transCancelledLis); - console.log(getComputedStyle(elem).getPropertyValue("opacity")); if (getComputedStyle(elem).getPropertyValue("opacity") === "1"){ resolve(false); } @@ -4605,7 +4607,7 @@ class Matomo { static init() { Matomo.isTrackingPromise = new Promise(async (resolve) => { - let shouldTrack = localStorage.getItem(Matomo.LOCAL_STORAGE_KEY); + let shouldTrack = Helper.nonNull(localStorage.getItem(Matomo.LOCAL_STORAGE_KEY), "1"); if (Helper.isNull(shouldTrack)) { shouldTrack = await Matomo._askIsTracking(); localStorage.setItem(Matomo.LOCAL_STORAGE_KEY, shouldTrack); @@ -4617,10 +4619,10 @@ class Matomo { resolve(shouldTrack); }); Matomo.isTrackingPromise.then(() => { - Matomo.push(['trackPageView']); - Matomo.push(['enableLinkTracking']); - Matomo.push(['setTrackerUrl', Matomo.TRACK_SITE + '/piwik.php']); - Matomo.push(['setSiteId', Matomo.SIDE_ID]); + Matomo.push(['trackPageView'], true); + Matomo.push(['enableLinkTracking'], true); + Matomo.push(['setTrackerUrl', Matomo.TRACK_SITE + '/piwik.php'], true); + Matomo.push(['setSiteId', Matomo.SIDE_ID + ""], true); let d = document, g = d.createElement('script'), s = d.getElementsByTagName('head')[0]; g.type = 'text/javascript'; @@ -4629,19 +4631,52 @@ class Matomo { g.src = Matomo.TRACK_SITE + '/piwik.js'; s.appendChild(g); }); + // window.addEventListener('hashchange', () => { + // Matomo.update() + // }); + } + + static update(title) { + if (Helper.nonNull(Matomo.currentUrl)){ + Matomo.push(['setReferrerUrl', Matomo.currentUrl]); + } + Matomo.currentUrl = window.location.pathname+window.location.search; + Matomo.push(['setCustomUrl', Matomo.currentUrl]); + Matomo.push(['setDocumentTitle', title]); + + // remove all previously assigned custom variables, requires Matomo (formerly Piwik) 3.0.2 + Matomo.push(['deleteCustomVariables', 'page']); + Matomo.push(['setGenerationTimeMs', 0]); + Matomo.push(['trackPageView']); + + // make Matomo aware of newly added content + var content = document.getElementById('site-content'); + Matomo.push(['MediaAnalytics::scanForMedia', content]); + Matomo.push(['FormAnalytics::scanForForms', content]); + Matomo.push(['trackContentImpressionsWithinNode', content]); + Matomo.push(['enableLinkTracking']); } static async _askIsTracking() { - Matomo.isTrackingPromise = Matomo.query("isTracked") - .then(xml => { - let textContent = xml.firstChild.textContent; - // localStorage.setItem(Matomo.LOCAL_STORAGE_KEY, textContent); - return (textContent === "1") - }); + Matomo.isTrackingPromise = new Promise(resolve => { + Matomo.push([function () { + resolve(!this["isUserOptedOut"]()); + }]); + Matomo.push([function () { + resolve(!this["isUserOptedOut"]()); + }]); + }); + // Matomo.isTrackingPromise = Matomo.query("isTracked") + // .then(xml => { + // let textContent = xml.firstChild.textContent; + // // localStorage.setItem(Matomo.LOCAL_STORAGE_KEY, textContent); + // return (textContent === "1") + // }); return Matomo.isTrackingPromise; } - static async query(method) { + static + async query(method) { return fetch(Matomo.TRACK_SITE + Matomo.BASE_PATH + method, { "mode": "cors", "credentials": "include", @@ -4652,19 +4687,34 @@ class Matomo { return Matomo.isTrackingPromise; } - static async setTrack(shouldTrack) { + static + async setTrack(shouldTrack) { Matomo.isTrackingPromise = Promise.resolve(shouldTrack); localStorage.setItem(Matomo.LOCAL_STORAGE_KEY, (shouldTrack === true) ? "1" : "0"); - return await Matomo.query((shouldTrack) ? "doTrack" : "doIgnore"); - } - - static async push(arr) { - if (await Matomo.getTrackingPromise()) { - window["_paq"].push(arr); + // return await Matomo.query((shouldTrack) ? "doTrack" : "doIgnore"); + if (shouldTrack) { + Matomo.push(["forgetUserOptOut"], true); + } + else { + Matomo.push(["optUserOut"], true); } } + + static + async push(arr, force) { + // force = Helper.nonNull(force, false); + + if (!Array.isArray(arr)) { + arr = [arr]; + } + // if (force || await Matomo.getTrackingPromise()) { + window["_paq"].push(arr); + // } + } } +Matomo.currentUrl = null; + Matomo.LOCAL_STORAGE_KEY = "matomoShouldTrack"; Matomo.TRACK_SITE = "//matomo.silas.link"; Matomo.BASE_PATH = "/index.php?module=API&method=AjaxOptOut."; @@ -4672,7 +4722,6 @@ Matomo.SIDE_ID = "1"; InitPromise.addPromise(() => { window["_paq"] = window["_paq"] || []; - Matomo.init(); }); @@ -5851,6 +5900,11 @@ class EndSite extends WordRotatorBaseSite{ constructor(siteManager) { super(siteManager, "html/application/end.html"); } + + onStart(args) { + Matomo.update("End Site"); + return super.onStart(args); + } } class LevelSite extends WordRotatorBaseSite { @@ -5979,7 +6033,9 @@ class LevelSite extends WordRotatorBaseSite { this.levelScaler = await scaleHelper.scaleToFull(levelSegment, levelSegment.parentElement, false, false, 1, level.words[0].length * 1.5, null, 0); this.level = level; - return this.tutorial(); + let res = this.tutorial(); + Matomo.push(["trackEvent", "LevelSite", "LoadLastLevel"]); + return res; } } catch (e) { @@ -6027,6 +6083,10 @@ class LevelSite extends WordRotatorBaseSite { this.wonParams.aborted = true; clearTimeout(this.wonParams.coinCounterTimer); + //LevelCounter * 2 - 1, damit der durchschnittswert stimmt + Matomo.push(["trackEvent", "LevelSite", "NextLevel", "Level Number Average", this.levelCounter*2-1]); + Matomo.push(["trackEvent", "LevelSite", "NextLevel", "Level Number Normal", this.levelCounter]); + return this.tutorial(); } catch (e) { @@ -6035,6 +6095,7 @@ class LevelSite extends WordRotatorBaseSite { } onStart(args) { + Matomo.update("Level Site"); let res = super.onStart(args); if (this.levelCounterAction) { @@ -6124,6 +6185,8 @@ class LevelSite extends WordRotatorBaseSite { this.continueButtonScaler(); this.levelScaler(); + Matomo.push(["trackEvent", "LevelSite", "LevelWon", "Coins", parseInt(Helper.nonNull(localStorage.getItem("coins"), "0"))]); + await savePromise; } catch (e) { @@ -6154,14 +6217,16 @@ class LevelSite extends WordRotatorBaseSite { } segmentToHelp.setIsRotatable(false); this.level.saveAsCurrentLevel(); + + Matomo.push(["trackEvent", "LevelSite", "Help", "Coins", parseInt(Helper.nonNull(localStorage.getItem("coins"), "0"))]); } else { FlashMessenger.addMessage("not-enough-coins"); + Matomo.push(["trackEvent", "LevelSite", "Help", "Not enough Coins", parseInt(Helper.nonNull(localStorage.getItem("coins"), "0"))]); } } async tutorial() { - if (this.level.id === LevelSite.TUTORIAL.FIRST_LEVEL) { let currentStep = Helper.nonNull(localStorage.getItem("tutorial-step"), "1"); @@ -6303,6 +6368,7 @@ class MenuSite extends WordRotatorBaseSite { } onStart(args) { + Matomo.update("Menu Site"); let res = super.onStart(args); let level = new MainMenuLevel(this.templateContainer); @@ -6310,6 +6376,7 @@ class MenuSite extends WordRotatorBaseSite { level.createSegments(); level.getWonPromise().then(() => { + Matomo.push(["trackEvent", "MainMenu", "levelSolved"]); this.startSite(LevelSite); }); @@ -6378,6 +6445,7 @@ class MenuSite extends WordRotatorBaseSite { let playButton = this.findBy("#play-button"); playButton.addEventListener("click", () => { + Matomo.push(["trackEvent", "MainMenu", "startButton"]); this.startSite(LevelSite, this.loadLevelPromise); }); @@ -6417,6 +6485,7 @@ class MenuSite extends WordRotatorBaseSite { if (playMusicButton.checked){ soundManager.play(SoundManager.CHANNELS.MUSIC); } + Matomo.push(["trackEvent", "MainMenu", "PlayMusic", "Play Music", (playMusicButton.checked)?1:0]); }); let playSoundButton = this.findBy("#play-sound"); @@ -6424,6 +6493,7 @@ class MenuSite extends WordRotatorBaseSite { playSoundButton.addEventListener("change", () => { settingsManager.setSetting("play-sound", playSoundButton.checked); soundManager.set({muted: !playSoundButton.checked}, SoundManager.CHANNELS.SOUND); + Matomo.push(["trackEvent", "MainMenu", "PlaySound", "Play Sound", (playSoundButton.checked)?1:0]); }); } @@ -6482,6 +6552,11 @@ class PrivacyPolicySite extends WordRotatorBaseSite { constructor(siteManager) { super(siteManager, "html/application/privacyPolicy.html", "privacyPolicy"); } + + onStart(args) { + Matomo.update("Privacy Policy Site"); + return super.onStart(args); + } } InitPromise.addPromise(app => { @@ -6492,6 +6567,11 @@ class CreditsSite extends WordRotatorBaseSite{ constructor(siteManager) { super(siteManager, "html/application/credits.html", "credits"); } + + onStart(args) { + Matomo.update("Credits Site"); + return super.onStart(args); + } } InitPromise.addPromise(app => { @@ -6535,27 +6615,6 @@ class WordRotatorSettingFragment extends LocalStorageSettingsFragment { } onFirstStart() { - // let themeTemplate = this.findBy("#theme-radio-template"); - // delete themeTemplate["id"]; - // let themeTemplateContainer = themeTemplate.parentNode; - // themeTemplateContainer.removeAllChildren(); - // - // for (let i = 0; i < ThemeManager.themes.length; i++) { - // let themeElem = Helper.cloneNode(themeTemplate); - // let theme = ThemeManager.themes[i]; - // themeElem.appendChild(Translator.makePersistentTranslation(theme._name)); - // - // let inputElem = themeElem.querySelector("input"); - // inputElem.value = theme._className; - // - // inputElem.addEventListener("change", function() { - // if (this.checked){ - // ThemeManager.changeCurrentTheme(theme) - // } - // }); - // themeTemplateContainer.appendChild(themeElem); - // } - let currentThemeName = ThemeManager.currentTheme._name; SettingsManager.getInstance().setSetting("theme", currentThemeName); @@ -6607,6 +6666,11 @@ class WordRotatorSettingFragment extends LocalStorageSettingsFragment { return super.onFirstStart(); } + + onStart() { + Matomo.update("Settings Site"); + super.onStart(); + } } InitPromise.addPromise(function () { @@ -6623,6 +6687,8 @@ SystemSettings.setBasePath(basePath); Translator.supportedLanguages = ["de"]; Translator.markTranslations = false; +Matomo.SIDE_ID = "2"; + applyPolyfills(); ThemeManager.addTheme(new Theme('red', '')); diff --git a/src/js/lib/pwa-assets.js b/src/js/lib/pwa-assets.js index 1dc16e3..758e973 100755 --- a/src/js/lib/pwa-assets.js +++ b/src/js/lib/pwa-assets.js @@ -12,7 +12,7 @@ class Matomo { static init() { Matomo.isTrackingPromise = new Promise(async (resolve) => { - let shouldTrack = localStorage.getItem(Matomo.LOCAL_STORAGE_KEY); + let shouldTrack = Helper.nonNull(localStorage.getItem(Matomo.LOCAL_STORAGE_KEY), "1"); if (Helper.isNull(shouldTrack)) { shouldTrack = await Matomo._askIsTracking(); localStorage.setItem(Matomo.LOCAL_STORAGE_KEY, shouldTrack); @@ -24,10 +24,10 @@ class Matomo { resolve(shouldTrack); }); Matomo.isTrackingPromise.then(() => { - Matomo.push(['trackPageView']); - Matomo.push(['enableLinkTracking']); - Matomo.push(['setTrackerUrl', Matomo.TRACK_SITE + '/piwik.php']); - Matomo.push(['setSiteId', Matomo.SIDE_ID]); + Matomo.push(['trackPageView'], true); + Matomo.push(['enableLinkTracking'], true); + Matomo.push(['setTrackerUrl', Matomo.TRACK_SITE + '/piwik.php'], true); + Matomo.push(['setSiteId', Matomo.SIDE_ID + ""], true); let d = document, g = d.createElement('script'), s = d.getElementsByTagName('head')[0]; g.type = 'text/javascript'; @@ -36,19 +36,52 @@ class Matomo { g.src = Matomo.TRACK_SITE + '/piwik.js'; s.appendChild(g); }); + // window.addEventListener('hashchange', () => { + // Matomo.update() + // }); + } + + static update(title) { + if (Helper.nonNull(Matomo.currentUrl)){ + Matomo.push(['setReferrerUrl', Matomo.currentUrl]); + } + Matomo.currentUrl = window.location.pathname+window.location.search; + Matomo.push(['setCustomUrl', Matomo.currentUrl]); + Matomo.push(['setDocumentTitle', title]); + + // remove all previously assigned custom variables, requires Matomo (formerly Piwik) 3.0.2 + Matomo.push(['deleteCustomVariables', 'page']); + Matomo.push(['setGenerationTimeMs', 0]); + Matomo.push(['trackPageView']); + + // make Matomo aware of newly added content + var content = document.getElementById('site-content'); + Matomo.push(['MediaAnalytics::scanForMedia', content]); + Matomo.push(['FormAnalytics::scanForForms', content]); + Matomo.push(['trackContentImpressionsWithinNode', content]); + Matomo.push(['enableLinkTracking']); } static async _askIsTracking() { - Matomo.isTrackingPromise = Matomo.query("isTracked") - .then(xml => { - let textContent = xml.firstChild.textContent; - // localStorage.setItem(Matomo.LOCAL_STORAGE_KEY, textContent); - return (textContent === "1") - }); + Matomo.isTrackingPromise = new Promise(resolve => { + Matomo.push([function () { + resolve(!this["isUserOptedOut"]()); + }]); + Matomo.push([function () { + resolve(!this["isUserOptedOut"]()); + }]); + }); + // Matomo.isTrackingPromise = Matomo.query("isTracked") + // .then(xml => { + // let textContent = xml.firstChild.textContent; + // // localStorage.setItem(Matomo.LOCAL_STORAGE_KEY, textContent); + // return (textContent === "1") + // }); return Matomo.isTrackingPromise; } - static async query(method) { + static + async query(method) { return fetch(Matomo.TRACK_SITE + Matomo.BASE_PATH + method, { "mode": "cors", "credentials": "include", @@ -59,19 +92,34 @@ class Matomo { return Matomo.isTrackingPromise; } - static async setTrack(shouldTrack) { + static + async setTrack(shouldTrack) { Matomo.isTrackingPromise = Promise.resolve(shouldTrack); localStorage.setItem(Matomo.LOCAL_STORAGE_KEY, (shouldTrack === true) ? "1" : "0"); - return await Matomo.query((shouldTrack) ? "doTrack" : "doIgnore"); - } - - static async push(arr) { - if (await Matomo.getTrackingPromise()) { - window["_paq"].push(arr); + // return await Matomo.query((shouldTrack) ? "doTrack" : "doIgnore"); + if (shouldTrack) { + Matomo.push(["forgetUserOptOut"], true); + } + else { + Matomo.push(["optUserOut"], true); } } + + static + async push(arr, force) { + // force = Helper.nonNull(force, false); + + if (!Array.isArray(arr)) { + arr = [arr]; + } + // if (force || await Matomo.getTrackingPromise()) { + window["_paq"].push(arr); + // } + } } +Matomo.currentUrl = null; + Matomo.LOCAL_STORAGE_KEY = "matomoShouldTrack"; Matomo.TRACK_SITE = "//matomo.silas.link"; Matomo.BASE_PATH = "/index.php?module=API&method=AjaxOptOut."; @@ -79,7 +127,6 @@ Matomo.SIDE_ID = "1"; InitPromise.addPromise(() => { window["_paq"] = window["_paq"] || []; - Matomo.init(); }); diff --git a/src/js/lib/pwa-lib.js b/src/js/lib/pwa-lib.js index 7e969d2..a122e30 100755 --- a/src/js/lib/pwa-lib.js +++ b/src/js/lib/pwa-lib.js @@ -4156,6 +4156,11 @@ function applyPolyfills() { elem.addEventListener("transitionend", transEndLis); elem.addEventListener("transitioncancel", transCancelledLis); }); + //Fallback + setTimeout(() => { + resolve(false); + }, (time+delay)*1000); + //Nach Seitenneuzeichnen, damit chrome das immer macht (und FF auch) requestAnimationFrame(function () { requestAnimationFrame(function () { @@ -4178,7 +4183,6 @@ function applyPolyfills() { elem.removeEventListener("transitioncancel", transCancelledLis); elem.style.opacity = null; elem.style.transition = null; - console.log("transEnd"); resolve(true, e); }; @@ -4187,13 +4191,11 @@ function applyPolyfills() { elem.removeEventListener("transitioncancel", transCancelledLis); elem.style.opacity = null; elem.style.transition = null; - console.log("transCancelled"); resolve(false, e); }; elem.addEventListener("transitionend", transEndLis); elem.addEventListener("transitioncancel", transCancelledLis); - console.log(getComputedStyle(elem).getPropertyValue("opacity")); if (getComputedStyle(elem).getPropertyValue("opacity") === "1"){ resolve(false); } diff --git a/src/js/settings.js b/src/js/settings.js index 5e151b2..3aec2cf 100755 --- a/src/js/settings.js +++ b/src/js/settings.js @@ -12,4 +12,4 @@ SystemSettings.setBasePath(basePath); Translator.supportedLanguages = ["de"]; Translator.markTranslations = false; -Matomo.SIDE_ID = 2; +Matomo.SIDE_ID = "2"; diff --git a/src/module/Application/pwa/html/application/setting-template.html b/src/module/Application/pwa/html/application/setting-template.html index 4ba69be..0391640 100644 --- a/src/module/Application/pwa/html/application/setting-template.html +++ b/src/module/Application/pwa/html/application/setting-template.html @@ -1,4 +1,4 @@ -
+
diff --git a/src/module/Application/pwa/js/Fragment/WordRotatorSettingFragment.js b/src/module/Application/pwa/js/Fragment/WordRotatorSettingFragment.js index cd4d47b..8679a97 100644 --- a/src/module/Application/pwa/js/Fragment/WordRotatorSettingFragment.js +++ b/src/module/Application/pwa/js/Fragment/WordRotatorSettingFragment.js @@ -12,27 +12,6 @@ export class WordRotatorSettingFragment extends LocalStorageSettingsFragment { } onFirstStart() { - // let themeTemplate = this.findBy("#theme-radio-template"); - // delete themeTemplate["id"]; - // let themeTemplateContainer = themeTemplate.parentNode; - // themeTemplateContainer.removeAllChildren(); - // - // for (let i = 0; i < ThemeManager.themes.length; i++) { - // let themeElem = Helper.cloneNode(themeTemplate); - // let theme = ThemeManager.themes[i]; - // themeElem.appendChild(Translator.makePersistentTranslation(theme._name)); - // - // let inputElem = themeElem.querySelector("input"); - // inputElem.value = theme._className; - // - // inputElem.addEventListener("change", function() { - // if (this.checked){ - // ThemeManager.changeCurrentTheme(theme) - // } - // }); - // themeTemplateContainer.appendChild(themeElem); - // } - let currentThemeName = ThemeManager.currentTheme._name; SettingsManager.getInstance().setSetting("theme", currentThemeName); @@ -84,6 +63,11 @@ export class WordRotatorSettingFragment extends LocalStorageSettingsFragment { return super.onFirstStart(); } + + onStart() { + Matomo.update("Settings Site"); + super.onStart(); + } } InitPromise.addPromise(function () { diff --git a/src/module/Application/pwa/js/site/CreditsSite.js b/src/module/Application/pwa/js/site/CreditsSite.js index 3f090a9..61563f3 100644 --- a/src/module/Application/pwa/js/site/CreditsSite.js +++ b/src/module/Application/pwa/js/site/CreditsSite.js @@ -1,11 +1,17 @@ import {WordRotatorBaseSite} from "./WordRotatorBaseSite"; import {InitPromise} from "../../../../../js/lib/pwa-lib"; import {PrivacyPolicySite} from "./PrivacyPolicySite"; +import {Matomo} from "../../../../../js/lib/pwa-assets"; export class CreditsSite extends WordRotatorBaseSite{ constructor(siteManager) { super(siteManager, "html/application/credits.html", "credits"); } + + onStart(args) { + Matomo.update("Credits Site"); + return super.onStart(args); + } } InitPromise.addPromise(app => { diff --git a/src/module/Application/pwa/js/site/EndSite.js b/src/module/Application/pwa/js/site/EndSite.js index bf48bbf..e2f9e03 100755 --- a/src/module/Application/pwa/js/site/EndSite.js +++ b/src/module/Application/pwa/js/site/EndSite.js @@ -1,7 +1,13 @@ import {WordRotatorBaseSite} from "./WordRotatorBaseSite"; +import {Matomo} from "../../../../../js/lib/pwa-assets"; export class EndSite extends WordRotatorBaseSite{ constructor(siteManager) { super(siteManager, "html/application/end.html"); } + + onStart(args) { + Matomo.update("End Site"); + return super.onStart(args); + } } \ No newline at end of file diff --git a/src/module/Application/pwa/js/site/LevelSite.js b/src/module/Application/pwa/js/site/LevelSite.js index c1575c4..061836a 100755 --- a/src/module/Application/pwa/js/site/LevelSite.js +++ b/src/module/Application/pwa/js/site/LevelSite.js @@ -2,7 +2,7 @@ import {FlashMessenger, Helper, Menu, MenuAction, SystemSettings} from "../../.. import {TemplateContainer} from "../wordrotator/Segment/TemplateContainer"; import {LevelHelper} from "../wordrotator/Level/LevelHelper"; import {WordRotatorDb} from "../WordRotatorDb"; -import {ScaleHelper, SoundManager} from "../../../../../js/lib/pwa-assets"; +import {Matomo, ScaleHelper, SoundManager} from "../../../../../js/lib/pwa-assets"; import {EndSite} from "./EndSite"; import {WordRotatorBaseSite} from "./WordRotatorBaseSite"; import {SettingsManager} from "../../../../../js/lib/pwa-core"; @@ -133,7 +133,9 @@ export class LevelSite extends WordRotatorBaseSite { this.levelScaler = await scaleHelper.scaleToFull(levelSegment, levelSegment.parentElement, false, false, 1, level.words[0].length * 1.5, null, 0); this.level = level; - return this.tutorial(); + let res = this.tutorial(); + Matomo.push(["trackEvent", "LevelSite", "LoadLastLevel"]); + return res; } } catch (e) { @@ -181,6 +183,10 @@ export class LevelSite extends WordRotatorBaseSite { this.wonParams.aborted = true; clearTimeout(this.wonParams.coinCounterTimer); + //LevelCounter * 2 - 1, damit der durchschnittswert stimmt + Matomo.push(["trackEvent", "LevelSite", "NextLevel", "Level Number Average", this.levelCounter*2-1]); + Matomo.push(["trackEvent", "LevelSite", "NextLevel", "Level Number Normal", this.levelCounter]); + return this.tutorial(); } catch (e) { @@ -189,6 +195,7 @@ export class LevelSite extends WordRotatorBaseSite { } onStart(args) { + Matomo.update("Level Site"); let res = super.onStart(args); if (this.levelCounterAction) { @@ -278,6 +285,8 @@ export class LevelSite extends WordRotatorBaseSite { this.continueButtonScaler(); this.levelScaler(); + Matomo.push(["trackEvent", "LevelSite", "LevelWon", "Coins", parseInt(Helper.nonNull(localStorage.getItem("coins"), "0"))]); + await savePromise; } catch (e) { @@ -308,14 +317,16 @@ export class LevelSite extends WordRotatorBaseSite { } segmentToHelp.setIsRotatable(false); this.level.saveAsCurrentLevel(); + + Matomo.push(["trackEvent", "LevelSite", "Help", "Coins", parseInt(Helper.nonNull(localStorage.getItem("coins"), "0"))]); } else { FlashMessenger.addMessage("not-enough-coins"); + Matomo.push(["trackEvent", "LevelSite", "Help", "Not enough Coins", parseInt(Helper.nonNull(localStorage.getItem("coins"), "0"))]); } } async tutorial() { - if (this.level.id === LevelSite.TUTORIAL.FIRST_LEVEL) { let currentStep = Helper.nonNull(localStorage.getItem("tutorial-step"), "1"); diff --git a/src/module/Application/pwa/js/site/MenuSite.js b/src/module/Application/pwa/js/site/MenuSite.js index 3ccfc06..800d1de 100644 --- a/src/module/Application/pwa/js/site/MenuSite.js +++ b/src/module/Application/pwa/js/site/MenuSite.js @@ -1,6 +1,6 @@ import {WordRotatorBaseSite} from "./WordRotatorBaseSite"; import {LevelSite} from "./LevelSite"; -import {ScaleHelper, SoundManager} from "../../../../../js/lib/pwa-assets"; +import {Matomo, ScaleHelper, SoundManager} from "../../../../../js/lib/pwa-assets"; import {TemplateContainer} from "../wordrotator/Segment/TemplateContainer"; import {MainMenuLevel} from "../wordrotator/Level/MainMenuLevel"; import {FlashMessenger, Helper, InitPromise} from "../../../../../js/lib/pwa-lib"; @@ -15,6 +15,7 @@ export class MenuSite extends WordRotatorBaseSite { } onStart(args) { + Matomo.update("Menu Site"); let res = super.onStart(args); let level = new MainMenuLevel(this.templateContainer); @@ -22,6 +23,7 @@ export class MenuSite extends WordRotatorBaseSite { level.createSegments(); level.getWonPromise().then(() => { + Matomo.push(["trackEvent", "MainMenu", "levelSolved"]); this.startSite(LevelSite); }); @@ -90,6 +92,7 @@ export class MenuSite extends WordRotatorBaseSite { let playButton = this.findBy("#play-button"); playButton.addEventListener("click", () => { + Matomo.push(["trackEvent", "MainMenu", "startButton"]); this.startSite(LevelSite, this.loadLevelPromise); }); @@ -129,6 +132,7 @@ export class MenuSite extends WordRotatorBaseSite { if (playMusicButton.checked){ soundManager.play(SoundManager.CHANNELS.MUSIC); } + Matomo.push(["trackEvent", "MainMenu", "PlayMusic", "Play Music", (playMusicButton.checked)?1:0]); }); let playSoundButton = this.findBy("#play-sound"); @@ -136,6 +140,7 @@ export class MenuSite extends WordRotatorBaseSite { playSoundButton.addEventListener("change", () => { settingsManager.setSetting("play-sound", playSoundButton.checked); soundManager.set({muted: !playSoundButton.checked}, SoundManager.CHANNELS.SOUND); + Matomo.push(["trackEvent", "MainMenu", "PlaySound", "Play Sound", (playSoundButton.checked)?1:0]); }); } diff --git a/src/module/Application/pwa/js/site/PrivacyPolicySite.js b/src/module/Application/pwa/js/site/PrivacyPolicySite.js index 433e793..548a98b 100644 --- a/src/module/Application/pwa/js/site/PrivacyPolicySite.js +++ b/src/module/Application/pwa/js/site/PrivacyPolicySite.js @@ -1,10 +1,16 @@ import {WordRotatorBaseSite} from "./WordRotatorBaseSite"; import {InitPromise} from "../../../../../js/lib/pwa-lib"; +import {Matomo} from "../../../../../js/lib/pwa-assets"; export class PrivacyPolicySite extends WordRotatorBaseSite { constructor(siteManager) { super(siteManager, "html/application/privacyPolicy.html", "privacyPolicy"); } + + onStart(args) { + Matomo.update("Privacy Policy Site"); + return super.onStart(args); + } } InitPromise.addPromise(app => {