HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/delta/wp-content/plugins/wp-smushit/_src/js/global-tracking.js
import tracker from './utils/tracker';

export default class GlobalTracking {
	init() {
		this.trackSubmenuProUpsell();
		this.trackPluginListProUpsell();
		this.trackDashboardWidgetProUpsell();
	}

	trackSubmenuProUpsell() {
		const submenuUpgradeLink = document.querySelector( '#toplevel_page_smush a[href*="utm_campaign=smush_submenu_upsell' );
		if ( submenuUpgradeLink ) {
			submenuUpgradeLink.addEventListener( 'click', ( event ) => {
				this.trackGeneralProUpsell( 'submenu', event?.target?.href );
			} );
		}
	}

	trackPluginListProUpsell() {
		const pluginlistUpgradeLink = document.getElementById( 'smush-pluginlist-upgrade-link' );
		if ( pluginlistUpgradeLink ) {
			pluginlistUpgradeLink.addEventListener( 'click', ( event ) => {
				this.trackGeneralProUpsell( 'plugins_list', event?.target?.href );
			} );
		}
	}

	trackDashboardWidgetProUpsell() {
		const upsellBox = document.getElementById( 'smush-box-dashboard-upsell-upsell' );
		if ( ! upsellBox ) {
			return;
		}

		const dashboardProUpsellLink = upsellBox.querySelector( 'a[href*=smush-dashboard-upsell]' );
		if ( dashboardProUpsellLink ) {
			dashboardProUpsellLink.addEventListener( 'click', ( event ) => {
				this.trackGeneralProUpsell( 'dash_widget', event?.target?.href );
			} );
		}
	}

	trackSetupWizardProUpsell( utmLink, proInterests ) {
		this.trackGeneralProUpsell( 'wizard', utmLink, proInterests );
	}

	trackGeneralProUpsell( localtion, utmLink, proInterests = 'na' ) {
		this.trackProUpsell( {
			Feature: 'pro_general',
			Location: localtion,
			'UTM Link': utmLink,
			'Pro Interests': proInterests,
		} );
	}

	trackProUpsell( properties ) {
		properties = Object.assign( {
			'User Action': 'cta_clicked',
		}, properties );

		tracker.track( 'smush_pro_upsell', properties );
	}
}