HEX
Server: nginx/1.18.0
System: Linux iZj6c1ieg2jrpk1z5tzi19Z 6.3.9-1.el7.elrepo.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 21 22:18:40 EDT 2023 x86_64
User: www (1001)
PHP: 8.2.4
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,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_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/www.cytocare.cn/wp-content/plugins/hummingbird-performance/_src/js/mixpanel.js
/* global wphb */
import Fetcher from './utils/fetcher';

( function() {
	'use strict';

	window.wphbMixPanel = {
		/**
		 * Opt in tracking.
		 */
		optIn() {
			wphb.mixpanel.enabled = true;
		},

		/**
		 * Deactivate feedback.
		 *
		 * @param {string} reason   Deactivation reason.
		 * @param {string} feedback Deactivation feedback.
		 */
		deactivate( reason, feedback = '' ) {
			this.track( 'plugin_deactivate', {
				reason,
				feedback,
			} );
		},

		/**
		 * Track HB Upsell events.
		 *
		 * @param {string} feature  Feature name.
		 * @param {string} location Location.
		 * @param {string} action   Action.
		 * @param {string} utmLink  UTM link.
		 * @param {string} evenName Event name.
		 */
		trackHBUpsell( feature, location, action, utmLink, evenName = 'hb_upsell_triggered' ) {
			this.track( evenName, {
				Feature: feature,
				Location: location,
				'User Action': action,
				'UTM Link': utmLink,
			} );
		},

		/**
		 * Track feature enable.
		 *
		 * @param {string} feature Feature name.
		 */
		enableFeature( feature ) {
			this.track( 'plugin_feature_activate', { feature } );
		},

		/**
		 * Track EO Upsell event.
		 *
		 * @param {string} eventName Event name.
		 * @param {string} location  Location.
		 */
		trackEoUpsell( eventName, location ) {
			const mpEventName = 'delayjs' === eventName ? 'js_delay_upsell' : 'critical_css_upsell';
	
			this.track( mpEventName, {
				'Modal Action': 'direct_cta',
				'Location': location,
			} );
		},

		/**
		 * Get update type
		 *
		 * @param {string} update_type Update type.
		 */
		getUpdateType( update_type ) {
			if ( 'activate' === update_type ) {
				return 'plugin_feature_activate';
			}

			if ( 'deactivate' === update_type ) {
				return 'plugin_feature_deactivate';
			}

			return '';
		},

		/**
		 * Track Delay JS Upsell event.
		 *
		 * @param {object} properties Properties.
		 */
		 trackDelayJSEvent( properties ) {
			if ( 'activate' === properties.update_type ) {
				this.enableFeature( 'JS Delay' );
			}

			if ( 'deactivate' === properties.update_type ) {
				this.disableFeature( 'JS Delay' );
			}

			this.track( 'js_delay_updated', properties );
		},

		/**
		 * Track Font Optimization event.
		 *
		 * @param {string} updateType Properties.
		 * @param {string} feature    Feature.
		 */
		trackFontOptimizationEvent( updateType, feature ) {
			if ( 'activate' === updateType ) {
				this.enableFeature( feature );
			}

			if ( 'deactivate' === updateType ) {
				this.disableFeature( feature );
			}
		},

		/**
		 * Track Critical Upsell event.
		 *
		 * @param {object} properties Properties.
		 */
		trackCriticalCSSEvent( properties ) {
			if ( 'activate' === properties.update_type ) {
				this.enableFeature( 'Critical Css' );
			}

			if ( 'deactivate' === properties.update_type ) {
				this.disableFeature( 'Critical Css' );
			}

			this.track( 'critical_css_updated', properties );
		},

		/**
		 * Track AO updated event.
		 *
		 * @param {object} properties Properties.
		 */
		 trackAOUpdated( properties ) {
			const mode = properties.Mode.charAt(0).toUpperCase() + properties.Mode.slice(1);
			properties.Mode = mode;
			this.track( 'ao_updated', properties );
		},

		/**
		 * Track AO updated event.
		 *
		 * @param {object} feature Feature.
		 */
		 trackGutenbergEvent( feature ) {
			this.track( 'critical_css_gutenberg', { feature } );

			if ( 'revert' === feature ) {
				this.track( 'critical_css_cache_purge', {
					location: 'gutenberg'
				} );
			}
		},

		/**
		 * Track Page Caching event.
		 *
		 * @param {string} updateType       Update type.
		 * @param {string} method           Method.
		 * @param {string} location         Location.
		 * @param {string} settingsModified Modified Settings.
		 * @param {string} preloadHomepage  Settings default.
		 */
		trackPageCachingSettings( updateType, method, location, settingsModified, preloadHomepage ) {
			const feature = 'local_page_cache' === method ? 'Page Caching' : method;
			if ( 'activate' === updateType ) {
				this.enableFeature( feature );
			}

			if ( 'deactivate' === updateType ) {
				this.disableFeature( feature );
			}

			this.track( 'page_caching_updated', {
				'update_type': updateType,
				'Method': method,
				'Location': location,
				'modified_settings': settingsModified,
				'preload_homepage': preloadHomepage,
			} );
		},

		/**
		 * Track PRO Upsell event.
		 *
		 * @param {string} eventName Event name.
		 * @param {string} action    Action.
		 * @param {string} location  Location.
		 */
		trackProUpsell( eventName, action, location = 'submenu' ) {
			this.track( eventName, {
				'Location': location,
				'User Action': action,
			} );
		},

		/**
		 * Track feature disable.
		 *
		 * @param {string} feature Feature name.
		 */
		disableFeature( feature ) {
			this.track( 'plugin_feature_deactivate', { feature } );
		},

		/**
		 * Track an event.
		 *
		 * @param {string} event                Event ID.
		 * @param {Object} data                 Event data.
		 */
		track( event, data = {} ) {
			if (
				'undefined' === typeof wphb.mixpanel ||
				! wphb.mixpanel.enabled
			) {
				return;
			}

			Fetcher.mixpanel.trackMixpanelEvent( event, data );
		}
	};
}() );