PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3
Jetpack – WP Security, Backup, Speed, & Growth v16.3
16.3 16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 All 508 releases
jetpack / jetpack_vendor / automattic / jetpack-admin-ui / src / admin-ui-upgrade-menu-tracking.js

admin-ui-upgrade-menu-tracking.js in Jetpack – WP Security, Backup, Speed, & Growth 16.3, at jetpack_vendor/automattic/jetpack-admin-ui/src/admin-ui-upgrade-menu-tracking.js

33 lines 851 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Marks the wp-admin Jetpack sidebar "Upgrade Jetpack" item for Tracks.
3 */
4 document.addEventListener( 'DOMContentLoaded', () => {
5 const config = window.jetpackAdminUiUpgradeMenu;
6 if ( typeof config === 'undefined' ) {
7 return;
8 }
9
10 const className = config.menuItemClass;
11 if ( ! className ) {
12 return;
13 }
14
15 // Class comes from PHP (UPGRADE_MENU_SLUG); safe for querySelector.
16 const item = document.querySelector( `li.${ className } a` );
17 if ( ! item ) {
18 return;
19 }
20
21 // Initialize Tracks
22 if ( 'undefined' !== typeof window?.analytics && config.tracksUserData ) {
23 window.analytics.initialize( config.tracksUserData?.userid, config.tracksUserData?.username );
24 }
25
26 item.addEventListener( 'click', function () {
27 window.analytics?.tracks?.recordEvent(
28 'jetpack_sidebar_free_upgrade_click',
29 config.tracksEventData
30 );
31 } );
32 } );
33