Stirling-PDF/frontend/src
ConnorYoh 960d48f80c
Customised Analytics for admins and users (#4687)
Adds granular privacy controls for analytics - splits single
enableAnalytics toggle into separate PostHog and Scarf controls with
improved admin
  UX.

  Backend Changes

  Configuration (ApplicationProperties.java)
  - Added enablePosthog and enableScarf boolean fields
- New methods: isPosthogEnabled(), isScarfEnabled() (null = enabled when
analytics is on)

  Services
- PostHogService: Now checks isPosthogEnabled() instead of
isAnalyticsEnabled()
  - ConfigController: Exposes new flags via API
- SettingsController: Changed endpoint from @RequestBody to
@RequestParam

  Frontend Changes

  Architecture
- Converted useAppConfig hook → AppConfigContext provider for global
access
  - Added refetch() method for config updates without reload

  New Features
1. AdminAnalyticsChoiceModal: First-launch modal when enableAnalytics
=== null
    - Enable/disable without editing YAML
    - Includes documentation link
  2. Scarf Tracking System: Modular utility with React hook wrapper
    - Respects config + per-service cookie consent
    - Works from any code location (React or vanilla JS)
3. Enhanced Cookie Consent: Per-service toggles (PostHog and Scarf
separate)

  Integration
  - App.tsx: Added AppConfigProvider + scarf initializer
  - HomePage.tsx: Shows admin modal when needed
  - index.tsx: PostHog opt-out by default, service-level consent

  Key Benefits

 Backward compatible (null defaults to enabled)
 Granular control per analytics service
 First-launch admin modal (no YAML editing)
 Privacy-focused with opt-out defaults
 API-based config updates

---------

Co-authored-by: Connor Yoh <connor@stirlingpdf.com>
2025-10-27 16:54:59 +00:00
..
assets Feature/v2/sign (#4485) 2025-09-26 19:11:03 +01:00
auth V2: Login Feature (#4701) 2025-10-24 10:49:52 +01:00
components Customised Analytics for admins and users (#4687) 2025-10-27 16:54:59 +00:00
constants Refactor to fix circular imports (#4700) 2025-10-21 14:53:18 +01:00
contexts Customised Analytics for admins and users (#4687) 2025-10-27 16:54:59 +00:00
data style(frontend): remove redundant React imports in TypeScript components (#4738) 2025-10-27 16:40:43 +00:00
hooks Customised Analytics for admins and users (#4687) 2025-10-27 16:54:59 +00:00
i18n V2: Convert Tool (#3828) 2025-08-01 16:08:04 +01:00
pages Customised Analytics for admins and users (#4687) 2025-10-27 16:54:59 +00:00
routes Customised Analytics for admins and users (#4687) 2025-10-27 16:54:59 +00:00
services V2: Login Feature (#4701) 2025-10-24 10:49:52 +01:00
styles Customised Analytics for admins and users (#4687) 2025-10-27 16:54:59 +00:00
tests style(frontend): enforce semicolons across auth & shared components (#4737) 2025-10-27 16:22:56 +00:00
theme Feature/toasts and error handling (#4496) 2025-09-25 21:03:53 +01:00
tools style(frontend): remove redundant React imports in TypeScript components (#4738) 2025-10-27 16:40:43 +00:00
types Refactor to fix circular imports (#4700) 2025-10-21 14:53:18 +01:00
utils Customised Analytics for admins and users (#4687) 2025-10-27 16:54:59 +00:00
App.css Initial react set up 2025-05-09 20:01:09 +01:00
App.tsx Customised Analytics for admins and users (#4687) 2025-10-27 16:54:59 +00:00
global.d.ts Feature/v2/sign (#4485) 2025-09-26 19:11:03 +01:00
i18n.ts path (#4488) 2025-09-24 20:37:51 +01:00
index.css Feature/v2/viewer tabs (#4646) 2025-10-13 15:03:07 +01:00
index.tsx Customised Analytics for admins and users (#4687) 2025-10-27 16:54:59 +00:00
logo.svg Initial react set up 2025-05-09 20:01:09 +01:00
output.css Mantine overhaul 2025-05-15 20:07:33 +01:00
reportWebVitals.js Initial react set up 2025-05-09 20:01:09 +01:00
setupTests.js Initial react set up 2025-05-09 20:01:09 +01:00
setupTests.ts Refactor to fix circular imports (#4700) 2025-10-21 14:53:18 +01:00