Skip to content

feat: implement analytics privacy preservation with differential privacy (#407)#1

Open
sheyman546 wants to merge 19 commits into
mainfrom
feat/analytics-differential-privacy
Open

feat: implement analytics privacy preservation with differential privacy (#407)#1
sheyman546 wants to merge 19 commits into
mainfrom
feat/analytics-differential-privacy

Conversation

@sheyman546
Copy link
Copy Markdown
Owner

Summary

Closes rinafcode#407

Implements differential privacy for the mobile analytics pipeline so that numeric and boolean event properties are noise-sanitized before leaving the device.

Changes

New files

  • src/utils/differentialPrivacy.ts — Laplace and Gaussian noise mechanisms, randomized response for booleans, and sanitizeEventProperties helper.
  • src/utils/privacyBudgetManager.tsPrivacyBudgetManager tracks cumulative ε consumption per session and suppresses events once the budget is exhausted.
  • tests/utils/differentialPrivacy.test.ts — 23 unit tests (23/23 passing).

Modified files

  • src/services/mobileAnalytics.tstrackEvent sanitizes properties with DP noise and checks the budget before forwarding events.
  • src/components/mobile/AnalyticsProvider.tsx — Accepts privacyConfig and noiseType props and forwards them to the service on mount.

Privacy guarantees

Mechanism Guarantee
Laplace ε-differential privacy
Gaussian (ε, δ)-differential privacy
Randomized response ε-local DP for booleans

Testing

npx jest tests/utils/differentialPrivacy.test.ts  # 23/23 passed

Michvista and others added 19 commits May 27, 2026 01:03
Automatically switch light/dark mode from Android lux readings with hysteresis and debounced consecutive readings, plus a Settings toggle and manual override when the user picks a theme.

Co-authored-by: Cursor <cursoragent@cursor.com>
…ormance (rinafcode#403)

Replace generic ActivityIndicator spinners with content-aware skeleton
screens that match each screen's final UI layout:
- CourseViewerSkeleton, QuizSkeleton, SettingsSkeleton,
  SubscriptionSkeleton, DataGridSkeleton
- Updated Suspense fallbacks and component-level loaders in
  course-viewer, quiz, settings, profile, MobileCourseViewer,
  SubscriptionManager, AdvancedDataGrid
- Fixed duplicate MobileQuizManager declaration bug in app/quiz.tsx
- Cleaned up unused imports and orphaned styles
- Added 8 new tests in SkeletonScreens.test.tsx

Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
…nafcode#411)

Add sessionRestorationService that detects crashes and restores users
to their last active screen on next launch.

- New service persists a "session-active" flag to AsyncStorage on
  launch and clears it on clean shutdown. If the flag survives,
  the previous session crashed.
- Route changes are saved to a snapshot on every navigation so the
  user can be returned to the exact screen they were on.
- crashReportingService calls captureOnCrash() on fatal errors to
  ensure the snapshot is preserved.
- Root layout detects crash on mount and shows an Alert offering to
  restore the previous session or start fresh. Snapshots older than
  1 hour are discarded.
- 14 unit tests cover the full lifecycle: begin, save, crash detect,
  restore, and clean shutdown paths.

Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
…fcode#402)

- Add parseSemver to parse semver strings into major/minor/patch
- Add shouldInvalidateCache: major/minor bumps invalidate, patch preserves
- Add getStoredCacheVersion/setStoredCacheVersion for AsyncStorage persistence
- Add handleCacheVersionUpdate: clears AsyncStorage + image cache on breaking change
- 20 tests covering all scenarios
…rotocol-for-websocket

feat(socket): add protobuf-style binary websocket protocol
…#410)

- Add Trie data structure with O(k) insert/search and O(k+n) autocomplete
- Replace linear suggestion filter in MobileSearch with module-level Trie
- Add 25 unit tests including 10k-item <10ms performance assertion
Add adaptive theme based on ambient light sensor
…eton-loading-states

feat: implement contextual skeleton loading states for perceived performance (rinafcode#403)
…h-recovery

feat: implement automatic crash recovery with session restoration (rinafcode#411)
…oning-402

feat: implement app content cache versioning with smart updates
…-autocomplete

feat: Trie-based instant autocomplete for search (rinafcode#410)
feat(analytics): implement event sampling and stabilize secure storag…
Add automated performance budget enforcement
…acy (rinafcode#407)

- Add differentialPrivacy utility with Laplace and Gaussian noise mechanisms,
  randomized response for booleans, and sanitizeEventProperties helper
- Add PrivacyBudgetManager to track and enforce cumulative epsilon budget
  per session; events are suppressed when the budget is exhausted
- Update MobileAnalyticsService to sanitize numeric/boolean event properties
  with DP noise before forwarding to the analytics backend
- Update AnalyticsProvider to accept privacyConfig and noiseType props
- Add 23 unit tests covering all mechanisms and edge cases (23/23 passing)
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.

Implement app analytics privacy preservation with differential privacy

8 participants