Skip to content

docs: expand UX roadmap with detailed phases for PWA and theme enhanc…#20

Merged
zlovtnik merged 1 commit intomainfrom
dev
Nov 22, 2025
Merged

docs: expand UX roadmap with detailed phases for PWA and theme enhanc…#20
zlovtnik merged 1 commit intomainfrom
dev

Conversation

@zlovtnik
Copy link
Copy Markdown
Owner

@zlovtnik zlovtnik commented Nov 22, 2025

…ements

  • Updated ROADMAP_UX.md with specific phases (2.1 and 2.2) for Progressive Web App completion and theme system enhancements
  • Added status tracking, task breakdowns, time estimates, and success criteria for better project planning
  • Minor dependency updates in package-lock.json (removed "dev" flags and added license info for isexe and path-key)

Summary by CodeRabbit

  • New Features

    • Added analytics integration for tracking page views, user sessions, custom events, errors, and form submissions.
    • Integrated user identification and tracking capabilities.
  • Documentation

    • Added comprehensive analytics integration guide covering configuration, API reference, and best practices.
    • Updated development roadmap with detailed Phase 2 milestones, task breakdown, and success criteria.

✏️ Tip: You can customize this high-level summary in your review settings.

…ements

- Updated ROADMAP_UX.md with specific phases (2.1 and 2.2) for Progressive Web App completion and theme system enhancements
- Added status tracking, task breakdowns, time estimates, and success criteria for better project planning
- Minor dependency updates in package-lock.json (removed "dev" flags and added license info for isexe and path-key)
@vercel
Copy link
Copy Markdown

vercel bot commented Nov 22, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
spring-graphql Ready Ready Preview Comment Nov 22, 2025 2:33am

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Nov 22, 2025

Walkthrough

The PR integrates PostHog analytics into the frontend application, adding a new PosthogService for event tracking and user identification, configuring environment-based initialization, integrating user tracking into the auth flow during login and logout, and providing comprehensive analytics documentation.

Changes

Cohort / File(s) Summary
Documentation & Roadmap Planning
ROADMAP_UX.md, docs/ANALYTICS.md
Updated ROADMAP with structured Phase 2 milestones including PWA, theme system, keyboard shortcuts, and accessibility. Added comprehensive ANALYTICS.md documenting PostHog configuration, API surface, integration points, and best practices.
Dependencies
frontend/package.json
Added echarts (^5.6.0) and posthog-js (^1.293.0) dependencies; removed duplicate echarts entry.
PostHog Service Implementation
frontend/src/app/core/services/posthog.service.ts
New Angular service providing PostHog initialization, automatic page view tracking via router events, and public methods for event tracking, user identification, error tracking, form submissions, and API call logging. All operations guarded with error handling.
Auth Service Integration
frontend/src/app/core/services/auth.service.ts
Integrated PosthogService for user tracking during login and logout; modified loadCurrentUser logic; restructured setAuthToken to defer token refresh scheduling and perform non-blocking PostHog identification when user is present.
Configuration & Initialization
frontend/src/app/app.config.ts, frontend/src/environments/environment.ts, frontend/src/environments/environment.prod.ts, frontend/src/main.ts
Added PosthogService to app providers; added posthog configuration objects (enabled, key, apiHost) to development and production environments; added conditional PostHog initialization in main.ts with try-catch error handling and global exposure via window.posthog.

Sequence Diagram(s)

sequenceDiagram
    participant Main as main.ts
    participant Posthog as PostHog JS
    participant App as Angular App
    participant Router as Router
    participant PService as PosthogService
    participant Auth as AuthService

    Main->>+Posthog: init(config)
    Posthog->>Posthog: initialize
    Posthog-->>Main: loaded
    Main->>Main: expose window.posthog
    Main->>+App: bootstrap app

    App->>+PService: inject & init
    PService->>Router: subscribe(NavigationEnd)
    PService-->>App: ready

    Auth->>Auth: login(credentials)
    Auth->>+PService: identifyUser(user)
    PService->>Posthog: identify(distinctId)
    PService-->>Auth: identified
    Auth->>Auth: setAuthToken(token)

    Router->>Router: navigate
    Router-->>PService: NavigationEnd event
    PService->>Posthog: capture("page_view", {page_path, page_title})
    Posthog-->>PService: ✓
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Auth service changes: Review the modified logic in loadCurrentUser, setAuthToken, and logout flow to ensure correct state management and PostHog tracking behavior under various scenarios (user present/absent, successful/failed loads, token errors).
  • Error handling robustness: Verify that all PostHog calls in auth.service.ts and posthog.service.ts are properly guarded with try-catch and isPostHogAvailable checks to prevent app breakage.
  • Environment configuration consistency: Confirm that PostHog environment variables (NG_APP_POSTHOG_KEY, NG_APP_POSTHOG_HOST) are correctly mapped across development and production environments.

