HEX
Server: Apache/2.4.54 (Unix) OpenSSL/1.0.2k-fips
System: Linux f17.eelserver.com 3.10.0-1160.80.1.el7.x86_64 #1 SMP Tue Nov 8 15:48:59 UTC 2022 x86_64
User: zulfiqar (1155)
PHP: 8.2.0
Disabled: mail, exec, system, popen, proc_open, shell_exec, passthru, show_source
Upload Files
File: /home/zulfiqar/public_html/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 );
	}
}