Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | 3x 1x 2x 5x 5x 5x 3x 3x 1x 1x 1x 1x | import { getScan } from '../sections/scan/store';
import { recordEvent } from './tracks';
import type { ScanState } from '../sections/scan/types';
/**
* The scan status the Protect plugin's page view reported.
*
* @param scan - The latest report.
* @return The status.
*/
function getCheckStatus( scan: ScanState ): string {
if ( scan.error ) {
return 'error';
}
return scan.lastChecked ? 'active' : 'in_progress';
}
/**
* Record a page view for a dashboard tab, named after the Protect plugin screen it replaces.
*
* @param tab - The tab, such as "overview".
* @param section - The Settings card the tab opened at, if any.
*/
export function recordPageView( tab: string, section?: string ): void {
const scan = getScan();
const plan = scan ? { has_plan: scan.hasPlan } : {};
switch ( tab ) {
case 'overview':
recordEvent( 'jetpack_protect_admin_page_view', {
...plan,
...( scan && { check_status: getCheckStatus( scan ) } ),
} );
break;
case 'history':
recordEvent( 'jetpack_protect_scan_history_page_view' );
break;
case 'settings':
recordEvent( 'jetpack_protect_settings_page_view', {
...plan,
...( section && { section } ),
} );
break;
}
}
|