Possibly related PRs

  • Dev #14: Modifies frontend package.json to add/adjust echarts-related dependencies alongside other frontend configuration changes.

Poem

🐰 PostHog hops in with analytics cheer,
Events and users now crystal clear,
Auth flows track who comes and goes,
Page views bloom where the router flows,
Data insights hop, skip, and bound!

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The PR title partially relates to the changeset. While the title mentions PWA and theme enhancements for the UX roadmap, the actual changes also include substantial PostHog analytics integration (new service, environment config, package dependencies) not referenced in the title. Consider a more comprehensive title that reflects the dual nature of changes, such as: 'docs: expand UX roadmap and add PostHog analytics integration' to accurately represent both major change areas.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (7)
docs/ANALYTICS.md (2)

21-24: Align environment variable names and examples with the actual configuration

Docs use POSTHOG_KEY / POSTHOG_HOST, while the production environment config expects NG_APP_POSTHOG_KEY / NG_APP_POSTHOG_HOST, and the dev example for environment.ts doesn’t match the current code. This can easily lead to PostHog not initializing in some environments.

Consider:

  • Standardizing on a single pair of env var names (e.g., NG_APP_POSTHOG_KEY / NG_APP_POSTHOG_HOST) across .env, GitHub Actions, and both environment files.
  • Updating the code snippets here so they mirror the real environment.ts and environment.prod.ts.

Also applies to: 35-41, 45-50


70-74: Update analytics tooling reference to PostHog for consistency

The “Add Web App Install Analytics” TODO still mentions GTM/Mixpanel, while the stack has standardized on PostHog.

Consider rephrasing to “Track install events via PostHog” (and similar wording) to avoid confusion about which analytics system should be implemented.

ROADMAP_UX.md (1)

57-323: Phase 2 roadmap is very clear; only minor markdownlint nits

The Phase 2.1–2.6 breakdown (tasks, durations, success criteria) is well structured and makes planning straightforward. Markdown linters may complain about the *Status: ...* lines being used like headings; if you care about a clean lint pass, consider turning those into proper #### Status headings or disabling MD036 for this file.

frontend/src/app/app.config.ts (1)

21-21: Avoid double‑providing PosthogService

PosthogService is marked providedIn: 'root' and is also added explicitly to the providers array here. That duplication isn’t harmful but is unnecessary and can confuse future readers about where the singleton actually comes from.

Consider removing it from providers and relying solely on providedIn: 'root' (or, if you prefer explicit app‑level providers, drop providedIn: 'root' from the service).

Also applies to: 38-38

frontend/src/app/core/services/posthog.service.ts (2)

19-36: Decouple router subscription from PostHog initialization order

initPageTracking() skips registering the NavigationEnd subscription if isPostHogAvailable() is false at construction time. That couples page-view tracking to the precise init order of posthog.init vs. service instantiation (and to test setups), even though trackPageView() already has its own availability guard.

Consider always subscribing to router events and keeping the guard only inside trackPageView():

