=== Raqeeb Funnel ===
Contributors: elalmy111
Donate link: https://ahmed-abdelhamed.com/RAQEEB_PLUGIN
Tags: woocommerce, checkout monitoring, funnel monitoring, form monitoring, conversion alerts
Requires at least: 6.4
Tested up to: 7.1
Requires PHP: 8.0
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Stop silent revenue leaks. Real-time WooCommerce checkout, lead form, pixel/CAPI, and conversion drop monitoring — 100% standalone inside WordPress.

== Description ==

**Your uptime monitor says "200 OK" — while your checkout button is broken and your ads are burning budget.**

Standard uptime monitors (UptimeRobot, Pingdom, ManageWP) only check if your homepage loads. They are completely blind when a plugin update breaks your WooCommerce Checkout button, aggressive caching freezes checkout security nonces, a payment gateway webhook starts failing, a lead form silently drops emails, or your Meta Pixel / Conversions API (CAPI) stops firing.

**Raqeeb Funnel** is a **100% standalone, zero-bloat Funnel & Conversion Health Sentinel** built natively inside WordPress. No expensive $60–$250/month external SaaS subscriptions, no monthly test-run limits, and full bilingual **English (LTR) + Arabic (RTL)** support right out of the box.

= Why Store Owners, Media Buyers & Agencies Use Raqeeb Funnel =

* **Real-User Funnel Telemetry (Ultra-Light Frontend Script):** Loads conditionally only on checkout, cart, form, and paid UTM landing pages. Captures live JavaScript errors (with automatic culprit plugin slug extraction), WooCommerce AJAX & Store API failures, dead submit buttons (rage clicks), infinite checkout loading spinners, and missing payment gateway DOM fields — alerting only after configurable unique-session thresholds to eliminate false alarms.
* **Deep WooCommerce & Safe Ghost Checkout Engine (HPOS-Compatible):**
  * Runs scheduled, manual, and post-update **Ghost Checkout synthetic tests** using an isolated hidden $0 virtual product and instantly hard-purges test orders so your analytics, emails, and inventory remain 100% spotless.
  * **Checkout Cache & Stale Nonce Detector:** Detects accidental Cart/Checkout caching from Cloudflare, LiteSpeed Cache, WP Rocket, Varnish, or server proxies before it breaks orders.
  * **Payment Gateway & Queue Watchdog:** Alerts on consecutive failed orders, abnormal failed-order ratios, critical `wc-logs` gateway errors (Stripe, PayPal, Paymob, Moyasar, Tap, HyperPay, Tabby, Tamara, Fawry, Kashier, etc.), and backed-up **Action Scheduler** queues.
  * **Estimated Revenue at Risk:** Automatically computes estimated revenue impact using your trailing 30-day store run-rate.
* **Universal Forms Sentinel & Failed Email Recovery Vault:**
  * Native hooks for **Contact Form 7, WPForms, Elementor Pro Forms, Fluent Forms, Gravity Forms, Ninja Forms, Formidable Forms, WS Form**, plus custom HTML form selectors.
  * **Failed Email Vault:** Captures every `wp_mail_failed` event (lead or order notification) with full message backup and **1-Click Resend** so you never lose a lead when SMTP breaks.
  * Detects CAPTCHA / Turnstile rejection spikes and warns if no dedicated SMTP plugin is active.
* **Silent Conversion Drop & Anomaly Detection:**
  * Learns your store's hourly and day-of-week baseline over 28 days.
  * **Traffic-Correlated Alerts:** Distinguishes low traffic from active paid/UTM traffic (`utm_source`, `fbclid`, `gclid`, `ttclid`) producing zero orders or leads.
  * Detects stage-specific funnel leaks (e.g., healthy Add-to-Cart & Checkout views with zero completed orders), with configurable Quiet Hours, manual Zero-Order fallback rules, and High-Season / Flash Sale sensitivity mode.
* **Marketing Stack, Pixels/CAPI & Ad-Spend Emergency Brake:**
  * Monitors real-browser initialization of **Meta Pixel (`fbq`), GA4 / GTM (`gtag` / `dataLayer`), TikTok Pixel (`ttq`), Snapchat Pixel (`snaptr`)**, and custom tracking globals.
  * Watches outbound Server-Side CAPI & webhook calls (`graph.facebook.com`, `business-api.tiktok.com`, `tr.snapchat.com`, GA4 Measurement Protocol, custom CRMs) to catch expired access tokens (400/401/190) and 5xx errors immediately.
  * Audits paid landing pages for HTTP status, TTFB, SSL certificate expiration, and **UTM parameter preservation across redirects**.
  * **Ad-Spend Emergency Brake:** Fires an HMAC-SHA256 signed webhook (`PAUSE_AD_CAMPAIGNS` / `RESUME_AD_CAMPAIGNS`) to **n8n, Make, or Zapier** (complete with a downloadable ready-to-import n8n workflow JSON!) when a critical outage persists.
