=== Rayetun Site Monitor ===
Contributors:      rayetun
Donate link:       https://wise.com/pay/me/mdrayhanu2
Tags:              core web vitals, performance, lcp, page speed, real user monitoring
Requires at least: 6.2
Tested up to:      7.0
Stable tag:        1.0.0
Requires PHP:      8.0
License:           GPL-2.0-or-later
License URI:       https://www.gnu.org/licenses/gpl-2.0.html

Real-user performance monitoring for Core Web Vitals. LCP, CLS, INP, FCP & TTFB dashboards with PSI lab tests, alerts & webhooks — zero config.

== Description ==

**Stop guessing about your site's performance.** Rayetun Site Monitor gives you real-user Core Web Vitals data collected directly from your visitors' browsers — no external account, no API key, no tracking from third parties.

Activate it. Visit a few pages. Within seconds you'll see live performance metrics on your WordPress dashboard.

### ⚡ Why This Plugin?

Unlike Search Console (which shows aggregated, delayed data), Rayetun Site Monitors **every page in real-time** from the moment of activation. No sample-size thresholds. No waiting for Google to collect data. Just instant, actionable insights.

* 🎯 **Zero configuration** — activate and data flows immediately
* 📊 **Real users, real data** — field metrics from actual visitors (not synthetic robots)
* 🔒 **Your data stays yours** — everything lives in your WordPress database
* ⚡ **No impact on performance** — sub-4KB beacon, loaded with defer, zero blocking
* 🔐 **GDPR-friendly** — no cookies, no third-party data sharing

---

## 📈 What It Measures

The plugin tracks all five Core Web Vitals and presents them with Google's official thresholds:

| Metric | Target | What It Means |
|--------|--------|---------------|
| **LCP** — Largest Contentful Paint | ≤ 2.5s | How fast your main content appears |
| **CLS** — Cumulative Layout Shift | ≤ 0.1 | How stable your page layout stays |
| **INP** — Interaction to Next Paint | ≤ 200ms | How responsive your site feels to clicks |
| **FCP** — First Contentful Paint | ≤ 1.8s | How fast anything appears on screen |
| **TTFB** — Time to First Byte | ≤ 800ms | How quick your server responds |

---

## 🖥️ The Dashboard

A single glance tells you everything about your site's performance:

* **Score cards** — P75 value per metric with color-coded Good / Needs Improvement / Poor badges
* **Distribution bars** — see at a glance what % of page loads fall into each rating band
* **Sparkline trend charts** — watch how each metric improves (or worsens) over 7, 14, or 30 days
* **Slowest Pages ranking** — which URLs need the most work, sorted by LCP
* **Device split** — toggle between All Devices, Mobile Only, or Desktop Only
* **Date range & URL filters** — drill into specific time periods and individual pages

---

## 🔍 LCP Element Attribution

"My LCP is slow. But *what* is slow?"

Rayetun Site Monitor answers that automatically. The beacon captures the exact DOM element responsible for Largest Contentful Paint — whether it's a hero image, a video embed, a heading, or a background. See the element tag, CSS class, and image source right alongside the metric.

**No guesswork. No DevTools digging. Just answers.**

---

## 🧪 PageSpeed Insights Lab Tests

Click **PSI ↗** on any page row and Google's lab test runs instantly inside your WordPress admin. Compare your real-user data (Field LCP P75) with Google's synthetic lab test in a single view:

* Lab performance score
* Lab metrics: LCP, FCP, CLS, TBT
* Field LCP P75 (real-user percentile)
* Failed Opportunities list (unused JS, render-blocking resources, unoptimized images)
* One-hour result caching to stay under API limits

No plugin configuration needed — the plugin works without an API key. Add a free key to get 25,000 requests/day instead of 25.

---

## 📬 Alerts & Notifications

**Email Digests**
* Daily or weekly summaries with P75 scores and trend arrows
* See which pages improved and which got worse at a glance

**Threshold Alerts**
* Set performance targets per metric
* Instant email notification when any page exceeds your limit
* Never miss a regression

