feat: make analytics opt-in via a settings checkbox - #21
Merged
Conversation
…f-report The eventReporting field now requires both the bot protection gate (API key + enabled flag) and the analytics opt-in setting, fixing the scenario where a CAP-on/analytics-off site would misreport eventReporting=true.
There was a problem hiding this comment.
Pull request overview
This PR makes Supertab Connect analytics explicitly opt-in by adding a persisted “Enable analytics” setting (default off) and wiring it through initialization and the status self-report so analytics batching/dispatch and SDK analytics transport only activate after the merchant opts in.
Changes:
- Add a new stored setting (
supertab_connect_analytics_enabled) with getter/setter, and ensure it’s removed on delete/uninstall. - Add an “Enable analytics” checkbox to the settings UI and save/reset it alongside CAP settings.
- Gate SDK
analyticsEnabled, queue dispatcher registration, and/.well-known/supertab/statuseventReportingon both CAP being active and analytics opt-in.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| uninstall.php | Deletes the new analytics opt-in option during uninstall cleanup. |
| tests/StatusHandlerTest.php | Updates and adds tests to ensure eventReporting requires analytics opt-in. |
| tests/SettingsTest.php | Adds tests for analytics opt-in default, persistence, and deletion behavior. |
| templates/settings.php | Adds the “Enable analytics” checkbox within the CAP section of the settings UI. |
| src/class-status-handler.php | Updates status payload to report eventReporting only when opted in. |
| src/class-settings.php | Adds OPTION_ANALYTICS_ENABLED plus is_analytics_enabled() / set_analytics_enabled(), and deletes the option in delete(). |
| src/class-plugin.php | Derives analytics_enabled from CAP-active + opt-in, and passes it to the SDK; only registers analytics dispatcher when enabled. |
| src/admin/class-settings-page.php | Reads/saves analytics_enabled from form submission and passes it into the template data. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
github-actions Bot
pushed a commit
that referenced
this pull request
Jul 16, 2026
# [1.3.0-beta.11](v1.3.0-beta.10...v1.3.0-beta.11) (2026-07-16) ### Features * make analytics opt-in via a settings checkbox ([#21](#21)) ([9df74f0](9df74f0))
|
🎉 This PR is included in version 1.3.0-beta.11 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR makes analytics opt-in: a new "Enable analytics" checkbox on the plugin settings screen, off by default. Only when checked does the plugin pass
analyticsEnabled: trueto the SDK or register the batch-buffer delivery machinery.Context
Analytics was implicitly always on: whenever CAP ran,
Plugin::init()passed a hardcodedanalyticsEnabled: trueto the SDK, and (with the WP queue enabled) buffered and delivered events. Merchants had no control. This PR gives them the switch and defaults it to off.Key Changes
Settings— new optionsupertab_connect_analytics_enabledwithis_analytics_enabled()/set_analytics_enabled(), mirroring the CAP pair; cleared bySettings::delete()and on uninstall.Plugin::init()— the misnamed$analytics_enabledlocal (it actually gated bot protection) is renamed$bot_protection_active; a real$analytics_enabled = $bot_protection_active && is_analytics_enabled()now gates the batch-buffer dispatcher, and the SDK receives the derived flag instead of hardcodedtrue. With analytics off there is no queue registration, no flush schedule, and the SDK builds its noop transport. CAP behavior is unchanged by the toggle.eventReportingin/.well-known/supertab/statusnow also requires the opt-in, so the backend prober sees the truth on analytics-off sites (found in review;enforcementreporting unchanged).Verification
composer test— 116/116 passing (213 assertions); lint, phpcs (WordPress-VIP-Go), phpstan (level 5) clean.eventReporting: falseuntil opted in.