Skip to content

Add static analytics site generator to analytics package #4779

@MillenniumFalconMechanic

Description

Summary

Add a reusable static analytics site generator to the shared analytics package, based on the reference implementation in NIH-NCPI/ncpi-dataset-catalog#341.

The generator produces a static HTML dashboard with Chart.js visualizations displaying GA4 analytics data (monthly traffic, pageviews, outbound links, filter selections, custom events). Each app (AnVIL Catalog, AnVIL Explorer, HCA, LungMAP) should be able to generate its own dashboard with minimal configuration.

Approach

Add to the analytics package (analytics/analytics_package/):

  • static_site/generator.py — parameterized fetch + export logic
  • static_site/template.html — HTML template (parameterized with logo, title, colors, event sections)
  • static_site/export.py — DataFrame-to-JSON export helpers

Per-app config (in each app's existing directory):

  • Branding (logo URL, site title, primary color)
  • GA4 property ID (already in constants.py)
  • First-party hosts for outbound link filtering
  • Which custom events to include (e.g., filter_selected, chat_submitted)

Usage

from analytics.static_site import generate_site

generate_site(
    property_id=ANVIL_CATALOG_ID,
    site_title="AnVIL Catalog",
    logo_url="https://anvilproject.org/images/logo.png",
    primary_color="#035C94",
    first_party_hosts={"anvilproject.org", "explore.anvilproject.org"},
    events=["filter_selected"],
)

Reference

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions