Skip to content

Hotfix: Disable PostHog automatic data collection#1747

Open
subodhr258 wants to merge 1 commit intomainfrom
fix/posthog-auto-enable-main
Open

Hotfix: Disable PostHog automatic data collection#1747
subodhr258 wants to merge 1 commit intomainfrom
fix/posthog-auto-enable-main

Conversation

@subodhr258
Copy link
Copy Markdown
Collaborator

@subodhr258 subodhr258 commented Mar 19, 2026

Issue - https://github.com/rtCamp/godam-core/issues/936

This pull request updates how PostHog tracking is enabled in the application, ensuring that user consent is always respected and tracking is only enabled when the user has explicitly opted in. The changes prevent automatic enabling of tracking in scenarios where the user has not made a clear choice.

Consent and tracking logic improvements:

  • In admin/godam-transcoder-functions.php, PostHog tracking is now auto-enabled only if the user has never made a consent choice (posthog_initialized is empty), and will not be re-enabled automatically if the user previously opted out—even when activating an API key. This ensures user consent is respected.
  • In pages/utils/posthog.js, PostHog tracking is now enabled only when the configuration explicitly indicates an opt-in (enabled === '1' or enabled === 1), preventing tracking from being enabled by default.

Recordings

Before

PostHog.before.mov

After

PostHog.after.mov

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates PostHog initialization and consent handling to prevent tracking from being enabled by default, and to avoid re-enabling tracking after a prior opt-out during API key activation/verification.

Changes:

  • Tightens PostHog enablement in JS to require an explicit enabled opt-in value (1 / '1').
  • Adjusts API key verification flow to only auto-enable PostHog when no prior consent state has been recorded (posthog_initialized empty).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pages/utils/posthog.js Requires explicit opt-in (enabled === 1 / '1') before initializing PostHog.
admin/godam-transcoder-functions.php Avoids re-enabling tracking after opt-out; still auto-enables when no consent state exists.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +515 to 521
// Auto-enable PostHog tracking only when the user has never made a consent choice.
// If posthog_initialized is already true the user has either opted in or explicitly opted out — respect that decision.
$settings = get_option( 'rtgodam-settings', array() );
if ( $save || empty( $settings['general']['posthog_initialized'] ) ) {
if ( empty( $settings['general']['posthog_initialized'] ) ) {
$settings['general']['enable_posthog_tracking'] = true;
$settings['general']['posthog_initialized'] = true;
update_option( 'rtgodam-settings', $settings );
@github-actions
Copy link
Copy Markdown

🔍 WordPress Plugin Check Report

⚠️ Status: Passed with warnings

📊 Report

🎯 Total Issues ❌ Errors ⚠️ Warnings
16 0 16

⚠️ Warnings (16)

📁 composer.json (1 warning)
📍 Line 🔖 Check 💬 Message
0 missing_composer_json_file The "/vendor" directory using composer exists, but "composer.json" file is missing.
📁 readme.txt (2 warnings)
📍 Line 🔖 Check 💬 Message
0 mismatched_plugin_name Plugin name "GoDAM - Organize WordPress Media Library & File Manager with Unlimited Folders for Images, Videos & more" is different from the name declared in plugin header "GoDAM".
0 trademarked_term The plugin name includes a restricted term. Your chosen plugin name - "GoDAM - Organize WordPress Media Library & File Manager with Unlimited Folders for Images, Videos & more" - contains the restricted term "wordpress" which cannot be used at all in your plugin name.
📁 assets/build/css/main.css (1 warning)
📍 Line 🔖 Check 💬 Message
0 EnqueuedStylesScope This style is being loaded in all contexts.
📁 assets/src/libs/analytics.min.js (6 warnings)
📍 Line 🔖 Check 💬 Message
0 EnqueuedScriptsScope This script is being loaded in all frontend contexts.
0 NonBlockingScripts.NoStrategy This script on http://localhost:8880 (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead.
0 NonBlockingScripts.NoStrategy This script on http://localhost:8880/2026/03/19/demo-post-post/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead.
0 NonBlockingScripts.NoStrategy This script on http://localhost:8880/demo-page-post/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead.
0 NonBlockingScripts.NoStrategy This script on http://localhost:8880/demo-attachment-post/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead.
0 NonBlockingScripts.NoStrategy This script on http://localhost:8880/?godam-video=demo-godam-video-post (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead.
📁 assets/build/js/main.min.js (6 warnings)
📍 Line 🔖 Check 💬 Message
0 EnqueuedScriptsScope This script is being loaded in all frontend contexts.
0 NonBlockingScripts.NoStrategy This script on http://localhost:8880 (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead.
0 NonBlockingScripts.NoStrategy This script on http://localhost:8880/2026/03/19/demo-post-post/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead.
0 NonBlockingScripts.NoStrategy This script on http://localhost:8880/demo-page-post/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead.
0 NonBlockingScripts.NoStrategy This script on http://localhost:8880/demo-attachment-post/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead.
0 NonBlockingScripts.NoStrategy This script on http://localhost:8880/?godam-video=demo-godam-video-post (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead.

🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

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.

2 participants