**Webhook Notifications**
* POST alerts to Slack, Discord, Zapier, Make, or any HTTP endpoint
* Perfect for automating performance reviews in team workflows

---

## 📤 Export to CSV

Download raw performance data for any date range and device filter. Up to 50,000 rows, compatible with:
* Excel / Google Sheets
* BI tools (Tableau, Power BI, Looker)
* Custom data analysis pipelines

---

## 🔗 WordPress Integrations

**Site Health**
Core Web Vitals status appears in Tools → Site Health so you see performance right alongside other site diagnostics.

**Posts & Pages Column**
Every post and page list shows a quick Core Web Vitals summary:
* Color-coded metric badges (green = good, amber = needs work, red = poor)
* Progress bars showing how close you are to targets
* Quick-link to run a PSI lab test

**Dashboard Widget**
P75 scores for LCP, INP, and CLS with trend arrows on your WordPress home dashboard. Monitor performance without leaving the home screen.

---

## ⚡ Performance & Privacy

**Zero Impact on Your Site Speed**
* Front-end beacon: < 4 KB (minified + gzipped)
* Loaded with `defer` — completely non-blocking
* Uses browser's native PerformanceObserver API — no external libraries
* Runs after your page is fully loaded

**Your Data Stays Yours**
* All performance metrics stored in your own WordPress database
* Zero cookies, zero tracking pixels
* Beacon sends data **only** to your site's REST API (not to Google, not to us, not to anyone)
* GDPR-compatible when used appropriately

---

== Installation ==

1. **Upload** the plugin folder to `/wp-content/plugins/` or install directly from **Plugins → Add New → Upload Plugin**
2. **Activate** the plugin from the Plugins screen
3. **Navigate** to **Site Monitor** in the WordPress admin sidebar
4. **Browse** your site in any browser — data appears within seconds

**That's it.** No API keys to hunt down. No forms to fill. No waiting for data to accumulate. Just activate and go.

---

== Frequently Asked Questions ==

= Why is my dashboard empty after activation? =

The plugin collects metrics from real visitors. Open a few pages on your site in a web browser after activation, then refresh the dashboard. You'll see data within seconds of each page view.

= Will this slow down my site? =

No. The beacon loads with the `defer` attribute (non-blocking) and is under 4 KB. It uses the browser's native PerformanceObserver API — no external library downloads, no render-blocking scripts. Your page speed is unaffected.

= How is this different from Google Search Console? =

**Search Console** shows aggregated, multi-day-old data that requires a minimum sample size before displaying. **Rayetun** shows data from the moment of activation for every individual page, broken down by device, with real-time threshold alerts and PSI lab tests triggered on-demand.

= How long is data kept? =

Data older than 30 days is automatically purged by a daily WordPress cron job. This keeps your database lean with zero manual cleanup.

= Does it work with caching plugins? =

Yes. The JavaScript beacon runs in the visitor's browser after page load completes, regardless of server-side caching.

= How do I use the PageSpeed Insights integration? =

Click **PSI ↗** on any row in the Slowest Pages table or the Posts/Pages list column. The PSI API works without a key. To avoid Google's anonymous rate limits on high-traffic sites, get a free API key at [developers.google.com](https://developers.google.com/speed/docs/insights/v5/get-started) and paste it into **Site Monitor → Settings**.

= How do I send alerts to Slack or Discord? =

Go to **Site Monitor → Settings → Webhook Notifications**, toggle it on, and paste your endpoint URL. For Slack, use an Incoming Webhook URL. For Discord, append `/slack` to the webhook URL. Alerts fire only when a configured threshold is exceeded.

= Can I export the data? =

Yes. The **Export CSV** button downloads up to 50,000 rows for your selected date range and device filter. The file opens directly in Excel, Google Sheets, or any BI tool.

= Is multisite supported? =

Currently designed for single-site installs. Multisite support is on the roadmap for a future release.

= Does it conflict with Yoast SEO, Rank Math, or other plugins? =

No. Rayetun Site Monitor is completely standalone — it doesn't read, modify, or interfere with any other plugin's data.

= What if I have a custom WordPress installation or a heavily modified site? =

