Skip to content

feat: count visits AI products send (AI referrals) - #99

Merged
cport1 merged 1 commit into
mainfrom
feat/ai-referrals
Sep 25, 2026
Merged

cport1 merged 1 commit into
mainfrom
feat/ai-referrals

Conversation

@cport1

@cport1 cport1 commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Companion to WebDecoy/app#1324 / #1325 (issue app#1321).

  • WebDecoy\\LlmReferral: PHP port of the app's classifier over a generated table (sdk/src/registry/llm-platforms.generated.php); tests/LlmReferralTest.php replays all 79 generated vectors. Reads repeated query keys like browsers do (not parse_str).
  • WebDecoy_AI_Referrals: on template_redirect, counts GET document navigations (Sec-Fetch-Mode: navigate) from an AI product into {prefix}webdecoy_ai_referrals (ref_key = sha1(platform+path) keeps the key within older MySQL index limits; bounded at 5000 rows). Cron every 15 min claims open rows under a batch id and sends {report_id, source: 'wordpress', referrals}; failure keeps the id for retry (server dedupes); 4xx drops the batch.
  • Active only with an API key (connect keys are site-scoped with detections:write); webdecoy_count_ai_referrals filter disables it.
  • DB 2.3.0 creates the table; uninstall drops it and clears the cron (single and multisite).
  • readme External Services discloses what is sent.

Tests: php tests/run.php 181 passed; phpcs clean on changed files. Full-page caches mean the count is a floor.

Release after the ingest endpoint is deployed (version bump PR then bin/release-all.sh).

When connected to WebDecoy Cloud, the plugin counts page visits whose
Referer (or campaign tags) names an AI product, by platform and landing
path, in a small table (DB 2.3.0), and sends the counts every fifteen
minutes to /api/v1/sdk/ai-referrals as source wordpress. A send claims the
open counts under a batch id; a failed send is retried with the same id,
which WebDecoy counts once. Nothing about a visitor is stored or sent.

The platform table and the golden vectors the PHP classifier replays are
generated from WebDecoy's own classifier (WebDecoy/app#1321). Only a GET
document navigation counts; pages served from a full-page cache never reach
PHP, so the figure is a floor. Disclosed under External Services; the
webdecoy_count_ai_referrals filter turns it off. Uninstall drops the table.
@cport1
cport1 merged commit 5f58317 into main Sep 25, 2026
4 checks passed
@cport1
cport1 deleted the feat/ai-referrals branch September 25, 2026 00:36
@cport1 cport1 mentioned this pull request Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant