Logging von Sharing und Installing
This commit is contained in:
@@ -2936,7 +2936,7 @@ class ShareButton {
|
||||
this._deviceType = deviceType;
|
||||
this._icon = icon;
|
||||
this._callback = callback;
|
||||
console.log("shouldLoad", Helper.nonNull(shouldLoadImg, false), shouldLoadImg);
|
||||
|
||||
if (Helper.nonNull(shouldLoadImg, false)){
|
||||
this._icon = ViewInflater.inflate(this._icon);
|
||||
}
|
||||
@@ -2963,6 +2963,34 @@ ShareButton.TYPE_MOBILE_LEFTOVER = 4;
|
||||
ShareButton.TYPE_MOBILE = ShareButton.TYPE_MOBILE_APPLE+ShareButton.TYPE_MOBILE_LEFTOVER;
|
||||
ShareButton.TYPE_ALL = ShareButton.TYPE_DESKTOP+ShareButton.TYPE_MOBILE;
|
||||
|
||||
class MultipleShareButton extends ShareButton{
|
||||
constructor(deviceType, icon, callbacks, shouldLoadImg)
|
||||
{
|
||||
console.log(Array.isArray(deviceType), deviceType[0] instanceof ShareButton);
|
||||
if (Array.isArray(deviceType) && deviceType[0] instanceof ShareButton){
|
||||
let btn = deviceType[0];
|
||||
deviceType = btn._deviceType;
|
||||
icon = btn._icon;
|
||||
callbacks = deviceType;
|
||||
shouldLoadImg = Helper.nonNull(shouldLoadImg, icon);
|
||||
}
|
||||
|
||||
super(deviceType, icon, function (link, element, event) {
|
||||
if (!Array.isArray(callbacks)){
|
||||
callbacks = [callbacks];
|
||||
}
|
||||
for (let i = 0; i < callbacks.length; i++) {
|
||||
if (callbacks[i] instanceof ShareButton){
|
||||
callbacks[i].getCallback()(link, element, event);
|
||||
}
|
||||
else {
|
||||
callbacks[i](link, element, event);
|
||||
}
|
||||
}
|
||||
}, shouldLoadImg);
|
||||
}
|
||||
}
|
||||
|
||||
class ShareManager {
|
||||
static init() {
|
||||
ShareManager.shareButtons = [];
|
||||
@@ -4677,16 +4705,13 @@ 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)){
|
||||
if (Helper.nonNull(Matomo.currentUrl)) {
|
||||
Matomo.push(['setReferrerUrl', Matomo.currentUrl]);
|
||||
}
|
||||
Matomo.currentUrl = window.location.pathname+window.location.search;
|
||||
Matomo.currentUrl = window.location.pathname + window.location.search;
|
||||
Matomo.push(['setCustomUrl', Matomo.currentUrl]);
|
||||
Matomo.push(['setDocumentTitle', title]);
|
||||
|
||||
@@ -4712,17 +4737,10 @@ class Matomo {
|
||||
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",
|
||||
@@ -4733,11 +4751,10 @@ 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");
|
||||
|
||||
if (shouldTrack) {
|
||||
Matomo.push(["forgetUserOptOut"], true);
|
||||
}
|
||||
@@ -4746,16 +4763,24 @@ class Matomo {
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
async push(arr, force) {
|
||||
// force = Helper.nonNull(force, false);
|
||||
static async trackEvent(event, name, label, value){
|
||||
let ev = ["trackEvent", event, name];
|
||||
if (Helper.isNotNull(label)){
|
||||
ev.push(label);
|
||||
}
|
||||
if (Helper.isNotNull(value) && !isNaN(parseFloat(value)) && isFinite(value)){
|
||||
ev.push(value);
|
||||
}
|
||||
|
||||
return this.push(ev);
|
||||
}
|
||||
|
||||
static async push(arr, force) {
|
||||
|
||||
if (!Array.isArray(arr)) {
|
||||
arr = [arr];
|
||||
}
|
||||
// if (force || await Matomo.getTrackingPromise()) {
|
||||
window["_paq"].push(arr);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4771,6 +4796,15 @@ InitPromise.addPromise(() => {
|
||||
Matomo.init();
|
||||
});
|
||||
|
||||
class MatomoShareButton extends MultipleShareButton{
|
||||
|
||||
constructor(baseButton, platform, shouldLoadImg) {
|
||||
super([baseButton, (url) => {
|
||||
Matomo.trackEvent("shared", url, platform);
|
||||
}], shouldLoadImg);
|
||||
}
|
||||
}
|
||||
|
||||
class ScaleHelper {
|
||||
async scaleTo(scale, fontElement, container, ignoreHeight, ignoreWidth, margin, fontWeight, animationDelay, addListener) {
|
||||
|
||||
@@ -6848,6 +6882,9 @@ class WordRotatorSettingFragment extends LocalStorageSettingsFragment {
|
||||
installButton.classList.add("hidden");
|
||||
InstallManager.prompt().then((e) => {
|
||||
console.log("clicked", e);
|
||||
if (e["outcome"] === "accepted"){
|
||||
Matomo.trackEvent("installed", "installed");
|
||||
}
|
||||
});
|
||||
});
|
||||
installButton.classList.remove("hidden");
|
||||
@@ -6887,9 +6924,9 @@ ThemeManager.addTheme(new Theme("green", "green"));
|
||||
ThemeManager.addTheme(new Theme("pink", "pink"));
|
||||
ThemeManager.addTheme(new Theme("dark", "dark"));
|
||||
|
||||
ShareManager.addShareButton(new WhatsappShareButton('img/whatsapp.svg', true));
|
||||
ShareManager.addShareButton(new SmsShareButton('img/sms.svg', true));
|
||||
ShareManager.addShareButton(new TelegramShareButton('img/telegram.svg', true));
|
||||
ShareManager.addShareButton(new MatomoShareButton(new WhatsappShareButton('img/whatsapp.svg'), "whatsapp", true));
|
||||
ShareManager.addShareButton(new MatomoShareButton(new SmsShareButton('img/sms.svg'), "sms", true));
|
||||
ShareManager.addShareButton(new MatomoShareButton(new TelegramShareButton('img/telegram.svg'), "telegram", true));
|
||||
// ShareManager.addShareButton(new CopyShareButton('img/copy.svg'));
|
||||
|
||||
let app = new App();
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user