Skip to main content

Visitor Telemetry & Live Presence Tracking

Modern insurance platforms require accurate audience intelligence without exposing policyholders to invasive third-party ad tracking scripts or violating CCPA/GDPR compliance standards.

veridex-hitech-web-application features an integrated, privacy-first Visitor Telemetry Subsystem (src/app/api/telemetry/* and src/lib/analytics/).


1. Active Presence Heartbeat Beacon (/api/telemetry/heartbeat)​

Live concurrent audience counts are maintained through a low-overhead heartbeat protocol:

1.1 Automatic 5-Minute TTL Eviction​

If a driver in a rural transit corridor loses cellular signal, the client cannot dispatch a clean exit signal.

  • The ActiveVisitor schema establishes a TTL index on lastHeartbeat:
    ActiveVisitorSchema.index({ lastHeartbeat: 1 }, { expireAfterSeconds: 300 });
  • MongoDB background worker threads purge expired session records within 60 seconds of expiration, guaranteeing that dashboard metrics reflect actual active visitors.

2. Page View Logging & Privacy-First Geolocation​

When a page renders in the browser, the client dispatches a visit beacon to POST /api/telemetry/visit:

2.1 IP Anonymization & Local Resolution​

  1. No External Network Latency: Rather than querying slow third-party geolocation REST services, the server uses geoip-lite to resolve geographic regions locally from memory-mapped binary databases in under 0.5 milliseconds.
  2. IP Stripping: The raw IP address is hashed using a one-way salt (ipHash = sha256(ip + salt)). Exact residential street addresses and GPS coordinates are never captured. Only country codes (e.g. 'US', 'CA', 'MX') and US state codes (e.g. 'TX', 'CA', 'FL') are stored.

2.2 Device & Technology Parsing​

The server inspects the User-Agent header to categorize audience parameters:

  • Device Category: desktop, mobile, or tablet.
  • Operating System: iOS, Android, Windows, macOS, Linux.
  • Browser Family: Chrome, Safari, Firefox, Edge.

3. High-Speed Daily Traffic Aggregation (DailyVisit)​

To eliminate expensive table scans across millions of granular visit records when administrators load analytics dashboards:

  • Every visit automatically increments pre-computed daily counters in DailyVisit using atomic $inc updates:
    await DailyVisit.findOneAndUpdate(
    { date: todayDateString }, // e.g. "2026-10-20"
    {
    $inc: {
    totalPageViews: 1,
    [deviceCountKey]: 1, // e.g. mobileCount, desktopCount
    },
    $setOnInsert: { date: todayDateString },
    },
    { upsert: true }
    );
  • The Admin Analytics dashboard queries 30 days of data with a single 30-document lookup, rendering graphs in sub-20ms.

4. Geographic Distribution Aggregates (CountryVisit & UsStateVisit)​

  • Domestic US State Metrics (UsStateVisit): Aggregates traffic across all 50 states to analyze commercial trucking concentration in freight corridors (Texas, California, Florida, Ohio).
  • International Country Metrics (CountryVisit): Tracks cross-border interest, specifically identifying Mexico traffic utilizing the licensed Mexico Tourist Auto Insurance product line.