Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions admin/godam-transcoder-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -512,16 +512,13 @@ function rtgodam_verify_api_key( $api_key, $save = false ) {
rtgodam_set_api_key_status( Api_Key_Status::VALID );
rtgodam_clear_api_key_invalid_timestamp();

// Enable PostHog tracking once API key is activated or plugin is updated with active API key.
// 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 );
Comment on lines +515 to 521
} elseif ( ! empty( $settings['general']['posthog_initialized'] ) && ! $settings['general']['enable_posthog_tracking'] && $save ) {
// If user previously opted out but is now activating an API key, re-enable tracking.
$settings['general']['enable_posthog_tracking'] = true;
update_option( 'rtgodam-settings', $settings );
}

if ( $save ) {
Expand Down
2 changes: 1 addition & 1 deletion pages/utils/posthog.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const initPostHog = () => {

const posthogKey = posthogConfig.key || '';
const posthogHost = posthogConfig.host || '';
const posthogEnabled = posthogConfig.enabled !== '0'; // Enable by default, disable on 0, "0", or false
const posthogEnabled = posthogConfig.enabled === '1' || posthogConfig.enabled === 1; // Only enable when explicitly opted in; never default to enabled.

if ( ! posthogEnabled ) {
return posthog;
Expand Down
Loading