* **Post-Update Guard & Automatic Root-Cause Attribution:**
  * Logs every plugin/theme update, activation, deactivation, and WooCommerce gateway change, runs an automatic post-update smoke test, captures PHP Fatal Errors on shutdown, and attaches a **"Suspected Root Cause"** correlation to every incident alert.
* **Multi-Channel Instant Alerts & Outgoing Dead-Man's-Switch:**
  * Native support for **Telegram Bot, WhatsApp (Meta Cloud API, Evolution API, UltraMsg, Twilio, Custom), Slack, Discord, Branded HTML Email (RTL/LTR), and Custom Signed Webhooks**.
  * Includes Severity Routing Matrix, Cooldown protection, Escalation Ladder, Auto-Recovery (`RESOLVED`) alerts, and an **Outgoing Heartbeat Ping URL** (for Healthchecks.io / UptimeRobot Heartbeat / Better Stack) to catch complete server crashes.
* **Branded SLA Reports, White-Label Agency Mode & WP-CLI:**
  * Generate 7-day / 30-day Print-to-PDF branded executive reports, schedule weekly/monthly email SLA reports, export Incidents CSV, clone settings JSON across client sites, customize full White-Label agency branding, and automate via **WP-CLI** (`wp raqeeb status`, `wp raqeeb scan`, `wp raqeeb test-checkout`, `wp raqeeb test-alert`, `wp raqeeb incidents`).

= Bilingual Interface (English LTR & Arabic RTL) =

Switch seamlessly between **Auto (WordPress Locale)**, **English (LTR)**, and **Arabic (RTL)** directly from plugin settings, including full RTL layouts, Arabic email alerts, and Arabic printable client SLA reports.

= Documentation, Support & Author =

