openpanel integration und entwurf blog
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user