feat: add frontend logging system with router and visibility tracking
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import { DOCUMENT } from '@angular/common';
|
||||
import { DestroyRef, Inject, Injectable, effect, signal, computed } from '@angular/core';
|
||||
import { DestroyRef, Inject, Injectable, effect, signal, computed, inject } from '@angular/core';
|
||||
import { LogService } from '../../../core/logging/log.service';
|
||||
|
||||
export type ThemeName = 'light' | 'dark';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class ThemeService {
|
||||
private readonly logService = inject(LogService);
|
||||
private static readonly STORAGE_KEY = 'obsiwatcher.theme';
|
||||
|
||||
private readonly document = this.doc;
|
||||
@@ -50,11 +52,30 @@ export class ThemeService {
|
||||
}
|
||||
|
||||
setTheme(theme: ThemeName): void {
|
||||
const previousTheme = this.currentTheme();
|
||||
this.currentTheme.set(theme);
|
||||
|
||||
// Log theme change
|
||||
if (previousTheme !== theme) {
|
||||
this.logService.log('THEME_CHANGE', {
|
||||
from: previousTheme,
|
||||
to: theme,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
toggleTheme(): void {
|
||||
const previousTheme = this.currentTheme();
|
||||
this.currentTheme.update(theme => (theme === 'light' ? 'dark' : 'light'));
|
||||
|
||||
// Log theme change
|
||||
const newTheme = this.currentTheme();
|
||||
if (previousTheme !== newTheme) {
|
||||
this.logService.log('THEME_CHANGE', {
|
||||
from: previousTheme,
|
||||
to: newTheme,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private detectSystemTheme(): ThemeName {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Injectable, signal } from '@angular/core';
|
||||
import { Injectable, signal, inject } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { BehaviorSubject, Subject, debounceTime, catchError, of, tap } from 'rxjs';
|
||||
import { GraphConfig, DEFAULT_GRAPH_CONFIG, validateGraphConfig } from './graph-settings.types';
|
||||
import { LogService } from '../../core/logging/log.service';
|
||||
|
||||
/** Response from graph config API */
|
||||
interface GraphConfigResponse {
|
||||
@@ -20,6 +21,7 @@ export type Unsubscribe = () => void;
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class GraphSettingsService {
|
||||
private readonly logService = inject(LogService);
|
||||
private configSubject = new BehaviorSubject<GraphConfig>(DEFAULT_GRAPH_CONFIG);
|
||||
private saveQueue = new Subject<Partial<GraphConfig>>();
|
||||
private currentRev: string | null = null;
|
||||
@@ -85,6 +87,11 @@ export class GraphSettingsService {
|
||||
|
||||
// Queue for debounced save
|
||||
this.saveQueue.next(patch);
|
||||
|
||||
// Log settings change
|
||||
this.logService.log('GRAPH_VIEW_SETTINGS_CHANGE', {
|
||||
changes: Object.keys(patch),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user