=== AI Kansoku Lab Tracker ===
Contributors:      aikansokulab
Tags:              ai, crawler, tracking, seo, gptbot
Requires at least: 6.0
Tested up to:      6.9
Requires PHP:      7.4
Stable tag:        1.4.6
License:           GPL-2.0-or-later
License URI:       https://www.gnu.org/licenses/gpl-2.0.html

Track AI crawler visits (GPTBot, ClaudeBot, PerplexityBot, etc.) server-side and visualize them in the AI Kansoku Lab dashboard.

== Description ==

**AI Kansoku Lab Tracker** detects visits from AI crawlers such as GPTBot, ClaudeBot, and PerplexityBot using PHP server-side detection. Because AI crawlers do not execute JavaScript, traditional analytics tools like GA4 cannot capture these visits. This plugin solves that problem.

= Features =

* **14 AI-related crawler patterns** - GPTBot, ChatGPT-User, ClaudeBot, PerplexityBot, ByteSpider, Meta-ExternalAgent, AppleBot, DeepSeek, Grok, and related AI access patterns including Google-Extended
* **Explicit opt-in** - External tracking only activates when you enable it via checkbox
* **Minimal performance impact** - Uses non-blocking POST requests (blocking: false)
* **Simple setup** - Just paste your Site ID, enable tracking, and save
* **WordPress standards** - Uses wp_remote_post, register_setting, nonce verification, and proper escaping throughout
* **Front-end only** - Does not fire on admin, cron, AJAX, or REST API requests

= How It Works =

When a front-end page is requested, the plugin checks the User-Agent string against known AI crawler patterns. If a match is found — and you have explicitly enabled external tracking — it sends an asynchronous POST request to the AI Kansoku Lab API to log the visit. The site visitor experiences no delay.

= External Services =

This plugin may connect to the following external service:

