Create New Item
×
Item Type
File
Folder
Item Name
×
Search file in folder and subfolders...
File Manager
/
wp-content
/
plugins
/
burst-statistics
/
settings
/
src
/
api
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
import {getData} from '../utils/api'; import {formatNumber, formatTime} from '../utils/formatting'; export const transformTodayData = ( response ) => { for ( let key in response ) { if ( response.hasOwnProperty( key ) ) { if ( 'timeOnPage' === key ) { response[key].value = formatTime( response[key].value ); } else { response[key].value = formatNumber( response[key].value ); } } } return response; }; /** * Get live visitors * @param {Object} args * @param {string} args.startDate * @param {string} args.endDate * @param {string} args.range * @param {Object} args.filters * @returns {Promise<*>} */ const getTodayData = async( args ) => { const { startDate, endDate, range, filters } = args; const { data } = await getData( 'today', startDate, endDate, range, { filters } ); return transformTodayData( data ); }; export default getTodayData;