Skip to content

Tracking Preferences & Privacy Signals

SunDevil311 edited this page Jun 15, 2025 · 3 revisions

Overview

This document explains how Network Proβ„’ handles analytics tracking in a privacy-aware, user-consented, and standards-compliant manner. It covers:

  • Tracking preference storage (cookies)
  • Browser signals (DNT and GPC)
  • Reconsent logic
  • Reactive store architecture

πŸ” Principles

  • Privacy by default: Tracking is disabled when browser signals indicate user preference (DNT/GPC).
  • Explicit consent: Users may opt-in or opt-out manually, overriding signals.
  • Persistent choice: Consent state is remembered via first-party cookies.
  • Transparency: The tracking status is shown to users in the UI.

🧠 Architecture Summary

  • Store: src/lib/stores/trackingPreferences.js
    • Consolidates logic for cookie preferences, browser signals, and consent state.
    • SSR-safe, reactive, and fully declarative.
  • Deprecated:
    • utils/privacy.js β†’ replaced by derived store logic.
    • utils/trackingCookies.js β†’ merged into the store with SSR-safe cookie APIs.

Reactive State

Store Type Description
trackingPreferences Readable<TrackingState> Contains current tracking metadata (opt-in/out, DNT, GPC, status, etc).
trackingEnabled Writable<boolean> Exposed to toggle or query PostHog tracking state reactively.
remindUserToReconsent Readable<boolean> Indicates whether a consent renewal prompt should be shown.
showReminder Writable<boolean> Used by PostHog to conditionally display a reminder or banner.

⏳ Reconsent Logic

The derived store remindUserToReconsent evaluates whether a user should be reminded to re-consent to tracking.

It checks for:

  • Manual opt-in or opt-out
  • A valid tracking_consent_timestamp cookie
  • Whether 6+ months have elapsed since that timestamp

βš™οΈ Developer Notes

  • Changes to tracking preferences update cookies and reactive state
  • Reconsent timestamp is written/cleared via store utility functions
  • Use $trackingPreferences and remindUserToReconsent wherever reactive values are needed

πŸ’‘ Related Components

File Purpose
+layout.svelte Initializes PostHog client and service worker; references trackingPreferences.
PrivacyDashboard.svelte UI control panel for opt-in/out toggles and consent status display.
PrivacyContent.svelte Informational content rendered in modals, footers, and standalone pages.
stores/trackingPreferences.js Primary source of truth; tracks and derives tracking state.
stores/posthog.js Encapsulates privacy-safe analytics setup and event capture logic.

🧠 Network Pro Wiki

🏠 Home

Placeholder structure; most pages are pending creation.


πŸ›  Setup & Tooling


🚧 Development


πŸ” Application Behavior


πŸš€ CI/CD


πŸ” PGP Usage

  1. Getting Started with PGP
  2. PGP on Windows
  3. PGP for Email

πŸ“š Docs Maintenance


πŸ“Ž Related Repos


🀝 Getting Started

New here? Start with:

Clone this wiki locally