**AI Kansoku Lab** (https://www.ai-kansoku.com)

External tracking is **opt-in only**. Data is only transmitted after you explicitly enable it in the settings page.

When an AI crawler is detected, the following data is sent to the AI Kansoku Lab API:
* User-Agent string of the detected AI crawler
* URL path of the visited page
* HTTP referer header (if present)
* HTTP status code of the page (200 or 404)
* Your Site ID (configured in plugin settings)

No personally identifiable information is collected. This plugin does not collect cookies, account credentials, form contents, or visitor IP addresses.

* Service URL: https://www.ai-kansoku.com
* Privacy Policy: https://www.ai-kansoku.com/privacy
* Terms of Service: https://www.blog.ai-kansoku.com/terms

= Requirements =

* A free account at AI Kansoku Lab (https://www.ai-kansoku.com)
* Your Site ID from the dashboard

== Installation ==

1. Upload the plugin ZIP via Plugins > Add New > Upload Plugin
2. Activate the plugin
3. Go to Settings > AI Kansoku Lab
4. Enter your Site ID from https://www.ai-kansoku.com/dashboard
5. Check "Enable external tracking to AI Kansoku Lab"
6. Click Save Settings

== Frequently Asked Questions ==

= Where do I find my Site ID? =

Log in to AI Kansoku Lab (https://www.ai-kansoku.com), register your site, and copy the Site ID shown in the Tracking Code section of your dashboard.

= Will this slow down my site? =

No. The plugin uses `wp_remote_post` with `blocking: false`, so the HTTP request is fired asynchronously and does not delay page rendering.

= Does it run on every request? =

No. The plugin only fires on front-end page requests when both a Site ID is set and external tracking is explicitly enabled. Admin pages, AJAX calls, REST API requests, and WP-Cron jobs are excluded.

= Can it detect crawlers that do not run JavaScript? =

Yes. That is the main purpose of this plugin. GA4 and other JavaScript-based tools miss AI crawlers entirely. This plugin detects them at the PHP level using the HTTP_USER_AGENT server variable.

= Which AI crawlers are supported? =

GPTBot, ChatGPT-User, OAI-SearchBot, ClaudeBot, Anthropic-AI, ByteSpider, Meta-ExternalAgent, Google-Extended, Grok, xAI, AppleBot, DeepSeek, CopilotBot, PerplexityBot.

= What happens when I uninstall the plugin? =

All plugin settings stored in the WordPress database are removed automatically on uninstall.

== Changelog ==

= 1.4.6 =
* 修正: secret_key が DB に保存されない不具合を修正（sanitize_callback で除外されていた）
* 修正: 設定ページの CSS/JS が一部環境で読み込まれない不具合を修正

= 1.4.5 =
* Fixed: Local crawler logging now works without external service connection (trialware removal)
* Improved: REST API authentication moved to permission_callback with site_id + secret_key verification
* Improved: External API transmission only occurs when site_id is configured

= 1.4.0 =
* Removed all PRO/free feature restrictions — all features now fully available to everyone
* Removed Stripe payment integration (billing moved to ai-kansoku.com)
* Removed AI citation checker (keywords.php) — feature moved to ai-kansoku.com
* Replaced Chart.js CDN with locally bundled file (WordPress.org guideline compliance)
* Removed inline script/style output; all assets now enqueued via wp_enqueue_script and wp_add_inline_style
* Improved output escaping throughout
* Updated readme to fully disclose all transmitted data fields (referer, status_code)

= 1.0.6 =
* Renamed plugin to Kansoku Lab Tracker for WordPress.org guidelines compliance
* Updated all prefixes from AIK_ to AIKLAB_ to meet 4+ character prefix requirement
* Replaced inline <style> block with wp_enqueue_style() and wp_add_inline_style()
* Updated Terms of Service URL

= 1.0.4 =
* Replaced HTML-mixed echo with PHP template syntax in status panel
* Changed Tested up to from 6.9 to 6.8 for accuracy

= 1.0.3 =
* Changed hook from `init` to `template_redirect` for cleaner front-end-only targeting
* Removed redundant is_admin/cron/AJAX/REST guards (handled by hook context)
* Replaced Markdown link syntax in readme with plain URLs for better compatibility

= 1.0.2 =
* Added explicit opt-in checkbox — external tracking now requires user consent
* Unified all URLs to https://www.ai-kansoku.com
* Refined crawler regex (replaced broad /anthropic/ with /anthropic-ai/)
* Updated privacy wording to accurately reflect transmitted data
* Status panel now shows tracking state (Active / Disabled / Not configured)

= 1.0.1 =
* Changed tracking from GET to POST request for cleaner data transmission
* Increased timeout from 0.1s to 1s for better reliability
* Restricted tracking to front-end requests only (excludes admin, AJAX, REST, cron)
* Added explicit External API Notice in settings page
* Added uninstall.php to clean up database options on removal

= 1.0.0 =
* Initial release

== Upgrade Notice ==

= 1.4.0 =
All features are now free with no restrictions. Stripe billing and AI citation checker have been removed from the plugin.

= 1.0.6 =
Internal refactor for WordPress.org compliance and improved settings handling.

= 1.0.2 =
Added explicit opt-in checkbox for external tracking. Please re-enable tracking in Settings > AI Kansoku Lab after updating.

== Privacy Policy ==

This plugin connects to an external service to log AI crawler visits.

External tracking is opt-in only and only activates after explicit user consent via the settings page.

Data transmitted to AI Kansoku Lab (https://www.ai-kansoku.com) when tracking is enabled:
* User-Agent string of the detected AI crawler
* URL path of the visited page
* HTTP referer header (if present)
* HTTP status code of the page (200 or 404)
* Site ID configured in plugin settings

No personally identifiable information is collected. This plugin does not collect cookies, account credentials, form contents, or visitor IP addresses.

Full privacy policy: https://www.ai-kansoku.com/privacy