import { connect } from 'react-redux'; import cn from 'classnames'; import { Link, Icon, OsIcon, BrowserIcon, CountryFlag, Avatar, TextEllipsis, Label, } from 'UI'; import { deviceTypeIcon } from 'App/iconNames'; import { toggleFavorite, setSessionPath } from 'Duck/sessions'; import { session as sessionRoute, liveSession as liveSessionRoute, withSiteId } from 'App/routes'; import { durationFormatted, formatTimeOrDate } from 'App/date'; import stl from './sessionItem.css'; import LiveTag from 'Shared/LiveTag'; import Bookmark from 'Shared/Bookmark'; import Counter from './Counter' import { withRouter } from 'react-router-dom'; import SessionMetaList from './SessionMetaList'; import ErrorBars from './ErrorBars'; import { assist as assistRoute, liveSession, isRoute } from "App/routes"; import { capitalize } from 'App/utils'; const ASSIST_ROUTE = assistRoute(); const ASSIST_LIVE_SESSION = liveSession() // const Label = ({ label = '', color = 'color-gray-medium'}) => ( //
{label}
// ) @connect(state => ({ timezone: state.getIn(['sessions', 'timezone']), siteId: state.getIn([ 'user', 'siteId' ]), }), { toggleFavorite, setSessionPath }) @withRouter export default class SessionItem extends React.PureComponent { // eslint-disable-next-line complexity render() { const { session: { sessionId, userBrowser, userOs, userId, userAnonymousId, userDisplayName, userCountry, startedAt, duration, eventsCount, errorsCount, pagesCount, viewed, favorite, userDeviceType, userUuid, userNumericHash, live, metadata, userSessionsCount, issueTypes, active, }, timezone, onUserClick = () => null, hasUserFilter = false, disableUser = false, metaList = [], showActive = false, } = this.props; const formattedDuration = durationFormatted(duration); const hasUserId = userId || userAnonymousId; const isAssist = isRoute(ASSIST_ROUTE, this.props.location.pathname) || isRoute(ASSIST_LIVE_SESSION, this.props.location.pathname); const _metaList = Object.keys(metadata).filter(i => metaList.includes(i)).map(key => { const value = metadata[key]; return { label: key, value }; }); return (
(!disableUser && !hasUserFilter) && onUserClick(userId, userAnonymousId)} >
{formatTimeOrDate(startedAt, timezone) }
{!isAssist && ( <>
{ eventsCount } { eventsCount === 0 || eventsCount > 1 ? 'Events' : 'Event' }
·
)}
{ live ? : formattedDuration }
·
·
{ !isAssist && (
)}
{ isAssist && showActive && ( )}
{ _metaList.length > 0 && ( )}
); } }