openpanel integration und entwurf blog

This commit is contained in:
2026-04-03 17:05:16 +02:00
parent 5138005397
commit cd694d0776
45 changed files with 2558 additions and 310 deletions

View File

@@ -48,19 +48,21 @@ export class OpenPanelService implements OnDestroy {
}
private setupRouteTracking(): void {
// Nur einmalig subscriben, vorherige Sub zerstören
this.routerSubscription?.unsubscribe();
this.routerSubscription = this.router.events
.pipe(
filter((event) => event instanceof NavigationEnd),
// Ersten initialNavigation-Event überspringen SSR hat ihn schon getriggert
skip(1),
)
.subscribe((event) => {
const navEvent = event as NavigationEnd;
this.trackScreenView(navEvent.urlAfterRedirects);
});
this.routerSubscription = this.router.events.pipe(
filter((event) => event instanceof NavigationEnd),
).subscribe(() => {
const route = this.getActiveRoute();
const trackName = route.snapshot.data['trackName'] ?? this.router.url;
this.trackScreenView(trackName);
});
}
private getActiveRoute() {
let route = this.router.routerState.root;
while (route.firstChild) route = route.firstChild;
return route;
}
// ─── Public API ────────────────────────────────────────────────────────────
@@ -121,7 +123,7 @@ export class OpenPanelService implements OnDestroy {
/**
* Decrements a numeric property on the user profile.
* @example opService.decrement('credits', 5);
* @example opService.decrement('credits');
*/
decrement(property: string): void {
if (!this.op) return;