Move config to TS class

This commit is contained in:
N-Pex 2025-07-04 17:32:23 +02:00
parent ad6bb903db
commit eb58f77162
6 changed files with 122 additions and 103 deletions

View file

@ -1,8 +1,9 @@
import cleaninsights from "./cleaninsights.service";
import { Config } from "./config.service";
import matomo from "./matomo.service";
export interface AnalyticsEngine {
event(category: string, action: string);
event(category: string, action: string): void;
}
type AnalyticsEvent = {
@ -11,7 +12,7 @@ type AnalyticsEvent = {
}
export default {
install(app) {
install(app: any) {
class AnalyticsServiceClass {
engines: AnalyticsEngine[];
@ -23,7 +24,7 @@ export default {
this.cachedEvents = [];
this.initialized = false;
app.$config.promise.then((config) => {
app.$config.load().then((config: Config) => {
var analytics = config.analytics || {};
if (!Array.isArray(analytics)) {
analytics = [analytics];
@ -58,7 +59,7 @@ export default {
});
}
event(category, action) {
event(category: string, action: string) {
if (!this.initialized) {
this.cachedEvents.push({category, action});
return;