-  private initPageTracking(): void {
-    if (!this.isPostHogAvailable()) {
-      return;
-    }
-    this.routerSub = this.router.events
+  private initPageTracking(): void {
+    this.routerSub = this.router.events
       .pipe(filter((event) => event instanceof NavigationEnd))
       .subscribe((event: NavigationEnd) => {
         // Track page view with route name
         this.trackPageView(event.urlAfterRedirects);
       });
   }

This makes page tracking robust even if PostHog is initialized later or is disabled in certain test environments.


1-5: Confirm posthog-js behavior in SSR and non‑browser contexts

The service imports posthog-js directly and uses document.title inside trackPageView(). In an SSR or non‑browser build, this can be problematic if posthog-js or document isn’t safely shimmed.

If you render on the server, consider:

  • Guarding analytics behind a browser check (e.g., isPlatformBrowser) before calling any posthog APIs or touching document.
  • Verifying that posthog-js@1.293.0 is SSR‑safe (does not reference window/document at module load). If it isn’t, move the import behind a browser guard or use window.posthog injected in main.ts instead.

Also applies to: 42-54, 204-210

frontend/src/app/core/services/auth.service.ts (1)

164-169: Make PostHog reset robust to async implementations

Right now resetUser() is wrapped in a try/catch, which only guards against synchronous exceptions. If resetUser() ever returns a Promise and rejects, that rejection won’t be caught here.

Consider making resetUser() a purely sync fire‑and‑forget wrapper, or explicitly handling potential Promise rejections, e.g.:

-    try {
-      this.posthogService.resetUser();
-    } catch (error) {
-      console.warn('Failed to reset PostHog user:', error);
-    }
+    try {
+      const result = this.posthogService.resetUser();
+      if (result instanceof Promise) {
+        void result.catch((error) =>
+          console.warn('Failed to reset PostHog user:', error)
+        );
+      }
+    } catch (error) {
+      console.warn('Failed to reset PostHog user:', error);
+    }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2205c3f and 3f579d9.

⛔ Files ignored due to path filters (2)
  • frontend/package-lock.json is excluded by !**/package-lock.json
  • frontend/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (9)
  • ROADMAP_UX.md (1 hunks)
  • docs/ANALYTICS.md (1 hunks)
  • frontend/package.json (2 hunks)
  • frontend/src/app/app.config.ts (2 hunks)
  • frontend/src/app/core/services/auth.service.ts (5 hunks)
  • frontend/src/app/core/services/posthog.service.ts (1 hunks)
  • frontend/src/environments/environment.prod.ts (1 hunks)
  • frontend/src/environments/environment.ts (1 hunks)
  • frontend/src/main.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
frontend/src/app/core/services/posthog.service.ts (1)
frontend/src/app/core/services/auth.service.ts (1)
  • Injectable (38-297)
frontend/src/main.ts (2)
frontend/src/environments/environment.prod.ts (1)
  • environment (4-14)
frontend/src/environments/environment.ts (1)
  • environment (1-20)
🪛 Gitleaks (8.29.0)
docs/ANALYTICS.md

[high] 22-22: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

frontend/src/environments/environment.ts

[high] 17-17: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🪛 LanguageTool
docs/ANALYTICS.md

[style] ~113-~113: ‘with success’ might be wordy. Consider a shorter alternative.
Context: ...ring, any> ) Track form submissions with success/failure status. **Examples**:types...

(EN_WORDINESS_PREMIUM_WITH_SUCCESS)

🪛 markdownlint-cli2 (0.18.1)
ROADMAP_UX.md

91-91: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


129-129: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


172-172: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


221-221: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


338-338: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

🔇 Additional comments (4)
frontend/package.json (1)

37-44: Dependency additions look consistent with the stack

Adding echarts and posthog-js at these versions aligns with existing Angular 18 + ngx-echarts usage and the new analytics integration.

frontend/src/main.ts (1)

4-28: PostHog initialization is well‑guarded; consider omitting key from logs

The conditional init with try/catch and a global window.posthog is clean and won’t break bootstrap if analytics fails. You may want to drop the (even truncated) key from the log payload to avoid leaking any part of credentials into shared logs; logging the host and a simple “enabled/disabled” flag is usually enough.

frontend/src/environments/environment.prod.ts (1)

8-13: Production PostHog configuration pattern looks safe

Using NG_APP_POSTHOG_KEY / NG_APP_POSTHOG_HOST with an empty‑string fallback avoids committing secrets while keeping analytics enabled when properly configured in the environment.

frontend/src/app/core/services/auth.service.ts (1)

13-13: PosthogService DI usage looks good

Using inject(PosthogService) alongside other services is consistent and keeps the service tree-shakable. No issues from the DI pattern itself.

Also applies to: 54-55

Comment thread docs/ANALYTICS.md
Comment thread frontend/src/app/core/services/auth.service.ts
Comment thread frontend/src/app/core/services/auth.service.ts
Comment thread frontend/src/environments/environment.ts
@zlovtnik zlovtnik merged commit 30e5424 into main Nov 22, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant