How @prc/analytics wires providers, settings, REST, and Abilities.
Bootstrap
Bootstrap instantiates a Loader, then attaches Providers, Ability, Rest_API, and Settings.
Bootstrap
├── Providers
│ ├── Parsely (lazy; API v2 + CLI)
│ ├── Google_Analytics (lazy; GA4 Data API + CLI)
│ ├── Tracking_Pixels (Meta, Pinterest, LinkedIn, Reddit)
│ └── Civis (API key auth + CSV exports)
├── Ability (analyze-post, analyze-topic)
├── Rest_API (query-by-url, query)
└── Settings (Settings → Analytics)
Source: includes/class-bootstrap.php, includes/providers/.
Providers
| Provider | Role |
|---|---|
| Parse.ly | Post detail, per-URL referrers (referrers/post/detail), and top-posts analytics via API v2 |
| Google Analytics 4 | Server-side runReport with JWT service account |
| Tracking pixels | Consent-gated client scripts when constants are set |
| Civis | Paginated CSV exports for Civis “Import from URL” |
Parse.ly and GA4 load lazily on first use. CLI commands register at bootstrap (wp prc analytics parsely, wp prc analytics ga).
Files such as class-semrush.php and class-data-mart.php exist under includes/providers/ but are not constructed by Providers. Salesforce beacon loading uses filters prc_analytics_salesforce_script_url and prc_analytics_salesforce_dataset (see class-predictive-response.php).
Secrets and constants
All secrets belong in vip-config/keys-and-tokens.php (or VIP Platform Secrets), not in the repo.
| Constant / file | Purpose |
|---|---|
PRC_PLATFORM_PARSELY_API_KEY, PRC_PLATFORM_PARSELY_SECRET | Parse.ly API |
PRC_PLATFORM_GA4_PROPERTY_ID | GA4 property |
private/ga4-service-account.json → WPCOM_VIP_PRIVATE_DIR | GA4 service account (file-only) |
PRC_PLATFORM_*_PIXEL_ID / partner IDs | Client pixels |
PRC_PLATFORM_GOOGLE_GTAG_ID | Client-side gtag only (not in Settings pixel toggles) |
Civis API keys are stored in prc_analytics_settings, not as PHP constants.
Dependencies
- Upstream:
prc-platform-core/prc-scripts,prc-privacy-consent+wp-consent-api(pixels),prc-staff-bylines(REST bylines), Firebase (Civis users export) - Downstream: Civis Import-from-URL jobs, MCP / Abilities consumers