mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-14 21:10:34 +01:00
Update display of combined referrer urls.
This commit is contained in:
parent
f113d0cb34
commit
4ab71c42a6
@ -20,9 +20,9 @@ export default function ReferrersTable({ websiteId, websiteDomain, limit, onExpa
|
|||||||
{ label: <FormattedMessage id="metrics.filter.raw" defaultMessage="Raw" />, value: FILTER_RAW },
|
{ label: <FormattedMessage id="metrics.filter.raw" defaultMessage="Raw" />, value: FILTER_RAW },
|
||||||
];
|
];
|
||||||
|
|
||||||
const renderLink = ({ x: url }) => {
|
const renderLink = ({ w: href, x: url }) => {
|
||||||
return url.startsWith('http') ? (
|
return (href || url).startsWith('http') ? (
|
||||||
<a href={url} target="_blank" rel="noreferrer">
|
<a href={href || url} target="_blank" rel="noreferrer">
|
||||||
{decodeURI(url)}
|
{decodeURI(url)}
|
||||||
</a>
|
</a>
|
||||||
) : (
|
) : (
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import firstBy from 'thenby';
|
import firstBy from 'thenby';
|
||||||
import { BROWSERS, ISO_COUNTRIES } from './constants';
|
import { BROWSERS, ISO_COUNTRIES } from './constants';
|
||||||
import { removeTrailingSlash, getDomainName } from './url';
|
import { removeTrailingSlash, removeWWW, getDomainName } from './url';
|
||||||
|
|
||||||
export const urlFilter = (data, { raw }) => {
|
export const urlFilter = (data, { raw }) => {
|
||||||
const isValidUrl = url => {
|
const isValidUrl = url => {
|
||||||
@ -55,6 +55,7 @@ export const urlFilter = (data, { raw }) => {
|
|||||||
export const refFilter = (data, { domain, domainOnly, raw }) => {
|
export const refFilter = (data, { domain, domainOnly, raw }) => {
|
||||||
const domainName = getDomainName(domain);
|
const domainName = getDomainName(domain);
|
||||||
const regex = new RegExp(`http[s]?://${domainName}`);
|
const regex = new RegExp(`http[s]?://${domainName}`);
|
||||||
|
const links = {};
|
||||||
|
|
||||||
const isValidRef = ref => {
|
const isValidRef = ref => {
|
||||||
return ref !== '' && !ref.startsWith('/') && !ref.startsWith('#');
|
return ref !== '' && !ref.startsWith('/') && !ref.startsWith('#');
|
||||||
@ -85,7 +86,7 @@ export const refFilter = (data, { domain, domainOnly, raw }) => {
|
|||||||
const ref = searchParams.get('ref');
|
const ref = searchParams.get('ref');
|
||||||
const query = ref ? `?ref=${ref}` : '';
|
const query = ref ? `?ref=${ref}` : '';
|
||||||
|
|
||||||
return `${origin}${path}${query}`;
|
return removeTrailingSlash(`${removeWWW(hostname)}${path}`) + query;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -101,6 +102,10 @@ export const refFilter = (data, { domain, domainOnly, raw }) => {
|
|||||||
|
|
||||||
const url = cleanUrl(x);
|
const url = cleanUrl(x);
|
||||||
|
|
||||||
|
if (!domainOnly && !raw) {
|
||||||
|
links[url] = x;
|
||||||
|
}
|
||||||
|
|
||||||
if (url) {
|
if (url) {
|
||||||
if (!obj[url]) {
|
if (!obj[url]) {
|
||||||
obj[url] = y;
|
obj[url] = y;
|
||||||
@ -113,7 +118,7 @@ export const refFilter = (data, { domain, domainOnly, raw }) => {
|
|||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
return Object.keys(map)
|
return Object.keys(map)
|
||||||
.map(key => ({ x: key, y: map[key] }))
|
.map(key => ({ x: key, y: map[key], w: links[key] }))
|
||||||
.sort(firstBy('y', -1).thenBy('x'));
|
.sort(firstBy('y', -1).thenBy('x'));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ export const dateLocales = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const menuOptions = [
|
export const menuOptions = [
|
||||||
{ label: 'English', value: 'en', display: 'EN' },
|
{ label: 'English', value: 'en-US', display: 'EN' },
|
||||||
{ label: '中文', value: 'zh-CN', display: 'CN' },
|
{ label: '中文', value: 'zh-CN', display: 'CN' },
|
||||||
{ label: 'Deutsch', value: 'de-DE', display: 'DE' },
|
{ label: 'Deutsch', value: 'de-DE', display: 'DE' },
|
||||||
{ label: 'Español', value: 'es-MX', display: 'ES' },
|
{ label: 'Español', value: 'es-MX', display: 'ES' },
|
||||||
|
@ -2,6 +2,10 @@ export function removeTrailingSlash(url) {
|
|||||||
return url && url.length > 1 && url.endsWith('/') ? url.slice(0, -1) : url;
|
return url && url.length > 1 && url.endsWith('/') ? url.slice(0, -1) : url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function removeWWW(url) {
|
||||||
|
return url && url.length > 1 && url.startsWith('www.') ? url.slice(4) : url;
|
||||||
|
}
|
||||||
|
|
||||||
export function getDomainName(str) {
|
export function getDomainName(str) {
|
||||||
try {
|
try {
|
||||||
return new URL(str).hostname;
|
return new URL(str).hostname;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "umami",
|
"name": "umami",
|
||||||
"version": "0.35.0",
|
"version": "0.36.0",
|
||||||
"description": "A simple, fast, website analytics alternative to Google Analytics. ",
|
"description": "A simple, fast, website analytics alternative to Google Analytics. ",
|
||||||
"author": "Mike Cao <mike@mikecao.com>",
|
"author": "Mike Cao <mike@mikecao.com>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user