Raqeeb Funnel is developed and maintained by **[Ahmed Abdelhamed](https://ahmed-abdelhamed.com/)** (**أحمد عبدالحميد**), specializing in WordPress engineering, marketing automation, and conversion tracking systems.

* Official Plugin Page, Guides & n8n Templates: [Raqeeb Funnel Documentation](https://ahmed-abdelhamed.com/RAQEEB_PLUGIN)
* Developer Website & Marketing Automation Resources: [ahmed-abdelhamed.com](https://ahmed-abdelhamed.com/)

== External Services ==

Raqeeb Funnel is **100% standalone** and never transmits data to any Raqeeb cloud server. All external integrations below are **strictly opt-in** and are only called if you explicitly enable and configure them in **Raqeeb Funnel -> Alerts & Automation**:

1. **Telegram Bot API (`https://api.telegram.org`)** — Sends incident notifications to your chosen Telegram chat when enabled. [Privacy Policy](https://telegram.org/privacy) | [Terms](https://telegram.org/tos)
2. **WhatsApp Cloud API (`https://graph.facebook.com`) / Twilio (`https://api.twilio.com`) / UltraMsg (`https://api.ultramsg.com`) / Self-Hosted Evolution API** — Sends incident alerts to your chosen phone numbers when enabled. [Meta Privacy](https://www.whatsapp.com/legal/privacy-policy) | [Twilio Privacy](https://www.twilio.com/en-us/legal/privacy)
3. **Slack Incoming Webhooks (`https://hooks.slack.com`)** — Sends formatted alert attachments to your Slack workspace when enabled. [Privacy Policy](https://slack.com/trust/privacy/privacy-policy)
4. **Discord Webhooks (`https://discord.com/api/webhooks/`)** — Sends rich embed alerts to your Discord channel when enabled. [Privacy Policy](https://discord.com/privacy)
5. **User-Configured Custom Webhooks / Outgoing Heartbeat Ping URLs** — Sends signed JSON incident envelopes or health heartbeat pings exclusively to URLs you manually enter (such as your n8n, Make, Zapier, Healthchecks.io, or UptimeRobot Heartbeat endpoint).

== Installation ==

1. Upload the `raqeeb-funnel` folder to `/wp-content/plugins/` or install via **Plugins -> Add New -> Upload Plugin**.
2. Activate **Raqeeb Funnel** through the **Plugins** menu in WordPress.
3. Open **Raqeeb Funnel** in your WordPress Admin sidebar.
4. Go to **Alerts & Automation**, configure at least one notification channel (Telegram, WhatsApp, Slack, Discord, Email, or Webhook), and click **Test**.
5. Click **Run Full Funnel Scan** in the top bar to run your first complete diagnostic check.

== Frequently Asked Questions ==

= Does Raqeeb Funnel require an external SaaS subscription or account? =

No. Raqeeb Funnel is 100% self-hosted inside WordPress with zero external account required and zero monthly test-run limits.

= Will Ghost Checkout tests pollute my WooCommerce orders, analytics, or inventory? =

No. Ghost Checkout uses an isolated hidden `$0` virtual product (`private` / `hidden`), suppresses all WooCommerce order emails during the check, verifies HPOS persistence, and immediately hard-purges the synthetic test order.

= Does it work with WooCommerce HPOS and Cart/Checkout Blocks? =

Yes. Raqeeb Funnel formally declares compatibility with both **High-Performance Order Storage (HPOS)** and **WooCommerce Cart & Checkout Blocks**, as well as Classic Shortcode Checkout.

= Will the frontend telemetry script slow down my store or break page caching? =

No. The script is lightweight, non-blocking (`navigator.sendBeacon`), conditionally loaded only on checkout, cart, form, and UTM landing pages, and uses a cache-safe 48-hour rolling HMAC token so cached pages continue reporting errors reliably.

= What happens if my entire WordPress server crashes (500 / Database Down)? =

Enable **Outgoing Heartbeat Ping** in **Alerts & Automation** and paste any free ping URL (e.g., Healthchecks.io or UptimeRobot Heartbeat). Raqeeb Funnel pings it every 5 minutes only when your site and funnel are healthy — if the server goes down completely, your heartbeat monitor alerts you immediately.

= Does it support Arabic RTL? =

Yes! Raqeeb Funnel ships with complete English (LTR) and Arabic (RTL) interfaces, alerts, and printable client reports, with an instant language switcher in **Tools & System**.

== Screenshots ==

1. Command Center — Live Funnel Health Score (0-100), 24-hour Conversion Pipeline Strip, Conversions vs Errors timeline, and Active Incidents.
2. Incidents & Diagnostics — Filterable incident log with automatic Root-Cause Attribution, Real-User Telemetry events, and Site Changes timeline.
3. Monitors Hub & Failed Email Vault — Configure RUM Telemetry, Ghost Checkout, Cache/Nonce detection, Forms Sentinel, Anomaly Detection, Pixels/CAPI, and 1-Click Resend failed emails.
4. Alerts & Automation — Native Telegram, WhatsApp (5 drivers), Slack, Discord, Email, Severity Routing Matrix, Ad-Spend Emergency Brake (with n8n JSON export), and Outgoing Heartbeat Ping.
5. Executive SLA Reports & Arabic RTL — Branded 7/30-day Print-to-PDF reports, scheduled email reports, CSV exports, and native full Arabic RTL dashboard.
6. White-Label Agency Mode & Tools — Full agency rebranding, modular licensing layer, JSON config clone (Import/Export), and WP-CLI automation.

== Changelog ==

= 1.0.0 =
* Initial public release on WordPress.org.
* Real-User Funnel Telemetry (JS errors, WooCommerce AJAX/Store API errors, dead submit buttons, stuck spinners, payment DOM guard).
* Safe HPOS-compatible Ghost Checkout Runner, Checkout Cache/Nonce Detector, Gateway/wc-logs Auditor, and Action Scheduler monitor.
* Universal Forms Sentinel (8 major form plugins + custom selectors) and Failed Email Recovery Vault with 1-Click Resend.
* Smart 28-day Anomaly Detection with paid/UTM traffic correlation, stage leak detection, quiet hours, and high-season mode.
* Marketing Stack Monitor (Meta/GA4/GTM/TikTok/Snap pixels, Server-Side CAPI watchdog, landing page UTM/SSL guard, Ad-Spend Emergency Brake + n8n template).
* Post-Update Guard, Root-Cause Blame Engine, and PHP Fatal Shutdown Catcher.
* Multi-channel Alerts (Telegram, WhatsApp 5 drivers, Slack, Discord, Email, Signed Webhooks, Outgoing Heartbeat).
* Branded SLA Reports, White-Label Agency Mode, JSON Config Import/Export, WP-CLI commands, and full English/Arabic RTL support.

== Upgrade Notice ==

= 1.0.0 =
Initial stable release of Raqeeb Funnel – Checkout, Form & Conversion Monitor.
