|
|
|
|
@ -15,7 +15,7 @@ class AllSources extends React.Component {
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props)
|
|
|
|
|
this.onVisible = this.onVisible.bind(this)
|
|
|
|
|
this.state = {loading: true}
|
|
|
|
|
this.state = { loading: true }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onVisible() {
|
|
|
|
|
@ -25,7 +25,7 @@ class AllSources extends React.Component {
|
|
|
|
|
|
|
|
|
|
componentDidUpdate(prevProps) {
|
|
|
|
|
if (this.props.query !== prevProps.query) {
|
|
|
|
|
this.setState({loading: true, referrers: null})
|
|
|
|
|
this.setState({ loading: true, referrers: null })
|
|
|
|
|
this.fetchReferrers()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -39,12 +39,12 @@ class AllSources extends React.Component {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fetchReferrers() {
|
|
|
|
|
api.get(`/api/stats/${encodeURIComponent(this.props.site.domain)}/sources`, this.props.query, {show_noref: this.showNoRef()})
|
|
|
|
|
.then((res) => this.setState({loading: false, referrers: res}))
|
|
|
|
|
api.get(`/api/stats/${encodeURIComponent(this.props.site.domain)}/sources`, this.props.query, { show_noref: this.showNoRef() })
|
|
|
|
|
.then((res) => this.setState({ loading: false, referrers: res }))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renderReferrer(referrer) {
|
|
|
|
|
const maxWidthDeduction = this.showConversionRate() ? "10rem" : "5rem"
|
|
|
|
|
const maxWidthDeduction = this.showConversionRate() ? "10rem" : "5rem"
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
@ -66,11 +66,11 @@ class AllSources extends React.Component {
|
|
|
|
|
src={`/favicon/sources/${encodeURIComponent(referrer.name)}`}
|
|
|
|
|
className="inline w-4 h-4 mr-2 -mt-px align-middle"
|
|
|
|
|
/>
|
|
|
|
|
{ referrer.name }
|
|
|
|
|
{referrer.name}
|
|
|
|
|
</Link>
|
|
|
|
|
</span>
|
|
|
|
|
</Bar>
|
|
|
|
|
<span className="font-medium dark:text-gray-200 w-20 text-right">{numberFormatter(referrer.visitors)}</span>
|
|
|
|
|
<span className="font-medium dark:text-gray-200 w-20 text-right" tooltip={referrer.visitors}>{numberFormatter(referrer.visitors)}</span>
|
|
|
|
|
{this.showConversionRate() && <span className="font-medium dark:text-gray-200 w-20 text-right">{referrer.conversion_rate}%</span>}
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
@ -116,11 +116,11 @@ class AllSources extends React.Component {
|
|
|
|
|
<LazyLoader className="flex flex-col flex-grow" onVisible={this.onVisible}>
|
|
|
|
|
<div id="sources" className="flex justify-between w-full">
|
|
|
|
|
<h3 className="font-bold dark:text-gray-100">Top Sources</h3>
|
|
|
|
|
{ this.props.renderTabs() }
|
|
|
|
|
{this.props.renderTabs()}
|
|
|
|
|
</div>
|
|
|
|
|
{ this.state.loading && <div className="mx-auto loading mt-44"><div></div></div> }
|
|
|
|
|
{this.state.loading && <div className="mx-auto loading mt-44"><div></div></div>}
|
|
|
|
|
<FadeIn show={!this.state.loading} className="flex flex-col flex-grow">
|
|
|
|
|
{ this.renderList() }
|
|
|
|
|
{this.renderList()}
|
|
|
|
|
</FadeIn>
|
|
|
|
|
</LazyLoader>
|
|
|
|
|
)
|
|
|
|
|
@ -131,24 +131,24 @@ class AllSources extends React.Component {
|
|
|
|
|
<div
|
|
|
|
|
className="relative p-4 bg-white rounded shadow-xl stats-item flex flex-col mt-6 w-full dark:bg-gray-825"
|
|
|
|
|
>
|
|
|
|
|
{ this.renderContent() }
|
|
|
|
|
{this.renderContent()}
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const UTM_TAGS = {
|
|
|
|
|
utm_medium: {label: 'UTM Medium', shortLabel: 'UTM Medium', endpoint: 'utm_mediums'},
|
|
|
|
|
utm_source: {label: 'UTM Source', shortLabel: 'UTM Source', endpoint: 'utm_sources'},
|
|
|
|
|
utm_campaign: {label: 'UTM Campaign', shortLabel: 'UTM Campai', endpoint: 'utm_campaigns'},
|
|
|
|
|
utm_content: {label: 'UTM Content', shortLabel: 'UTM Conten', endpoint: 'utm_contents'},
|
|
|
|
|
utm_term: {label: 'UTM Term', shortLabel: 'UTM Term', endpoint: 'utm_terms'},
|
|
|
|
|
utm_medium: { label: 'UTM Medium', shortLabel: 'UTM Medium', endpoint: 'utm_mediums' },
|
|
|
|
|
utm_source: { label: 'UTM Source', shortLabel: 'UTM Source', endpoint: 'utm_sources' },
|
|
|
|
|
utm_campaign: { label: 'UTM Campaign', shortLabel: 'UTM Campai', endpoint: 'utm_campaigns' },
|
|
|
|
|
utm_content: { label: 'UTM Content', shortLabel: 'UTM Conten', endpoint: 'utm_contents' },
|
|
|
|
|
utm_term: { label: 'UTM Term', shortLabel: 'UTM Term', endpoint: 'utm_terms' },
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class UTMSources extends React.Component {
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props)
|
|
|
|
|
this.state = {loading: true}
|
|
|
|
|
this.state = { loading: true }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
|
@ -158,7 +158,7 @@ class UTMSources extends React.Component {
|
|
|
|
|
|
|
|
|
|
componentDidUpdate(prevProps) {
|
|
|
|
|
if (this.props.query !== prevProps.query || this.props.tab !== prevProps.tab) {
|
|
|
|
|
this.setState({loading: true, referrers: null})
|
|
|
|
|
this.setState({ loading: true, referrers: null })
|
|
|
|
|
this.fetchReferrers()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -173,12 +173,12 @@ class UTMSources extends React.Component {
|
|
|
|
|
|
|
|
|
|
fetchReferrers() {
|
|
|
|
|
const endpoint = UTM_TAGS[this.props.tab].endpoint
|
|
|
|
|
api.get(`/api/stats/${encodeURIComponent(this.props.site.domain)}/${endpoint}`, this.props.query, {show_noref: this.showNoRef()})
|
|
|
|
|
.then((res) => this.setState({loading: false, referrers: res}))
|
|
|
|
|
api.get(`/api/stats/${encodeURIComponent(this.props.site.domain)}/${endpoint}`, this.props.query, { show_noref: this.showNoRef() })
|
|
|
|
|
.then((res) => this.setState({ loading: false, referrers: res }))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renderReferrer(referrer) {
|
|
|
|
|
const maxWidthDeduction = this.showConversionRate() ? "10rem" : "5rem"
|
|
|
|
|
const maxWidthDeduction = this.showConversionRate() ? "10rem" : "5rem"
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
@ -197,11 +197,11 @@ class UTMSources extends React.Component {
|
|
|
|
|
className="md:truncate block hover:underline"
|
|
|
|
|
to={url.setQuery(this.props.tab, referrer.name)}
|
|
|
|
|
>
|
|
|
|
|
{ referrer.name }
|
|
|
|
|
{referrer.name}
|
|
|
|
|
</Link>
|
|
|
|
|
</span>
|
|
|
|
|
</Bar>
|
|
|
|
|
<span className="font-medium dark:text-gray-200 w-20 text-right">{numberFormatter(referrer.visitors)}</span>
|
|
|
|
|
<span className="font-medium dark:text-gray-200 w-20 text-right" tooltip={referrer.visitors}>{numberFormatter(referrer.visitors)}</span>
|
|
|
|
|
{this.showConversionRate() && <span className="font-medium dark:text-gray-200 w-20 text-right">{referrer.conversion_rate}%</span>}
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
@ -247,11 +247,11 @@ class UTMSources extends React.Component {
|
|
|
|
|
<React.Fragment>
|
|
|
|
|
<div className="flex justify-between w-full">
|
|
|
|
|
<h3 className="font-bold dark:text-gray-100">Top Sources</h3>
|
|
|
|
|
{ this.props.renderTabs() }
|
|
|
|
|
{this.props.renderTabs()}
|
|
|
|
|
</div>
|
|
|
|
|
{ this.state.loading && <div className="mx-auto loading mt-44"><div></div></div> }
|
|
|
|
|
{this.state.loading && <div className="mx-auto loading mt-44"><div></div></div>}
|
|
|
|
|
<FadeIn show={!this.state.loading} className="flex flex-col flex-grow">
|
|
|
|
|
{ this.renderList() }
|
|
|
|
|
{this.renderList()}
|
|
|
|
|
</FadeIn>
|
|
|
|
|
</React.Fragment>
|
|
|
|
|
)
|
|
|
|
|
@ -262,7 +262,7 @@ class UTMSources extends React.Component {
|
|
|
|
|
<div
|
|
|
|
|
className="relative p-4 bg-white rounded shadow-xl stats-item flex flex-col dark:bg-gray-825 mt-6 w-full"
|
|
|
|
|
>
|
|
|
|
|
{ this.renderContent() }
|
|
|
|
|
{this.renderContent()}
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
@ -286,7 +286,7 @@ export default class SourceList extends React.Component {
|
|
|
|
|
setTab(tab) {
|
|
|
|
|
return () => {
|
|
|
|
|
storage.setItem(this.tabKey, tab)
|
|
|
|
|
this.setState({tab})
|
|
|
|
|
this.setState({ tab })
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -303,7 +303,7 @@ export default class SourceList extends React.Component {
|
|
|
|
|
<Menu as="div" className="relative inline-block text-left">
|
|
|
|
|
<div>
|
|
|
|
|
<Menu.Button className="inline-flex justify-between focus:outline-none">
|
|
|
|
|
<span style={{width: '4.2rem'}} className={this.state.tab.startsWith('utm_') ? activeClass : defaultClass}>{buttonText}</span>
|
|
|
|
|
<span style={{ width: '4.2rem' }} className={this.state.tab.startsWith('utm_') ? activeClass : defaultClass}>{buttonText}</span>
|
|
|
|
|
<ChevronDownIcon className="-mr-1 ml-px h-4 w-4" aria-hidden="true" />
|
|
|
|
|
</Menu.Button>
|
|
|
|
|
</div>
|
|
|
|
|
@ -319,7 +319,7 @@ export default class SourceList extends React.Component {
|
|
|
|
|
>
|
|
|
|
|
<Menu.Items className="text-left origin-top-right absolute right-0 mt-2 w-56 rounded-md shadow-lg bg-white dark:bg-gray-800 ring-1 ring-black ring-opacity-5 focus:outline-none z-10">
|
|
|
|
|
<div className="py-1">
|
|
|
|
|
{ dropdownOptions.map((option) => {
|
|
|
|
|
{dropdownOptions.map((option) => {
|
|
|
|
|
return (
|
|
|
|
|
<Menu.Item key={option}>
|
|
|
|
|
{({ active }) => (
|
|
|
|
|
|