The plugin is built on WordPress standards (REST API, WP-Cron, options API) and works with any properly configured WordPress site. It's been tested on WordPress 6.2+ with PHP 8.0+.

---

== Screenshots ==

1. **Main Dashboard** — Score cards with P75 values, Good/NI/Poor distribution bars, and sparkline trend charts for all five metrics
2. **Slowest Pages Table** — Ranked by LCP with element attribution, samples, and inline PSI lab test results
3. **Posts List Integration** — Core Web Vitals column showing color-coded metrics, progress bars, and PSI quick-link
4. **Settings Page** — Email digest frequency
5. **Settings Page** — Threshold Alerts
6. **Settings Page** — Webhook notifications, and PageSpeed Insights API key configuration

---

== External Services ==

This plugin contacts external services **only when explicitly triggered by an admin action** or through an opt-in configuration. No data is transmitted automatically in the background.

= 🔬 Google PageSpeed Insights API =

**Triggered by:** Clicking the **PSI ↗** button on a page row (manual, admin-only action)

**Data sent:** The page URL being tested (e.g., `https://example.com/my-page/`). No visitor data, no personal information.

**Recipient:** Google LLC

**Endpoints:**
- `https://www.googleapis.com/pagespeedonline/v5/runPagespeed` — API endpoint
- `https://pagespeed.web.dev/` — report viewer (browser link only, no plugin data sent)

**Privacy:** [Google Privacy Policy](https://policies.google.com/privacy) | [Terms of Service](https://policies.google.com/terms)

= 📚 Google web.dev Documentation Links =

The WordPress Site Health integration displays links to Google's public Core Web Vitals documentation. These are standard hyperlinks that open in a browser tab — **the plugin sends no HTTP requests to these URLs.**

- `https://web.dev/articles/lcp/`
- `https://web.dev/articles/cls/`
- `https://web.dev/articles/inp/`
- `https://web.dev/articles/fcp/`
- `https://web.dev/articles/ttfb/`

= 🔔 Webhook Notifications (opt-in) =

**Triggered by:** Site admin enabling the feature and configuring a URL in **Settings → Webhook Notifications**, **and** a performance threshold being exceeded

**Data sent:** Site name, site URL, metric name, P75 value, threshold, and the page URL that triggered the alert. No visitor data.

**Recipient:** The URL configured by the site admin (Slack workspace, Discord server, Zapier account, custom server, etc.). The plugin author has no access to webhook destinations.

= 🏠 Front-end Beacon (your site only) =

The JavaScript beacon collects performance data **only from your own site's REST API** at `/wp-json/rayetun-site-monitor/v1/collect`. Zero data is sent to external servers. Visitor metrics stay on your server.

---

== Support ==

Found a bug? Have a feature request? Visit the [plugin support forum](https://wordpress.org/support/plugin/rayetun-site-monitor/) on WordPress.org.

If it's urgent please contact: rayetun2.0@gmail.com

---

== Changelog ==

= 1.0.0 =
* Initial release featuring real-user monitoring for LCP, CLS, INP, FCP, and TTFB.
* LCP Element Attribution — the beacon captures the DOM element causing LCP (tag, id, CSS class, image src) and displays it alongside each page's score in the Slowest Pages table.
* Admin dashboard with score cards, Good/NI/Poor distribution bars, sparkline trend charts (7/14/30 days), and a Slowest Pages by LCP table.
* Filter data by date range and by individual page URL. One-click Clear All Data.
* 30-day rolling data retention with automatic daily cleanup.
* Scheduled email digest (daily or weekly) with P75 scores and trend arrows.
* Dashboard adds All / Mobile / Desktop filter that applies to all charts, cards, and tables.
* Performance alerts — email notification when any page exceeds configurable thresholds.
* WordPress Site Health integration (Tools → Site Health).
* Export to CSV — one-click export of raw vitals data for any date range and device filter. Up to 50,000 rows.
* Web Vitals column on Posts and Pages list screens.
* Dashboard widget showing P75 for LCP, INP, and CLS with trend arrows.
* Native PerformanceObserver beacon — no external library or CDN dependency.

== Upgrade Notice ==

= 1.0.0 =
Initial release.